提交 e3cf154a 编写于 作者: J jiangminsen 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

Signed-off-by: Njiangminsen <jiangminsen@huawei.com>
...@@ -15,14 +15,15 @@ Common events are classified into system common events and custom common events. ...@@ -15,14 +15,15 @@ Common events are classified into system common events and custom common events.
Common events are also classified into unordered, ordered, and sticky common events. Common events are also classified into unordered, ordered, and sticky common events.
- Unordered common events: common events that CES forwards based on the subscription sequence, regardless of whether subscribers receive the events. - Unordered common events: common events that CES forwards regardless of whether subscribers receive the events and when they subscribe to the events.
- Ordered common events: common events that CES forwards based on the subscriber priority. CES forwards common events to the subscriber with lower priority only after receiving a reply from the previous subscriber with higher priority. - Ordered common events: common events that CES forwards based on the subscriber priority. CES forwards common events to the subscriber with lower priority only after receiving a reply from the previous subscriber with higher priority. Subscribers with the same priority receive common events in a random order.
- Sticky common events: common events that can be sent to a subscriber before they initiate a subscription. Only system applications and system services can send sticky common events, and they must request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file). - Sticky common events: common events that can be sent to a subscriber before or after they initiate a subscription. Only system applications and system services can send sticky common events, which remain in the system after being sent. The sends must first request the **ohos.permission.COMMONEVENT_STICKY** permission. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md#declaring-permissions-in-the-configuration-file).
Each application can subscribe to common events as required. After your application subscribes to a common event, the system sends it to your application every time the event is published. Such an event may be published by the system, other applications, or your own application. Each application can subscribe to common events as required. After your application subscribes to a common event, the system sends it to your application every time the event is published. Such an event may be published by the system, other applications, or your own application.
**Figure 1** Common events **Figure 1** Common events
![common-event](figures/common-event.png) ![common-event](figures/common-event.png)
\ No newline at end of file
...@@ -89,8 +89,3 @@ httpRequest.request( ...@@ -89,8 +89,3 @@ httpRequest.request(
} }
); );
``` ```
## Samples
The following sample is provided to help you better understand how to develop the HTTP data request feature:
- [`HTTP`: Data Request (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Connectivity/Http)
- [HTTP Communication (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH)
# IPC & RPC Development Guidelines # IPC & RPC Development
## When to Use ## When to Use
......
...@@ -63,7 +63,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen ...@@ -63,7 +63,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
}); });
// Call startSharing to start network sharing of the specified type. // Call startSharing to start network sharing of the specified type.
sharing.startSharing(SharingIfaceType.SHARING_WIFI, (error) => { sharing.startSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
}); });
``` ```
...@@ -88,7 +88,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen ...@@ -88,7 +88,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
}); });
// Call stopSharing to stop network sharing of the specified type. // Call stopSharing to stop network sharing of the specified type.
sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => { sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
}); });
``` ```
...@@ -107,7 +107,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen ...@@ -107,7 +107,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
import sharing from '@ohos.net.sharing' import sharing from '@ohos.net.sharing'
// Call startSharing to start network sharing of the specified type. // Call startSharing to start network sharing of the specified type.
sharing.startSharing(SharingIfaceType.SHARING_WIFI, (error) => { sharing.startSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
}); });
...@@ -118,7 +118,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen ...@@ -118,7 +118,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen
}); });
// Call stopSharing to stop network sharing of the specified type and clear the data volume of network sharing. // Call stopSharing to stop network sharing of the specified type and clear the data volume of network sharing.
sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => { sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
}); });
......
...@@ -319,10 +319,3 @@ TLS Socket connection process on the client: ...@@ -319,10 +319,3 @@ TLS Socket connection process on the client:
tlsTwoWay.off('close'); tlsTwoWay.off('close');
}); });
``` ```
## Samples
The following samples are provided to help you better understand how to develop Socket connection features:
- [`Socket`: Socket Connection (ArkTS) (API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/Network/Socket)
- [UDP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/UdpDemoOH)
- [TCP Socket (ArkTS) (API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/TcpSocketDemo)
# Development of Application Recovery # Application Recovery Development
## When to Use ## When to Use
During application running, some unexpected behaviors are inevitable. For example, unprocessed exceptions and errors are thrown, and the call or running constraints of the framework are violated. During application running, some unexpected behaviors are inevitable. For example, unprocessed exceptions and errors are thrown, and the call or running constraints of the recovery framework are violated.
By default, the processes will exit as exception handling. However, if user data is generated during application use, process exits may interrupt user operations and cause data loss. Process exit is treated as the default exception handling method. However, if user data is generated during application use, process exit may interrupt user operations and cause data loss.
In this way, application recovery APIs may help you save temporary data, restart an application after it exits, and restore its status and data, which deliver a better user experience. Application recovery helps to restore the application state and save temporary data upon next startup in the case of an abnormal process exit, thus providing more consistent user experience. The application state includes two parts, namely, the page stack of the and the data saved in **onSaveState**.
Currently, the APIs support only the development of an application that adopts the stage model, single process, and single ability. In API version 9, application recovery is supported only for a single ability of the application developed using the stage model. Application state saving and automatic restart are performed when a JsError occurs.
In API version 10, application recovery is also supported for multiple abilities of the application developed using the stage model. Application state storage and restore are performed when an AppFreeze occurs. If an application is killed in control mode, the application state will be restored upon next startup.
## Available APIs ## Available APIs
The application recovery APIs are provided by the **appRecovery** module, which can be imported via **import**. For details, please refer to [Development Example](#development-example). This document describes behaviors of APIs in API version 9, and the content will update with changes. The application recovery APIs are provided by the **appRecovery** module, which can be imported via **import**. For details, see [Development Example](#development-example).
### Available APIs ### Available APIs
| API | Description | | API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ---------------------------------------------------- |
| enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void; | Enables the application recovery function. | | enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void;<sup>9+</sup> | Enables application recovery. After this API is called, the first ability that is displayed when the application is started from the initiator can be restored.|
| saveAppState(): boolean; | Saves the ability status of an application. | | saveAppState(): boolean;<sup>9+</sup> | Saves the state of the ability that supports recovery in the current application.|
| restartApp(): void; | Restarts the current process. If there is saved ability status, it will be passed to the **want** parameter's **wantParam** attribute of the **onCreate** lifecycle callback of the ability.| | restartApp(): void;<sup>9+</sup> | Restarts the current process and starts the ability specified by **setRestartWant**. If no ability is specified, a foreground ability that supports recovery is restarted.|
| saveAppState(context?: UIAbilityContext): boolean;<sup>10+</sup> | Saves the ability state specified by **Context**.|
| setRestartWant(want: Want): void;<sup>10+</sup> | Sets the abilities to restart when **restartApp** is actively called and **RestartFlag** is not **NO_RESTART**. The abilities must be under the same bundle name and must be a **UiAbility**.|
No error will be thrown if the preceding APIs are used in the troubleshooting scenario. The following are some notes on API usage:
**enableAppRecovery**: This API should be called during application initialization. For example, you can call this API in **onCreate** of **AbilityStage**. For details, see [Parameter Description](../reference/apis/js-apis-app-ability-appRecovery.md).
**saveAppState**: After this API is called, the recovery framework invokes **onSaveState** for all abilities that support recovery in the current process. If you choose to save data in **onSaveState**, the related data and ability page stack are persistently stored in the local cache of the application. To save data of the specified ability, you need to specify the context corresponding to that ability.
**setRestartWant**: This API specifies the ability to be restarted by **appRecovery**.
**restartApp**: After this API is called, the recovery framework kills the current process and restarts the ability specified by **setRestartWant**, with **APP_RECOVERY** set as the startup cause. In API version 9 and scenarios where an ability is not specified by **setRestartWant**, the last foreground ability that supports recovery is started. If the no foreground ability supports recovery, the application crashes. If a saved state is available for the restarted ability, the saved state is passed as the **wantParam** attribute in the **want** parameter of the ability's **onCreate** callback.
### Application State Management
Since API version 10, application recovery is not limited to automatic restart in the case of an exception. Therefore, you need to understand when the application will load the saved state.
If the last exit of an application is not initiated by a user and a saved state is available for recovery, the startup reason is set to **APP_RECOVERY** when the application is started by the user next time, and the recovery state of the application is cleared.
The application recovery status flag is set when **saveAppState** is actively or passively called. The flag is cleared when the application exits normally or the saved state is consumed. (A normal exit is usually triggered by pressing the back key or clearing recent tasks.)
The APIs are used for troubleshooting and do not return any exception. Therefore, you need to be familiar with when they are used. ![Application recovery status management](./figures/application_recovery_status_management.png)
**enableAppRecovery**: This API should be called during application initialization. For example, you can call this API in **onCreate** of **AbilityStage**. For details, please refer to the [parameter description](../reference/apis/js-apis-app-ability-appRecovery.md). ### Application State Saving and Restore
**saveAppState**: After this API is called, the framework calls back **onSaveState** of the ability. If data saving is agreed to in this method, relevant data and the page stack of the ability are persisted to the local cache of the application. API version 10 or later supports saving of the application state when an application is suspended. If a JsError occurs, **onSaveState** is called in the main thread. If an AppFreeze occurs, however, the main thread may be suspended, and therefore **onSaveState** is called in a non-main thread. The following figure shows the main service flow.
**restartApp**: After this API is called, the framework kills the current application process and restarts the ability in the foreground, with **APP_RECOVERY** specified as the startup cause. ![Application recovery from the freezing state](./figures/application_recovery_from_freezing.png)
### Framework Fault Management Process When the application is suspended, the callback is not executed in the JS thread. Therefore, you are advised not to use the imported dynamic Native library or access the **thread_local** object created by the main thread in the code of the **onSaveState** callback.
### Framework Fault Management
Fault management is an important way for applications to deliver a better user experience. The application framework offers three methods for application fault management: fault listening, fault rectification, and fault query. Fault management is an important way for applications to deliver a better user experience. The application framework offers three methods for application fault management: fault listening, fault rectification, and fault query.
- Fault listening refers to the process of registering [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) via [errorManager](../reference/apis/js-apis-application-errorManager.md), listening for fault occurrence, and notifying the fault listener. - Fault listening refers to the process of registering an [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) via [errorManager](../reference/apis/js-apis-app-ability-errorManager.md), listening for faults, and notifying the listener of the faults.
- Fault rectification refers to the process of restoring the application state and data through [appRecovery](../reference/apis/js-apis-app-ability-appRecovery.md).
- Fault rectification refers to [appRecovery](../reference/apis/js-apis-app-ability-appRecovery.md) and restarts an application to restore its status previous to a fault. - Fault query is the process of calling APIs of [faultLogger](../reference/apis/js-apis-faultLogger.md) to obtain the fault information.
- Fault query indicates that [faultLogger](../reference/apis/js-apis-faultLogger.md) obtains the fault information using its query API. The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to the [LastExitReason](../reference/apis/js-apis-app-ability-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query information about the previous fault.
The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to [LastExitReason](../reference/apis/js-apis-app-ability-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query the information about the last fault.
![Fault rectification process](./figures/fault_rectification.png) ![Fault rectification process](./figures/fault_rectification.png)
It is recommended that you call [errorManager](../reference/apis/js-apis-application-errorManager.md) to process the exception. After the processing is complete, you can call the status saving API and restart the application. It is recommended that you call [errorManager](../reference/apis/js-apis-app-ability-errorManager.md) to handle the exception. After the processing is complete, you can call the **saveAppState** API and restart the application.
If you do not register [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) or enable application recovery, the application process will exit according to the default processing logic of the system. Users can restart the application from the home screen.
If you have enabled application recovery, the framework first checks whether a fault allows for ability status saving and whether you have configured ability status saving. If so, [onSaveState](../reference/apis/js-apis-application-ability.md#abilityonsavestate) of [Ability](../reference/apis/js-apis-application-ability.md#ability) is called back. Finally, the application is restarted. If you do not register [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) or enable application recovery, the application process will exit according to the default processing logic of the system. Users can restart the application from the home screen.
If you have enabled application recovery, the recovery framework first checks whether application state saving is supported and whether the application state saving is enabled. If so, the recovery framework invokes [onSaveState](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonsavestate) of the [Ability](../reference/apis/js-apis-app-ability-uiAbility.md). Finally, the application is restarted.
### Scenarios Supported by Application Fault Management APIs ### Supported Application Recovery Scenarios
Common fault types include JavaScript application crash, application freezing, and C++ application crash. Generally, an application is closed when a crash occurs. Application freezing occurs when the application does not respond. The fault type can be ignored for the upper layer of an application. The recovery framework implements fault management in different scenarios based on the fault type. Common fault types include JavaScript application crash, application freezing, and C++ application crash. Generally, an application is closed when a crash occurs. Application freezing occurs when the application does not respond. The fault type can be ignored for the upper layer of an application. The recovery framework implements fault management in different scenarios based on the fault type.
| Fault | Fault Listening| Status Saving| Automatic Restart| Log Query| | Fault | Fault Listening | State Saving| Automatic Restart| Log Query|
| ------------------------------------------------------------ | -------- | -------- | -------- | -------- | | ----------|--------- |--------- |--------- |--------- |
| [JS_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Supported | Supported | Supported | Supported | | [JS_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Supported|Supported|Supported|Supported|
| [APP_FREEZE](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported | Not supported | Supported | Supported | | [APP_FREEZE](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported|Supported|Supported|Supported|
| [CPP_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported | Not supported | Not supported | Supported | | [CPP_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported|Not supported|Not supported|Supported|
**Status Saving** in the table header means status saving when a fault occurs. To protect user data as much as possible in the application freezing fault, you can adopt either the periodic or automatic way, and the latter will save user data when an ability is switched to the background. **State Saving** in the table header means saving of the application state when a fault occurs. To protect user data as much as possible when an AppFreeze occurs, you can adopt either the periodic or automatic way, and the latter will save user data when an ability is switched to the background.
...@@ -78,11 +103,23 @@ export default class MyAbilityStage extends AbilityStage { ...@@ -78,11 +103,23 @@ export default class MyAbilityStage extends AbilityStage {
appRecovery.SaveModeFlag.SAVE_WITH_FILE); appRecovery.SaveModeFlag.SAVE_WITH_FILE);
} }
} }
```
### Enabling Application Recovery for the Specified Abilities
Generally, the ability configuration list is named **module.json5**.
```json
{
"abilities": [
{
"name": "EntryAbility",
"recoverable": true,
}]
}
``` ```
### Saving and Restoring Data ### Saving and Restoring Data
After enabling **appRecovery**, you can use this function by either actively or passively saving the status and restoring data in the ability. After enabling **appRecovery**, you can use this function by either actively or passively saving the application state and restoring data in the ability.
The following is an example of **EntryAbility**: The following is an example of **EntryAbility**:
#### Importing the Service Package #### Importing the Service Package
...@@ -93,9 +130,9 @@ import appRecovery from '@ohos.app.ability.appRecovery'; ...@@ -93,9 +130,9 @@ import appRecovery from '@ohos.app.ability.appRecovery';
import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import AbilityConstant from '@ohos.app.ability.AbilityConstant';
``` ```
#### Actively Saving Status and Restoring Data #### Actively Saving the Application State and Restoring Data
- Define and register the [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) callback. - Define and register the [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) callback.
```ts ```ts
var registerId = -1; var registerId = -1;
...@@ -108,7 +145,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant'; ...@@ -108,7 +145,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created. Set a main page for this ability. // Main window is created, set main page for this ability
console.log("[Demo] EntryAbility onWindowStageCreate") console.log("[Demo] EntryAbility onWindowStageCreate")
globalThis.registerObserver = (() => { globalThis.registerObserver = (() => {
...@@ -125,7 +162,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state, ...@@ -125,7 +162,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state,
```ts ```ts
onSaveState(state, wantParams) { onSaveState(state, wantParams) {
// Save application data. // Ability has called to save app data
console.log("[Demo] EntryAbility onSaveState") console.log("[Demo] EntryAbility onSaveState")
wantParams["myData"] = "my1234567"; wantParams["myData"] = "my1234567";
return AbilityConstant.onSaveResult.ALL_AGREE; return AbilityConstant.onSaveResult.ALL_AGREE;
...@@ -134,7 +171,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state, ...@@ -134,7 +171,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state,
- Restore data. - Restore data.
After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onCreate(want, launchParam)** of **EntryAbility** is called, and the saved data is in **parameters** of **want**. After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onCreate(want, launchParam)** of **EntryAbility** is called, and the saved data is stored in **parameters** of **want**.
```ts ```ts
storage: LocalStorage storage: LocalStorage
...@@ -150,11 +187,11 @@ onCreate(want, launchParam) { ...@@ -150,11 +187,11 @@ onCreate(want, launchParam) {
} }
``` ```
- Deregister **ErrorObserver callback**. - Unregister the **ErrorObserver** callback.
```ts ```ts
onWindowStageDestroy() { onWindowStageDestroy() {
// Main window is destroyed to release UI resources. // Main window is destroyed, release UI related resources
console.log("[Demo] EntryAbility onWindowStageDestroy") console.log("[Demo] EntryAbility onWindowStageDestroy")
globalThis.unRegisterObserver = (() => { globalThis.unRegisterObserver = (() => {
...@@ -165,9 +202,9 @@ onWindowStageDestroy() { ...@@ -165,9 +202,9 @@ onWindowStageDestroy() {
} }
``` ```
#### Passively Saving Status and Restoring Data #### Passively Saving the Application State and Restoring Data
This is triggered by the recovery framework. You do not need to register **ErrorObserver callback**. You only need to implement **onSaveState** of the ability for status saving and **onCreate** of the ability for data restoration. This is triggered by the recovery framework. You do not need to register an **ErrorObserver** callback. You only need to implement **onSaveState** for application state saving and **onCreate** for data restore.
```ts ```ts
export default class EntryAbility extends Ability { export default class EntryAbility extends Ability {
...@@ -184,7 +221,7 @@ export default class EntryAbility extends Ability { ...@@ -184,7 +221,7 @@ export default class EntryAbility extends Ability {
} }
onSaveState(state, wantParams) { onSaveState(state, wantParams) {
// Save application data. // Ability has called to save app data
console.log("[Demo] EntryAbility onSaveState") console.log("[Demo] EntryAbility onSaveState")
wantParams["myData"] = "my1234567"; wantParams["myData"] = "my1234567";
return AbilityConstant.onSaveResult.ALL_AGREE; return AbilityConstant.onSaveResult.ALL_AGREE;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. For more details about APIs and their usage, see [intl](../reference/apis/js-apis-intl.md). The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402. For more details about APIs and their usage, see [intl](../reference/apis/js-apis-intl.md).
The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities. The [i18n](../reference/apis/js-apis-i18n.md) module provides enhanced I18N capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities.
## Setting Locale Information ## Setting Locale Information
...@@ -111,7 +111,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug ...@@ -111,7 +111,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let dateTimeFormat = new Intl.DateTimeFormat(); let dateTimeFormat = new Intl.DateTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions). Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md#datetimeoptions9).
```js ```js
let options = {dateStyle: "full", timeStyle: "full"}; let options = {dateStyle: "full", timeStyle: "full"};
...@@ -150,7 +150,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug ...@@ -150,7 +150,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let resolvedOptions = dateTimeFormat.resolvedOptions(); // resolvedOptions = {"locale": "zh-CN", "calendar": "gregorian", "dateStyle":"full", "timeStyle":"full", "timeZone": "CST"} let resolvedOptions = dateTimeFormat.resolvedOptions(); // resolvedOptions = {"locale": "zh-CN", "calendar": "gregorian", "dateStyle":"full", "timeStyle":"full", "timeZone": "CST"}
``` ```
## Number Formatting ## Formatting Numbers
[NumberFormat](../reference/apis/js-apis-intl.md#numberformat) provides APIs to implement the number formatting specific to a locale. [NumberFormat](../reference/apis/js-apis-intl.md#numberformat) provides APIs to implement the number formatting specific to a locale.
...@@ -181,7 +181,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug ...@@ -181,7 +181,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let numberFormat = new Intl.NumberFormat(); let numberFormat = new Intl.NumberFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions). Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md#numberoptions9).
```js ```js
let options = {compactDisplay: "short", notation: "compact"}; let options = {compactDisplay: "short", notation: "compact"};
...@@ -209,7 +209,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug ...@@ -209,7 +209,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug
let resolvedOptions = numberFormat.resolvedOptions(); // resolvedOptions = {"locale": "zh-CN", "compactDisplay": "short", "notation": "compact", "numberingSystem": "Latn"} let resolvedOptions = numberFormat.resolvedOptions(); // resolvedOptions = {"locale": "zh-CN", "compactDisplay": "short", "notation": "compact", "numberingSystem": "Latn"}
``` ```
## String Sorting ## Sorting Strings
Users in different regions have different requirements for string sorting. [Collator](../reference/apis/js-apis-intl.md#collator8) provides APIs to sort character strings specific to a locale. Users in different regions have different requirements for string sorting. [Collator](../reference/apis/js-apis-intl.md#collator8) provides APIs to sort character strings specific to a locale.
...@@ -317,7 +317,7 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -317,7 +317,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let categoryResult = pluralRules.select(number); // categoryResult = "other" let categoryResult = pluralRules.select(number); // categoryResult = "other"
``` ```
## Formatting Relative Time ## Formatting the Relative Time
[RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8) provides APIs to format the relative time for a specific locale. [RelativeTimeFormat](../reference/apis/js-apis-intl.md#relativetimeformat8) provides APIs to format the relative time for a specific locale.
...@@ -385,9 +385,3 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -385,9 +385,3 @@ According to grammars in certain languages, the singular or plural form of a nou
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"} let options = relativeTimeFormat.resolvedOptions(); // options = {"locale": "zh-CN", "style": "long", "numeric": "always", "numberingSystem": "latn"}
``` ```
## Samples
The following sample is provided to help you better understand how to develop internationalization capabilities:
-[`International`: Internationalization (ArkTS) (API9) (Full SDK)] (https://gitee.com/openharmony/applications_app_samples/tree/master/code/SystemFeature/Internationalnation/International)
...@@ -256,7 +256,7 @@ struct MyComponent { ...@@ -256,7 +256,7 @@ struct MyComponent {
this.data.pushData('/path/image' + this.data.totalCount() + '.png') this.data.pushData('/path/image' + this.data.totalCount() + '.png')
}) })
}, item => item) }, item => item)
} }.height('100%').width('100%')
} }
} }
``` ```
......
...@@ -7,7 +7,7 @@ The host application of an inter-application HSP is a special form of applicatio ...@@ -7,7 +7,7 @@ The host application of an inter-application HSP is a special form of applicatio
1. The code of an inter-application HSP runs in the application process. When invoking the code, implement an exception capture and fault tolerance mechanism to avoid stability issues caused by malfunctioning of the inter-application HSP. 1. The code of an inter-application HSP runs in the application process. When invoking the code, implement an exception capture and fault tolerance mechanism to avoid stability issues caused by malfunctioning of the inter-application HSP.
2. An application can depend on multiple inter-application HSP files at the same time. 2. An application can depend on multiple inter-application HSP files at the same time.
3. The inter-application HSP may slow down the startup of the application that depends on it. To avoid significant increase in the startup delay, limit the number of inter-application HSP dependencies within 16. 3. The inter-application HSP may slow down the startup of the application that depends on it. To avoid significant increase in the startup delay, limit the number of inter-application HSP dependencies within 16.
4. Third-party developers can only use the system-provided inter-application HSP files. 4. Privilege verification is conducted during inter-application HSP installation. To develop an inter-application HSP, you must configure the **allowAppShareLibrary** application privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md).
## Inter-Application HSP Usage ## Inter-Application HSP Usage
An inter-application HSP works by combining the following parts: An inter-application HSP works by combining the following parts:
...@@ -23,7 +23,7 @@ src ...@@ -23,7 +23,7 @@ src
├── main ├── main
| └── module.json5 | └── module.json5
├── index.d.ets ├── index.d.ets
└── package.json └── oh-package.json5
``` ```
Below is an example of the **index.d.ets** file content: Below is an example of the **index.d.ets** file content:
```ts ```ts
...@@ -40,7 +40,7 @@ export declare function foo2(): string; ...@@ -40,7 +40,7 @@ export declare function foo2(): string;
export declare function nativeHello(): string; export declare function nativeHello(): string;
``` ```
In the example, **UIComponent** is an ArkUI component, **hello()**, **foo1()**, and **foo2()** are TS methods, and **nativeHello()** is an native method. Specific implementation is as follows: In the example, **UIComponent** is an ArkUI component, **hello()**, **foo1()**, and **foo2()** are TS methods, and **nativeHello()** is a native method. Specific implementation is as follows:
#### ArkUI Components #### ArkUI Components
The following is an implementation example of ArkUI components in the HSP: The following is an implementation example of ArkUI components in the HSP:
```ts ```ts
...@@ -117,7 +117,7 @@ extern "C" __attribute__((constructor)) void RegisterLibaModule(void) { ...@@ -117,7 +117,7 @@ extern "C" __attribute__((constructor)) void RegisterLibaModule(void) {
} }
``` ```
### Using the Capabilities Exported from the HAR ### Using the Capabilities Exported from the HAR
To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR. The dependency information will then be generated in the **module.json** file of the corresponding module, as shown in the following: To start with, [configure dependency](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-development-npm-package-0000001222578434#section89674298391) on the HAR. The dependency information will then be generated in the **module.json5** file of the corresponding module, as shown in the following:
```json ```json
"dependencies": [ "dependencies": [
{ {
......
...@@ -30,7 +30,7 @@ When obfuscation is enabled, DevEco Studio compiles, obfuscates, and compresses ...@@ -30,7 +30,7 @@ When obfuscation is enabled, DevEco Studio compiles, obfuscates, and compresses
- The HAR of the stage model cannot reference content in the **AppScope** folder. This is because the content in the **AppScope** folder is not packaged into the HAR during compilation and building. - The HAR of the stage model cannot reference content in the **AppScope** folder. This is because the content in the **AppScope** folder is not packaged into the HAR during compilation and building.
## Exporting ArkUI Components, APIs, and Resources of the HAR ## Exporting ArkUI Components, APIs, and Resources of the HAR
The **index.ets** file acts as the entry of the HAR export declaration file and is where the HAR exports APIs. This file is automatically generated by DevEco Studio by default. You can specify another file as the entry declaration file in the **main** field in the **package.json** file of the module. The code snippet is as follows: The **index.ets** file acts as the entry of the HAR export declaration file and is where the HAR exports APIs. This file is automatically generated by DevEco Studio by default. You can specify another file as the entry declaration file in the **main** field in the **oh-package.json5** file of the module. The code snippet is as follows:
```json ```json
{ {
"main": "index.ets" "main": "index.ets"
......
...@@ -15,7 +15,7 @@ library ...@@ -15,7 +15,7 @@ library
│ │ └── index.ets │ │ └── index.ets
│ ├── resources │ ├── resources
│ └── module.json5 │ └── module.json5
└── package.json └── oh-package.json5
``` ```
In the **module.json5** file, set **type** to **shared** for the HSP. In the **module.json5** file, set **type** to **shared** for the HSP.
```json ```json
...@@ -24,7 +24,7 @@ In the **module.json5** file, set **type** to **shared** for the HSP. ...@@ -24,7 +24,7 @@ In the **module.json5** file, set **type** to **shared** for the HSP.
} }
``` ```
The HSP provides capabilities for external systems by exporting APIs in the entry file. Specify the entry file in **main** in the **package.json** file. For example: The HSP provides capabilities for external systems by exporting APIs in the entry file. Specify the entry file in **main** in the **oh-package.json5** file. For example:
```json ```json
{ {
"main": "./src/main/ets/index.ets" "main": "./src/main/ets/index.ets"
...@@ -103,9 +103,9 @@ export { nativeMulti } from './utils/nativeTest' ...@@ -103,9 +103,9 @@ export { nativeMulti } from './utils/nativeTest'
``` ```
## Using the In-Application HSP ## Using the In-Application HSP
To use APIs in the HSP, first configure the dependency on the HSP in the **package.json** file of the module that needs to call the APIs (called the invoking module). If the HSP and the invoking module are in the same project, the APIs can be referenced locally. The sample code is as follows: To use APIs in the HSP, first configure the dependency on the HSP in the **oh-package.json5** file of the module that needs to call the APIs (called the invoking module). If the HSP and the invoking module are in the same project, the APIs can be referenced locally. The sample code is as follows:
```json ```json
// entry/src/main/module.json5 // entry/oh-package.json5
"dependencies": { "dependencies": {
"library": "file:../library" "library": "file:../library"
} }
......
...@@ -14,110 +14,6 @@ To subscribe to the call status, use [`observer.on('callStateChange')`](js-apis- ...@@ -14,110 +14,6 @@ To subscribe to the call status, use [`observer.on('callStateChange')`](js-apis-
import call from '@ohos.telephony.call'; import call from '@ohos.telephony.call';
``` ```
## call.dial<sup>(deprecated)</sup>
dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
Initiates a call. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example**
```js
call.dial("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.dial<sup>(deprecated)</sup>
dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean\>\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example**
```js
call.dial("138xxxxxxxx", {
extras: false
}, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.dial<sup>(deprecated)</sup>
dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
Initiates a call. You can set call options as needed. This API uses a promise to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | -------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call.|
**Return value**
| Type | Description |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example**
```js
let promise = call.dial("138xxxxxxxx", {
extras: false
});
promise.then(data => {
console.log(`dial success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`dial fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.dialCall<sup>9+</sup> ## call.dialCall<sup>9+</sup>
dialCall\(phoneNumber: string, callback: AsyncCallback<void\>\): void dialCall\(phoneNumber: string, callback: AsyncCallback<void\>\): void
...@@ -260,6 +156,107 @@ promise.then(() => { ...@@ -260,6 +156,107 @@ promise.then(() => {
}); });
``` ```
## call.dial<sup>(deprecated)</sup>
dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
Initiates a call. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications.
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example**
```js
call.dial("138xxxxxxxx", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.dial<sup>(deprecated)</sup>
dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean\>\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications.
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example**
```js
call.dial("138xxxxxxxx", {
extras: false
}, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.dial<sup>(deprecated)</sup>
dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
Initiates a call. You can set call options as needed. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9). The substitute API is available only for system applications.
**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | -------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call.|
**Return value**
| Type | Description |
| ---------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result.<br>- **true**: success<br>- **false**: failure|
**Example**
```js
let promise = call.dial("138xxxxxxxx", {
extras: false
});
promise.then(data => {
console.log(`dial success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`dial fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.makeCall<sup>7+</sup> ## call.makeCall<sup>7+</sup>
...@@ -2387,7 +2384,7 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba ...@@ -2387,7 +2384,7 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | -------------------------- | | -------- | ------------------------------------------------------- | ---- | -------------------------- |
| type | string | Yes | Event type. This field has a fixed value of **callDetailsChange**.| | type | string | Yes | Call event change. This field has a fixed value of **callDetailsChange**.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. | | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2427,7 +2424,7 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback ...@@ -2427,7 +2424,7 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | This interface is used to monitor the change of call events during a call. The parameter has a fixed value of callEventChange.| | type | string | Yes | Call event change. This field has a fixed value of **callEventChange**.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. | | callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2467,7 +2464,7 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca ...@@ -2467,7 +2464,7 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | Event type. The field has a fixed value of **callDisconnectedCause**.| | type | string | Yes | Call disconnection cause. This field has a fixed value of **callDisconnectedCause**.|
| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. | | callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2507,7 +2504,7 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t ...@@ -2507,7 +2504,7 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | --------------------- | | -------- | -------------------------------------------- | ---- | --------------------- |
| type | string | Yes | Event type. The field has a fixed value of **mmiCodeResult**.| | type | string | Yes | MMI code result. This field has a fixed value of **mmiCodeResult**.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. | | callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2547,7 +2544,7 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca ...@@ -2547,7 +2544,7 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------------- | ---- | ---------------------------------- | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- |
| type | string | Yes | Event type. The field has a fixed value of **callDetailsChange**.| | type | string | Yes | Call details change. This field has a fixed value of **callDetailsChange**.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. | | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2587,7 +2584,7 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call ...@@ -2587,7 +2584,7 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ---------------------------------- | | -------- | ------------------------------------------------ | ---- | ---------------------------------- |
| type | string | Yes | Event type. The field has a fixed value of **callEventChange**.| | type | string | Yes | Call event change. This field has a fixed value of **callEventChange**.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. | | callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2627,7 +2624,7 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou ...@@ -2627,7 +2624,7 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------------- | ---- | ------------------- | | -------- | ---------------------------------------------------------- | ---- | ------------------- |
| type | string | Yes | Event type. The field has a fixed value of **callDisconnectedCause**.| | type | string | Yes | Call disconnection cause. This field has a fixed value of **callDisconnectedCause**.|
| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. | | callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2667,7 +2664,7 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba ...@@ -2667,7 +2664,7 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ----------- | | -------- | ------------------------------------------------ | ---- | ----------- |
| type | string | Yes | Event type. The field has a fixed value of **mmiCodeResult**.| | type | string | Yes | MMI code result. This field has a fixed value of **mmiCodeResult**.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. | | callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. |
**Error codes** **Error codes**
......
...@@ -122,7 +122,9 @@ try { ...@@ -122,7 +122,9 @@ try {
addRule(rule: bigint): void addRule(rule: bigint): void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hichecker.addCheckRule](#hicheckeraddcheckrule9) instead. > **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [hichecker.addCheckRule](#hicheckeraddcheckrule9).
Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules. Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.
...@@ -149,7 +151,9 @@ hichecker.addRule( ...@@ -149,7 +151,9 @@ hichecker.addRule(
removeRule(rule: bigint): void removeRule(rule: bigint): void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hichecker.removeCheckRule](#hicheckerremovecheckrule9) instead. > **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [hichecker.removeCheckRule](#hicheckerremovecheckrule9).
Removes one or more rules. The removed rules will become ineffective. Removes one or more rules. The removed rules will become ineffective.
...@@ -200,7 +204,9 @@ hichecker.getRule(); // return 1n; ...@@ -200,7 +204,9 @@ hichecker.getRule(); // return 1n;
contains(rule: bigint): boolean contains(rule: bigint): boolean
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hichecker.containsCheckRule](#hicheckercontainscheckrule9) instead. > **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [hichecker.containsCheckRule](#hicheckercontainscheckrule9).
Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread. Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread.
......
# @ohos.hidebug (HiDebug) # @ohos.hidebug (HiDebug)
The **hidebug** module provides APIs for you to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data. > **NOTE**
>
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **hidebug** module provides APIs for you to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data.
## Modules to Import ## Modules to Import
...@@ -19,31 +19,25 @@ getNativeHeapSize(): bigint ...@@ -19,31 +19,25 @@ getNativeHeapSize(): bigint
Obtains the total heap memory size of this application. Obtains the total heap memory size of this application.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------------------- | | ------ | --------------------------- |
| bigint | Total heap memory size of the application, in KB.| | bigint | Total heap memory size of the application, in KB.|
**Example** **Example**
```js ```js
let nativeHeapSize = hidebug.getNativeHeapSize(); let nativeHeapSize = hidebug.getNativeHeapSize();
``` ```
## hidebug.getNativeHeapAllocatedSize ## hidebug.getNativeHeapAllocatedSize
getNativeHeapAllocatedSize(): bigint getNativeHeapAllocatedSize(): bigint
Obtains the allocated heap memory size of this application. Obtains the allocated heap memory size of this application.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value** **Return value**
...@@ -58,15 +52,12 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. ...@@ -58,15 +52,12 @@ This API is defined but not implemented in OpenHarmony 3.1 Release.
let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize();
``` ```
## hidebug.getNativeHeapFreeSize ## hidebug.getNativeHeapFreeSize
getNativeHeapFreeSize(): bigint getNativeHeapFreeSize(): bigint
Obtains the free heap memory size of this application. Obtains the free heap memory size of this application.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value** **Return value**
...@@ -80,7 +71,6 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. ...@@ -80,7 +71,6 @@ This API is defined but not implemented in OpenHarmony 3.1 Release.
let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize();
``` ```
## hidebug.getPss ## hidebug.getPss
getPss(): bigint getPss(): bigint
...@@ -100,7 +90,6 @@ Obtains the size of the physical memory actually used by the application process ...@@ -100,7 +90,6 @@ Obtains the size of the physical memory actually used by the application process
let pss = hidebug.getPss(); let pss = hidebug.getPss();
``` ```
## hidebug.getSharedDirty ## hidebug.getSharedDirty
getSharedDirty(): bigint getSharedDirty(): bigint
...@@ -135,7 +124,6 @@ Obtains the size of the private dirty memory of a process. ...@@ -135,7 +124,6 @@ Obtains the size of the private dirty memory of a process.
| ------ | -------------------------- | | ------ | -------------------------- |
| bigint | Size of the private dirty memory of the process, in KB.| | bigint | Size of the private dirty memory of the process, in KB.|
**Example** **Example**
```js ```js
let privateDirty = hidebug.getPrivateDirty(); let privateDirty = hidebug.getPrivateDirty();
...@@ -163,76 +151,6 @@ For example, if the CPU usage is **50%**, **0.5** is returned. ...@@ -163,76 +151,6 @@ For example, if the CPU usage is **50%**, **0.5** is returned.
let cpuUsage = hidebug.getCpuUsage(); let cpuUsage = hidebug.getCpuUsage();
``` ```
## hidebug.startProfiling<sup>(deprecated)</sup>
startProfiling(filename : string) : void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hidebug.startJsCpuProfiling](#hidebugstartjscpuprofiling9) instead.
Starts the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the sequence similar to the following is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined profile name. The `filename.json` file is generated in the `files` directory of the application based on the specified `filename`.|
**Example**
```js
hidebug.startProfiling("cpuprofiler-20220216");
// code block
// ...
// code block
hidebug.stopProfiling();
```
## hidebug.stopProfiling<sup>(deprecated)</sup>
stopProfiling() : void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hidebug.stopJsCpuProfiling](#hidebugstopjscpuprofiling9) instead.
Stops the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the sequence similar to the following is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Example**
```js
hidebug.startProfiling("cpuprofiler-20220216");
// code block
// ...
// code block
hidebug.stopProfiling();
```
## hidebug.dumpHeapData<sup>(deprecated)</sup>
dumpHeapData(filename : string) : void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hidebug.dumpJsHeapData](#hidebugdumpjsheapdata9) instead.
Exports the heap data.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the application based on the specified `filename`.|
**Example**
```js
hidebug.dumpHeapData("heap-20220216");
```
## hidebug.getServiceDump<sup>9+<sup> ## hidebug.getServiceDump<sup>9+<sup>
getServiceDump(serviceid : number, fd : number, args : Array\<string>) : void getServiceDump(serviceid : number, fd : number, args : Array\<string>) : void
...@@ -360,3 +278,71 @@ try { ...@@ -360,3 +278,71 @@ try {
console.info(error.message) console.info(error.message)
} }
``` ```
## hidebug.startProfiling<sup>(deprecated)</sup>
startProfiling(filename : string) : void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hidebug.startJsCpuProfiling](#hidebugstartjscpuprofiling9) instead.
Starts the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the sequence similar to the following is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined profile name. The `filename.json` file is generated in the `files` directory of the application based on the specified `filename`.|
**Example**
```js
hidebug.startProfiling("cpuprofiler-20220216");
// code block
// ...
// code block
hidebug.stopProfiling();
```
## hidebug.stopProfiling<sup>(deprecated)</sup>
stopProfiling() : void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hidebug.stopJsCpuProfiling](#hidebugstopjscpuprofiling9) instead.
Stops the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the sequence similar to the following is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Example**
```js
hidebug.startProfiling("cpuprofiler-20220216");
// code block
// ...
// code block
hidebug.stopProfiling();
```
## hidebug.dumpHeapData<sup>(deprecated)</sup>
dumpHeapData(filename : string) : void
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [hidebug.dumpJsHeapData](#hidebugdumpjsheapdata9) instead.
Exports the heap data.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the application based on the specified `filename`.|
**Example**
```js
hidebug.dumpHeapData("heap-20220216");
```
# @ohos.net.http (Data Request) # @ohos.net.http (Data Request)
This module provides the HTTP data request capability. An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**. The **http** module provides the HTTP data request capability. An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**.
>**NOTE** >**NOTE**
> >
...@@ -13,10 +13,10 @@ This module provides the HTTP data request capability. An application can initia ...@@ -13,10 +13,10 @@ This module provides the HTTP data request capability. An application can initia
import http from '@ohos.net.http'; import http from '@ohos.net.http';
``` ```
## Example ## Examples
```js ```js
// Import the http namespace. // Import the HTTP namespace.
import http from '@ohos.net.http'; import http from '@ohos.net.http';
// Each httpRequest corresponds to an HTTP request task and cannot be reused. // Each httpRequest corresponds to an HTTP request task and cannot be reused.
...@@ -27,7 +27,7 @@ httpRequest.on('headersReceive', (header) => { ...@@ -27,7 +27,7 @@ httpRequest.on('headersReceive', (header) => {
console.info('header: ' + JSON.stringify(header)); console.info('header: ' + JSON.stringify(header));
}); });
httpRequest.request( httpRequest.request(
// Customize EXAMPLE_URL on your own. It is up to you whether to add parameters to the URL. // Customize EXAMPLE_URL in extraData on your own. It is up to you whether to add parameters to the URL.
"EXAMPLE_URL", "EXAMPLE_URL",
{ {
method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET. method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET.
...@@ -69,7 +69,7 @@ httpRequest.request( ...@@ -69,7 +69,7 @@ httpRequest.request(
createHttp(): HttpRequest createHttp(): HttpRequest
Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An HttpRequest object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request. Creates an HTTP request. You can use this API to initiate or destroy an HTTP request, or enable or disable listening for HTTP Response Header events. An **HttpRequest** object corresponds to an HTTP request. To initiate multiple HTTP requests, you must create an **HttpRequest** object for each HTTP request.
**System capability**: SystemCapability.Communication.NetStack **System capability**: SystemCapability.Communication.NetStack
...@@ -112,7 +112,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -112,7 +112,7 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -164,7 +164,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -164,7 +164,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -231,7 +231,7 @@ httpRequest.request("EXAMPLE_URL", ...@@ -231,7 +231,7 @@ httpRequest.request("EXAMPLE_URL",
request(url: string, options? : HttpRequestOptions): Promise\<HttpResponse\> request(url: string, options? : HttpRequestOptions): Promise\<HttpResponse\>
Initiates an HTTP request to a given URL. This API uses a promise to return the result. Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result.
>**NOTE** >**NOTE**
>This API supports only transfer of data not greater than 5 MB. >This API supports only transfer of data not greater than 5 MB.
...@@ -255,7 +255,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the ...@@ -255,7 +255,7 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -332,7 +332,7 @@ httpRequest.destroy(); ...@@ -332,7 +332,7 @@ httpRequest.destroy();
### request2<sup>10+</sup> ### request2<sup>10+</sup>
request2(url: string, callback: AsyncCallback\<void\>): void request2(url: string, callback: AsyncCallback\<number\>): void
Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response. Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response.
...@@ -345,11 +345,11 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -345,11 +345,11 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | ----------------------------------------------- | | -------- | ---------------------------------------------- | ---- | ----------------------------------------------- |
| url | string | Yes | URL for initiating an HTTP request. | | url | string | Yes | URL for initiating an HTTP request. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[number](#responsecode)\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -366,9 +366,9 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -366,9 +366,9 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
**Example** **Example**
```js ```js
httpRequest.request2("EXAMPLE_URL", (err) => { httpRequest.request2("EXAMPLE_URL", (err, data) => {
if (!err) { if (!err) {
console.info("request2 OK!"); console.info("request2 OK! ResponseCode is " + JSON.stringify(data));
} else { } else {
console.info("request2 ERROR : err = " + JSON.stringify(err)); console.info("request2 ERROR : err = " + JSON.stringify(err));
} }
...@@ -377,7 +377,7 @@ httpRequest.request2("EXAMPLE_URL", (err) => { ...@@ -377,7 +377,7 @@ httpRequest.request2("EXAMPLE_URL", (err) => {
### request2<sup>10+</sup> ### request2<sup>10+</sup>
request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\<void\>): void request2(url: string, options: HttpRequestOptions, callback: AsyncCallback\<number\>): void
Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response. Initiates an HTTP request to a given URL. This API uses an asynchronous callback to return the result, which is a streaming response.
...@@ -391,11 +391,11 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback ...@@ -391,11 +391,11 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback
| -------- | ---------------------------------------------- | ---- | ----------------------------------------------- | | -------- | ---------------------------------------------- | ---- | ----------------------------------------------- |
| url | string | Yes | URL for initiating an HTTP request. | | url | string | Yes | URL for initiating an HTTP request. |
| options | HttpRequestOptions | Yes | Request options. For details, see [HttpRequestOptions](#httprequestoptions).| | options | HttpRequestOptions | Yes | Request options. For details, see [HttpRequestOptions](#httprequestoptions).|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[number](#responsecode)\> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -444,9 +444,9 @@ httpRequest.request2("EXAMPLE_URL", ...@@ -444,9 +444,9 @@ httpRequest.request2("EXAMPLE_URL",
}, },
readTimeout: 60000, readTimeout: 60000,
connectTimeout: 60000 connectTimeout: 60000
}, (err) => { }, (err, data) => {
if (!err) { if (!err) {
console.info("request2 OK!"); console.info("request2 OK! ResponseCode is " + JSON.stringify(data));
} else { } else {
console.info("request2 ERROR : err = " + JSON.stringify(err)); console.info("request2 ERROR : err = " + JSON.stringify(err));
} }
...@@ -454,7 +454,7 @@ httpRequest.request2("EXAMPLE_URL", ...@@ -454,7 +454,7 @@ httpRequest.request2("EXAMPLE_URL",
``` ```
### request2<sup>10+</sup> ### request2<sup>10+</sup>
request2(url: string, options? : HttpRequestOptions): Promise\<void\> request2(url: string, options? : HttpRequestOptions): Promise\<number\>
Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result, which is a streaming response. Initiates an HTTP request containing specified options to a given URL. This API uses a promise to return the result, which is a streaming response.
...@@ -473,11 +473,11 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -473,11 +473,11 @@ Initiates an HTTP request containing specified options to a given URL. This API
| Type | Description | | Type | Description |
| :------------------------------------- | :-------------------------------- | | :------------------------------------- | :-------------------------------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<[number](#responsecode)\> | Promise used to return the result.|
**Error codes** **Error codes**
| Code | Error Message | | ID | Error Message |
|---------|-------------------------------------------------------| |---------|-------------------------------------------------------|
| 401 | Parameter error. | | 401 | Parameter error. |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -513,7 +513,7 @@ Initiates an HTTP request containing specified options to a given URL. This API ...@@ -513,7 +513,7 @@ Initiates an HTTP request containing specified options to a given URL. This API
>**NOTE** >**NOTE**
> For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md). > For details about the error codes, see [HTTP Error Codes](../errorcodes/errorcode-net-http.md).
> The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see [Curl Error Codes](https://curl.se/libcurl/c/libcurl-errors.html). > The HTTP error code mapping is in the format of 2300000 + Curl error code. For more common error codes, see:
**Example** **Example**
...@@ -526,8 +526,8 @@ let promise = httpRequest.request("EXAMPLE_URL", { ...@@ -526,8 +526,8 @@ let promise = httpRequest.request("EXAMPLE_URL", {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}); });
promise.then(() => { promise.then((data) => {
console.info("request2 OK!"); console.info("request2 OK!" + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.info("request2 ERROR : err = " + JSON.stringify(err)); console.info("request2 ERROR : err = " + JSON.stringify(err));
}); });
...@@ -839,7 +839,7 @@ Enumerates the response codes for an HTTP request. ...@@ -839,7 +839,7 @@ Enumerates the response codes for an HTTP request.
| Name | Value | Description | | Name | Value | Description |
| ----------------- | ---- | ------------------------------------------------------------ | | ----------------- | ---- | ------------------------------------------------------------ |
| OK | 200 | The request is successful. The request has been processed successfully. This return code is generally used for GET and POST requests. | | OK | 200 | "OK." The request has been processed successfully. This return code is generally used for GET and POST requests. |
| CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. | | CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. |
| ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. | | ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. |
| NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. | | NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. |
...@@ -1007,7 +1007,7 @@ Disables the cache and deletes the data in it. This API uses a promise to return ...@@ -1007,7 +1007,7 @@ Disables the cache and deletes the data in it. This API uses a promise to return
| Type | Description | | Type | Description |
| --------------------------------- | ------------------------------------- | | --------------------------------- | ------------------------------------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<void\> | Promise used to return the result.|
**Example** **Example**
......
...@@ -294,8 +294,8 @@ let httpProxy = { ...@@ -294,8 +294,8 @@ let httpProxy = {
port: 8080, port: 8080,
exclusionList: exclusionArray exclusionList: exclusionArray
} }
connection.setGlobalHttpProxy(httpProxy).then((error, data) => { connection.setGlobalHttpProxy(httpProxy).then(() => {
console.info(JSON.stringify(data)); console.info("success");
}).catch(error=>{ }).catch(error=>{
console.info(JSON.stringify(error)); console.info(JSON.stringify(error));
}) })
...@@ -436,8 +436,8 @@ Binds an application to the specified network, so that the application can acces ...@@ -436,8 +436,8 @@ Binds an application to the specified network, so that the application can acces
```js ```js
connection.getDefaultNet().then(function (netHandle) { connection.getDefaultNet().then(function (netHandle) {
connection.setAppNet(netHandle).then((error, data) => { connection.setAppNet(netHandle).then(() => {
console.log(JSON.stringify(data)) console.log("success")
}).catch(error => { }).catch(error => {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}) })
...@@ -1097,7 +1097,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): ...@@ -1097,7 +1097,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
Resolves the host name by using the default network to obtain all IP addresses. This API uses an asynchronous callback to return the result. Resolves the host name by using the default network to obtain all IP addresses. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -1134,7 +1134,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>> ...@@ -1134,7 +1134,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result. Resolves the host name by using the default network to obtain all IP addresses. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -1639,7 +1639,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>): ...@@ -1639,7 +1639,7 @@ getAddressesByName(host: string, callback: AsyncCallback\<Array\<NetAddress>>):
Resolves the host name by using the corresponding network to obtain all IP addresses. This API uses an asynchronous callback to return the result. Resolves the host name by using the corresponding network to obtain all IP addresses. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -1678,7 +1678,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>> ...@@ -1678,7 +1678,7 @@ getAddressesByName(host: string): Promise\<Array\<NetAddress>>
Resolves the host name by using the corresponding network to obtain all IP addresses. This API uses a promise to return the result. Resolves the host name by using the corresponding network to obtain all IP addresses. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -1721,7 +1721,7 @@ getAddressByName(host: string, callback: AsyncCallback\<NetAddress>): void ...@@ -1721,7 +1721,7 @@ getAddressByName(host: string, callback: AsyncCallback\<NetAddress>): void
Resolves the host name by using the corresponding network to obtain the first IP address. This API uses an asynchronous callback to return the result. Resolves the host name by using the corresponding network to obtain the first IP address. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
...@@ -1760,7 +1760,7 @@ getAddressByName(host: string): Promise\<NetAddress> ...@@ -1760,7 +1760,7 @@ getAddressByName(host: string): Promise\<NetAddress>
Resolves the host name by using the corresponding network to obtain the first IP address. This API uses a promise to return the result. Resolves the host name by using the corresponding network to obtain the first IP address. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO **Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
......
...@@ -25,13 +25,15 @@ Registers an observer for network status change events. This API uses an asynchr ...@@ -25,13 +25,15 @@ Registers an observer for network status change events. This API uses an asynchr
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------------------- |
| type | string | Yes | Network status change event. | | type | string | Yes | Network status change event. This field has a fixed value of **networkStateChange**. |
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).| | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -62,14 +64,16 @@ Registers an observer for network status change events of the SIM card in the sp ...@@ -62,14 +64,16 @@ Registers an observer for network status change events of the SIM card in the sp
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------------------- |
| type | string | Yes | Network status change event. | | type | string | Yes | Network status change event. This field has a fixed value of **networkStateChange**. |
| 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 |
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).| | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | Yes | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -104,7 +108,7 @@ Unregisters the observer for network status change events. This API uses an asyn ...@@ -104,7 +108,7 @@ Unregisters the observer for network status change events. This API uses an asyn
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Network status change event. | | type | string | Yes | Network status change event. This field has a fixed value of **networkStateChange**. |
| callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | No | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).| | callback | Callback\<[NetworkState](js-apis-radio.md#networkstate)\> | No | Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#networkstate).|
| ID| Error Message | | ID| Error Message |
...@@ -138,12 +142,14 @@ Registers an observer for signal status change events. This API uses an asynchro ...@@ -138,12 +142,14 @@ Registers an observer for signal status change events. This API uses an asynchro
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
| type | string | Yes | Signal information change event. | | type | string | Yes | Signal status change event. This field has a fixed value of **signalInfoChange**. |
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| | callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -172,14 +178,16 @@ Registers an observer for signal status change events of the SIM card in the spe ...@@ -172,14 +178,16 @@ Registers an observer for signal status change events of the SIM card in the spe
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
| type | string | Yes | Signal information change event. | | type | string | Yes | Signal status change event. This field has a fixed value of **signalInfoChange**. |
| 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 |
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| | callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -214,11 +222,13 @@ Unregisters the observer for signal status change events. This API uses an async ...@@ -214,11 +222,13 @@ Unregisters the observer for signal status change events. This API uses an async
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Signal information change event. | | type | string | Yes | Signal status change event. This field has a fixed value of **signalInfoChange**. |
| callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | No | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| | callback | Callback<Array<[SignalInformation](js-apis-radio.md#signalinformation)\>\> | No | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -255,7 +265,7 @@ Registers an observer for cell information change events. This API uses an async ...@@ -255,7 +265,7 @@ Registers an observer for cell information change events. This API uses an async
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- |------------------------------------------------------------| | -------- | --------------------------------------------------------- | ---- |------------------------------------------------------------|
| type | string | Yes | Cell information change event. This field has a fixed value of **cellInfoChange**. | | type | string | Yes | Cell information change event. This field has a fixed value of **cellInfoChange**. |
| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | Yes | Callback used to return the result.| | callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -370,12 +380,14 @@ Registers an observer for call status change events. This API uses an asynchrono ...@@ -370,12 +380,14 @@ Registers an observer for call status change events. This API uses an asynchrono
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
| type | string | Yes | Call status change event. | | type | string | Yes | Call status change event. This field has a fixed value of **callStateChange**. |
| callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | Yes | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.<br>**number**: phone number.| | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | Yes | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.<br>**number**: phone number.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -404,13 +416,15 @@ Registers an observer for call status change events. This API uses an asynchrono ...@@ -404,13 +416,15 @@ Registers an observer for call status change events. This API uses an asynchrono
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
| type | string | Yes | Call status change event. | | type | string | Yes | Call status change event. This field has a fixed value of **callStateChange**. |
| 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 |
| callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | Yes | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.<br>**number**: phone number.| | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | Yes | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.<br>**number**: phone number.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -443,12 +457,14 @@ Unregisters the observer for call status change events. This API uses an asynchr ...@@ -443,12 +457,14 @@ Unregisters the observer for call status change events. This API uses an asynchr
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
| type | string | Yes | Call status change event. | | type | string | Yes | Call status change event. This field has a fixed value of **callStateChange**. |
| callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | No | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.<br>**number**: phone number.| | callback | Callback\<{ state: [CallState](js-apis-call.md#callstate), number: string }\> | No | Callback function. For details, see [CallState](js-apis-call.md#callstate) in call.<br>**number**: phone number.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -482,11 +498,13 @@ Registers an observer for connection status change events of the cellular data l ...@@ -482,11 +498,13 @@ Registers an observer for connection status change events of the cellular data l
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Connection status change event of the cellular data link. | | type | string | Yes | Cellular data connection status event. This field has a fixed value of **cellularDataConnectionStateChange**.|
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -516,12 +534,14 @@ Registers an observer for connection status change events of the cellular data l ...@@ -516,12 +534,14 @@ Registers an observer for connection status change events of the cellular data l
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Connection status change event of the cellular data link. | | type | string | Yes | Cellular data connection status event. This field has a fixed value of **cellularDataConnectionStateChange**.|
| 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 |
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -555,11 +575,13 @@ Unregisters the observer for connection status change events of the cellular dat ...@@ -555,11 +575,13 @@ Unregisters the observer for connection status change events of the cellular dat
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Connection status change event of the cellular data link. | | type | string | Yes | Cellular data connection status event. This field has a fixed value of **cellularDataConnectionStateChange**.|
| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | No | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | No | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -593,11 +615,13 @@ Registers an observer for the uplink and downlink data flow status change events ...@@ -593,11 +615,13 @@ Registers an observer for the uplink and downlink data flow status change events
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Uplink and downlink data flow status change event of the cellular data service. | | type | string | Yes | Cellular data flow change event. This field has a fixed value of **cellularDataFlowChange**. |
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).| | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -627,12 +651,14 @@ Registers an observer for the uplink and downlink data flow status change events ...@@ -627,12 +651,14 @@ Registers an observer for the uplink and downlink data flow status change events
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Uplink and downlink data flow status change event of the cellular data service. | | type | string | Yes | Cellular data flow change event. This field has a fixed value of **cellularDataFlowChange**. |
| 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 |
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).| | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | Yes | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -664,13 +690,15 @@ Unregisters the observer for the uplink and downlink data flow status change eve ...@@ -664,13 +690,15 @@ Unregisters the observer for the uplink and downlink data flow status change eve
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Uplink and downlink data flow status change event of the cellular data service. | | type | string | Yes | Cellular data flow change event. This field has a fixed value of **cellularDataFlowChange**. |
| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | No | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).| | callback | Callback\<[DataFlowType](js-apis-telephony-data.md#dataflowtype)\> | No | Callback used to return the result. For details, see [DataFlowType](js-apis-telephony-data.md#dataflowtype).|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -703,12 +731,14 @@ Registers an observer for SIM card status change events. This API uses an asynch ...@@ -703,12 +731,14 @@ Registers an observer for SIM card status change events. This API uses an asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
| type | string | Yes | SIM card status change event. | | type | string | Yes | SIM status change event. This field has a fixed value of **simStateChange**. |
| callback | Callback\<[SimStateData](#simstatedata7)\> | Yes | Callback used to return the result.| | callback | Callback\<[SimStateData](#simstatedata7)\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -738,12 +768,14 @@ Registers an observer for status change events of the SIM card in the specified ...@@ -738,12 +768,14 @@ Registers an observer for status change events of the SIM card in the specified
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | SIM card status change event. | | type | string | Yes | SIM status change event. This field has a fixed value of **simStateChange**. |
| 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 |
| callback | Callback\<[SimStateData](#simstatedata7)\> | Yes | Callback used to return the result.| | callback | Callback\<[SimStateData](#simstatedata7)\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -777,11 +809,13 @@ Unregisters the observer for SIM card status change events. This API uses an asy ...@@ -777,11 +809,13 @@ Unregisters the observer for SIM card status change events. This API uses an asy
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | SIM card status change event. | | type | string | Yes | SIM status change event. This field has a fixed value of **simStateChange**. |
| callback | Callback\<[SimStateData](#simstatedata7)\> | No | Callback used to return the result.| | callback | Callback\<[SimStateData](#simstatedata7)\> | No | Callback used to return the result.|
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
......
...@@ -32,6 +32,8 @@ Obtains the RAT used in the CS and PS domains for the SIM card in the specified ...@@ -32,6 +32,8 @@ Obtains the RAT used in the CS and PS domains for the SIM card in the specified
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -75,6 +77,8 @@ Obtains the RAT used in the CS and PS domains for the SIM card in the specified ...@@ -75,6 +77,8 @@ Obtains the RAT used in the CS and PS domains for the SIM card in the specified
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -115,6 +119,8 @@ Obtains the network status. This API uses an asynchronous callback to return the ...@@ -115,6 +119,8 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -152,6 +158,8 @@ Obtains the network status. This API uses an asynchronous callback to return the ...@@ -152,6 +158,8 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -195,6 +203,8 @@ Obtains the network status. This API uses a promise to return the result. ...@@ -195,6 +203,8 @@ Obtains the network status. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -234,6 +244,8 @@ Obtains the network selection mode of the SIM card in the specified slot. This A ...@@ -234,6 +244,8 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -274,6 +286,8 @@ Obtains the network selection mode of the SIM card in the specified slot. This A ...@@ -274,6 +286,8 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -312,6 +326,8 @@ Obtains the ISO country code of the network with which the SIM card in the speci ...@@ -312,6 +326,8 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -352,6 +368,8 @@ Obtains the ISO country code of the network with which the SIM card in the speci ...@@ -352,6 +368,8 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -389,6 +407,8 @@ Obtains the ID of the slot in which the primary card is located. This API uses a ...@@ -389,6 +407,8 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
...@@ -421,6 +441,8 @@ Obtains the ID of the slot in which the primary card is located. This API uses a ...@@ -421,6 +441,8 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
...@@ -457,6 +479,8 @@ Obtains a list of signal strengths of the network with which the SIM card in the ...@@ -457,6 +479,8 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -497,6 +521,8 @@ Obtains a list of signal strengths of the network with which the SIM card in the ...@@ -497,6 +521,8 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -644,6 +670,8 @@ Checks whether the radio service is enabled on the primary SIM card. This API us ...@@ -644,6 +670,8 @@ Checks whether the radio service is enabled on the primary SIM card. This API us
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -681,6 +709,8 @@ Checks whether the radio service is enabled on the SIM card in the specified slo ...@@ -681,6 +709,8 @@ Checks whether the radio service is enabled on the SIM card in the specified slo
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -724,6 +754,8 @@ Checks whether the radio service is enabled on the SIM card in the specified slo ...@@ -724,6 +754,8 @@ Checks whether the radio service is enabled on the SIM card in the specified slo
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -763,6 +795,8 @@ Obtains the carrier name for the SIM card in the specified slot. This API uses a ...@@ -763,6 +795,8 @@ Obtains the carrier name for the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -803,6 +837,8 @@ Obtains the carrier name for the SIM card in the specified slot. This API uses a ...@@ -803,6 +837,8 @@ Obtains the carrier name for the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -844,6 +880,8 @@ Sets the ID of the slot in which the primary card is located. This API uses an a ...@@ -844,6 +880,8 @@ Sets the ID of the slot in which the primary card is located. This API uses an a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -858,8 +896,8 @@ Sets the ID of the slot in which the primary card is located. This API uses an a ...@@ -858,8 +896,8 @@ Sets the ID of the slot in which the primary card is located. This API uses an a
```js ```js
let slotId = 0; let slotId = 0;
radio.setPrimarySlotId(slotId, (err, data) => { radio.setPrimarySlotId(slotId, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -890,6 +928,8 @@ Sets the ID of the slot in which the primary card is located. This API uses a pr ...@@ -890,6 +928,8 @@ Sets the ID of the slot in which the primary card is located. This API uses a pr
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -905,9 +945,9 @@ Sets the ID of the slot in which the primary card is located. This API uses a pr ...@@ -905,9 +945,9 @@ Sets the ID of the slot in which the primary card is located. This API uses a pr
```js ```js
let slotId = 0; let slotId = 0;
let promise = radio.setPrimarySlotId(slotId); let promise = radio.setPrimarySlotId(slotId);
promise.then(data => { promise.then(() => {
console.log(`setPrimarySlotId success, promise: data->${JSON.stringify(data)}`); console.log(`setPrimarySlotId success.`);
}).catch(err => { }).catch((err) => {
console.log(`setPrimarySlotId failed, promise: err->${JSON.stringify(err)}`); console.log(`setPrimarySlotId failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -932,6 +972,8 @@ Obtains the IMEI of the SIM card in a card slot. This API uses an asynchronous c ...@@ -932,6 +972,8 @@ Obtains the IMEI of the SIM card in a card slot. This API uses an asynchronous c
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -971,6 +1013,8 @@ Obtains the IMEI of the SIM card in the specified card slot. This API uses an as ...@@ -971,6 +1013,8 @@ Obtains the IMEI of the SIM card in the specified card slot. This API uses an as
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1016,6 +1060,8 @@ Obtains the IMEI of the SIM card in the specified card slot. This API uses a pro ...@@ -1016,6 +1060,8 @@ Obtains the IMEI of the SIM card in the specified card slot. This API uses a pro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1057,6 +1103,8 @@ Obtains the MEID of the SIM card in a card slot. This API uses an asynchronous c ...@@ -1057,6 +1103,8 @@ Obtains the MEID of the SIM card in a card slot. This API uses an asynchronous c
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1096,6 +1144,8 @@ Obtains the MEID of the SIM card in the specified card slot. This API uses an as ...@@ -1096,6 +1144,8 @@ Obtains the MEID of the SIM card in the specified card slot. This API uses an as
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1141,6 +1191,8 @@ Obtains the MEID of the SIM card in the specified card slot. This API uses a pro ...@@ -1141,6 +1191,8 @@ Obtains the MEID of the SIM card in the specified card slot. This API uses a pro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1182,6 +1234,8 @@ Obtains the unique device ID of the SIM card in a card slot. This API uses an as ...@@ -1182,6 +1234,8 @@ Obtains the unique device ID of the SIM card in a card slot. This API uses an as
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1221,6 +1275,8 @@ Obtains the unique device ID of the SIM card in the specified card slot. This AP ...@@ -1221,6 +1275,8 @@ Obtains the unique device ID of the SIM card in the specified card slot. This AP
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1266,6 +1322,8 @@ Obtains the unique device ID of the SIM card in the specified card slot. This AP ...@@ -1266,6 +1322,8 @@ Obtains the unique device ID of the SIM card in the specified card slot. This AP
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1307,6 +1365,8 @@ Sends a cell location update request. This API uses an asynchronous callback to ...@@ -1307,6 +1365,8 @@ Sends a cell location update request. This API uses an asynchronous callback to
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1319,8 +1379,8 @@ Sends a cell location update request. This API uses an asynchronous callback to ...@@ -1319,8 +1379,8 @@ Sends a cell location update request. This API uses an asynchronous callback to
**Example** **Example**
```js ```js
radio.sendUpdateCellLocationRequest((err, data) => { radio.sendUpdateCellLocationRequest((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1345,6 +1405,8 @@ Sends a cell location update request for the SIM card in the specified slot. Thi ...@@ -1345,6 +1405,8 @@ Sends a cell location update request for the SIM card in the specified slot. Thi
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1358,8 +1420,8 @@ Sends a cell location update request for the SIM card in the specified slot. Thi ...@@ -1358,8 +1420,8 @@ Sends a cell location update request for the SIM card in the specified slot. Thi
```js ```js
let slotId = 0; let slotId = 0;
radio.sendUpdateCellLocationRequest(slotId, (err, data) => { radio.sendUpdateCellLocationRequest(slotId, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1389,6 +1451,8 @@ Sends a cell location update request for the SIM card in the specified slot. Thi ...@@ -1389,6 +1451,8 @@ Sends a cell location update request for the SIM card in the specified slot. Thi
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1402,10 +1466,9 @@ Sends a cell location update request for the SIM card in the specified slot. Thi ...@@ -1402,10 +1466,9 @@ Sends a cell location update request for the SIM card in the specified slot. Thi
```js ```js
let slotId = 0; let slotId = 0;
let promise = radio.sendUpdateCellLocationRequest(slotId); radio.sendUpdateCellLocationRequest(slotId).then(() => {
promise.then(data => { console.log(`sendUpdateCellLocationRequest success.`);
console.log(`sendUpdateCellLocationRequest success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.log(`sendUpdateCellLocationRequest failed, promise: err->${JSON.stringify(err)}`); console.log(`sendUpdateCellLocationRequest failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1430,6 +1493,8 @@ Obtains cell information. This API uses an asynchronous callback to return the r ...@@ -1430,6 +1493,8 @@ Obtains cell information. This API uses an asynchronous callback to return the r
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1469,6 +1534,8 @@ Obtains cell information for the SIM card in the specified slot. This API uses a ...@@ -1469,6 +1534,8 @@ Obtains cell information for the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1514,6 +1581,8 @@ Obtains cell information for the SIM card in the specified slot. This API uses a ...@@ -1514,6 +1581,8 @@ Obtains cell information for the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1556,6 +1625,8 @@ Sets the network selection mode. This API uses an asynchronous callback to retur ...@@ -1556,6 +1625,8 @@ Sets the network selection mode. This API uses an asynchronous callback to retur
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1580,8 +1651,8 @@ let networkSelectionModeOptions={ ...@@ -1580,8 +1651,8 @@ let networkSelectionModeOptions={
networkInformation: networkInformation, networkInformation: networkInformation,
resumeSelection: true resumeSelection: true
} }
radio.setNetworkSelectionMode(networkSelectionModeOptions, (err, data) => { radio.setNetworkSelectionMode(networkSelectionModeOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1611,6 +1682,8 @@ Sets the network selection mode. This API uses a promise to return the result. ...@@ -1611,6 +1682,8 @@ Sets the network selection mode. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1636,9 +1709,9 @@ let networkSelectionModeOptions={ ...@@ -1636,9 +1709,9 @@ let networkSelectionModeOptions={
resumeSelection: true resumeSelection: true
} }
let promise = radio.setNetworkSelectionMode(networkSelectionModeOptions); let promise = radio.setNetworkSelectionMode(networkSelectionModeOptions);
promise.then(data => { promise.then(() => {
console.log(`setNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); console.log(`setNetworkSelectionMode success.`);
}).catch(err => { }).catch((err) => {
console.log(`setNetworkSelectionMode failed, promise: err->${JSON.stringify(err)}`); console.log(`setNetworkSelectionMode failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1664,6 +1737,8 @@ Obtains network search information for the SIM card in the specified slot. This ...@@ -1664,6 +1737,8 @@ Obtains network search information for the SIM card in the specified slot. This
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1707,6 +1782,8 @@ Obtains network search information for the SIM card in the specified slot. This ...@@ -1707,6 +1782,8 @@ Obtains network search information for the SIM card in the specified slot. This
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1745,6 +1822,8 @@ Obtains the NR option mode. This API uses an asynchronous callback to return the ...@@ -1745,6 +1822,8 @@ Obtains the NR option mode. This API uses an asynchronous callback to return the
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1781,6 +1860,8 @@ Obtains the NR option mode for the SIM card in the specified slot. This API uses ...@@ -1781,6 +1860,8 @@ Obtains the NR option mode for the SIM card in the specified slot. This API uses
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1823,6 +1904,8 @@ Obtains the NR option mode for the SIM card in the specified slot. This API uses ...@@ -1823,6 +1904,8 @@ Obtains the NR option mode for the SIM card in the specified slot. This API uses
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1863,6 +1946,8 @@ Turns on the radio function. This API uses an asynchronous callback to return th ...@@ -1863,6 +1946,8 @@ Turns on the radio function. This API uses an asynchronous callback to return th
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1875,8 +1960,8 @@ Turns on the radio function. This API uses an asynchronous callback to return th ...@@ -1875,8 +1960,8 @@ Turns on the radio function. This API uses an asynchronous callback to return th
**Example** **Example**
```js ```js
radio.turnOnRadio((err, data) => { radio.turnOnRadio((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1902,6 +1987,8 @@ Turns on the radio function for the SIM card in the specified slot. This API use ...@@ -1902,6 +1987,8 @@ Turns on the radio function for the SIM card in the specified slot. This API use
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1915,8 +2002,8 @@ Turns on the radio function for the SIM card in the specified slot. This API use ...@@ -1915,8 +2002,8 @@ Turns on the radio function for the SIM card in the specified slot. This API use
```js ```js
let slotId = 0; let slotId = 0;
radio.turnOnRadio(slotId, (err, data) => { radio.turnOnRadio(slotId, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1947,6 +2034,8 @@ Turns on the radio function for the SIM card in the specified slot. This API use ...@@ -1947,6 +2034,8 @@ Turns on the radio function for the SIM card in the specified slot. This API use
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1960,10 +2049,9 @@ Turns on the radio function for the SIM card in the specified slot. This API use ...@@ -1960,10 +2049,9 @@ Turns on the radio function for the SIM card in the specified slot. This API use
```js ```js
let slotId = 0; let slotId = 0;
let promise = radio.turnOnRadio(slotId); radio.turnOnRadio(slotId).then(() => {
promise.then(data => { console.log(`turnOnRadio success.`);
console.log(`turnOnRadio success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`turnOnRadio failed, promise: err->${JSON.stringify(err)}`); console.error(`turnOnRadio failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1988,6 +2076,8 @@ Turns off the radio function. This API uses an asynchronous callback to return t ...@@ -1988,6 +2076,8 @@ Turns off the radio function. This API uses an asynchronous callback to return t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2000,8 +2090,8 @@ Turns off the radio function. This API uses an asynchronous callback to return t ...@@ -2000,8 +2090,8 @@ Turns off the radio function. This API uses an asynchronous callback to return t
**Example** **Example**
```js ```js
radio.turnOffRadio((err, data) => { radio.turnOffRadio((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2027,6 +2117,8 @@ Turns off the radio function for the SIM card in the specified slot. This API us ...@@ -2027,6 +2117,8 @@ Turns off the radio function for the SIM card in the specified slot. This API us
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2040,8 +2132,8 @@ Turns off the radio function for the SIM card in the specified slot. This API us ...@@ -2040,8 +2132,8 @@ Turns off the radio function for the SIM card in the specified slot. This API us
```js ```js
let slotId = 0; let slotId = 0;
radio.turnOffRadio(slotId, (err, data) => { radio.turnOffRadio(slotId, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2072,6 +2164,8 @@ Turns off the radio function for the SIM card in the specified slot. This API us ...@@ -2072,6 +2164,8 @@ Turns off the radio function for the SIM card in the specified slot. This API us
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2085,10 +2179,9 @@ Turns off the radio function for the SIM card in the specified slot. This API us ...@@ -2085,10 +2179,9 @@ Turns off the radio function for the SIM card in the specified slot. This API us
```js ```js
let slotId = 0; let slotId = 0;
let promise = radio.turnOffRadio(slotId); radio.turnOffRadio(slotId).then(() => {
promise.then(data => { console.log(`turnOffRadio success.`);
console.log(`turnOffRadio success, promise: data->${JSON.stringify(data)}`); }).catch((err) => {
}).catch(err => {
console.error(`turnOffRadio failed, promise: err->${JSON.stringify(err)}`); console.error(`turnOffRadio failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2115,6 +2208,8 @@ Sets the preferred network for the SIM card in the specified slot. This API uses ...@@ -2115,6 +2208,8 @@ Sets the preferred network for the SIM card in the specified slot. This API uses
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2127,8 +2222,9 @@ Sets the preferred network for the SIM card in the specified slot. This API uses ...@@ -2127,8 +2222,9 @@ Sets the preferred network for the SIM card in the specified slot. This API uses
**Example** **Example**
```js ```js
radio.setPreferredNetwork(0, 1, (err, data) => { let slotId = 0;
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); radio.setPreferredNetwork(slotId, radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_GSM, (err) => {
console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2159,7 +2255,9 @@ Sets the preferred network for the SIM card in the specified slot. This API uses ...@@ -2159,7 +2255,9 @@ Sets the preferred network for the SIM card in the specified slot. This API uses
**Error codes** **Error codes**
| ID| Error Message | For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -2171,10 +2269,10 @@ Sets the preferred network for the SIM card in the specified slot. This API uses ...@@ -2171,10 +2269,10 @@ Sets the preferred network for the SIM card in the specified slot. This API uses
**Example** **Example**
```js ```js
let promise = radio.setPreferredNetwork(0, 1); let slotId = 0;
promise.then(data => { radio.setPreferredNetwork(slotId, radio.PreferredNetworkMode.PREFERRED_NETWORK_MODE_GSM).then(() => {
console.log(`setPreferredNetwork success, promise: data->${JSON.stringify(data)}`); console.log(`setPreferredNetwork success.`);
}).catch(err => { }).catch((err) => {
console.log(`setPreferredNetwork failed, promise: err->${JSON.stringify(err)}`); console.log(`setPreferredNetwork failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2200,6 +2298,8 @@ Obtains the preferred network for the SIM card in the specified slot. This API u ...@@ -2200,6 +2298,8 @@ Obtains the preferred network for the SIM card in the specified slot. This API u
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2243,6 +2343,8 @@ Obtains the preferred network for the SIM card in the specified slot. This API u ...@@ -2243,6 +2343,8 @@ Obtains the preferred network for the SIM card in the specified slot. This API u
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2285,6 +2387,8 @@ Obtains the IMS registration status of the specified IMS service type for the SI ...@@ -2285,6 +2387,8 @@ Obtains the IMS registration status of the specified IMS service type for the SI
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2329,6 +2433,8 @@ Obtains the IMS registration status of the specified IMS service type for the SI ...@@ -2329,6 +2433,8 @@ Obtains the IMS registration status of the specified IMS service type for the SI
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2372,6 +2478,8 @@ Enables listening for **imsRegStateChange** events. This API uses an asynchronou ...@@ -2372,6 +2478,8 @@ Enables listening for **imsRegStateChange** events. This API uses an asynchronou
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2412,6 +2520,8 @@ Disables listening for **imsRegStateChange** events. This API uses an asynchrono ...@@ -2412,6 +2520,8 @@ Disables listening for **imsRegStateChange** events. This API uses an asynchrono
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
......
...@@ -13,7 +13,7 @@ The Resource Manager module provides APIs to obtain information about applicatio ...@@ -13,7 +13,7 @@ The Resource Manager module provides APIs to obtain information about applicatio
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
``` ```
## How to Use ## Instruction
Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. For the FA model, you need to import the required bundle and then call the [getResourceManager](#resourcemanagergetresourcemanager) API to obtain a **ResourceManager** object. Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. For the FA model, you need to import the required bundle and then call the [getResourceManager](#resourcemanagergetresourcemanager) API to obtain a **ResourceManager** object.
For details about how to reference context in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md). For details about how to reference context in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md).
...@@ -78,7 +78,7 @@ Obtains the **ResourceManager** object of an application based on the specified ...@@ -78,7 +78,7 @@ Obtains the **ResourceManager** object of an application based on the specified
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ----------------------------- | | ---------- | ---------------------------------------- | ---- | ----------------------------- |
| bundleName | string | Yes | Bundle name of the target application. | | bundleName | string | Yes | Bundle name of the application. |
| callback | AsyncCallback&lt;[ResourceManager](#resourcemanager)&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;[ResourceManager](#resourcemanager)&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -118,7 +118,7 @@ Obtains the **ResourceManager** object of this application. This API uses a prom ...@@ -118,7 +118,7 @@ Obtains the **ResourceManager** object of this application. This API uses a prom
console.log("error is " + error); console.log("error is " + error);
}); });
``` ```
> **NOTE**<br>> In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file. > **NOTE**<br>In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file.
## resourceManager.getResourceManager ## resourceManager.getResourceManager
...@@ -135,7 +135,7 @@ Obtains the **ResourceManager** object of an application based on the specified ...@@ -135,7 +135,7 @@ Obtains the **ResourceManager** object of an application based on the specified
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ------------- | | ---------- | ------ | ---- | ------------- |
| bundleName | string | Yes | Bundle name of the target application.| | bundleName | string | Yes | Bundle name of the application.|
**Return value** **Return value**
...@@ -171,12 +171,12 @@ Enumerates the device types. ...@@ -171,12 +171,12 @@ Enumerates the device types.
| Name | Value | Description | | Name | Value | Description |
| -------------------- | ---- | ---- | | -------------------- | ---- | ---- |
| DEVICE_TYPE_PHONE | 0x00 | Phone. | | DEVICE_TYPE_PHONE | 0x00 | Phone |
| DEVICE_TYPE_TABLET | 0x01 | Tablet. | | DEVICE_TYPE_TABLET | 0x01 | Tablet |
| DEVICE_TYPE_CAR | 0x02 | Head unit. | | DEVICE_TYPE_CAR | 0x02 | Head unit |
| DEVICE_TYPE_PC | 0x03 | PC. | | DEVICE_TYPE_PC | 0x03 | PC |
| DEVICE_TYPE_TV | 0x04 | TV. | | DEVICE_TYPE_TV | 0x04 | TV |
| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. | | DEVICE_TYPE_WEARABLE | 0x06 | Wearable |
## ScreenDensity ## ScreenDensity
...@@ -278,7 +278,7 @@ Defines the capability of accessing application resources. ...@@ -278,7 +278,7 @@ Defines the capability of accessing application resources.
> **NOTE** > **NOTE**
> >
> - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm. > - The APIs involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm.
> >
> - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**. > - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**.
...@@ -645,7 +645,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco ...@@ -645,7 +645,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco
getMediaContent(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void getMediaContent(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result. Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -1658,7 +1658,7 @@ Obtains the string corresponding to the specified resource name. This API uses a ...@@ -1658,7 +1658,7 @@ Obtains the string corresponding to the specified resource name. This API uses a
| Type | Description | | Type | Description |
| --------------------- | ---------- | | --------------------- | ---------- |
| Promise&lt;string&gt; | Promise used to return the result.| | Promise&lt;string&gt; | String corresponding to the resource name.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
...@@ -1770,7 +1770,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco ...@@ -1770,7 +1770,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco
getMediaByName(resName: string, callback: AsyncCallback&lt;Uint8Array&gt;): void getMediaByName(resName: string, callback: AsyncCallback&lt;Uint8Array&gt;): void
Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result. Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Global.ResourceManager **System capability**: SystemCapability.Global.ResourceManager
...@@ -2036,7 +2036,7 @@ Obtains the string corresponding to the specified resource ID. This API returns ...@@ -2036,7 +2036,7 @@ Obtains the string corresponding to the specified resource ID. This API returns
| Type | Description | | Type | Description |
| ------ | ----------- | | ------ | ----------- |
| string | String corresponding to the specified resource ID.| | string | Promise used to return the result.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
...@@ -2075,7 +2075,7 @@ Obtains the string corresponding to the specified resource object. This API retu ...@@ -2075,7 +2075,7 @@ Obtains the string corresponding to the specified resource object. This API retu
| Type | Description | | Type | Description |
| ------ | ---------------- | | ------ | ---------------- |
| string | String corresponding to the resource object.| | string | Promise used to return the result.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
...@@ -2119,7 +2119,7 @@ Obtains the string corresponding to the specified resource name. This API return ...@@ -2119,7 +2119,7 @@ Obtains the string corresponding to the specified resource name. This API return
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| string | String corresponding to the resource name.| | string | String corresponding to the specified resource name.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
...@@ -2395,6 +2395,142 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco ...@@ -2395,6 +2395,142 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco
} }
``` ```
### getDrawableDescriptor<sup>10+</sup>
getDrawableDescriptor(resId: number, density?: number): DrawableDescriptor;
Obtains the **DrawableDescriptor** object based on the specified resource ID. This API returns the result synchronously.
**System capability**: SystemCapability.Global.ResourceManager
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----- |
| resId | number | Yes | Resource ID.|
| [density](#screendensity) | number | No | Screen density. The default value is **0**.|
**Return value**
| Type | Description |
| ------ | ---------- |
| DrawableDescriptor | **DrawableDescriptor** object corresponding to the resource ID.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
**Error codes**
| ID| Error Message|
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**Example**
```ts
try {
this.context.resourceManager.getDrawableDescriptor($r('app.media.icon').id);
} catch (error) {
console.error(`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`)
}
try {
this.context.resourceManager.getDrawableDescriptor($r('app.media.icon').id, 120);
} catch (error) {
console.error(`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getDrawableDescriptor<sup>10+</sup>
getDrawableDescriptor(resource: Resource, density?: number): DrawableDescriptor;
Obtains the **DrawableDescriptor** object based on the specified resource. This API returns the result synchronously.
**System capability**: SystemCapability.Global.ResourceManager
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ---- |
| resource | [Resource](#resource9) | Yes | Resource object.|
| [density](#screendensity) | number | No | Screen density. The default value is **0**.|
**Return value**
| Type | Description |
| ------- | ----------------- |
| DrawableDescriptor | **DrawableDescriptor** object corresponding to the resource ID.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
**Error codes**
| ID| Error Message|
| -------- | ---------------------------------------- |
| 9001001 | If the resId invalid. |
| 9001002 | If the resource not found by resId. |
**Example**
```ts
let resource = {
bundleName: "com.example.myapplication",
moduleName: "entry",
id: $r('app.media.icon').id
};
try {
this.context.resourceManager.getDrawableDescriptor(resource);
} catch (error) {
console.error(`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`)
}
try {
this.context.resourceManager.getDrawableDescriptor(resource, 120);
} catch (error) {
console.error(`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getDrawableDescriptorByName<sup>10+</sup>
getDrawableDescriptorByName(resName: string, density?: number): DrawableDescriptor;
Obtains the **DrawableDescriptor** object based on the specified resource name. This API returns the result synchronously.
**System capability**: SystemCapability.Global.ResourceManager
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---- |
| resName | string | Yes | Resource name.|
| [density](#screendensity) | number | No | Screen density. The default value is **0**.|
**Return value**
| Type | Description |
| ------ | --------- |
| DrawableDescriptor | **DrawableDescriptor** object corresponding to the resource ID.|
For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md).
**Error codes**
| ID| Error Message|
| -------- | ---------------------------------------- |
| 9001003 | If the resName invalid. |
| 9001004 | If the resource not found by resName. |
**Example**
```ts
try {
this.context.resourceManager.getDrawableDescriptorByName('icon');
} catch (error) {
console.error(`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`)
}
try {
this.context.resourceManager.getDrawableDescriptorByName('icon', 120);
} catch (error) {
console.error(`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`)
}
```
### getString<sup>(deprecated)</sup> ### getString<sup>(deprecated)</sup>
...@@ -2530,7 +2666,7 @@ This API is deprecated since API version 9. You are advised to use [getStringArr ...@@ -2530,7 +2666,7 @@ This API is deprecated since API version 9. You are advised to use [getStringArr
getMedia(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void getMedia(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result. Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9) instead. This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9) instead.
......
...@@ -134,13 +134,14 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -134,13 +134,14 @@ Checks whether the application (caller) has been granted the operator permission
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -173,13 +174,14 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -173,13 +174,14 @@ Checks whether the application (caller) has been granted the operator permission
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -210,6 +212,8 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use ...@@ -210,6 +212,8 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -250,6 +254,8 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use ...@@ -250,6 +254,8 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -288,6 +294,8 @@ Obtains the public land mobile network \(PLMN\) ID of the SIM card in the specif ...@@ -288,6 +294,8 @@ Obtains the public land mobile network \(PLMN\) ID of the SIM card in the specif
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -328,6 +336,8 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi ...@@ -328,6 +336,8 @@ Obtains the PLMN ID of the SIM card in the specified slot. This API uses a promi
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -366,6 +376,8 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T ...@@ -366,6 +376,8 @@ Obtains the service provider name (SPN) of the SIM card in the specified slot. T
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -406,6 +418,8 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t ...@@ -406,6 +418,8 @@ Obtains the SPN of the SIM card in the specified slot. This API uses a promise t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -444,13 +458,14 @@ Obtains the state of the SIM card in the specified slot. This API uses an asynch ...@@ -444,13 +458,14 @@ Obtains the state of the SIM card in the specified slot. This API uses an asynch
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -484,13 +499,14 @@ Obtains the state of the SIM card in the specified slot. This API uses a promise ...@@ -484,13 +499,14 @@ Obtains the state of the SIM card in the specified slot. This API uses a promise
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -521,6 +537,8 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr ...@@ -521,6 +537,8 @@ Obtains the type of the SIM card in the specified slot. This API uses an asynchr
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -561,6 +579,8 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise ...@@ -561,6 +579,8 @@ Obtains the type of the SIM card in the specified slot. This API uses a promise
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -599,13 +619,14 @@ Checks whether the SIM card in the specified slot is installed. This API uses an ...@@ -599,13 +619,14 @@ Checks whether the SIM card in the specified slot is installed. This API uses an
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -639,13 +660,14 @@ Checks whether the SIM card in the specified slot is installed. This API uses a ...@@ -639,13 +660,14 @@ Checks whether the SIM card in the specified slot is installed. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -680,6 +702,8 @@ Obtains SIM card account information. This API uses an asynchronous callback to ...@@ -680,6 +702,8 @@ Obtains SIM card account information. This API uses an asynchronous callback to
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -726,6 +750,8 @@ Obtains SIM card account information. This API uses a promise to return the resu ...@@ -726,6 +750,8 @@ Obtains SIM card account information. This API uses a promise to return the resu
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -768,6 +794,8 @@ Obtains the account information list of the active SIM card. This API uses an as ...@@ -768,6 +794,8 @@ Obtains the account information list of the active SIM card. This API uses an as
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -807,6 +835,8 @@ Obtains the account information list of the active SIM card. This API uses a pro ...@@ -807,6 +835,8 @@ Obtains the account information list of the active SIM card. This API uses a pro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -849,6 +879,8 @@ Sets the default slot ID of the SIM card that provides voice services. This API ...@@ -849,6 +879,8 @@ Sets the default slot ID of the SIM card that provides voice services. This API
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -863,8 +895,8 @@ Sets the default slot ID of the SIM card that provides voice services. This API ...@@ -863,8 +895,8 @@ Sets the default slot ID of the SIM card that provides voice services. This API
**Example** **Example**
```js ```js
sim.setDefaultVoiceSlotId(0, (err, data) => { sim.setDefaultVoiceSlotId(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -895,6 +927,8 @@ Sets the default slot ID of the SIM card that provides voice services. This API ...@@ -895,6 +927,8 @@ Sets the default slot ID of the SIM card that provides voice services. This API
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -910,9 +944,9 @@ Sets the default slot ID of the SIM card that provides voice services. This API ...@@ -910,9 +944,9 @@ Sets the default slot ID of the SIM card that provides voice services. This API
```js ```js
let promise = sim.setDefaultVoiceSlotId(0); let promise = sim.setDefaultVoiceSlotId(0);
promise.then(data => { promise.then(() => {
console.log(`setDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`setDefaultVoiceSlotId success.`);
}).catch(err => { }).catch((err) => {
console.log(`setDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`); console.log(`setDefaultVoiceSlotId failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -939,6 +973,8 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy ...@@ -939,6 +973,8 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -953,8 +989,8 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy ...@@ -953,8 +989,8 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy
```js ```js
let name = "ShowName"; let name = "ShowName";
sim.setShowName(0, name, (err, data) => { sim.setShowName(0, name, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -985,6 +1021,8 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom ...@@ -985,6 +1021,8 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1000,9 +1038,9 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom ...@@ -1000,9 +1038,9 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom
```js ```js
let name = "ShowName"; let name = "ShowName";
let promise = sim.setShowName(0, name); let promise = sim.setShowName(0, name);
promise.then(data => { promise.then(() => {
console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); console.log(`setShowName success.`);
}).catch(err => { }).catch((err) => {
console.log(`setShowName failed, promise: err->${JSON.stringify(err)}`); console.log(`setShowName failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1028,6 +1066,8 @@ Obtains the name of the SIM card in the specified slot. This API uses an asynchr ...@@ -1028,6 +1066,8 @@ Obtains the name of the SIM card in the specified slot. This API uses an asynchr
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1073,6 +1113,8 @@ Obtains the name of the SIM card in the specified slot. This API uses a promise ...@@ -1073,6 +1113,8 @@ Obtains the name of the SIM card in the specified slot. This API uses a promise
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1116,6 +1158,8 @@ Sets a display number for the SIM card in the specified slot. This API uses an a ...@@ -1116,6 +1158,8 @@ Sets a display number for the SIM card in the specified slot. This API uses an a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1130,8 +1174,8 @@ Sets a display number for the SIM card in the specified slot. This API uses an a ...@@ -1130,8 +1174,8 @@ Sets a display number for the SIM card in the specified slot. This API uses an a
```js ```js
let number = '+861xxxxxxxxxx'; let number = '+861xxxxxxxxxx';
sim.setShowNumber(0, number, (err, data) => { sim.setShowNumber(0, number, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1163,6 +1207,8 @@ Sets a display number for the SIM card in the specified slot. This API uses a pr ...@@ -1163,6 +1207,8 @@ Sets a display number for the SIM card in the specified slot. This API uses a pr
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1178,9 +1224,9 @@ Sets a display number for the SIM card in the specified slot. This API uses a pr ...@@ -1178,9 +1224,9 @@ Sets a display number for the SIM card in the specified slot. This API uses a pr
```js ```js
let number = '+861xxxxxxxxxx'; let number = '+861xxxxxxxxxx';
let promise = sim.setShowNumber(0, number); let promise = sim.setShowNumber(0, number);
promise.then(data => { promise.then(() => {
console.log(`setShowNumber success, promise: data->${JSON.stringify(data)}`); console.log(`setShowNumber success.`);
}).catch(err => { }).catch((err) => {
console.log(`setShowNumber failed, promise: err->${JSON.stringify(err)}`); console.log(`setShowNumber failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1206,6 +1252,8 @@ Obtains the display number of the SIM card in the specified slot. This API uses ...@@ -1206,6 +1252,8 @@ Obtains the display number of the SIM card in the specified slot. This API uses
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1251,6 +1299,8 @@ Obtains the display number of the SIM card in the specified slot. This API uses ...@@ -1251,6 +1299,8 @@ Obtains the display number of the SIM card in the specified slot. This API uses
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1293,6 +1343,8 @@ Activates a SIM card in a specified card slot. This API uses an asynchronous cal ...@@ -1293,6 +1343,8 @@ Activates a SIM card in a specified card slot. This API uses an asynchronous cal
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1306,8 +1358,8 @@ Activates a SIM card in a specified card slot. This API uses an asynchronous cal ...@@ -1306,8 +1358,8 @@ Activates a SIM card in a specified card slot. This API uses an asynchronous cal
**Example** **Example**
```js ```js
sim.activateSim(0, (err, data) => { sim.activateSim(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1338,6 +1390,8 @@ Activates the SIM card in the specified slot. This API uses a promise to return ...@@ -1338,6 +1390,8 @@ Activates the SIM card in the specified slot. This API uses a promise to return
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1352,9 +1406,9 @@ Activates the SIM card in the specified slot. This API uses a promise to return ...@@ -1352,9 +1406,9 @@ Activates the SIM card in the specified slot. This API uses a promise to return
```js ```js
let promise = sim.activateSim(0); let promise = sim.activateSim(0);
promise.then(data => { promise.then(() => {
console.log(`activateSim success, promise: data->${JSON.stringify(data)}`); console.log(`activateSim success.`);
}).catch(err => { }).catch((err) => {
console.log(`activateSim failed, promise: err->${JSON.stringify(err)}`); console.log(`activateSim failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1380,6 +1434,8 @@ Disables the SIM card in the specified slot. This API uses an asynchronous callb ...@@ -1380,6 +1434,8 @@ Disables the SIM card in the specified slot. This API uses an asynchronous callb
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1393,8 +1449,8 @@ Disables the SIM card in the specified slot. This API uses an asynchronous callb ...@@ -1393,8 +1449,8 @@ Disables the SIM card in the specified slot. This API uses an asynchronous callb
**Example** **Example**
```js ```js
sim.deactivateSim(0, (err, data) => { sim.deactivateSim(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1425,6 +1481,8 @@ Disables the SIM card in the specified slot. This API uses a promise to return t ...@@ -1425,6 +1481,8 @@ Disables the SIM card in the specified slot. This API uses a promise to return t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1439,9 +1497,9 @@ Disables the SIM card in the specified slot. This API uses a promise to return t ...@@ -1439,9 +1497,9 @@ Disables the SIM card in the specified slot. This API uses a promise to return t
```js ```js
let promise = sim.deactivateSim(0); let promise = sim.deactivateSim(0);
promise.then(data => { promise.then(() => {
console.log(`deactivateSim success, promise: data->${JSON.stringify(data)}`); console.log(`deactivateSim success.`);
}).catch(err => { }).catch((err) => {
console.log(`deactivateSim failed, promise: err->${JSON.stringify(err)}`); console.log(`deactivateSim failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1468,6 +1526,8 @@ Sets the lock status of the SIM card in the specified slot. This API uses an asy ...@@ -1468,6 +1526,8 @@ Sets the lock status of the SIM card in the specified slot. This API uses an asy
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1520,6 +1580,8 @@ Sets the lock status of the SIM card in the specified slot. This API uses a prom ...@@ -1520,6 +1580,8 @@ Sets the lock status of the SIM card in the specified slot. This API uses a prom
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1569,6 +1631,8 @@ Obtains the lock status of the SIM card in the specified slot. This API uses an ...@@ -1569,6 +1631,8 @@ Obtains the lock status of the SIM card in the specified slot. This API uses an
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1616,6 +1680,8 @@ Obtains the lock status of the SIM card in the specified slot. This API uses a p ...@@ -1616,6 +1680,8 @@ Obtains the lock status of the SIM card in the specified slot. This API uses a p
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1661,6 +1727,8 @@ Changes the PIN of the SIM card in the specified slot. This API uses an asynchro ...@@ -1661,6 +1727,8 @@ Changes the PIN of the SIM card in the specified slot. This API uses an asynchro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1709,6 +1777,8 @@ Changes the PIN of the SIM card in the specified slot. This API uses a promise t ...@@ -1709,6 +1777,8 @@ Changes the PIN of the SIM card in the specified slot. This API uses a promise t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1754,6 +1824,8 @@ Changes PIN 2 of the SIM card in the specified slot. This API uses an asynchrono ...@@ -1754,6 +1824,8 @@ Changes PIN 2 of the SIM card in the specified slot. This API uses an asynchrono
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1802,6 +1874,8 @@ Changes PIN 2 of the SIM card in the specified slot. This API uses a promise to ...@@ -1802,6 +1874,8 @@ Changes PIN 2 of the SIM card in the specified slot. This API uses a promise to
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1846,6 +1920,8 @@ Unlocks the PIN of the SIM card in the specified slot. This API uses an asynchro ...@@ -1846,6 +1920,8 @@ Unlocks the PIN of the SIM card in the specified slot. This API uses an asynchro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1894,6 +1970,8 @@ Unlocks the PIN of the SIM card in the specified slot. This API uses a promise t ...@@ -1894,6 +1970,8 @@ Unlocks the PIN of the SIM card in the specified slot. This API uses a promise t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1940,6 +2018,8 @@ Unlocks the PUK of the SIM card in the specified slot. This API uses an asynchro ...@@ -1940,6 +2018,8 @@ Unlocks the PUK of the SIM card in the specified slot. This API uses an asynchro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -1990,6 +2070,8 @@ Unlocks the PUK of the SIM card in the specified slot. This API uses a promise t ...@@ -1990,6 +2070,8 @@ Unlocks the PUK of the SIM card in the specified slot. This API uses a promise t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2036,6 +2118,8 @@ Unlocks PIN 2 of the SIM card in the specified slot. This API uses an asynchrono ...@@ -2036,6 +2118,8 @@ Unlocks PIN 2 of the SIM card in the specified slot. This API uses an asynchrono
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2084,6 +2168,8 @@ Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to ...@@ -2084,6 +2168,8 @@ Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2130,6 +2216,8 @@ Unlocks PUK 2 of the SIM card in the specified slot. This API uses an asynchrono ...@@ -2130,6 +2216,8 @@ Unlocks PUK 2 of the SIM card in the specified slot. This API uses an asynchrono
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2180,6 +2268,8 @@ Unlocks PUK 2 of the SIM card in the specified slot. This API uses a promise to ...@@ -2180,6 +2268,8 @@ Unlocks PUK 2 of the SIM card in the specified slot. This API uses a promise to
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2245,6 +2335,8 @@ Obtains the ICCID of the SIM card in the specified slot. This API uses an asynch ...@@ -2245,6 +2335,8 @@ Obtains the ICCID of the SIM card in the specified slot. This API uses an asynch
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2290,6 +2382,8 @@ Obtains the ICCID of the SIM card in the specified slot. This API uses a promise ...@@ -2290,6 +2382,8 @@ Obtains the ICCID of the SIM card in the specified slot. This API uses a promise
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2332,6 +2426,8 @@ Obtains the voice mailbox alpha identifier of the SIM card in the specified slot ...@@ -2332,6 +2426,8 @@ Obtains the voice mailbox alpha identifier of the SIM card in the specified slot
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2377,6 +2473,8 @@ Obtains the voice mailbox alpha identifier of the SIM card in the specified slot ...@@ -2377,6 +2473,8 @@ Obtains the voice mailbox alpha identifier of the SIM card in the specified slot
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2419,6 +2517,8 @@ Obtains the voice mailbox number of the SIM card in the specified slot. This API ...@@ -2419,6 +2517,8 @@ Obtains the voice mailbox number of the SIM card in the specified slot. This API
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2464,6 +2564,8 @@ Obtains the voice mailbox number of the SIM card in the specified slot. This API ...@@ -2464,6 +2564,8 @@ Obtains the voice mailbox number of the SIM card in the specified slot. This API
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2509,6 +2611,8 @@ Sets voice mailbox information for the SIM card in the specified slot. This API ...@@ -2509,6 +2611,8 @@ Sets voice mailbox information for the SIM card in the specified slot. This API
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2523,8 +2627,8 @@ Sets voice mailbox information for the SIM card in the specified slot. This API ...@@ -2523,8 +2627,8 @@ Sets voice mailbox information for the SIM card in the specified slot. This API
**Example** **Example**
```js ```js
sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err, data) => { sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com", (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2557,6 +2661,8 @@ Sets voice mailbox information for the SIM card in the specified slot. This API ...@@ -2557,6 +2661,8 @@ Sets voice mailbox information for the SIM card in the specified slot. This API
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2572,9 +2678,9 @@ Sets voice mailbox information for the SIM card in the specified slot. This API ...@@ -2572,9 +2678,9 @@ Sets voice mailbox information for the SIM card in the specified slot. This API
```js ```js
let promise = sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com"); let promise = sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com");
promise.then(data => { promise.then(() => {
console.log(`setVoiceMailInfo success, promise: data->${JSON.stringify(data)}`); console.log(`setVoiceMailInfo success.`);
}).catch(err => { }).catch((err) => {
console.log(`setVoiceMailInfo failed, promise: err->${JSON.stringify(err)}`); console.log(`setVoiceMailInfo failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -2600,6 +2706,8 @@ Obtains the MSISDN of the SIM card in the specified slot. This API uses an async ...@@ -2600,6 +2706,8 @@ Obtains the MSISDN of the SIM card in the specified slot. This API uses an async
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2645,6 +2753,8 @@ Obtains the MSISDN of the SIM card in the specified slot. This API uses a promis ...@@ -2645,6 +2753,8 @@ Obtains the MSISDN of the SIM card in the specified slot. This API uses a promis
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2687,6 +2797,8 @@ Obtains the group identifier level 1 (GID1) of the SIM card in the specified slo ...@@ -2687,6 +2797,8 @@ Obtains the group identifier level 1 (GID1) of the SIM card in the specified slo
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2732,6 +2844,8 @@ Obtains the GID1 of the SIM card in the specified slot. This API uses a promise ...@@ -2732,6 +2844,8 @@ Obtains the GID1 of the SIM card in the specified slot. This API uses a promise
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2774,6 +2888,8 @@ Obtains the international mobile subscriber identity (IMSI) of the SIM card in t ...@@ -2774,6 +2888,8 @@ Obtains the international mobile subscriber identity (IMSI) of the SIM card in t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2819,6 +2935,8 @@ Obtains the IMSI of the SIM card in the specified slot. This API uses a promise ...@@ -2819,6 +2935,8 @@ Obtains the IMSI of the SIM card in the specified slot. This API uses a promise
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2861,6 +2979,8 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP ...@@ -2861,6 +2979,8 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2868,7 +2988,6 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP ...@@ -2868,7 +2988,6 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -2906,6 +3025,8 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP ...@@ -2906,6 +3025,8 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2913,7 +3034,6 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP ...@@ -2913,7 +3034,6 @@ Obtains the carrier configuration of the SIM card in the specified slot. This AP
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -2949,6 +3069,8 @@ Queries contact numbers of the SIM card in the specified slot. This API uses an ...@@ -2949,6 +3069,8 @@ Queries contact numbers of the SIM card in the specified slot. This API uses an
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -2996,6 +3118,8 @@ Queries contact numbers of the SIM card in the specified slot. This API uses a p ...@@ -2996,6 +3118,8 @@ Queries contact numbers of the SIM card in the specified slot. This API uses a p
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3041,6 +3165,8 @@ Adds contact numbers for the SIM card in the specified slot. This API uses an as ...@@ -3041,6 +3165,8 @@ Adds contact numbers for the SIM card in the specified slot. This API uses an as
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3060,8 +3186,8 @@ let diallingNumbersInof = { ...@@ -3060,8 +3186,8 @@ let diallingNumbersInof = {
number: "138xxxxxxxx", number: "138xxxxxxxx",
pin2: "1234" pin2: "1234"
}; };
sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3094,6 +3220,8 @@ Adds contact numbers for the SIM card in the specified slot. This API uses a pro ...@@ -3094,6 +3220,8 @@ Adds contact numbers for the SIM card in the specified slot. This API uses a pro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3113,9 +3241,9 @@ let diallingNumbersInof = { ...@@ -3113,9 +3241,9 @@ let diallingNumbersInof = {
number: "138xxxxxxxx" number: "138xxxxxxxx"
}; };
let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => { promise.then(() => {
console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); console.log(`addIccDiallingNumbers success.`);
}).catch(err => { }).catch((err) => {
console.log(`addIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); console.log(`addIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3143,6 +3271,8 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a ...@@ -3143,6 +3271,8 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3163,8 +3293,8 @@ let diallingNumbersInof = { ...@@ -3163,8 +3293,8 @@ let diallingNumbersInof = {
recordNumber: 123, recordNumber: 123,
pin2: "1234" pin2: "1234"
}; };
sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3197,6 +3327,8 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a ...@@ -3197,6 +3327,8 @@ Deletes contact numbers from the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3216,9 +3348,9 @@ let diallingNumbersInof = { ...@@ -3216,9 +3348,9 @@ let diallingNumbersInof = {
number: "138xxxxxxxx" number: "138xxxxxxxx"
}; };
let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => { promise.then(() => {
console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); console.log(`delIccDiallingNumbers success.`);
}).catch(err => { }).catch((err) => {
console.log(`delIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); console.log(`delIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3246,6 +3378,8 @@ Updates contact numbers for the SIM card in the specified slot. This API uses an ...@@ -3246,6 +3378,8 @@ Updates contact numbers for the SIM card in the specified slot. This API uses an
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3266,8 +3400,8 @@ let diallingNumbersInof = { ...@@ -3266,8 +3400,8 @@ let diallingNumbersInof = {
recordNumber: 123, recordNumber: 123,
pin2: "1234" pin2: "1234"
}; };
sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3300,6 +3434,8 @@ Updates contact numbers for the SIM card in the specified slot. This API uses a ...@@ -3300,6 +3434,8 @@ Updates contact numbers for the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3320,9 +3456,9 @@ let diallingNumbersInof = { ...@@ -3320,9 +3456,9 @@ let diallingNumbersInof = {
recordNumber: 123 recordNumber: 123
}; };
let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof);
promise.then(data => { promise.then(() => {
console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); console.log(`updateIccDiallingNumbers success.`);
}).catch(err => { }).catch((err) => {
console.log(`updateIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`); console.log(`updateIccDiallingNumbers failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3349,6 +3485,8 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a ...@@ -3349,6 +3485,8 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3362,8 +3500,8 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a ...@@ -3362,8 +3500,8 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a
**Example** **Example**
```js ```js
sim.sendEnvelopeCmd(0, "ls", (err, data) => { sim.sendEnvelopeCmd(0, "ls", (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3395,6 +3533,8 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a ...@@ -3395,6 +3533,8 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3409,9 +3549,9 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a ...@@ -3409,9 +3549,9 @@ Sends an envelope command to the SIM card in the specified slot. This API uses a
```js ```js
let promise = sim.sendEnvelopeCmd(0, "ls"); let promise = sim.sendEnvelopeCmd(0, "ls");
promise.then(data => { promise.then(() => {
console.log(`sendEnvelopeCmd success, promise: data->${JSON.stringify(data)}`); console.log(`sendEnvelopeCmd success.`);
}).catch(err => { }).catch((err) => {
console.log(`sendEnvelopeCmd failed, promise: err->${JSON.stringify(err)}`); console.log(`sendEnvelopeCmd failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3438,6 +3578,8 @@ Sends a terminal response command to the SIM card in the specified slot. This AP ...@@ -3438,6 +3578,8 @@ Sends a terminal response command to the SIM card in the specified slot. This AP
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3451,8 +3593,8 @@ Sends a terminal response command to the SIM card in the specified slot. This AP ...@@ -3451,8 +3593,8 @@ Sends a terminal response command to the SIM card in the specified slot. This AP
**Example** **Example**
```js ```js
sim.sendTerminalResponseCmd(0, "ls", (err, data) => { sim.sendTerminalResponseCmd(0, "ls", (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3484,6 +3626,8 @@ Sends a terminal response command to the SIM card in the specified slot. This AP ...@@ -3484,6 +3626,8 @@ Sends a terminal response command to the SIM card in the specified slot. This AP
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3498,9 +3642,9 @@ Sends a terminal response command to the SIM card in the specified slot. This AP ...@@ -3498,9 +3642,9 @@ Sends a terminal response command to the SIM card in the specified slot. This AP
```js ```js
let promise = sim.sendTerminalResponseCmd(0, "ls"); let promise = sim.sendTerminalResponseCmd(0, "ls");
promise.then(data => { promise.then(() => {
console.log(`sendTerminalResponseCmd success, promise: data->${JSON.stringify(data)}`); console.log(`sendTerminalResponseCmd success.`);
}).catch(err => { }).catch((err) => {
console.log(`sendTerminalResponseCmd failed, promise: err->${JSON.stringify(err)}`); console.log(`sendTerminalResponseCmd failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -3528,6 +3672,8 @@ Unlocks the SIM card in the specified slot. This API uses an asynchronous callba ...@@ -3528,6 +3672,8 @@ Unlocks the SIM card in the specified slot. This API uses an asynchronous callba
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3579,6 +3725,8 @@ Unlocks the SIM card in the specified slot. This API uses a promise to return th ...@@ -3579,6 +3725,8 @@ Unlocks the SIM card in the specified slot. This API uses a promise to return th
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -3622,6 +3770,8 @@ Obtains the opkey of the SIM card in the specified slot. This API uses an asynch ...@@ -3622,6 +3770,8 @@ Obtains the opkey of the SIM card in the specified slot. This API uses an asynch
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -3629,7 +3779,6 @@ Obtains the opkey of the SIM card in the specified slot. This API uses an asynch ...@@ -3629,7 +3779,6 @@ Obtains the opkey of the SIM card in the specified slot. This API uses an asynch
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -3671,6 +3820,8 @@ Obtains the opkey of the SIM card in the specified slot. This API uses a promise ...@@ -3671,6 +3820,8 @@ Obtains the opkey of the SIM card in the specified slot. This API uses a promise
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -3678,7 +3829,6 @@ Obtains the opkey of the SIM card in the specified slot. This API uses a promise ...@@ -3678,7 +3829,6 @@ Obtains the opkey of the SIM card in the specified slot. This API uses a promise
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -3709,6 +3859,8 @@ Obtains the OpName of the SIM card in the specified slot. This API uses an async ...@@ -3709,6 +3859,8 @@ Obtains the OpName of the SIM card in the specified slot. This API uses an async
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -3716,7 +3868,6 @@ Obtains the OpName of the SIM card in the specified slot. This API uses an async ...@@ -3716,7 +3868,6 @@ Obtains the OpName of the SIM card in the specified slot. This API uses an async
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -3758,6 +3909,8 @@ Obtains the OpName of the SIM card in the specified slot. This API uses a promis ...@@ -3758,6 +3909,8 @@ Obtains the OpName of the SIM card in the specified slot. This API uses a promis
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -3765,7 +3918,6 @@ Obtains the OpName of the SIM card in the specified slot. This API uses a promis ...@@ -3765,7 +3918,6 @@ Obtains the OpName of the SIM card in the specified slot. This API uses a promis
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. | | 8300003 | System internal error. |
| 8300004 | Do not have sim card. |
| 8300999 | Unknown error code. | | 8300999 | Unknown error code. |
**Example** **Example**
...@@ -3847,17 +3999,17 @@ Enumerates personalized lock types. ...@@ -3847,17 +3999,17 @@ Enumerates personalized lock types.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description | | Name | Value | Description |
| ------------ | ---- | ----------------------------------------------- | | ------------ | ---- | ------------------------------------------------ |
| PN_PIN_LOCK | 0 | Personalized network PIN lock. For details, see *3GPP TS 22.022 [33]*. | | PN_PIN_LOCK | 0 | Personalized network PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PN_PUK_LOCK | 1 | Personalized network PUK lock. | | PN_PUK_LOCK | 1 | Personalized network PUK lock. |
| PU_PIN_LOCK | 2 | Personalized network subset PIN lock. For details, see *3GPP TS 22.022 [33]*. | | PU_PIN_LOCK | 2 | Personalized network subset PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PU_PUK_LOCK | 3 | Personalized network subset PUK lock. | | PU_PUK_LOCK | 3 | Personalized network subset PUK lock. |
| PP_PIN_LOCK | 4 | Personalized service provider PIN lock. For details, see *3GPP TS 22.022 [33]*.| | PP_PIN_LOCK | 4 | Personalized service provider PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PP_PUK_LOCK | 5 | Personalized service provider PUK lock. | | PP_PUK_LOCK | 5 | Personalized service provider PUK lock. |
| PC_PIN_LOCK | 6 | Personalized corporate PIN lock. For details, see *3GPP TS 22.022 [33]*. | | PC_PIN_LOCK | 6 | Personalized corporate PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PC_PUK_LOCK | 7 | Personalized corporate PUK lock. | | PC_PUK_LOCK | 7 | Personalized corporate PUK lock. |
| SIM_PIN_LOCK | 8 | Personalized SIM card PIN lock. For details, see *3GPP TS 22.022 [33]*. | | SIM_PIN_LOCK | 8 | Personalized SIM card PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| SIM_PUK_LOCK | 9 | Personalized SIM card PUK lock. | | SIM_PUK_LOCK | 9 | Personalized SIM card PUK lock. |
## LockStatusResponse<sup>7+</sup> ## LockStatusResponse<sup>7+</sup>
......
...@@ -91,6 +91,19 @@ Sends an SMS message. ...@@ -91,6 +91,19 @@ Sends an SMS message.
| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS message.| | options | [SendMessageOptions](#sendmessageoptions) | Yes | Options (including the callback) for sending an SMS message.|
**Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message |
| -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. |
| 8300003 | System internal error. |
| 8300999 | Unknown error code. |
**Example** **Example**
```js ```js
...@@ -179,6 +192,8 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use ...@@ -179,6 +192,8 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -192,8 +207,8 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use ...@@ -192,8 +207,8 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use
**Example** **Example**
```js ```js
sms.setDefaultSmsSlotId(0, (err, data) => { sms.setDefaultSmsSlotId(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}.`);
}); });
``` ```
...@@ -224,6 +239,8 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use ...@@ -224,6 +239,8 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -238,9 +255,9 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use ...@@ -238,9 +255,9 @@ Sets the default slot ID of the SIM card used to send SMS messages. This API use
```js ```js
let promise = sms.setDefaultSmsSlotId(0); let promise = sms.setDefaultSmsSlotId(0);
promise.then(data => { promise.then(() => {
console.log(`setDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`setDefaultSmsSlotId success.`);
}).catch(err => { }).catch((err) => {
console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`); console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -267,6 +284,8 @@ Sets the short message service center (SMSC) address. This API uses an asynchron ...@@ -267,6 +284,8 @@ Sets the short message service center (SMSC) address. This API uses an asynchron
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -281,8 +300,8 @@ Sets the short message service center (SMSC) address. This API uses an asynchron ...@@ -281,8 +300,8 @@ Sets the short message service center (SMSC) address. This API uses an asynchron
```js ```js
let slotId = 0; let slotId = 0;
let smscAddr = '+861xxxxxxxxxx'; let smscAddr = '+861xxxxxxxxxx';
sms.setSmscAddr(slotId, smscAddr, (err,data) => { sms.setSmscAddr(slotId, smscAddr, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -314,6 +333,8 @@ Sets the SMSC address. This API uses a promise to return the result. ...@@ -314,6 +333,8 @@ Sets the SMSC address. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -329,9 +350,9 @@ Sets the SMSC address. This API uses a promise to return the result. ...@@ -329,9 +350,9 @@ Sets the SMSC address. This API uses a promise to return the result.
let slotId = 0; let slotId = 0;
let smscAddr = '+861xxxxxxxxxx'; let smscAddr = '+861xxxxxxxxxx';
let promise = sms.setSmscAddr(slotId, smscAddr); let promise = sms.setSmscAddr(slotId, smscAddr);
promise.then(data => { promise.then(() => {
console.log(`setSmscAddr success, promise: data->${JSON.stringify(data)}`); console.log(`setSmscAddr success.`);
}).catch(err => { }).catch((err) => {
console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`); console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -358,6 +379,8 @@ Obtains the SMSC address. This API uses an asynchronous callback to return the r ...@@ -358,6 +379,8 @@ Obtains the SMSC address. This API uses an asynchronous callback to return the r
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -403,6 +426,8 @@ Obtains the SMSC address. This API uses a promise to return the result. ...@@ -403,6 +426,8 @@ Obtains the SMSC address. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -464,6 +489,8 @@ Splits an SMS message into multiple segments. This API uses an asynchronous call ...@@ -464,6 +489,8 @@ Splits an SMS message into multiple segments. This API uses an asynchronous call
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -509,6 +536,8 @@ Splits an SMS message into multiple segments. This API uses a promise to return ...@@ -509,6 +536,8 @@ Splits an SMS message into multiple segments. This API uses a promise to return
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -551,6 +580,8 @@ Adds a SIM message. This API uses an asynchronous callback to return the result. ...@@ -551,6 +580,8 @@ Adds a SIM message. This API uses an asynchronous callback to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -569,8 +600,8 @@ let simMessageOptions = { ...@@ -569,8 +600,8 @@ let simMessageOptions = {
pdu: "xxxxxx", pdu: "xxxxxx",
status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
}; };
sms.addSimMessage(simMessageOptions, (err, data) => { sms.addSimMessage(simMessageOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -601,6 +632,8 @@ Adds a SIM message. This API uses a promise to return the result. ...@@ -601,6 +632,8 @@ Adds a SIM message. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -620,9 +653,9 @@ let simMessageOptions = { ...@@ -620,9 +653,9 @@ let simMessageOptions = {
status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ
}; };
let promise = sms.addSimMessage(simMessageOptions); let promise = sms.addSimMessage(simMessageOptions);
promise.then(data => { promise.then(() => {
console.log(`addSimMessage success, promise: data->${JSON.stringify(data)}`); console.log(`addSimMessage success.`);
}).catch(err => { }).catch((err) => {
console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`); console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -649,6 +682,8 @@ Deletes a SIM message. This API uses an asynchronous callback to return the resu ...@@ -649,6 +682,8 @@ Deletes a SIM message. This API uses an asynchronous callback to return the resu
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -663,8 +698,8 @@ Deletes a SIM message. This API uses an asynchronous callback to return the resu ...@@ -663,8 +698,8 @@ Deletes a SIM message. This API uses an asynchronous callback to return the resu
```js ```js
let slotId = 0; let slotId = 0;
let msgIndex = 1; let msgIndex = 1;
sms.delSimMessage(slotId, msgIndex, (err, data) => { sms.delSimMessage(slotId, msgIndex, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -696,6 +731,8 @@ Deletes a SIM message. This API uses a promise to return the result. ...@@ -696,6 +731,8 @@ Deletes a SIM message. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -711,9 +748,9 @@ Deletes a SIM message. This API uses a promise to return the result. ...@@ -711,9 +748,9 @@ Deletes a SIM message. This API uses a promise to return the result.
let slotId = 0; let slotId = 0;
let msgIndex = 1; let msgIndex = 1;
let promise = sms.delSimMessage(slotId, msgIndex); let promise = sms.delSimMessage(slotId, msgIndex);
promise.then(data => { promise.then(() => {
console.log(`delSimMessage success, promise: data->${JSON.stringify(data)}`); console.log(`delSimMessage success.`);
}).catch(err => { }).catch((err) => {
console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`); console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -739,6 +776,8 @@ Updates a SIM message. This API uses an asynchronous callback to return the resu ...@@ -739,6 +776,8 @@ Updates a SIM message. This API uses an asynchronous callback to return the resu
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -758,8 +797,8 @@ let updateSimMessageOptions = { ...@@ -758,8 +797,8 @@ let updateSimMessageOptions = {
pdu: "xxxxxxx", pdu: "xxxxxxx",
smsc: "test" smsc: "test"
}; };
sms.updateSimMessage(updateSimMessageOptions, (err, data) => { sms.updateSimMessage(updateSimMessageOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -790,6 +829,8 @@ Updates a SIM message. This API uses a promise to return the result. ...@@ -790,6 +829,8 @@ Updates a SIM message. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -810,9 +851,9 @@ let updateSimMessageOptions = { ...@@ -810,9 +851,9 @@ let updateSimMessageOptions = {
smsc: "test" smsc: "test"
}; };
let promise = sms.updateSimMessage(updateSimMessageOptions); let promise = sms.updateSimMessage(updateSimMessageOptions);
promise.then(data => { promise.then(() => {
console.log(`updateSimMessage success, promise: data->${JSON.stringify(data)}`); console.log(`updateSimMessage success.`);
}).catch(err => { }).catch((err) => {
console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`); console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -838,6 +879,8 @@ Obtains all SIM card messages. This API uses an asynchronous callback to return ...@@ -838,6 +879,8 @@ Obtains all SIM card messages. This API uses an asynchronous callback to return
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -883,6 +926,8 @@ Obtains all SIM card messages. This API uses a promise to return the result. ...@@ -883,6 +926,8 @@ Obtains all SIM card messages. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -925,6 +970,8 @@ Sets the cell broadcast configuration. This API uses an asynchronous callback to ...@@ -925,6 +970,8 @@ Sets the cell broadcast configuration. This API uses an asynchronous callback to
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -944,8 +991,8 @@ let cbConfigOptions = { ...@@ -944,8 +991,8 @@ let cbConfigOptions = {
endMessageId: 200, endMessageId: 200,
ranType: sms.RanType.TYPE_GSM ranType: sms.RanType.TYPE_GSM
}; };
sms.setCBConfig(cbConfigOptions, (err, data) => { sms.setCBConfig(cbConfigOptions, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -976,6 +1023,8 @@ Sets the cell broadcast configuration. This API uses a promise to return the res ...@@ -976,6 +1023,8 @@ Sets the cell broadcast configuration. This API uses a promise to return the res
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -996,9 +1045,9 @@ let cbConfigOptions = { ...@@ -996,9 +1045,9 @@ let cbConfigOptions = {
ranType: sms.RanType.TYPE_GSM ranType: sms.RanType.TYPE_GSM
}; };
let promise = sms.setCBConfig(cbConfigOptions); let promise = sms.setCBConfig(cbConfigOptions);
promise.then(data => { promise.then(() => {
console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`); console.log(`setCBConfig success.`);
}).catch(err => { }).catch((err) => {
console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`); console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -1024,6 +1073,8 @@ Obtains SMS message segment information. This API uses an asynchronous callback ...@@ -1024,6 +1073,8 @@ Obtains SMS message segment information. This API uses an asynchronous callback
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1068,6 +1119,8 @@ Obtains SMS message segment information. This API uses a promise to return the r ...@@ -1068,6 +1119,8 @@ Obtains SMS message segment information. This API uses a promise to return the r
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1107,6 +1160,8 @@ Checks whether SMS is supported on IMS. This API uses an asynchronous callback t ...@@ -1107,6 +1160,8 @@ Checks whether SMS is supported on IMS. This API uses an asynchronous callback t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1149,6 +1204,8 @@ This API uses an asynchronous callback to return the result. This API uses a pro ...@@ -1149,6 +1204,8 @@ This API uses an asynchronous callback to return the result. This API uses a pro
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1187,9 +1244,10 @@ Obtains the SMS format supported by the IMS. This API uses an asynchronous callb ...@@ -1187,9 +1244,10 @@ Obtains the SMS format supported by the IMS. This API uses an asynchronous callb
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -1223,9 +1281,10 @@ Obtains the SMS format supported by the IMS. This API uses a promise to return t ...@@ -1223,9 +1281,10 @@ Obtains the SMS format supported by the IMS. This API uses a promise to return t
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. | | 401 | Parameter error. |
| 8300001 | Invalid parameter value. | | 8300001 | Invalid parameter value. |
| 8300002 | Operation failed. Cannot connect to service. | | 8300002 | Operation failed. Cannot connect to service. |
...@@ -1262,6 +1321,8 @@ Decodes MMS messages. This API uses an asynchronous callback to return the resul ...@@ -1262,6 +1321,8 @@ Decodes MMS messages. This API uses an asynchronous callback to return the resul
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1304,6 +1365,8 @@ Decodes MMS messages. This API uses a promise to return the result. ...@@ -1304,6 +1365,8 @@ Decodes MMS messages. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1343,6 +1406,8 @@ MMS message code. This API uses an asynchronous callback to return the result. ...@@ -1343,6 +1406,8 @@ MMS message code. This API uses an asynchronous callback to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
...@@ -1393,6 +1458,8 @@ MMS message code. This API uses a promise to return the result. ...@@ -1393,6 +1458,8 @@ MMS message code. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 401 | Parameter error. | | 401 | Parameter error. |
......
# Socket Connection # # @ohos.net.socket (Socket Connection)
The **socket** module implements data transfer over TCPSocket, UDPSocket, WebSocket, and TLSSocket connections. The **socket** module implements data transfer over TCPSocket, UDPSocket, WebSocket, and TLSSocket connections.
...@@ -364,7 +364,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { ...@@ -364,7 +364,7 @@ udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => {
setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\<void\>): void setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback\<void\>): void
Sets other properties of the UDPSocket connection. This API uses an asynchronous callback to return the result. Sets other attributes of the UDPSocket connection. This API uses an asynchronous callback to return the result.
>**NOTE** >**NOTE**
>This API can be called only after **bind** is successfully called. >This API can be called only after **bind** is successfully called.
...@@ -418,7 +418,7 @@ udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> { ...@@ -418,7 +418,7 @@ udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> {
setExtraOptions(options: UDPExtraOptions): Promise\<void\> setExtraOptions(options: UDPExtraOptions): Promise\<void\>
Sets other properties of the UDPSocket connection. This API uses a promise to return the result. Sets other attributes of the UDPSocket connection. This API uses a promise to return the result.
>**NOTE** >**NOTE**
>This API can be called only after **bind** is successfully called. >This API can be called only after **bind** is successfully called.
...@@ -522,7 +522,7 @@ let callback = value =>{ ...@@ -522,7 +522,7 @@ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
} }
udp.on('message', callback); udp.on('message', callback);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
udp.off('message', callback); udp.off('message', callback);
udp.off('message'); udp.off('message');
``` ```
...@@ -582,14 +582,14 @@ let callback1 = () =>{ ...@@ -582,14 +582,14 @@ let callback1 = () =>{
console.log("on listening, success"); console.log("on listening, success");
} }
udp.on('listening', callback1); udp.on('listening', callback1);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
udp.off('listening', callback1); udp.off('listening', callback1);
udp.off('listening'); udp.off('listening');
let callback2 = () =>{ let callback2 = () =>{
console.log("on close, success"); console.log("on close, success");
} }
udp.on('close', callback2); udp.on('close', callback2);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
udp.off('close', callback2); udp.off('close', callback2);
udp.off('close'); udp.off('close');
``` ```
...@@ -646,7 +646,7 @@ let callback = err =>{ ...@@ -646,7 +646,7 @@ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
} }
udp.on('error', callback); udp.on('error', callback);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
udp.off('error', callback); udp.off('error', callback);
udp.off('error'); udp.off('error');
``` ```
...@@ -1426,7 +1426,7 @@ let callback = value =>{ ...@@ -1426,7 +1426,7 @@ let callback = value =>{
console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo);
} }
tcp.on('message', callback); tcp.on('message', callback);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
tcp.off('message', callback); tcp.off('message', callback);
tcp.off('message'); tcp.off('message');
``` ```
...@@ -1486,14 +1486,14 @@ let callback1 = () =>{ ...@@ -1486,14 +1486,14 @@ let callback1 = () =>{
console.log("on connect success"); console.log("on connect success");
} }
tcp.on('connect', callback1); tcp.on('connect', callback1);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
tcp.off('connect', callback1); tcp.off('connect', callback1);
tcp.off('connect'); tcp.off('connect');
let callback2 = () =>{ let callback2 = () =>{
console.log("on close success"); console.log("on close success");
} }
tcp.on('close', callback2); tcp.on('close', callback2);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
tcp.off('close', callback2); tcp.off('close', callback2);
tcp.off('close'); tcp.off('close');
``` ```
...@@ -1550,7 +1550,7 @@ let callback = err =>{ ...@@ -1550,7 +1550,7 @@ let callback = err =>{
console.log("on error, err:" + JSON.stringify(err)); console.log("on error, err:" + JSON.stringify(err));
} }
tcp.on('error', callback); tcp.on('error', callback);
// You can pass the **callback** of the **on** method to cancel listening for a certain type of callback. If you do not pass the **callback**, you will cancel listening for all callbacks. // You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks.
tcp.off('error', callback); tcp.off('error', callback);
tcp.off('error'); tcp.off('error');
``` ```
...@@ -2674,4 +2674,4 @@ Defines the certificate raw data. ...@@ -2674,4 +2674,4 @@ Defines the certificate raw data.
| Type | Description | | Type | Description |
| --------------------------------------------------------------------- | --------------------- | | --------------------------------------------------------------------- | --------------------- |
|[cryptoFramework.EncodingBlob](js-apis-cryptoFramework.md#datablob) | Data and encoding format of the certificate.| |[cert.EncodingBlob](js-apis-cert.md#datablob) | Data and encoding format of the certificate.|
...@@ -100,6 +100,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy ...@@ -100,6 +100,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -114,8 +116,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy ...@@ -114,8 +116,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses an asy
**Example** **Example**
```js ```js
data.setDefaultCellularDataSlotId(0, (err, data) => { data.setDefaultCellularDataSlotId(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}.`);
}); });
``` ```
...@@ -145,6 +147,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom ...@@ -145,6 +147,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -160,8 +164,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom ...@@ -160,8 +164,8 @@ Sets the default slot of the SIM card used for mobile data. This API uses a prom
```js ```js
let promise = data.setDefaultCellularDataSlotId(0); let promise = data.setDefaultCellularDataSlotId(0);
promise.then((data) => { promise.then(() => {
console.log(`setDefaultCellularDataSlotId success, promise: data->${JSON.stringify(data)}`); console.log(`setDefaultCellularDataSlotId success.`);
}).catch((err) => { }).catch((err) => {
console.error(`setDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`); console.error(`setDefaultCellularDataSlotId fail, promise: err->${JSON.stringify(err)}`);
}); });
...@@ -279,6 +283,8 @@ Checks whether the cellular data service is enabled. This API uses an asynchrono ...@@ -279,6 +283,8 @@ Checks whether the cellular data service is enabled. This API uses an asynchrono
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -314,6 +320,8 @@ Checks whether the cellular data service is enabled. This API uses a promise to ...@@ -314,6 +320,8 @@ Checks whether the cellular data service is enabled. This API uses a promise to
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -353,6 +361,8 @@ Checks whether roaming is enabled for the cellular data service. This API uses a ...@@ -353,6 +361,8 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -394,6 +404,8 @@ Checks whether roaming is enabled for the cellular data service. This API uses a ...@@ -394,6 +404,8 @@ Checks whether roaming is enabled for the cellular data service. This API uses a
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -434,6 +446,8 @@ Enables the cellular data service. This API uses an asynchronous callback to ret ...@@ -434,6 +446,8 @@ Enables the cellular data service. This API uses an asynchronous callback to ret
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -446,8 +460,8 @@ Enables the cellular data service. This API uses an asynchronous callback to ret ...@@ -446,8 +460,8 @@ Enables the cellular data service. This API uses an asynchronous callback to ret
**Example** **Example**
```js ```js
data.enableCellularData((err, data) => { data.enableCellularData((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -471,6 +485,8 @@ Enables the cellular data service. This API uses a promise to return the result. ...@@ -471,6 +485,8 @@ Enables the cellular data service. This API uses a promise to return the result.
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -484,8 +500,8 @@ Enables the cellular data service. This API uses a promise to return the result. ...@@ -484,8 +500,8 @@ Enables the cellular data service. This API uses a promise to return the result.
```js ```js
let promise = data.enableCellularData(); let promise = data.enableCellularData();
promise.then((data) => { promise.then(() => {
console.log(`enableCellularData success, promise: data->${JSON.stringify(data)}`); console.log(`enableCellularData success.`);
}).catch((err) => { }).catch((err) => {
console.error(`enableCellularData fail, promise: err->${JSON.stringify(err)}`); console.error(`enableCellularData fail, promise: err->${JSON.stringify(err)}`);
}); });
...@@ -511,6 +527,8 @@ Disables the cellular data service. This API uses an asynchronous callback to re ...@@ -511,6 +527,8 @@ Disables the cellular data service. This API uses an asynchronous callback to re
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -523,8 +541,8 @@ Disables the cellular data service. This API uses an asynchronous callback to re ...@@ -523,8 +541,8 @@ Disables the cellular data service. This API uses an asynchronous callback to re
**Example** **Example**
```js ```js
data.disableCellularData((err, data) => { data.disableCellularData((err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -548,6 +566,8 @@ Disables the cellular data service. This API uses a promise to return the result ...@@ -548,6 +566,8 @@ Disables the cellular data service. This API uses a promise to return the result
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -561,8 +581,8 @@ Disables the cellular data service. This API uses a promise to return the result ...@@ -561,8 +581,8 @@ Disables the cellular data service. This API uses a promise to return the result
```js ```js
let promise = data.disableCellularData(); let promise = data.disableCellularData();
promise.then((data) => { promise.then(() => {
console.log(`disableCellularData success, promise: data->${JSON.stringify(data)}`); console.log(`disableCellularData success.`);
}).catch((err) => { }).catch((err) => {
console.error(`disableCellularData fail, promise: err->${JSON.stringify(err)}`); console.error(`disableCellularData fail, promise: err->${JSON.stringify(err)}`);
}); });
...@@ -589,6 +609,8 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac ...@@ -589,6 +609,8 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -601,8 +623,8 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac ...@@ -601,8 +623,8 @@ Enables the cellular data roaming service. This API uses an asynchronous callbac
**Example** **Example**
```js ```js
data.enableCellularDataRoaming(0, (err, data) => { data.enableCellularDataRoaming(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -632,6 +654,8 @@ Enables the cellular data roaming service. This API uses a promise to return the ...@@ -632,6 +654,8 @@ Enables the cellular data roaming service. This API uses a promise to return the
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -645,8 +669,8 @@ Enables the cellular data roaming service. This API uses a promise to return the ...@@ -645,8 +669,8 @@ Enables the cellular data roaming service. This API uses a promise to return the
```js ```js
let promise = data.enableCellularDataRoaming(0); let promise = data.enableCellularDataRoaming(0);
promise.then((data) => { promise.then(() => {
console.log(`enableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`); console.log(`enableCellularDataRoaming success.`);
}).catch((err) => { }).catch((err) => {
console.error(`enableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); console.error(`enableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`);
}); });
...@@ -673,6 +697,8 @@ Disables the cellular data roaming service. This API uses an asynchronous callba ...@@ -673,6 +697,8 @@ Disables the cellular data roaming service. This API uses an asynchronous callba
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -685,8 +711,8 @@ Disables the cellular data roaming service. This API uses an asynchronous callba ...@@ -685,8 +711,8 @@ Disables the cellular data roaming service. This API uses an asynchronous callba
**Example** **Example**
```js ```js
data.disableCellularDataRoaming(0, (err, data) => { data.disableCellularDataRoaming(0, (err) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
...@@ -716,6 +742,8 @@ Disables the cellular data roaming service. This API uses a promise to return th ...@@ -716,6 +742,8 @@ Disables the cellular data roaming service. This API uses a promise to return th
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------------------- | | -------- | -------------------------------------------- |
| 201 | Permission denied. | | 201 | Permission denied. |
...@@ -729,8 +757,8 @@ Disables the cellular data roaming service. This API uses a promise to return th ...@@ -729,8 +757,8 @@ Disables the cellular data roaming service. This API uses a promise to return th
```js ```js
let promise = data.disableCellularDataRoaming(0); let promise = data.disableCellularDataRoaming(0);
promise.then((data) => { promise.then(() => {
console.log(`disableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`); console.log(`disableCellularDataRoaming success.`);
}).catch((err) => { }).catch((err) => {
console.error(`disableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); console.error(`disableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`);
}); });
......
...@@ -136,4 +136,4 @@ export default { ...@@ -136,4 +136,4 @@ export default {
} }
``` ```
![zh-cn_image_0000001176075554](figures/zh-cn_image_0000001176075554.gif) ![en-us_image_0000001176075554](figures/en-us_image_0000001176075554.gif)
...@@ -48,7 +48,7 @@ In addition to the [universal events](../arkui-js/js-components-common-events.md ...@@ -48,7 +48,7 @@ In addition to the [universal events](../arkui-js/js-components-common-events.md
| finish | - | Triggered when the last step on the navigator is complete. | | finish | - | Triggered when the last step on the navigator is complete. |
| skip | - | Triggered when users click the skip button to skip steps.| | skip | - | Triggered when users click the skip button to skip steps.|
| change | { prevIndex: prevIndex, index: index} | Triggered when users click the left or right (text) button of the step navigator to switch between steps. **prevIndex** indicates the index of the previous step, and **index** indicates that of the current step.| | change | { prevIndex: prevIndex, index: index} | Triggered when users click the left or right (text) button of the step navigator to switch between steps. **prevIndex** indicates the index of the previous step, and **index** indicates that of the current step.|
| next | { index: index, pendingIndex: pendingIndex } | Triggered when users click the next (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in **{pendingIndex:*** pendingIndex***}** format. You can use **pendingIndex** to specify a **<stepper-item>** child component as the next step to go.| | next | { index: index, pendingIndex: pendingIndex } | Triggered when users click the next (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in **{pendingIndex:*** pendingIndex***}** format. You can use **pendingIndex** to specify a **\<stepper-item>** child component as the next step to go. |
| back | { index: index, pendingIndex: pendingIndex } | Triggered when users click the previous (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in Object:{ **{pendingIndex:*** pendingIndex***}** format. You can use **pendingIndex** to specify a **<stepper-item>** child component as the previous step.| | back | { index: index, pendingIndex: pendingIndex } | Triggered when users click the previous (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in Object:{ **{pendingIndex:*** pendingIndex***}** format. You can use **pendingIndex** to specify a **<stepper-item>** child component as the previous step.|
......
...@@ -31,7 +31,7 @@ The following references the custom component: ...@@ -31,7 +31,7 @@ The following references the custom component:
## Named Slot ## Named Slot
When multiple slots are need inside a custom component, you can name them, so that you can specify the slot in which you want to fill content by setting the **<name>** attribute. When multiple slots are need inside a custom component, you can name them, so that you can specify the slot in which you want to fill content by setting the **\<name>** attribute.
```html ```html
<!-- comp.hml --> <!-- comp.hml -->
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
- [Transformation](ts-universal-attributes-transformation.md) - [Transformation](ts-universal-attributes-transformation.md)
- [Image Effect Configuration](ts-universal-attributes-image-effect.md) - [Image Effect Configuration](ts-universal-attributes-image-effect.md)
- [Shape Clipping](ts-universal-attributes-sharp-clipping.md) - [Shape Clipping](ts-universal-attributes-sharp-clipping.md)
- [Text Style](ts-universal-attributes-text-style.md)
- [Grid](ts-universal-attributes-grid.md) - [Grid](ts-universal-attributes-grid.md)
- [Gradient Color](ts-universal-attributes-gradient-color.md) - [Gradient Color](ts-universal-attributes-gradient-color.md)
- [Popup Control](ts-universal-attributes-popup.md) - [Popup Control](ts-universal-attributes-popup.md)
...@@ -43,7 +42,8 @@ ...@@ -43,7 +42,8 @@
- [Background Blur](ts-universal-attributes-backgroundBlurStyle.md) - [Background Blur](ts-universal-attributes-backgroundBlurStyle.md)
- [restoreId](ts-universal-attributes-restoreId.md) - [restoreId](ts-universal-attributes-restoreId.md)
- [Foreground Color](ts-universal-attributes-foreground-color.md) - [Foreground Color](ts-universal-attributes-foreground-color.md)
- Gesture Processing - [Universal Text Attributes](ts-universal-attributes-text-style.md)
- Gesture Handling
- [Gesture Binding Methods](ts-gesture-settings.md) - [Gesture Binding Methods](ts-gesture-settings.md)
- Basic Gestures - Basic Gestures
- [TapGesture](ts-basic-gestures-tapgesture.md) - [TapGesture](ts-basic-gestures-tapgesture.md)
......
...@@ -37,11 +37,11 @@ struct AttrAnimationExample { ...@@ -37,11 +37,11 @@ struct AttrAnimationExample {
build() { build() {
Column() { Column() {
Button('change width and height') Button('change size')
.onClick(() => { .onClick(() => {
if (this.flag) { if (this.flag) {
this.widthSize = 100 this.widthSize = 150
this.heightSize = 50 this.heightSize = 60
} else { } else {
this.widthSize = 250 this.widthSize = 250
this.heightSize = 100 this.heightSize = 100
...@@ -67,8 +67,8 @@ struct AttrAnimationExample { ...@@ -67,8 +67,8 @@ struct AttrAnimationExample {
duration: 1200, duration: 1200,
curve: Curve.Friction, curve: Curve.Friction,
delay: 500, delay: 500,
iterations: -1, // The value -1 indicates that the animation is played for an unlimited number of times. iterations: -1, // The value -1 indicates that the animation is played for an unlimited number of times.
playMode: PlayMode.AlternateReverse playMode: PlayMode.Alternate
}) })
}.width('100%').margin({ top: 20 }) }.width('100%').margin({ top: 20 })
} }
......
...@@ -417,21 +417,23 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -417,21 +417,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 | Description | | Name | Description |
| ------ | -------------- | | --------------------- | -------------- |
| Start | Aligned with the start.| | Start | Aligned with the start.|
| Center | Horizontally centered.| | Center | Horizontally centered.|
| End | Aligned with the end.| | End | Aligned with the end.|
| Justify<sup>10+</sup> | Aligned with both margins. |
## TextOverflow ## TextOverflow
Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets.
| Name | Description | | Name | Description |
| -------- | -------------------------------------- | | --------------------- | -------------------------------------- |
| Clip | Extra-long text is clipped. | | None | No clipping or ellipsis is used for text overflow. |
| Ellipsis | An ellipsis (...) is used to represent clipped text.| | Clip | Extra-long text is clipped. |
| None | No clipping or ellipsis is used for extra-long text. | | Ellipsis | An ellipsis (...) is used to represent text overflow.|
| Marquee<sup>10+</sup> | Text continuously scrolls when text overflow occurs. |
## TextDecorationType ## TextDecorationType
...@@ -513,3 +515,40 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -513,3 +515,40 @@ Since API version 9, this API is supported in ArkTS widgets.
| Block | The node responds to the hit test of a touch event, but its child node and sibling node are blocked from the hit test. | | Block | The node responds to the hit test of a touch event, but its child node and sibling node are blocked from the hit test. |
| Transparent | Both the node and its child node respond to the hit test of a touch event, and its sibling node is also considered during the hit test.| | Transparent | Both the node and its child node respond to the hit test of a touch event, and its sibling node is also considered during the hit test.|
| None | The node does not respond to the hit test of a touch event, but its child node and sibling node are considered during the hit test.| | None | The node does not respond to the hit test of a touch event, but its child node and sibling node are considered during the hit test.|
## BlurStyle<sup>9+</sup>
This API is supported in ArkTS widgets.
| Name| Description|
| ------- | ---------- |
| Thin | Thin material. |
| Regular | Regular material. |
| Thick | Thick material. |
| BackgroundThin | Material that creates the minimum depth of field effect.|
| BackgroundRegular | Material that creates a medium shallow depth of field effect.|
| BackgroundThick | Material that creates a high shallow depth of field effect.|
| BackgroundUltraThick | Material that creates the maximum depth of field effect.|
## ThemeColorMode<sup>10+</sup>
| Name | Description |
| ------- | ---------- |
| System | Following the system color mode.|
| Light | Light color mode.|
| Dark | Dark color mode.|
## AdaptiveColor<sup>10+</sup>
| Name | Description |
| ------- | ----------- |
| Default | Adaptive color mode is not used. The default color is used as the mask color.|
| Average | Adaptive color mode is used. The average color value of the color picking area is used as the mask color.|
## TextHeightAdaptivePolicy<sup>10+</sup>
| Name | Description |
| ----------------------- | ------------------------------------------------ |
| MAX_LINES_FIRST | Prioritize the **maxLines** settings. |
| MIN_FONT_SIZE_FIRST | Prioritize the **minFontSize** settings. |
| LAYOUT_CONSTRAINT_FIRST | Prioritize the layout constraint settings in terms of height.|
...@@ -25,10 +25,9 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -25,10 +25,9 @@ Since API version 9, this API is supported in ArkTS widgets.
| type | ButtonType | No | Button type.<br>Default value: **ButtonType.Capsule** | | type | ButtonType | No | Button type.<br>Default value: **ButtonType.Capsule** |
| stateEffect | boolean | No | Whether to enable the pressed effect on the click of the button. The value **false** means to disable the pressed effect.<br>Default value: **true**| | stateEffect | boolean | No | Whether to enable the pressed effect on the click of the button. The value **false** means to disable the pressed effect.<br>Default value: **true**|
**API 2:** Button(label?: ResourceStr, options?: { type?: ButtonType, stateEffect?: boolean }) **API 2:** Button(label?: ResourceStr, options?: { type?: ButtonType, stateEffect?: boolean })
Creates a button component based on text content. In this case, the component cannot contain child components. Creates a button component based on text content. In this case, the component cannot contain child components.
Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets.
...@@ -46,6 +45,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -46,6 +45,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| ----------- | ----------- | --------------------------------- | | ----------- | ----------- | --------------------------------- |
| type | ButtonType | Button type.<br>Default value: **ButtonType.Capsule**<br>Since API version 9, this API is supported in ArkTS widgets.| | type | ButtonType | Button type.<br>Default value: **ButtonType.Capsule**<br>Since API version 9, this API is supported in ArkTS widgets.|
| stateEffect | boolean | Whether to enable the pressed effect on the click of the button. The value **false** means to disable the pressed effect.<br>Default value: **true**<br>Since API version 9, this API is supported in ArkTS widgets.| | stateEffect | boolean | Whether to enable the pressed effect on the click of the button. The value **false** means to disable the pressed effect.<br>Default value: **true**<br>Since API version 9, this API is supported in ArkTS widgets.|
| labelStyle<sup>10+</sup> | [LabelStyle](#labelstyle10) | Label style of the button.|
## ButtonType enums ## ButtonType enums
...@@ -58,11 +58,22 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -58,11 +58,22 @@ Since API version 9, this API is supported in ArkTS widgets.
| Normal | Normal button (without rounded corners by default). | | Normal | Normal button (without rounded corners by default). |
> **NOTE** > **NOTE**
> - The rounded corner of a button is set by using [borderRadius](ts-universal-attributes-border.md), rather than by using the **border** API. Only a button-wide rounded corner setting is supported. > - The rounded corner of a button is set by using [borderRadius](ts-universal-attributes-border.md), rather than by using the **border** API. Only a rounded corner whose parameter is [Length](ts-types.md#length) is supported.
> - For a button of the **Capsule** type, the **borderRadius** settings do not take effect, and its rounded corner is always half of the button height. > - For a button of the **Capsule** type, the **borderRadius** settings do not take effect, and the radius of its rounded corner is always half of the button height or width, whichever is smaller.
> - For a button of the **Circle** type, its radius is the value of **borderRadius** (if set) or the width or height (whichever is smaller). > - For a button of the **Circle** type, its radius is the value of **borderRadius** (if set) or the width or height (whichever is smaller).
> - The button text is set using the [text style attributes](ts-universal-attributes-text-style.md). > - The button text is set using the [text style attributes](ts-universal-attributes-text-style.md).
> - Before setting the [gradient color](ts-universal-attributes-gradient-color.md), you need to set [backgroundColor](ts-universal-attributes-background.md) to transparent.
## LabelStyle<sup>10+</sup>
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| overflow | [TextOverflow](ts-appendix-enums.md#textoverflow) | No | Display mode when the label text is too long. Text is clipped at the transition between words. To clip text in the middle of a word, add **\u200B** between characters.|
| maxLines | number | No | Maximum number of lines in the label text. By default, text is automatically folded. If this attribute is specified, the text will not exceed the specified number of lines. If there is extra text, you can use **textOverflow** to specify how it is displayed.|
| minFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | No | Minimum font size of the label text. For the setting to take effect, this attribute must be used together with **maxFontSize**, **maxLines**, or layout constraint settings.|
| maxFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | No | Maximum font size of the label text. For the setting to take effect, this attribute must be used together with **minFontSize**, **maxLines**, or layout constraint settings.|
| heightAdaptivePolicy | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | No | How the adaptive height is determined for the label text. |
| font | [Font](ts-types.md#Font) | No | Font of the label text. |
## Example ## Example
......
...@@ -24,10 +24,20 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -24,10 +24,20 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Description| | Name | Type | Mandatory | Description|
| ----------------- | -------- | ----- | -------- | | ----------------- | -------- | ----- | -------- |
| values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. If the value is less than 0, the value 0 is used.| | values | number[] | Yes | Data value list. A maximum of nine values are supported. If more than nine values are set, only the first nine ones are used. A value less than 0 evaluates to the value **0**. |
| max | number | No | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion.<br>Default value: **100**| | max | number | No | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion.<br>Default value: **100**|
| type<sup>8+</sup> | [DataPanelType](#datapaneltype) | No| Type of the data panel (dynamic modification is not supported).<br>Default value: **DataPanelType.Circle**| | type<sup>8+</sup> | [DataPanelType](#datapaneltype) | No| Type of the data panel (dynamic modification is not supported).<br>Default value: **DataPanelType.Circle**|
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
| Name | Type | Description |
| ----------- | ------- | -------------------------------------------- |
| closeEffect | boolean | Whether to disable the rotation effect for the component.<br>Default value: **false**|
## DataPanelType ## DataPanelType
Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets.
......
...@@ -26,15 +26,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -26,15 +26,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| ----------- | ---------- | ------------------ | | ----------- | ---------- | ------------------ |
| vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.|
| color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Since API version 9, this API is supported in ArkTS widgets.| | color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeWidth | number \| string | Width of the divider.<br>Default value: **1**<br>Since API version 9, this API is supported in ArkTS widgets.| | strokeWidth | number \| string | Width of the divider.<br>Default value: **1**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage.|
| lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.| | lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.|
## Events
The universal events are not supported.
## Example ## Example
```ts ```ts
......
...@@ -81,11 +81,11 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -81,11 +81,11 @@ Since API version 9, this API is supported in ArkTS widgets.
In addition to the [universal events](ts-universal-events-click.md), the following events are supported. In addition to the [universal events](ts-universal-events-click.md), the following events are supported.
| Name | Description | | Name | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| onComplete(callback: (event?: { width: number, height: number, componentWidth: number,<br> componentHeight: number, loadingStatus: number }) =&gt; void) | Triggered when an image is successfully loaded. The size of the loaded image is returned.<br>- **width**: width of the image, in pixels.<br>- **height**: height of the image, in pixels.<br>- **componentWidth**: width of the container component, in pixels.<br>- **componentHeight**: height of the container component, in pixels.<br>- **loadingStatus**: image loading status.<br>Since API version 9, this API is supported in ArkTS widgets.| | onComplete(callback: (event?: { width: number, height: number, componentWidth: number,<br> componentHeight: number, loadingStatus: number }) =&gt; void) | Triggered when an image is successfully loaded. The size of the loaded image is returned.<br>- **width**: width of the image, in pixels.<br>- **height**: height of the image, in pixels.<br>- **componentWidth**: width of the container component, in pixels.<br>- **componentHeight**: height of the container component, in pixels.<br>- **loadingStatus**: image loading status. The value **1** means that the image is successfully loaded, and **0** means the opposite.<br>Since API version 9, this API is supported in ArkTS widgets. |
| onError(callback: (event?: { componentWidth: number, componentHeight: number , message<sup>9+</sup>: string }) =&gt; void) | Triggered when an exception occurs during image loading.<br>- **componentWidth**: width of the container component, in pixels.<br>- **componentHeight**: height of the container component, in pixels.<br>Since API version 9, this API is supported in ArkTS widgets.| | onError(callback: (event?: { componentWidth: number, componentHeight: number , message<sup>9+</sup>: string }) =&gt; void) | Triggered when an exception occurs during image loading.<br>- **componentWidth**: width of the container component, in pixels.<br>- **componentHeight**: height of the container component, in pixels.<br>Since API version 9, this API is supported in ArkTS widgets. |
| onFinish(event: () =&gt; void) | Triggered when the animation playback in the loaded SVG image is complete. If the animation is an infinite loop, this callback is not triggered.<br>Since API version 9, this API is supported in ArkTS widgets.| | onFinish(event: () =&gt; void) | Triggered when the animation playback in the loaded SVG image is complete. If the animation is an infinite loop, this callback is not triggered.<br>Since API version 9, this API is supported in ArkTS widgets. |
## Example ## Example
......
...@@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
## Events ## Events
Among all the universal events, only the [click event](ts-universal-events-click.md) is supported. Among the universal events, the [click event](ts-universal-events-click.md), [touch event](ts-universal-events-touch.md), and [show/hide event](ts-universal-events-show-hide.md) are supported.
## Example ## Example
......
...@@ -32,7 +32,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -32,7 +32,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| -------- | -------- | -------- | | -------- | -------- | -------- |
| stars | number | Total number of stars.<br>Default value: **5**<br>Since API version 9, this API is supported in ArkTS widgets.| | stars | number | Total number of stars.<br>Default value: **5**<br>Since API version 9, this API is supported in ArkTS widgets.|
| stepSize | number | Step of an operation.<br>Default value: **0.5**<br>Since API version 9, this API is supported in ArkTS widgets.| | stepSize | number | Step of an operation.<br>Default value: **0.5**<br>Since API version 9, this API is supported in ArkTS widgets.|
| starStyle | {<br>backgroundUri: string,<br>foregroundUri: string,<br>secondaryUri?: string<br>} | **backgroundUri**: image link of the unselected star. You can use the default image or a custom local image.<br>**foregroundUri**: image path of the selected star. You can use the default image or a custom local image.<br>**secondaryUir**: image path of the partially selected star. You can use the default image or a custom local image.<br>Since API version 9, this API is supported in ArkTS widgets.| | starStyle | {<br>backgroundUri: string,<br>foregroundUri: string,<br>secondaryUri?: string<br>} | Star style.<br>**backgroundUri**: image path for the unselected star. You can use the default system image or a custom image.<br>**foregroundUri**: image path for the selected star. You can use the default system image or a custom image.<br>**secondaryUir**: image path for the partially selected star. You can use the default system image or a custom image.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>For details about the image types supported by the **startStyle** attribute, see [Image](ts-basic-components-image.md).<br>Local and online images are supported, but not **PixelMap** and **Resource** objects.<br>By default, the image is loaded in asynchronous mode. Synchronous loading is not supported.|
## Events ## Events
......
...@@ -12,14 +12,14 @@ Not supported ...@@ -12,14 +12,14 @@ Not supported
## APIs ## APIs
Search(options?: { value?: string; placeholder?: string; icon?: string; controller?: SearchController }) Search(options?: { value?: string; placeholder?: ResourceStr; icon?: string; controller?: SearchController })
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------- | ---- | ------------------------------------------------------------ | | ----------- | ---------------- | ---- | ------------------------------------------------------------ |
| value | string | No | Text input in the search text box. | | value | string | No | Text input in the search text box. |
| placeholder | string | No | Text displayed when there is no input. | | placeholder | [ResourceStr](ts-types.md#resourcestr)<sup>10+</sup> | No | Text displayed when there is no input. |
| icon | string | No | Path to the search icon. By default, the system search icon is used. The supported icon formats are .svg, .jpg, and .png.| | icon | string | No | Path to the search icon. By default, the system search icon is used. The supported icon formats are .svg, .jpg, and .png.|
| controller | SearchController | No | Controller of the **\<Search>** component. | | controller | SearchController | No | Controller of the **\<Search>** component. |
...@@ -29,12 +29,46 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -29,12 +29,46 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name | Type | Description | | Name | Type | Description |
| ----------------------- | ------------------------------------------------ | ---------------------------------------------- | | ----------------------- | ------------------------------------------------ | ---------------------------------------------- |
| searchButton | string | Text on the search button located next to the search text box. By default, there is no search button. | | searchButton<sup>10+</sup> | value: string,<br>option?: [SearchButtonOption](#searchbuttonoption10) | Text on the search button located next to the search text box. By default, there is no search button. |
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color. | | placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color. |
| placeholderFont | [Font](ts-types.md#font) | Placeholder text font. | | placeholderFont | [Font](ts-types.md#font) | Placeholder text font. |
| textFont | [Font](ts-types.md#font) | Text font for the search text box. | | textFont | [Font](ts-types.md#font) | Text font for the search text box. |
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Text alignment mode in the search text box.<br>Default value: **TextAlign.Start** | | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Text alignment mode in the search text box.<br>Default value: **TextAlign.Start** |
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed. | | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed. |
| searchIcon<sup>10+</sup> | [IconOptions](#iconoptions10) | Style of the search icon on the left. |
| cancelButton<sup>10+</sup> | {<br>style? : [CancelButtonStyle](#cancelbuttonstyle10)<br>icon?: [IconOptions](#iconoptions10) <br>} | Style of the Cancel button on the right. |
| fontColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | Font color of the input text. |
| caretStyle<sup>10+</sup> | [CaretStyle](#caretstyle10) | Caret style. |
## IconOptions<sup>10+</sup>
| Name| Type | Mandatory| Description |
| ------ | ------------------------------------------ | ---- | ----------- |
| size | [Length](ts-types.md#length) | No | Icon size. |
| color | [ResourceColor](ts-types.md#resourcecolor) | No | Icon color. |
| src | [ResourceStr](ts-types.md#resourcestr) | No | Image source of the icon.|
## CaretStyle<sup>10+</sup>
| Name| Type | Mandatory| Description|
| ------ | ------------------------------------------ | ---- | -------- |
| width | [Length](ts-types.md#length) | No | Caret width.|
| color | [ResourceColor](ts-types.md#resourcecolor) | No | Caret color.|
## SearchButtonOption<sup>10+</sup>
| Name | Type | Mandatory| Description |
| --------- | ------------------------------------------ | ---- | ---------------- |
| fontSize | [Length](ts-types.md#length) | No | Font size of the button.|
| fontColor | [ResourceColor](ts-types.md#resourcecolor) | No | Font color of the button.|
## CancelButtonStyle<sup>10+</sup>
| Name | Description |
| ----------------------- | ---------------- |
| CONSTANT<sup>10+</sup> | The Cancel button is always displayed.|
| INVISIBLE<sup>10+</sup> | The Cancel button is always hidden.|
| INPUT<sup>10+</sup> | The Cancel button is displayed when there is text input.|
## Events ## Events
......
...@@ -50,9 +50,35 @@ Except touch target attributes, the universal attributes are supported. ...@@ -50,9 +50,35 @@ Except touch target attributes, the universal attributes are supported.
| trackColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the slider.<br>Since API version 9, this API is supported in ArkTS widgets.| | trackColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the slider.<br>Since API version 9, this API is supported in ArkTS widgets.|
| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the selected part of the slider track.<br>Since API version 9, this API is supported in ArkTS widgets.| | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the selected part of the slider track.<br>Since API version 9, this API is supported in ArkTS widgets.|
| showSteps | boolean | Whether to display the current step.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | showSteps | boolean | Whether to display the current step.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.|
| showTips | boolean | Whether to display a bubble to indicate the percentage when the user drags the slider.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | showTips | boolean | Whether to display a bubble to indicate the percentage when the user drags the slider.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>When **direction** is set to **Axis.Horizontal**, the bubble is displayed right above the slider. When **direction** is set to **Axis.Vertical**, the bubble is displayed on the left of the slider.<br>The drawing area of the bubble is the overlay of the slider.<br>If no margin is set for the slider or the margin is not large enough, the bubble will be clipped.|
| trackThickness | [Length](ts-types.md#length) | Track thickness of the slider.<br>Since API version 9, this API is supported in ArkTS widgets.| | trackThickness | [Length](ts-types.md#length) | Track thickness of the slider.<br>Since API version 9, this API is supported in ArkTS widgets.|
| blockBorderColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | Border color of the slider in the block direction.|
| blockBorderWidth<sup>10+</sup> | [Length](ts-types.md#length) | Border width of the slider in the block direction.|
| stepColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | Step color.|
| trackBorderRadius<sup>10+</sup> | [Length](ts-types.md#length) | Radius of the rounded corner of the slider track.|
| blockSize<sup>10+</sup> | [SizeOptions](ts-types.md#sizeoptions) | Size of the slider in the block direction.|
| blockStyle<sup>10+</sup> | [SliderBlockStyle](#sliderblockstyle10) | Style of the slider in the block direction.|
| stepSize<sup>10+</sup> | [Length](ts-types.md#length) | Step size (diameter).|
## SliderBlockStyle<sup>10+</sup>
Desribes the style of the slider in the block direction.
| Name | Type | Mandatory| Description |
| ----- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | [SliderBlockType](#sliderblocktype10) | Yes | Type of the slider in the block direction.<br>Default value: **SliderBlockType.DEFAULT**, indicating the round slider.|
| image | [ResourceStr](ts-types.md#resourcestr) | No | Image resource of the slider.<br>The area size for displaying the image is subject to the **blockSize** attribute. Be mindful of the image size when selecting an image.|
| shape | [Circle](ts-drawing-components-circle.md) \| [Ellipse](ts-drawing-components-ellipse.md) \| [Path](ts-drawing-components-path.md) \| [Rect](ts-drawing-components-rect.md) | No | Custom shape of the slider. |
## SliderBlockType<sup>10+</sup>
Enumerates the types of the slider in the block direction.
| Name | Description |
| ------- | ---------------------- |
| DEFAULT | Round slider. |
| IMAGE | Slider with an image background. |
| SHAPE | Slider in a custom shape.|
## Events ## Events
...@@ -60,7 +86,7 @@ In addition to the **OnAppear** and **OnDisAppear** universal events, the follow ...@@ -60,7 +86,7 @@ In addition to the **OnAppear** and **OnDisAppear** universal events, the follow
| Name| Description| | Name| Description|
| -------- | -------- | | -------- | -------- |
| onChange(callback: (value: number, mode: SliderChangeMode) =&gt; void) | Invoked when the slider slides.<br>**value**: current slider value. If the return value contains decimals, you can use **Math.toFixed()** to process the data to the desired precision.<br>**mode**: dragging state.<br>Since API version 9, this API is supported in ArkTS widgets.| | onChange(callback: (value: number, mode: SliderChangeMode) =&gt; void) | Invoked when the slider is dragged or clicked.<br>**value**: current slider value. If the return value contains decimals, you can use **Math.toFixed()** to process the data to the desired precision.<br>**mode**: state triggered by the event.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The **Begin** and **End** states are triggered when the slider is clicked with a gesture. The **Moving** and **Click** states are triggered when the value of **value** changes.<br>If the coherent action is a drag action, the **Click** state will not be triggered.<br>The value range of **value** is the **steps** value array.|
## SliderChangeMode ## SliderChangeMode
...@@ -68,9 +94,9 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -68,9 +94,9 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| Begin | 0 | The user starts to drag the slider.| | Begin | 0 | The user touches or presses the slider with a gesture or mouse.|
| Moving | 1 | The user is dragging the slider.| | Moving | 1 | The user is dragging the slider.|
| End | 2 | The user stops dragging the slider.| | End | 2 | The user stops dragging the slider by lifting their finger or releasing the mouse.|
| Click | 3 | The user moves the slider by touching the slider track.| | Click | 3 | The user moves the slider by touching the slider track.|
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
The **\<Text>** component is used to display a piece of textual information. The **\<Text>** component is used to display a piece of textual information.
> **NOTE**<br/> > **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.
...@@ -31,16 +31,18 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -31,16 +31,18 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name | Type | Description | | Name | Type | Description |
| ----------------------- | ----------------------------------- | ------------------------------------------- | | ----------------------- | ----------------------------------- | ------------------------------------------- |
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment mode of the text.<br>Default value: **TextAlign.Start**<br>**NOTE**<br>The text takes up the full width of the **\<Text>** component. To set the vertical alignment for the text, use the [align](ts-universal-attributes-location.md) attribute.<br>Since API version 9, this API is supported in ArkTS widgets.| | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment mode of the text.<br>Default value: **TextAlign.Start**<br>**NOTE**<br>The text takes up the full width of the **\<Text>** component. To set the vertical alignment for the text, use the [align](ts-universal-attributes-location.md) attribute.<br>Since API version 9, this API is supported in ArkTS widgets.|
| textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | Display mode when the text is too long.<br>Default value: **{overflow: TextOverflow.Clip}**<br>**NOTE**<br/>Text is clipped at the transition between words. To clip text in the middle of a word, add **\u200B** between characters.<br>This attribute must be used with `maxLines` to take effect.<br>Since API version 9, this API is supported in ArkTS widgets.| | textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | Display mode when the text is too long.<br>Default value: **{overflow: TextOverflow.Clip}**<br>**NOTE**<br/>Text is clipped at the transition between words. To clip text in the middle of a word, add **\u200B** between characters.<br>This attribute must be used with **maxLines** to take effect.<br>Since API version 9, this API is supported in ArkTS widgets. |
| maxLines | number | Maximum number of lines in the text.<br>Default value: **Infinity**<br>**NOTE**<br/>By default, text is automatically folded. If this attribute is specified, the text will not exceed the specified number of lines. If there is extra text, you can use **textOverflow** to specify how it is displayed.<br>Since API version 9, this API is supported in ArkTS widgets.| | maxLines | number | Maximum number of lines in the text.<br>Default value: **Infinity**<br>**NOTE**<br/>By default, text is automatically folded. If this attribute is specified, the text will not exceed the specified number of lines. If there is extra text, you can use **textOverflow** to specify how it is displayed.<br>Since API version 9, this API is supported in ArkTS widgets. |
| lineHeight | string \| number \| [Resource](ts-types.md#resource) | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.<br>Since API version 9, this API is supported in ArkTS widgets.| | lineHeight | string \| number \| [Resource](ts-types.md#resource) | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.<br>Since API version 9, this API is supported in ArkTS widgets.|
| decoration | {<br>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?: [ResourceColor](ts-types.md#resourcecolor)<br>} | Style and color of the text decorative line.<br>Default value: {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} <br>Since API version 9, this API is supported in ArkTS widgets.| | decoration | {<br>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?: [ResourceColor](ts-types.md#resourcecolor)<br>} | Style and color of the text decorative line.<br>Default value: {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} <br>Since API version 9, this API is supported in ArkTS widgets.|
| baselineOffset | number \| string | Baseline offset of the text. The default value is **0**.<br>Since API version 9, this API is supported in ArkTS widgets. | | baselineOffset | number \| string | Baseline offset of the text. The default value is **0**.<br>Since API version 9, this API is supported in ArkTS widgets. |
| letterSpacing | number \| string | Letter spacing.<br>Since API version 9, this API is supported in ArkTS widgets. | | letterSpacing | number \| string | Letter spacing.<br>Since API version 9, this API is supported in ArkTS widgets. |
| minFontSize | number \| string \| [Resource](ts-types.md#resource) | Minimum font size.<br>For the setting to take effect, this attribute must be used together with **maxFontSize**, **maxline**, or a layout size constraint.<br>Since API version 9, this API is supported in ArkTS widgets. | | minFontSize | number \| string \| [Resource](ts-types.md#resource) | Minimum font size.<br>For the setting to take effect, this attribute must be used together with **maxFontSize**, **maxLines**, or layout constraint settings.<br>Since API version 9, this API is supported in ArkTS widgets. |
| maxFontSize | number \| string \| [Resource](ts-types.md#resource) | Maximum font size.<br>For the setting to take effect, this attribute must be used together with **minFontSize**, **maxline**, or a layout size constraint.<br>Since API version 9, this API is supported in ArkTS widgets. | | maxFontSize | number \| string \| [Resource](ts-types.md#resource) | Maximum font size.<br>For the setting to take effect, this attribute must be used together with **minFontSize**, **maxLines**, or layout constraint settings.<br>Since API version 9, this API is supported in ArkTS widgets. |
| textCase | [TextCase](ts-appendix-enums.md#textcase) | Text case.<br>Default value: **TextCase.Normal**<br>Since API version 9, this API is supported in ArkTS widgets.| | textCase | [TextCase](ts-appendix-enums.md#textcase) | Text case.<br>Default value: **TextCase.Normal**<br>Since API version 9, this API is supported in ArkTS widgets.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>Default value: **CopyOptions.None**<br>This API is supported in ArkTS widgets.| | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>Default value: **CopyOptions.None**<br>This API is supported in ArkTS widgets.|
| textShadow<sup>10+</sup> | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions) | Text shadow.|
| heightAdaptivePolicy<sup>10+</sup> | [TextHeightAdaptivePolicy](ts-appendix-enums.md#TextHeightAdaptivePolicy10) | How the adaptive height is determined for the text.|
> **NOTE** > **NOTE**
> >
......
...@@ -38,6 +38,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -38,6 +38,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) => void<br>} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.| | inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) => void<br>} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.| | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.|
> **NOTE**
>
> The default value of the universal attribute [padding](ts-universal-attributes-size.md) is as follows: { top: 8 vp, right: 16 vp, bottom: 16 vp, left: 8 vp }
## Events ## Events
...@@ -72,6 +76,18 @@ Sets the position of the caret. ...@@ -72,6 +76,18 @@ Sets the position of the caret.
| ------ | -------- | ---- | -------------------------------------- | | ------ | -------- | ---- | -------------------------------------- |
| value | number | Yes | Length from the start of the string to the position where the caret is located.| | value | number | Yes | Length from the start of the string to the position where the caret is located.|
### setTextSelection<sup>10+</sup>
setTextSelection(selectionStart: number, selectionEnd: number): void
Sets the text selection range.
**Parameters**
| Name | Type| Mandatory| Description |
| -------------- | -------- | ---- | ------------------ |
| selectionStart | number | Yes | Start of the selection range.|
| selectionEnd | number | Yes | End of the selection range.|
## Example ## Example
......
...@@ -34,14 +34,21 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -34,14 +34,21 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| type | [InputType](#inputtype) | Input box type.<br>Default value: **InputType.Normal** | | type | [InputType](#inputtype) | Input box type.<br>Default value: **InputType.Normal** |
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color.| | placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color.|
| placeholderFont | [Font](ts-types.md#font) | Placeholder text font.| | placeholderFont | [Font](ts-types.md#font) | Placeholder text font.|
| enterKeyType | [EnterKeyType](#enterkeytype) | Type of the Enter key. Currently, only the default value is supported.<br>Default value: **EnterKeyType.Done**| | enterKeyType | [EnterKeyType](#enterkeytype) | Type of the Enter key. Only the default value is supported.<br>Default value: **EnterKeyType.Done**|
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. | | caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. |
| maxLength | number | Maximum number of characters in the text input. | | maxLength | number | Maximum number of characters in the text input. |
| inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) =&gt; void<br>} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.| | inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) =&gt; void<br>} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The regular expression can match single characters, but not strings.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.| | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.|
| showPasswordIcon<sup>9+</sup> | boolean | Whether to display the show password icon at the end of the password text box.<br>Default value: **true**| | showPasswordIcon<sup>9+</sup> | boolean | Whether to display the show password icon at the end of the password text box.<br>Default value: **true**|
| style<sup>9+</sup> | [TextInputStyle](#textinputstyle9) | Text input style.<br>Default value: **TextInputStyle.Default**| | style<sup>9+</sup> | [TextInputStyle](#textinputstyle9) | Text input style.<br>Default value: **TextInputStyle.Default**|
| textAlign<sup>9+</sup> | [TextAlign](ts-appendix-enums.md#textalign) | Alignment mode of the text in the text box.<br>Default value: **TextAlign.Start** | | textAlign<sup>9+</sup> | [TextAlign](ts-appendix-enums.md#textalign) | Alignment mode of the text in the text box.<br>Default value: **TextAlign.Start** |
| selectedBackgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected text.|
| caretStyle<sup>10+</sup> | {<br>caretWidth: [Length](ts-types.md#length)<br>} | Caret style. |
| caretPosition<sup>10+</sup> | number | Caret position.|
> **NOTE**
>
> The default value of the universal attribute [padding](ts-universal-attributes-size.md) is as follows: <br>{<br> top: 8 vp,<br> right: 16 vp,<br> bottom: 16 vp,<br> left: 8 vp<br> }
## EnterKeyType ## EnterKeyType
...@@ -103,7 +110,18 @@ Sets the position of the caret. ...@@ -103,7 +110,18 @@ Sets the position of the caret.
| Name| Type| Mandatory| Description | | Name| Type| Mandatory| Description |
| ------ | -------- | ---- | -------------------------------------- | | ------ | -------- | ---- | -------------------------------------- |
| value | number | Yes | Length from the start of the string to the position where the caret is located.| | value | number | Yes | Length from the start of the string to the position where the caret is located.|
### setTextSelection<sup>10+</sup>
setTextSelection(selectionStart: number, selectionStart: number): void
Sets the text selection area, which will be highlighted.
**Parameters**
| Name | Type| Mandatory| Description |
| -------------- | -------- | ---- | ---------------------- |
| selectionStart | number | Yes | Start position of the text selection area. The start position of the text in the text box is 0.|
| selectionEnd | number | Yes | End position of the text selection area.|
## Example ## Example
......
...@@ -35,9 +35,9 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -35,9 +35,9 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Description | | Name | Description |
| -------- | ---------------- | | -------- | ---------------- |
| Checkbox | Check box type.<br>**NOTE**<br>The default value of the universal attribute [padding](ts-universal-attributes-size.md) is as follows:<br>{<br> top: 14 vp,<br> right: 6 vp,<br> bottom: 14 vp,<br> left: 6 vp<br> } | | Checkbox | Check box type.<br>**NOTE**<br>The default value of the universal attribute [margin](ts-universal-attributes-size.md) is as follows:<br>{<br> top: 12 vp,<br> right: 12 vp,<br> bottom: 12 vp,<br> left: 12 vp<br> } |
| Button | Button type. The set string, if any, will be displayed inside the button. | | Button | Button type. The set string, if any, will be displayed inside the button. |
| Switch | Switch type.<br>**NOTE**<br>The default value of the universal attribute [padding](ts-universal-attributes-size.md) is as follows:<br>{<br> top: 12 vp,<br> right: 12 vp,<br> bottom: 12 vp,<br> left: 12 vp<br> } | | Switch | Switch type.<br>**NOTE**<br>The default value of the universal attribute [margin](ts-universal-attributes-size.md) is as follows:<br>{<br> top: 14 vp,<br> right:6 vp,<br> bottom: 6 vp,<br> left: 14 vp<br> } |
## Attributes ## Attributes
......
...@@ -5,7 +5,8 @@ The **\<Flex>** component allows for flexible layout of child components. ...@@ -5,7 +5,8 @@ The **\<Flex>** component allows for flexible layout of child components.
> **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.
> - The **\<Flex>** component adapts the layout of flex items during rendering. This may affect the performance. Therefore, you are advised to use **[\<Column>](ts-container-column.md)** or **[\<Row>](ts-container-row.md)** instead under scenarios where consistently high performance is required. > - The **\<Flex>** component adapts the layout of flex items during rendering. This may affect the performance. Therefore, you are advised to use **[Column](ts-container-column.md)** or **[Row](ts-container-row.md)** instead under scenarios where consistently high performance is required.
> - If the main axis of the **\<Flex>** component is not set, it follows the size of the parent container. On the contrary, if the main axis of the [\<Column>](ts-container-column.md) or [\<Row>](ts-container-row.md) component is not set, it follows the size of their child component.
## Child Components ## Child Components
......
...@@ -76,7 +76,7 @@ This API is supported in ArkTS widgets. ...@@ -76,7 +76,7 @@ This API is supported in ArkTS widgets.
| onScrollIndex(event: (start: number, end: number) => void) | Triggered when scrolling starts.<br>When calculating the index value, the **\<ListItemGroup>** accounts for one index value as a whole, and the index values of the list items within are not calculated.<br>- **start**: index of the scroll start position.<br>- **end**: index of the scroll end position.<br>Since API version 9, this API is supported in ArkTS widgets.| | onScrollIndex(event: (start: number, end: number) => void) | Triggered when scrolling starts.<br>When calculating the index value, the **\<ListItemGroup>** accounts for one index value as a whole, and the index values of the list items within are not calculated.<br>- **start**: index of the scroll start position.<br>- **end**: index of the scroll end position.<br>Since API version 9, this API is supported in ArkTS widgets.|
| onReachStart(event: () => void) | Triggered when the list reaches the start position.<br>Since API version 9, this API is supported in ArkTS widgets.| | onReachStart(event: () => void) | Triggered when the list reaches the start position.<br>Since API version 9, this API is supported in ArkTS widgets.|
| onReachEnd(event: () => void) | Triggered when the list reaches the end position.<br>Since API version 9, this API is supported in ArkTS widgets.| | onReachEnd(event: () => void) | Triggered when the list reaches the end position.<br>Since API version 9, this API is supported in ArkTS widgets.|
| onScrollFrameBegin<sup>9+</sup>(event: (offset: number, state: ScrollState) => { offsetRemain }) | Triggered when the list starts to scroll. The input parameters indicate the amount by which the list will scroll. The event handler then works out the amount by which the list needs to scroll based on the real-world situation and returns the result.<br>\- **offset**: amount to scroll by.<br>\- **state**: current sliding status.<br>- **offsetRemain**: actual amount by which the list scrolls.<br>This API is supported in ArkTS widgets.| | onScrollFrameBegin<sup>9+</sup>(event: (offset: number, state: ScrollState) => { offsetRemain }) | Triggered when the list starts to scroll. The input parameters indicate the amount by which the list will scroll. The event handler then works out the amount by which the list needs to scroll based on the real-world situation and returns the result.<br>\- **offset**: amount to scroll by.<br>\- **state**: current sliding status.<br>- **offsetRemain**: actual amount by which the list scrolls.<br>This API is supported in ArkTS widgets.<br>**NOTE**<br>If **listDirection** is set to **Axis.Vertical**, the return value is the amount by which the list needs to scroll in the vertical direction. If **listDirection** is set to **Axis.Horizontal**, the return value is the amount by which the list needs to scroll in the horizontal direction.|
| onScrollStart<sup>9+</sup>(event: () => void) | Triggered when the list starts scrolling initiated by the user's finger dragging the **\<Scroll>** component or its scrollbar. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) starts.<br>This API is supported in ArkTS widgets.| | onScrollStart<sup>9+</sup>(event: () => void) | Triggered when the list starts scrolling initiated by the user's finger dragging the **\<Scroll>** component or its scrollbar. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) starts.<br>This API is supported in ArkTS widgets.|
| onScrollStop(event: () => void) | Triggered when the list stops scrolling after the user's finger leaves the screen. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) stops.<br>Since API version 9, this API is supported in ArkTS widgets.| | onScrollStop(event: () => void) | Triggered when the list stops scrolling after the user's finger leaves the screen. This event is also triggered when the animation contained in the scrolling triggered by [Scroller](ts-container-scroll.md#scroller) stops.<br>Since API version 9, this API is supported in ArkTS widgets.|
| onItemMove(event: (from: number, to: number) => boolean) | Triggered when a list item moves.<br>- **from**: index of the item before moving.<br>- **to**: index of the item after moving.| | onItemMove(event: (from: number, to: number) => boolean) | Triggered when a list item moves.<br>- **from**: index of the item before moving.<br>- **to**: index of the item after moving.|
......
...@@ -42,7 +42,7 @@ struct AnimateToExample { ...@@ -42,7 +42,7 @@ struct AnimateToExample {
build() { build() {
Column() { Column() {
Button('change width and height') Button('change size')
.width(this.widthSize) .width(this.widthSize)
.height(this.heightSize) .height(this.heightSize)
.margin(30) .margin(30)
...@@ -57,8 +57,8 @@ struct AnimateToExample { ...@@ -57,8 +57,8 @@ struct AnimateToExample {
console.info('play end') console.info('play end')
} }
}, () => { }, () => {
this.widthSize = 100 this.widthSize = 150
this.heightSize = 50 this.heightSize = 60
}) })
} else { } else {
animateTo({}, () => { animateTo({}, () => {
...@@ -77,7 +77,7 @@ struct AnimateToExample { ...@@ -77,7 +77,7 @@ struct AnimateToExample {
curve: Curve.Friction, curve: Curve.Friction,
delay: 500, delay: 500,
iterations: -1, // The value -1 indicates that the animation is played for an unlimited number of times. iterations: -1, // The value -1 indicates that the animation is played for an unlimited number of times.
playMode: PlayMode.AlternateReverse, playMode: PlayMode.Alternate,
onFinish: () => { onFinish: () => {
console.info('play end') console.info('play end')
} }
...@@ -90,10 +90,4 @@ struct AnimateToExample { ...@@ -90,10 +90,4 @@ struct AnimateToExample {
} }
``` ```
The figure below shows two buttons in their initial state. ![animation1](figures/animation1.gif)
![animation](figures/animation.PNG)
Clicking the first button plays the animation of resizing the button, and clicking the second button plays the animation of rotating the button clockwise by 90 degrees. The figure below shows the two buttons when the animations have finished.
![animation1](figures/animation1.PNG)
...@@ -118,9 +118,9 @@ Requests full-screen mode. ...@@ -118,9 +118,9 @@ Requests full-screen mode.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description |
| ----- | ------- | ---- | --------------------- | | ------ | -------- | ---- | -------------------------------------------------- |
| value | boolean | Yes | Whether the playback is in full-screen mode.<br>Default value: **false**| | value | boolean | Yes | Whether to play the video in full screen mode within the application window.<br>Default value: **false**|
### exitFullscreen ### exitFullscreen
...@@ -173,7 +173,7 @@ struct VideoCreateComponent { ...@@ -173,7 +173,7 @@ struct VideoCreateComponent {
previewUri: this.previewUri, previewUri: this.previewUri,
currentProgressRate: this.curRate, currentProgressRate: this.curRate,
controller: this.controller controller: this.controller
}).width(800).height(600) }).width('100%').height(600)
.autoPlay(this.isAutoPlay) .autoPlay(this.isAutoPlay)
.controls(this.showControls) .controls(this.showControls)
.onStart(() => { .onStart(() => {
...@@ -186,7 +186,7 @@ struct VideoCreateComponent { ...@@ -186,7 +186,7 @@ struct VideoCreateComponent {
console.info('onFinish') console.info('onFinish')
}) })
.onError(() => { .onError(() => {
console.info('onFinish') console.info('onError')
}) })
.onPrepared((e) => { .onPrepared((e) => {
console.info('onPrepared is ' + e.duration) console.info('onPrepared is ' + e.duration)
......
...@@ -11,7 +11,7 @@ You can set the text content and response callback for an alert dialog box. ...@@ -11,7 +11,7 @@ You can set the text content and response callback for an alert dialog box.
| Name | Type | Description| | Name | Type | Description|
| ---- | --------------- | -------- | | ---- | --------------- | -------- |
| show | [AlertDialogParamWithConfirm](#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](#alertdialogparamwithbuttons) | Defines and displays the **<AlertDialog>** component.| | show | [AlertDialogParamWithConfirm](#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](#alertdialogparamwithbuttons) | Defines and displays the **\<AlertDialog>** component. |
## AlertDialogParamWithConfirm ## AlertDialogParamWithConfirm
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
......
...@@ -11,7 +11,7 @@ The motion path animation is used to animate a component along a custom path. ...@@ -11,7 +11,7 @@ The motion path animation is used to animate a component along a custom path.
| Name| Type| Default Value| Description| | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| motionPath | {<br>path: string,<br>from?: number,<br>to?: number,<br>rotatable?: boolean<br>}<br>**NOTE**<br>In a path, **start** and **end** can be used to replace the start point and end point. Example:<br>'Mstart.x start.y L50 50 Lend.x end.y Z'<br>For more information, see [Path Drawing](../../ui/ui-js-components-svg-path.md).| {<br>'',<br>0.0,<br>1.0,<br>false<br>} | Motion path of the component.<br>- **path**: motion path of the translation animation. The value is an SVG path string.<br>- **from**: start point of the motion path. The default value is **0.0**.<br>- **to**: end point of the motion path. The default value is **1.0**.<br>- **rotatable**: whether to rotate along the path. | | motionPath | {<br>path: string,<br>from?: number,<br>to?: number,<br>rotatable?: boolean<br>}<br>**NOTE**<br>In a path, **start** and **end** can be used to replace the start point and end point. Example:<br>'Mstart.x start.y L50 50 Lend.x end.y Z'<br>For more information, see [Path Drawing](../../ui/ui-js-components-svg-path.md).| {<br>'',<br>0.0,<br>1.0,<br>false<br>} | Motion path of the component.<br>- **path**: motion path of the translation animation. The value is an SVG path string.<br>- **from**: start point of the motion path. The default value is **0.0**.<br>- **to**: end point of the motion path. The default value is **1.0**.<br>- **rotatable**: whether to rotate along the path.|
## Example ## Example
...@@ -25,7 +25,7 @@ struct MotionPathExample { ...@@ -25,7 +25,7 @@ struct MotionPathExample {
build() { build() {
Column() { Column() {
Button('click me') Button('click me').margin(50)
// Execute the animation: Move from the start point to (300,200), then to (300,500), and finally to the end point. // Execute the animation: Move from the start point to (300,200), then to (300,500), and finally to the end point.
.motionPath({ path: 'Mstart.x start.y L300 200 L300 500 Lend.x end.y', from: 0.0, to: 1.0, rotatable: true }) .motionPath({ path: 'Mstart.x start.y L300 200 L300 500 Lend.x end.y', from: 0.0, to: 1.0, rotatable: true })
.onClick(() => { .onClick(() => {
...@@ -38,4 +38,4 @@ struct MotionPathExample { ...@@ -38,4 +38,4 @@ struct MotionPathExample {
} }
``` ```
![en-us_image_0000001212378420](figures/en-us_image_0000001212378420.gif) ![en-us_image_0000001174104400](figures/en-us_image_0000001174104400.gif)
...@@ -124,8 +124,8 @@ The **ResourceColor** type is used to describe the color types of resources. ...@@ -124,8 +124,8 @@ The **ResourceColor** type is used to describe the color types of resources.
| Type | Description | | Type | Description |
| ---------------------------------------- | ------------------------------------------------- | | ---------------------------------------- | ------------------------------------------------- |
| [Color](ts-appendix-enums.md#color) | Color enums. | | [Color](ts-appendix-enums.md#color) | Color enums. |
| number | Color in hexadecimal notation. | | number | Color in hexadecimal notation. RGB is supported. |
| string | Color in RGB or RGBA notation. | | string | Color in RGB or ARGB notation. |
| [Resource](#resource) | Color referenced from system or application resources.| | [Resource](#resource) | Color referenced from system or application resources.|
## ColoringStrategy ## ColoringStrategy
...@@ -134,7 +134,7 @@ The **ColoringStrategy** type is used to describe the foreground colors. ...@@ -134,7 +134,7 @@ The **ColoringStrategy** type is used to describe the foreground colors.
| Name | Description | | Name | Description |
| --------- | ------- | | --------- | ------- |
| Invert | Inverse of the component background color.| | INVERT | Inverse of the component background color.|
## LengthConstrain ## LengthConstrain
...@@ -225,3 +225,14 @@ The **CustomBuilder** type is used to define custom UI descriptions in component ...@@ -225,3 +225,14 @@ The **CustomBuilder** type is used to define custom UI descriptions in component
| Name | Type | Description | | Name | Type | Description |
| ------------- | ---------------------- | ---------------------------------------- | | ------------- | ---------------------- | ---------------------------------------- |
| CustomBuilder | () =&gt; any | Must be decorated by **@Builder**. For details, see [@Builder](../../quick-start/arkts-dynamic-ui-elememt-building.md#builder).| | CustomBuilder | () =&gt; any | Must be decorated by **@Builder**. For details, see [@Builder](../../quick-start/arkts-dynamic-ui-elememt-building.md#builder).|
## PixelStretchEffectOptions<sup>10+</sup>
Describes the pixel stretch effect options.
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ---------- |
| left | [Length](#length) | No | Length by which a pixel is stretched towards the left edge of the image.|
| right | [Length](#length) | No | Length by which a pixel is stretched towards the right edge of the image.|
| top | [Length](#length) | No | Length by which a pixel is stretched towards the top edge of the image.|
| bottom | [Length](#length) | No | Length by which a pixel is stretched towards the bottom edge of the image.|
...@@ -11,8 +11,8 @@ You can set the background of a component. ...@@ -11,8 +11,8 @@ You can set the background of a component.
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the component.<br>Since API version 9, this API is supported in ArkTS widgets.| | backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the component.<br>Since API version 9, this API is supported in ArkTS widgets.|
| backgroundImage | src: [ResourceStr](ts-types.md#resourcestr),<br>repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | **src**: image address, which can be the address of an Internet or a local image. (SVG images are not supported.)<br>**repeat**: whether the background image is repeatedly used. By default, the background image is not repeatedly used.<br>Since API version 9, this API is supported in ArkTS widgets.| | backgroundImage | src: [ResourceStr](ts-types.md#resourcestr),<br>repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | **src**: image address, which can be the address of an Internet or a local image or a Base64 encoded image. SVG images are not supported.<br>**repeat**: whether the background image is repeatedly used. By default, the background image is not repeatedly used. If the set image has a transparent background and **backgroundColor** is set, the image is overlaid on the background color.<br>Since API version 9, this API is supported in ArkTS widgets.|
| backgroundImageSize | {<br>width?: [Length](ts-types.md#length),<br>height?: [Length](ts-types.md#length)<br>} \| [ImageSize](ts-appendix-enums.md#imagesize) | Width and height of the background image. If the input is a **{width: Length, height: Length}** object and only one attribute is set, the other attribute is the set value multiplied by the original aspect ratio of the image. By default, the original image aspect ratio remains unchanged.<br>Default value: **ImageSize.Auto**<br>Since API version 9, this API is supported in ArkTS widgets.| | backgroundImageSize | {<br>width?: [Length](ts-types.md#length),<br>height?: [Length](ts-types.md#length)<br>} \| [ImageSize](ts-appendix-enums.md#imagesize) | Width and height of the background image. If the input is a **{width: Length, height: Length}** object and only one attribute is set, the other attribute is the set value multiplied by the original aspect ratio of the image. By default, the original image aspect ratio remains unchanged.<br>The value range of **width** and **height** is [0, +∞).<br>Default value: **ImageSize.Auto**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. If **height** is set but **width** is not, the image width is adjusted based on the original aspect ratio of the image.|
| backgroundImagePosition | [Position](ts-types.md#position8) \| [Alignment](ts-appendix-enums.md#alignment) | Position of the background image in the component, that is, the coordinates relative to the upper left corner of the component.<br>Default value:<br>{<br>x: 0,<br>y: 0<br>} <br> When **x** and **y** are set in percentage, the offset is calculated based on the width and height of the component.<br>Since API version 9, this API is supported in ArkTS widgets.| | backgroundImagePosition | [Position](ts-types.md#position8) \| [Alignment](ts-appendix-enums.md#alignment) | Position of the background image in the component, that is, the coordinates relative to the upper left corner of the component.<br>Default value:<br>{<br>x: 0,<br>y: 0<br>} <br> When **x** and **y** are set in percentage, the offset is calculated based on the width and height of the component.<br>Since API version 9, this API is supported in ArkTS widgets.|
## Example ## Example
......
...@@ -10,19 +10,16 @@ You can apply background blur effects to a component. ...@@ -10,19 +10,16 @@ You can apply background blur effects to a component.
## Attributes ## Attributes
| Name | Type | Description | | Name | Parameter | Description |
| -------------------- | ----------------------- | ------------------------ | | -------------------- | ----------------------- | ------------------------ |
| backgroundBlurStyle | [BlurStyle](#blurstyle) | Style of the blur between the background and content for the current component. The input parameter indicates a blur material.<br>This API is supported in ArkTS widgets.| | backgroundBlurStyle | value:[BlurStyle](ts-appendix-enums.md#blurstyle9),<br>options<sup>10+</sup>?:[BackgroundBlurStyleOptions](#backgroundblurstyleoptions10) | Background blur style applied between the content and the background.<br>**value**: settings of the background blur style, including the blur radius, mask color, mask opacity, and saturation.<br>**options**: background blur options. This parameter is optional.<br>This API is supported in ArkTS widgets.|
## BackgroundBlurStyleOptions<sup>10+</sup>
## BlurStyle | Name| Type| Mandatory| Description|
| ----------- | ------| ------ | ------ |
This API is supported in ArkTS widgets. | colorMode<sup>10+</sup> | [ThemeColorMode](ts-appendix-enums.md#themecolormode10) | No| Color mode used for the background blur.<br>Default value: **ThemeColorMode.System**|
| adaptiveColor<sup>10+</sup> | [AdaptiveColor](ts-appendix-enums.md#adaptivecolor10) | No| Adaptive color mode.<br>Default value: **AdaptiveColor.Default**|
| Name | Description |
| ------- | ---------- |
| Thin | Thin material. |
| Regular | Regular material. |
| Thick | Thick material. |
## Example ## Example
...@@ -30,16 +27,16 @@ This API is supported in ArkTS widgets. ...@@ -30,16 +27,16 @@ This API is supported in ArkTS widgets.
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct Index { struct BackgroundBlurStyleDemo {
build() { build() {
Column() { Column() {
Row() { Row() {
Text("Thin Material") Text("Thin Material")
} }
.width(350) .width('50%')
.height(300) .height('50%')
.backgroundBlurStyle(BlurStyle.Thin) .backgroundBlurStyle(BlurStyle.Thin, { colorMode: ThemeColorMode.Light, adaptiveColor: AdaptiveColor.Default })
.position({ x: "15%", y: "30%" }) .position({ x: '15%', y: '30%' })
} }
.height('100%') .height('100%')
.width('100%') .width('100%')
......
...@@ -12,9 +12,9 @@ Create a more gorgeous look for a component by applying a gradient color effect ...@@ -12,9 +12,9 @@ Create a more gorgeous look for a component by applying a gradient color effect
| Name | Type | Description | | Name | Type | Description |
| -------------- | -------------------------------------------- | ----------------------------------- | | -------------- | -------------------------------------------- | ----------------------------------- |
| linearGradient | {<br>angle?: number \| string,<br>direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),<br>colors: Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br>repeating?: boolean<br>} | Linear gradient.<br>- **angle**: start angle of the linear gradient. A positive value indicates a clockwise rotation from the origin, (0, 0).<br> Default value: **180**<br>- **direction**: direction of the linear gradient. It does not take effect when **angle** is set.<br> Default value: **GradientDirection.Bottom**<br>- **colors**: colors of the linear gradient.<br>- **repeating**: whether the colors are repeated.<br> Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | linearGradient | {<br>angle?: number \| string,<br>direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),<br>colors: Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br>repeating?: boolean<br>} | Linear gradient.<br>- **angle**: start angle of the linear gradient. A positive value indicates a clockwise rotation from the origin, (0, 0).<br> Default value: **180**<br>- **direction**: direction of the linear gradient. It does not take effect when **angle** is set.<br> Default value: **GradientDirection.Bottom**<br>- **colors**: colors of the linear gradient.<br>- **repeating**: whether the colors are repeated.<br> Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.|
| sweepGradient | {<br>center: Point,<br>start?: number \| string,<br>end?: number \| string,<br>rotation?: number\|string,<br>colors: Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br>repeating?: boolean<br>} | Sweep gradient, which can sweep around the specified center point in the 0–360 degree range. If the rotation angle exceeds the range, a monochrome color instead of a gradient will be drawn.<br>- **center**: center point of the sweep gradient, that is, the coordinates relative to the upper left corner of the current component.<br>- **start**: start point of the sweep gradient.<br> Default value: **0**<br>- **end**: end point of the sweep gradient.<br> Default value: **0**<br>- **rotation**: rotation angle of the sweep gradient.<br> Default value: **0**<br>- **colors**: colors of the sweep gradient.<br>- **repeating**: whether the colors are repeated.<br> Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | sweepGradient | {<br>center: Point,<br>start?: number \| string,<br>end?: number \| string,<br>rotation?: number\|string,<br>colors: Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br>repeating?: boolean<br>} | Sweep gradient, which can sweep around the specified center point in the 0–360 degree range. If the rotation angle exceeds the range, a monochrome color instead of a gradient will be drawn.<br>- **center**: center point of the sweep gradient, that is, the coordinates relative to the upper left corner of the current component.<br>- **start**: start point of the sweep gradient.<br> Default value: **0**<br>- **end**: end point of the sweep gradient.<br> Default value: **0**<br>- **rotation**: rotation angle of the sweep gradient.<br> Default value: **0**<br>- **colors**: colors of the sweep gradient.<br>- **repeating**: whether the colors are repeated.<br> Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. A value greater than 360 evaluates to the value **1**.<br>When the data type of **start**, **end**, and **rotation** is string, the value **"90"** or **"90%"** is equivalent to **90**. |
| radialGradient | {<br>center: Point,<br> radius: number \| string,<br>colors: Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br>repeating?: boolean<br>} | Radial gradient.<br>- **center**: center point of the radial gradient, that is, the coordinates relative to the upper left corner of the current component.<br>- **radius**: radius of the radial gradient.<br>- **colors**: colors of the radial gradient.<br>- **repeating**: whether the colors are repeated.<br> Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | radialGradient | {<br>center: Point,<br> radius: number \| string,<br>colors: Array&lt;[ColorStop](ts-basic-components-gauge.md#colorstop)&gt;,<br>repeating?: boolean<br>} | Radial gradient.<br>- **center**: center point of the radial gradient, that is, the coordinates relative to the upper left corner of the current component.<br>- **radius**: radius of the radial gradient.<br> Value range: [0, +∞)<br> **NOTE**<br>A value less than 0 evaluates to the value **0**.<br>- **colors**: colors of the radial gradient.<br>- **repeating**: whether the colors are repeated.<br> Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets. |
## Example ## Example
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
| Name | Type | Description | | Name | Type | Description |
| ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | | ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| useSizeType | {<br>xs?: number \| { span: number, offset: number },<br>sm?: number \| { span: number, offset: number },<br>md?: number \| { span: number, offset: number },<br>lg?: number \| { span: number, offset: number }<br>} | Number of occupied columns and offset columns for a specific device width type. **span** indicates the number of occupied columns, and **offset** indicates the number of offset columns.<br>If the value is of the number type, only the number of columns can be set. If the value is in the format of {"span": 1, "offset": 0}, both the number of occupied columns and the number of offset columns need to be set.<br>- **xs** indicates that the device width type is **SizeType.XS**.<br>- **sm** indicates that the device width type is **SizeType.SM**.<br>- **md** indicates that the device width type is **SizeType.MD**.<br>- **lg** indicates that the device width type is **SizeType.LG**.| | useSizeType<sup>(deprecated)</sup> | {<br>xs?: number \| { span: number, offset: number },<br>sm?: number \| { span: number, offset: number },<br>md?: number \| { span: number, offset: number },<br>lg?: number \| { span: number, offset: number }<br>} | Number of occupied columns and offset columns for a specific device width type. **span** indicates the number of occupied columns, and **offset** indicates the number of offset columns.<br>If the value is of the number type, only the number of columns can be set. If the value is in the format of {"span": 1, "offset": 0}, both the number of occupied columns and the number of offset columns need to be set.<br>- **xs** indicates that the device width type is **SizeType.XS**.<br>- **sm** indicates that the device width type is **SizeType.SM**.<br>- **md** indicates that the device width type is **SizeType.MD**.<br>- **lg** indicates that the device width type is **SizeType.LG**.<br>This attribute is deprecated since API version 9. You are advised to use [GridCol](ts-container-gridcol.md) and [GridRow](ts-container-gridrow.md) instead. |
| gridSpan | number | Default number of occupied columns, that is, the number of occupied columns when **span** in **useSizeType** is not set.<br>**NOTE**<br>If the **span** attribute is set, the component width is determined by the grid layout.<br>Default value: **1**| | gridSpan | number | Default number of occupied columns, that is, the number of occupied columns when **span** in **useSizeType** is not set.<br>**NOTE**<br>If the **span** attribute is set, the component width is determined by the grid layout.<br>Default value: **1**|
| gridOffset | number | Default number of offset columns, that is, the number of offset columns in the start direction of the parent component (which is also the nth column that the component is in) when **offset** in **useSizeType** is not set.<br>**NOTE**<br>- After this attribute is set, the horizontal layout of the current component does not follow the original layout of the parent component. Instead, it offsets along the start direction of the parent component.<br>- Offset = (Column width + Gap) \* Number of columns.<br>- After this attribute is set, sibling components will be arranged relatively to this component, as in the relative layout.<br>Default value: **0**| | gridOffset | number | Default number of offset columns, that is, the number of offset columns in the start direction of the parent component (which is also the nth column that the component is in) when **offset** in **useSizeType** is not set.<br>**NOTE**<br>- After this attribute is set, the horizontal layout of the current component does not follow the original layout of the parent component. Instead, it offsets along the start direction of the parent component.<br>- Offset = (Column width + Gap) \* Number of columns.<br>- After this attribute is set, sibling components will be arranged relatively to this component, as in the relative layout.<br>Default value: **0**|
......
...@@ -12,16 +12,16 @@ Image effects include blur, shadow, and much more. ...@@ -12,16 +12,16 @@ Image effects include blur, shadow, and much more.
| Name | Type | Default Value| Description | | Name | Type | Default Value| Description |
| ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ | | ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ |
| blur | number | - | Applies the content blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the content is. If the value is **0**, the content is not blurred.<br>Since API version 9, this API is supported in ArkTS widgets.| | blur | number | - | Applies the content blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the content is. If the value is **0**, the content is not blurred.<br>Value range: [0, +∞)<br>Since API version 9, this API is supported in ArkTS widgets.|
| backdropBlur | number | - | Applies the background blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the background is. If the value is **0**, the background is not blurred.<br>Since API version 9, this API is supported in ArkTS widgets.| | backdropBlur | number | - | Applies the background blur effect to the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the background is. If the value is **0**, the background is not blurred.<br>Value range: [0, +∞)<br>Since API version 9, this API is supported in ArkTS widgets.|
| shadow | [ShadowOptions](#shadowoptions) \| [ShadowStyle](#shadowstyle10) | - | Applies a shadow effect to the current component.<br>When the value type is **ShadowOptions**, the blur radius, shadow color, and offset along the x-axis and y-axis can be specified.<br>When the value type is **ShadowStyle**, the shadow style can be specified.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>ArkTS widgets do not support the [ShadowStyle](#shadowstyle10) value type. | | shadow | [ShadowOptions](#shadowoptions) \| [ShadowStyle](#shadowstyle10) | - | Applies a shadow effect to the current component.<br>When the value type is **ShadowOptions**, the blur radius, shadow color, and offset along the x-axis and y-axis can be specified.<br>When the value type is **ShadowStyle**, the shadow style can be specified.<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>ArkTS widgets do not support the [ShadowStyle](#shadowstyle10) value type.|
| grayscale | number | 0.0 | Converts the input image to grayscale. The value indicates the grayscale conversion ratio. If the input value is **1.0**, the image is converted into a grayscale image. If the input value is **0.0**, the image does not change. If the input value is between **0.0** and **1.0**, the effect changes in linear mode. The unit is percentage.<br>Since API version 9, this API is supported in ArkTS widgets.| | grayscale | number | 0.0 | Converts the input image to grayscale. The value indicates the grayscale conversion ratio. If the input value is **1.0**, the image is converted into a grayscale image. If the input value is **0.0**, the image does not change. If the input value is between **0.0** and **1.0**, the effect changes in linear mode. The unit is percentage.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.<br>Since API version 9, this API is supported in ArkTS widgets.|
| brightness | number | 1.0 | Applies a brightness to the current component. The input parameter is a brightness ratio. The value **1** indicates no effects. The value **0** indicates the complete darkness. If the value is less than **1**, the brightness decreases. If the value is greater than **1**, the brightness increases. A larger value indicates a higher brightness.<br>Since API version 9, this API is supported in ArkTS widgets.| | brightness | number | 1.0 | Applies a brightness to the current component. The input parameter is a brightness ratio. The value **1** indicates no effects. The value **0** indicates the complete darkness. If the value is less than **1**, the brightness decreases. If the value is greater than **1**, the brightness increases. A larger value indicates a higher brightness.<br>Value range: [0, +∞)<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.|
| saturate | number | 1.0 | Applies the saturation effect to the current component. The saturation is the ratio of the chromatic component to the achromatic component (gray) in a color. When the input value is **1**, the source image is displayed. When the input value is greater than **1**, a higher percentage of the chromatic component indicates a higher saturation. When the input value is less than **1**, a higher percentage of the achromatic component indicates a lower saturation. The unit is percentage.<br>Since API version 9, this API is supported in ArkTS widgets.| | saturate | number | 1.0 | Applies the saturation effect to the current component. The saturation is the ratio of the chromatic component to the achromatic component (gray) in a color. When the input value is **1**, the source image is displayed. When the input value is greater than **1**, a higher percentage of the chromatic component indicates a higher saturation. When the input value is less than **1**, a higher percentage of the achromatic component indicates a lower saturation. The unit is percentage.<br>Value range: [0, +∞)<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.|
| contrast | number | 1.0 | Applies the contrast effect to the current component. The input parameter is a contrast value. If the value is **1**, the source image is displayed. If the value is greater than **1**, a larger value indicates a higher contrast and a clearer image. If the value is less than **1**, a smaller value indicates a lower contrast is. If the value is **0**, the image becomes all gray. The unit is percentage.<br>Since API version 9, this API is supported in ArkTS widgets.| | contrast | number | 1.0 | Applies the contrast effect to the current component. The input parameter is a contrast value. If the value is **1**, the source image is displayed. If the value is greater than 1, a larger value indicates a higher contrast and a clearer image. If the value is less than 1, a smaller value indicates a lower contrast is. If the value is **0**, the image becomes all gray. The unit is percentage.<br>Value range: [0, +∞)<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 | Inverts the input image. The input parameter is an image inversion ratio. The value **1** indicates complete inversion. The value **0** indicates that the image does not change. The unit is percentage.<br>Since API version 9, this API is supported in ArkTS widgets.| | invert | number | 0 | Inverts the input image. The input parameter is an image inversion ratio. The value **1** indicates complete inversion, and **0** indicates that the image does not change. 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 | Converts the image color to sepia. The input parameter is an image inversion ratio. The value **1** indicates the image is completely sepia. The value **0** indicates that the image does not change. The unit is percentage.<br>Since API version 9, this API is supported in ArkTS widgets.| | sepia | number | 0 | Converts the image color to sepia. The input parameter is an image conversion ratio. The value **1** indicates the image is completely sepia, and **0** indicates that the image does not change. The unit is percentage.<br>Since API version 9, this API is supported in ArkTS widgets.|
| hueRotate | number \| string | '0deg' | Applies the hue rotation effect to the current component. The input parameter is a rotation angle.<br>Since API version 9, this API is supported in ArkTS widgets.| | hueRotate | number \| string | '0deg' | Applies the hue rotation effect to the current component. The input parameter is a rotation angle.<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) | - | Applies the color blend effect to the current component. The input parameter is the blended color.<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) | - | Applies the color blend effect to the current component. The input parameter is the blended color.<br>Since API version 9, this API is supported in ArkTS widgets.|
## ShadowOptions ## ShadowOptions
...@@ -32,8 +32,8 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -32,8 +32,8 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------------- | | ------ | ------ | ---- | --------------- |
| radius | number \| [Resource](ts-types.md#resource) | Yes | Blur radius of the shadow. | | radius | number \| [Resource](ts-types.md#resource) | Yes | Blur radius of the shadow.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.|
| color | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | No | Color of the shadow.<br>The default value is gray.| | color | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | No | Color of the shadow.<br>The default color is black.|
| offsetX | number \| [Resource](ts-types.md#resource) | No | Offset of the shadow along the x-axis.<br>The default value is **0**. | | offsetX | number \| [Resource](ts-types.md#resource) | No | Offset of the shadow along the x-axis.<br>The default value is **0**. |
| offsetY | number \| [Resource](ts-types.md#resource) | No | Offset of the shadow along the y-axis.<br>The default value is **0**.| | offsetY | number \| [Resource](ts-types.md#resource) | No | Offset of the shadow along the y-axis.<br>The default value is **0**.|
......
...@@ -32,19 +32,15 @@ struct PositionExample1 { ...@@ -32,19 +32,15 @@ struct PositionExample1 {
Column({ space: 10 }) { Column({ space: 10 }) {
// When the component content is within the area specified by the component width and height, set the alignment mode of the content in the component. // When the component content is within the area specified by the component width and height, set the alignment mode of the content in the component.
Text('align').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('align').fontSize(9).fontColor(0xCCCCCC).width('90%')
Text('top start') Stack() {
.align(Alignment.TopStart) Text('First show in bottom end').height('65%').backgroundColor(0xD2B48C)
.height(50) Text('Second show in bottom end').backgroundColor(0xF5DEB3).opacity(0.9)
.width('90%') }.width('90%').height(50).margin({ top: 5 }).backgroundColor(0xFFE4C4)
.fontSize(16) .align(Alignment.BottomEnd)
.backgroundColor(0xFFE4C4) Stack() {
Text('top start')
Text('Bottom end') }.width('90%').height(50).margin({ top: 5 }).backgroundColor(0xFFE4C4)
.align(Alignment.BottomEnd) .align(Alignment.TopStart)
.height(50)
.width('90%')
.fontSize(16)
.backgroundColor(0xFFE4C4)
// To arrange the child components from left to right, set direction of the parent container to Direction.Ltr. // To arrange the child components from left to right, set direction of the parent container to Direction.Ltr.
Text('direction').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('direction').fontSize(9).fontColor(0xCCCCCC).width('90%')
...@@ -86,6 +82,7 @@ struct PositionExample2 { ...@@ -86,6 +82,7 @@ struct PositionExample2 {
Text('position').fontSize(12).fontColor(0xCCCCCC).width('90%') Text('position').fontSize(12).fontColor(0xCCCCCC).width('90%')
Row() { Row() {
Text('1').size({ width: '30%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) Text('1').size({ width: '30%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16)
.textAlign(TextAlign.Center)
Text('2 position(30, 10)') Text('2 position(30, 10)')
.size({ width: '60%', height: '30' }) .size({ width: '60%', height: '30' })
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
...@@ -94,6 +91,7 @@ struct PositionExample2 { ...@@ -94,6 +91,7 @@ struct PositionExample2 {
.align(Alignment.Start) .align(Alignment.Start)
.position({ x: 30, y: 10 }) .position({ x: 30, y: 10 })
Text('3').size({ width: '45%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) Text('3').size({ width: '45%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16)
.textAlign(TextAlign.Center)
Text('4 position(50%, 70%)') Text('4 position(50%, 70%)')
.size({ width: '50%', height: '50' }) .size({ width: '50%', height: '50' })
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
...@@ -110,14 +108,20 @@ struct PositionExample2 { ...@@ -110,14 +108,20 @@ struct PositionExample2 {
.size({ width: '100', height: '100' }) .size({ width: '100', height: '100' })
.backgroundColor(0xdeb887) .backgroundColor(0xdeb887)
Text('text') Text('text')
.fontSize('30px')
.textAlign(TextAlign.Center)
.size({ width: 25, height: 25 }) .size({ width: 25, height: 25 })
.backgroundColor(Color.Green) .backgroundColor(Color.Green)
.markAnchor({ x: 25, y: 25 }) .markAnchor({ x: 25, y: 25 })
Text('text') Text('text')
.fontSize('30px')
.textAlign(TextAlign.Center)
.size({ width: 25, height: 25 }) .size({ width: 25, height: 25 })
.backgroundColor(Color.Green) .backgroundColor(Color.Green)
.markAnchor({ x: -100, y: -25 }) .markAnchor({ x: -100, y: -25 })
Text('text') Text('text')
.fontSize('30px')
.textAlign(TextAlign.Center)
.size({ width: 25, height: 25 }) .size({ width: 25, height: 25 })
.backgroundColor(Color.Green) .backgroundColor(Color.Green)
.markAnchor({ x: 25, y: -25 }) .markAnchor({ x: 25, y: -25 })
...@@ -127,6 +131,7 @@ struct PositionExample2 { ...@@ -127,6 +131,7 @@ struct PositionExample2 {
Text('offset').fontSize(12).fontColor(0xCCCCCC).width('90%') Text('offset').fontSize(12).fontColor(0xCCCCCC).width('90%')
Row() { Row() {
Text('1').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) Text('1').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16)
.textAlign(TextAlign.Center)
Text('2 offset(15, 30)') Text('2 offset(15, 30)')
.size({ width: 120, height: '50' }) .size({ width: 120, height: '50' })
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
...@@ -135,6 +140,7 @@ struct PositionExample2 { ...@@ -135,6 +140,7 @@ struct PositionExample2 {
.align(Alignment.Start) .align(Alignment.Start)
.offset({ x: 15, y: 30 }) .offset({ x: 15, y: 30 })
Text('3').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16) Text('3').size({ width: '15%', height: '50' }).backgroundColor(0xdeb887).border({ width: 1 }).fontSize(16)
.textAlign(TextAlign.Center)
Text('4 offset(-10%, 20%)') Text('4 offset(-10%, 20%)')
.size({ width: 100, height: '50' }) .size({ width: 100, height: '50' })
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
......
# Text Style # Universal Text Attributes
The text style attributes set the style for text in a component. Universal text attributes include text style attributes applicable to text containers.
> **NOTE** > **NOTE**
> >
...@@ -18,6 +18,8 @@ The text style attributes set the style for text in a component. ...@@ -18,6 +18,8 @@ The text style attributes set the style for text in a component.
| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | Font style.<br>Default value: **FontStyle.Normal** | | fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | Font style.<br>Default value: **FontStyle.Normal** |
| fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight. The string type supports only the string of the number type, for example, **400**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.<br>Default value: **FontWeight.Normal** | | fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight. The string type supports only the string of the number type, for example, **400**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.<br>Default value: **FontWeight.Normal** |
| fontFamily | string \| [Resource](ts-types.md#resource) | Font family.<br>Default value: **'HarmonyOS Sans'**<br>Currently, only the default font is supported. | | fontFamily | string \| [Resource](ts-types.md#resource) | Font family.<br>Default value: **'HarmonyOS Sans'**<br>Currently, only the default font is supported. |
| lineHeight | string \| number \| [Resource](ts-types.md#resource) | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.|
| decoration | {<br>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?: [ResourceColor](ts-types.md#resourcecolor)<br>} | Style and color of the text decorative line.<br>Default value: {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} |
## Example ## Example
......
...@@ -10,7 +10,7 @@ A drag event is triggered when a component is dragged. ...@@ -10,7 +10,7 @@ A drag event is triggered when a component is dragged.
| Name | Bubbling Supported| Description | | Name | Bubbling Supported| Description |
| ------------------------------------------------------------ | -------- | ------------------------------------------------------------ | | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| onDragStart(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; [CustomBuilder](ts-types.md#custombuilder8) \| [DragItemInfo](#dragiteminfo)) | No | Triggered when the component bound to the event is dragged for the first time.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>Return value: object being dragged, which is used for prompts displayed when the object is dragged.<br>A drag event can be triggered by a 150 ms long press. If the duration of a long-press gesture is set to less than or equal to 150 ms, the callback for the long-press gesture takes precedence. Otherwise, the callback for the drag event takes precedence.| | onDragStart(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; [CustomBuilder](ts-types.md#custombuilder8) \| [DragItemInfo](#dragiteminfo)) | No | Triggered when the component bound to the event is dragged for the first time.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>Return value: object being dragged, which is used for prompts displayed when the object is dragged.<br>A drag event can be triggered by a 500 ms long press. If the duration of a long-press gesture is set to less than or equal to 500 ms, the callback for the long-press gesture takes precedence. Otherwise, the callback for the drag event takes precedence.|
| onDragEnter(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; void) | No | Triggered when the dragged item enters a valid drop target.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>This event is valid only when a listener for the **onDrop** event is enabled.| | onDragEnter(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; void) | No | Triggered when the dragged item enters a valid drop target.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>This event is valid only when a listener for the **onDrop** event is enabled.|
| onDragMove(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; void) | No | Triggered when the dragged item moves in a valid drop target.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>This event is valid only when a listener for the **onDrop** event is enabled.| | onDragMove(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; void) | No | Triggered when the dragged item moves in a valid drop target.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>This event is valid only when a listener for the **onDrop** event is enabled.|
| onDragLeave(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; void) | No | Triggered when the dragged item leaves a valid drop target.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>This event is valid only when a listener for the **onDrop** event is enabled.| | onDragLeave(event: (event?: [DragEvent](#dragevent), extraParams?: string) =&gt; void) | No | Triggered when the dragged item leaves a valid drop target.<br>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br>- **extraParams**: additional information about the drag event. For details, see **[extraParams](#extraparams)**.<br>This event is valid only when a listener for the **onDrop** event is enabled.|
...@@ -67,7 +67,7 @@ struct DragExample { ...@@ -67,7 +67,7 @@ struct DragExample {
@State bananaVisible: Visibility = Visibility.Visible @State bananaVisible: Visibility = Visibility.Visible
private dragList: string[] = ['apple', 'orange', 'banana'] private dragList: string[] = ['apple', 'orange', 'banana']
@State fruitVisible: Visibility[] = [Visibility.Visible, Visibility.Visible, Visibility.Visible] @State fruitVisible: Visibility[] = [Visibility.Visible, Visibility.Visible, Visibility.Visible]
@State index: number = 0 @State idx: number = 0
// Customize the content displayed during dragging. // Customize the content displayed during dragging.
@Builder pixelMapBuilder() { @Builder pixelMapBuilder() {
...@@ -104,7 +104,7 @@ struct DragExample { ...@@ -104,7 +104,7 @@ struct DragExample {
.onTouch((event: TouchEvent) => { .onTouch((event: TouchEvent) => {
if (event.type === TouchType.Down) { if (event.type === TouchType.Down) {
this.eventType = 'Down' this.eventType = 'Down'
this.index = index this.idx = index
} }
if (event.type === TouchType.Up) { if (event.type === TouchType.Up) {
this.eventType = 'Up' this.eventType = 'Up'
...@@ -157,7 +157,7 @@ struct DragExample { ...@@ -157,7 +157,7 @@ struct DragExample {
this.numbers.splice(jsonString.insertIndex, 0, this.text) this.numbers.splice(jsonString.insertIndex, 0, this.text)
this.bool = false this.bool = false
} }
this.fruitVisible[this.index] = Visibility.None this.fruitVisible[this.idx] = Visibility.None
}) })
}.width('100%').height('100%').padding({ top: 20 }).margin({ top: 20 }) }.width('100%').height('100%').padding({ top: 20 }).margin({ top: 20 })
} }
......
...@@ -108,9 +108,3 @@ This permission is of the **system\_basic** level. Before applying for the permi ...@@ -108,9 +108,3 @@ This permission is of the **system\_basic** level. Before applying for the permi
console.log("call state change, data is:" + JSON.stringify(data)); console.log("call state change, data is:" + JSON.stringify(data));
}); });
``` ```
## Samples
The following sample is provided to help you better understand how to develop the call service:
- [Call](https://gitee.com/openharmony/applications_app_samples/tree/master/Telephony/Call)
...@@ -110,9 +110,3 @@ The Short Messaging Service (SMS) module provides basic SMS management functions ...@@ -110,9 +110,3 @@ The Short Messaging Service (SMS) module provides basic SMS management functions
} }
} }
``` ```
## Samples
The following sample is provided to help you better understand how to develop the SMS service:
- [SMS](https://gitee.com/openharmony/applications_app_samples/tree/master/Telephony/Message)
...@@ -132,7 +132,7 @@ The splash screen animation refers to the fade-in and fade-out of the logo. Afte ...@@ -132,7 +132,7 @@ The splash screen animation refers to the fade-in and fade-out of the logo. Afte
.onAppear(() => { .onAppear(() => {
animateTo({ animateTo({
duration: 2000, duration: 1000,
curve: this.curve1, curve: this.curve1,
delay: 100, delay: 100,
onFinish: () => { onFinish: () => {
...@@ -199,7 +199,7 @@ The splash screen animation refers to the fade-in and fade-out of the logo. Afte ...@@ -199,7 +199,7 @@ The splash screen animation refers to the fade-in and fade-out of the logo. Afte
.opacity(this.opacityValue) .opacity(this.opacityValue)
.onAppear(() => { .onAppear(() => {
animateTo({ animateTo({
duration: 2000, duration: 1000,
curve: this.curve1, curve: this.curve1,
delay: 100, delay: 100,
onFinish: () => { onFinish: () => {
......
...@@ -10,32 +10,32 @@ ...@@ -10,32 +10,32 @@
## Usage ## Usage
Invoke the **mediaquery** API to set the media query condition and the callback, and change the page layout or implement service logic in the callback corresponding to the condition. Invoke the **mediaquery** API to set the media query condition and the callback, and change the page layout or implement service logic in the callback corresponding to the condition. The procedure is as follows:
First, import the **mediaquery** module, as shown below: 1. Import the **mediaquery** module, as shown below:
```ts ```ts
import mediaquery from '@ohos.mediaquery' import mediaquery from '@ohos.mediaquery'
``` ```
Then, use the **matchMediaSync** API to set the media query condition and save the returned listener, as shown below: 2. Use the **matchMediaSync** API to set the media query condition and save the returned listener, as shown below:
```ts ```ts
listener = mediaquery.matchMediaSync('(orientation: landscape)') listener = mediaquery.matchMediaSync('(orientation: landscape)')
``` ```
Finally, register the **onPortrait** callback using the saved listener, and change the page layout or implement service logic in the callback. When the media query condition is matched, the callback is triggered. The sample code is as follows: 3. Register the **onPortrait** callback using the saved listener, and change the page layout or implement service logic in the callback. When the media query condition is matched, the callback is triggered. The sample code is as follows:
```ts ```ts
onPortrait(mediaQueryResult) { onPortrait(mediaQueryResult) {
if (mediaQueryResult.matches) { if (mediaQueryResult.matches) {
// do something here // do something here
} else { } else {
// do something here // do something here
} }
} }
listener.on('change', onPortrait) listener.on('change', onPortrait)
``` ```
## Media Query Conditions ## Media Query Conditions
...@@ -95,10 +95,10 @@ At MediaQuery Level 4, range query is imported so that you can use the operators ...@@ -95,10 +95,10 @@ At MediaQuery Level 4, range query is imported so that you can use the operators
| height | Height of the display area on the application page. | | height | Height of the display area on the application page. |
| min-height | Minimum height of the display area on the application page. | | min-height | Minimum height of the display area on the application page. |
| max-height | Maximum height of the display area on the application page. | | max-height | Maximum height of the display area on the application page. |
| width | Width of the display area on the app page. | | width | Width of the display area on the application page. |
| min-width | Minimum width of the display area on the application page. | | min-width | Minimum width of the display area on the application page. |
| max-width | Maximum width of the display area on the application page. | | max-width | Maximum width of the display area on the application page. |
| resolution | Resolution of the device. The unit can be dpi, dppx, or dpcm.<br>- **dpi** indicates the number of physical pixels per inch. 1 dpi ≈ 0.39 dpcm.<br>- **dpcm** indicates the number of physical pixels per centimeter. 1 dpcm ≈ 2.54 dpi.<br>- **dppx** indicates the number of physical pixels in each pixel. (This unit is calculated based on this formula: 96 px = 1 inch, which is different from the calculation method of the px unit on the page.) 1 dppx = 96 dpi.| | resolution | Resolution of the device. The unit can be dpi, dppx, or dpcm. <br>- **dpi** indicates the number of physical pixels per inch. 1 dpi ≈ 0.39 dpcm.<br>- **dpcm** indicates the number of physical pixels per centimeter. 1 dpcm ≈ 2.54 dpi.<br>- **dppx** indicates the number of physical pixels in each pixel. (This unit is calculated based on this formula: 96 px = 1 inch, which is different from the calculation method of the px unit on the page.) 1 dppx = 96 dpi.|
| min-resolution | Minimum device resolution. | | min-resolution | Minimum device resolution. |
| max-resolution | Maximum device resolution. | | max-resolution | Maximum device resolution. |
| orientation | Screen orientation.<br>Options are as follows:<br>- orientation: portrait<br>- orientation: landscape| | orientation | Screen orientation.<br>Options are as follows:<br>- orientation: portrait<br>- orientation: landscape|
...@@ -106,7 +106,7 @@ At MediaQuery Level 4, range query is imported so that you can use the operators ...@@ -106,7 +106,7 @@ At MediaQuery Level 4, range query is imported so that you can use the operators
| min-device-height | Minimum height of the device. | | min-device-height | Minimum height of the device. |
| max-device-height | Maximum height of the device. | | max-device-height | Maximum height of the device. |
| device-width | Width of the device. | | device-width | Width of the device. |
| device-type | Type of the device.<br>Value range: **default** | | device-type | Type of the device.<br>Options: **default** and tablet |
| min-device-width | Minimum width of the device. | | min-device-width | Minimum width of the device. |
| max-device-width | Maximum width of the device. | | max-device-width | Maximum width of the device. |
| round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite. | | round-screen | Screen type. The value **true** means that the screen is round, and **false** means the opposite. |
......
...@@ -26,15 +26,15 @@ Your feedback matters. Submit issues and leave as detailed information as possib ...@@ -26,15 +26,15 @@ Your feedback matters. Submit issues and leave as detailed information as possib
1. On the Gitee page, click the **Issues** tab. On the displayed page, click **New issue**. Then enter the issue title and issue details. 1. On the Gitee page, click the **Issues** tab. On the displayed page, click **New issue**. Then enter the issue title and issue details.
2. Click **New** to submit the issue. The Docs team will confirm the issue. 2. Click **New** to submit the issue. The Docs team will confirm the issue.
>![](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> **How can I provide a high-quality issue?**
> >
>**How can I provide a high-quality issue?** > - Provide a clear description of the issue, including the missing, outdated, incorrect, or to-be-improved content.
> > - Explain the impact of this issue on users.
>- Provide a clear description of the issue, including the missing, outdated, incorrect, or to-be-improved content. > - Limit the scope of the given issue to a specific task. If multiple fields are involved, break the issue down into smaller ones. For example, "Documents need to be optimized" is a broad issue, whereas "XX development guide lacks introduction to step XXX" is specific and operable.
>- Explain the impact of this issue on users. > - Search the list of existing issues to see if any related or similar issues have been submitted.
>- Limit the scope of the given issue to a specific task. If multiple fields are involved, break the issue down into smaller ones. For example, "Documents need to be optimized" is a broad issue, whereas "XX development guide lacks introduction to step XXX" is specific and operable. > - If an issue is associated with another issue or a pull request (PR), you can use its full URL or the combination of the number sign (#) and PR number to reference it.
>- Search the list of existing issues to see if any related or similar issues have been submitted.
>- If an issue is associated with another issue or a pull request (PR), you can use its full URL or the combination of the number sign (#) and PR number to reference it.
### Editing Existing Documents ### Editing Existing Documents
......
...@@ -60,8 +60,8 @@ Pictures used in **OpenHarmony\_DOCUMENTS/docs/quick-start/writing-instructions ...@@ -60,8 +60,8 @@ Pictures used in **OpenHarmony\_DOCUMENTS/docs/quick-start/writing-instructions
Use relative paths to reference pictures in the document. Use relative paths to reference pictures in the document.
>![](public_sys-resources/icon-caution.gif) **CAUTION:** > **CAUTION**
>Use the original pictures to avoid intellectual property infringement risks. > Use the original pictures to avoid intellectual property infringement risks.
- Pictures are clear and complete. For example, a flowchart has a start and an end. - Pictures are clear and complete. For example, a flowchart has a start and an end.
- The graphics has clear logic and are provided with text descriptions. Do not separate the graphics from the text. - The graphics has clear logic and are provided with text descriptions. Do not separate the graphics from the text.
...@@ -69,9 +69,9 @@ Use relative paths to reference pictures in the document. ...@@ -69,9 +69,9 @@ Use relative paths to reference pictures in the document.
- The text on pictures should be Chinese in Chinese documents and English in English documents. - The text on pictures should be Chinese in Chinese documents and English in English documents.
- It is recommended that pictures be named based on the content. Using only a number is difficult for picture inheritance. - It is recommended that pictures be named based on the content. Using only a number is difficult for picture inheritance.
>![](public_sys-resources/icon-note.gif) **NOTE:** > **NOTE:**
>Reference: > Reference:
>!\[\]\(./pic/pic-standard.png\) > !\[\]\(./pic/pic-standard.png\)
If a self-made picture is used, refer to the following figure to configure the color. The format can be **png**, **jpg**, **gif**, and so on. If a self-made picture is used, refer to the following figure to configure the color. The format can be **png**, **jpg**, **gif**, and so on.
......
...@@ -50,10 +50,6 @@ ...@@ -50,10 +50,6 @@
- [Sensor Overview](subsys-sensor-overview.md) - [Sensor Overview](subsys-sensor-overview.md)
- [Sensor Usage Guidelines](subsys-sensor-guide.md) - [Sensor Usage Guidelines](subsys-sensor-guide.md)
- [Sensor Usage Example](subsys-sensor-demo.md) - [Sensor Usage Example](subsys-sensor-demo.md)
- USB
- [USB Overview](subsys-usbservice-overview.md)
- [USB Usage Guidelines](subsys-usbservice-guide.md)
- [USB Usage Example](subsys-usbservice-demo.md)
- Application Framework - Application Framework
- [Application Framework Overview](subsys-application-framework-overview.md) - [Application Framework Overview](subsys-application-framework-overview.md)
- [Setting Up a Development Environment](subsys-application-framework-envbuild.md) - [Setting Up a Development Environment](subsys-application-framework-envbuild.md)
......
# USB Usage Example<a name="EN-US_TOPIC_0000001092792986"></a>
```cpp
#include <cstdio>
#include <iostream>
#include <map>
#include <mutex>
#include <sstream>
#include <sys/time.h>
#include "if_system_ability_manager.h"
#include "ipc_skeleton.h"
#include "iremote_object.h"
#include "iservice_registry.h"
#include "iusb_srv.h"
#include "string_ex.h"
#include "system_ability_definition.h"
#include "usb_common.h"
#include "usb_device.h"
#include "usb_errors.h"
#include "usb_request.h"
#include "usb_server_proxy.h"
#include "usb_srv_client.h"
const int32_t REQUESTYPE = ((1 << 7) | (0 << 5) | (0 & 0x1f));
const int32_t REQUESTCMD = 6;
const int32_t VALUE = (2 << 8) + 0;
const int32_t TIMEOUT = 5000;
const int32_t ITFCLASS = 10;
const int32_t PRAMATYPE = 2;
const int32_t BUFFERLENGTH = 21;
void GetType(OHOS::USB::USBEndpoint &tep, OHOS::USB::USBEndpoint &outEp, bool &outEpFlg)
{
if ((tep.GetType() == PRAMATYPE)) {
if (tep.GetDirection() == 0) {
outEp = tep;
outEpFlg = true;
}
}
}
bool SelectEndpoint(OHOS::USB::USBConfig config,
std::vector<OHOS::USB::UsbInterface> interfaces,
OHOS::USB::UsbInterface &interface,
OHOS::USB::USBEndpoint &outEp,
bool &outEpFlg)
{
for (int32_t i = 0; i < config.GetInterfaceCount(); ++i) {
OHOS::USB::UsbInterface tif = interfaces[i];
std::vector<OHOS::USB::USBEndpoint> mEndpoints = tif.GetEndpoints();
for (int32_t j = 0; j < tif.GetEndpointCount(); ++j) {
OHOS::USB::USBEndpoint tep = mEndpoints[j];
if ((tif.GetClass() == ITFCLASS) && (tif.GetSubClass() == 0) && (tif.GetProtocol() == PRAMATYPE)) {
GetType(tep, outEp, outEpFlg);
}
}
if (outEpFlg) {
interface = interfaces[i];
return true;
}
std::cout << std::endl;
}
return false;
}
int OpenDeviceTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::UsbDevice device, OHOS::USB::USBDevicePipe &pip)
{
int ret = Instran.RequestRight(device.GetName());
std::cout << "device RequestRight ret = " << ret << std::endl;
if (0 != ret) {
std::cout << "device RequestRight failed = " << ret << std::endl;
}
ret = Instran.OpenDevice(device, pip);
return ret;
}
int CtrTransferTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::USBDevicePipe &pip)
{
std::cout << "usb_device_test : << Control Transfer >> " << std::endl;
std::vector<uint8_t> vData;
const OHOS::USB::UsbCtrlTransfer tctrl = {REQUESTYPE, REQUESTCMD, VALUE, 0, TIMEOUT};
int ret = Instran.ControlTransfer(pip, tctrl, vData);
if (ret != 0) {
std::cout << "control message read failed width ret = " << ret << std::endl;
} else {
}
std::cout << "control message read success" << std::endl;
return ret;
}
int ClaimTest(OHOS::USB::UsbSrvClient &Instran,
OHOS::USB::USBDevicePipe &pip,
OHOS::USB::UsbInterface &interface,
bool interfaceFlg)
{
if (interfaceFlg) {
std::cout << "ClaimInterface InterfaceInfo:" << interface.ToString() << std::endl;
int ret = Instran.ClaimInterface(pip, interface, true);
if (ret != 0) {
std::cout << "ClaimInterface failed width ret = " << ret << std::endl;
} else {
std::cout << "ClaimInterface success" << std::endl;
}
}
return 0;
}
int BulkTransferTest(OHOS::USB::UsbSrvClient &Instran,
OHOS::USB::USBDevicePipe &pip,
OHOS::USB::USBEndpoint &outEp,
bool interfaceFlg,
bool outEpFlg)
{
if (interfaceFlg) {
std::cout << "usb_device_test : << Bulk transfer start >> " << std::endl;
if (outEpFlg) {
uint8_t buffer[50] = "hello world 123456789";
std::vector<uint8_t> vData(buffer, buffer + BUFFERLENGTH);
int ret = Instran.BulkTransfer(pip, outEp, vData, TIMEOUT);
if (ret != 0) {
std::cout << "Bulk transfer write failed width ret = " << ret << std::endl;
} else {
std::cout << "Bulk transfer write success" << std::endl;
}
return ret;
}
}
return 0;
}
int main(int argc, char **argv)
{
std::cout << "usb_device_test " << std::endl;
static OHOS::USB::UsbSrvClient &Instran = OHOS::USB::UsbSrvClient::GetInstance();
// GetDevices
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = Instran.GetDevices(deviceList);
if (ret != 0) {
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
}
if (deviceList.empty()) {
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
}
OHOS::USB::UsbDevice device = deviceList[0];
std::vector<OHOS::USB::USBConfig> configs = device.GetConfigs();
OHOS::USB::USBConfig config = configs[0];
std::vector<OHOS::USB::UsbInterface> interfaces = config.GetInterfaces();
OHOS::USB::UsbInterface interface;
OHOS::USB::USBEndpoint outEp;
bool interfaceFlg = false;
bool outEpFlg = false;
interfaceFlg = SelectEndpoint(config, interfaces, interface, outEp, outEpFlg);
// OpenDevice
std::cout << "usb_device_test : << OpenDevice >> test begin -> " << std::endl;
OHOS::USB::USBDevicePipe pip;
ret = OpenDeviceTest(Instran, device, pip);
if (ret != 0) {
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
}
// ControlTransfer
CtrTransferTest(Instran, pip);
// ClaimInterface
ClaimTest(Instran, pip, interface, interfaceFlg);
// BulkTransferWrite
BulkTransferTest(Instran, pip, outEp, interfaceFlg, outEpFlg);
// CloseDevice
std::cout << "usb_device_test : << Close Device >> " << std::endl;
ret = Instran.Close(pip);
if (ret == 0) {
std::cout << "Close device failed width ret = " << ret << std::endl;
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
} else {
std::cout << "Close Device success" << std::endl;
}
return 0;
}
```
# USB Usage Guidelines<a name="EN-US_TOPIC_0000001077367159"></a>
The following procedure uses bulk transfer as an example.
## Procedure<a name="section18816105182315"></a>
1. Obtain a USB service instance.
```cpp
static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance();
```
2. Obtain the USB device list.
```cpp
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList);
```
3. Apply for device access permissions.
```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName());
```
4. Open the USB device.
```cpp
USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip);
```
5. Configure the USB interface.
```cpp
ret = g_usbClient.ClaimInterface(pip, interface, true); // **interface** indicates an interface of the USB device in **deviceList**.
```
6. Transfer data.
```cpp
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
```
Parameter description:
- **pipe**: pipe for data transfer of the USB device opened.
- **endpoint**: endpoint for data transfer on the USB device.
- **vdata**: binary data block to be transferred or read.
- **timeout**: timeout duration of data transfer.
7. Close the USB device.
```cpp
ret = g_usbClient.Close(pip);
```
# USB
## Introduction
### Function Description
USB devices are classified into two types: USB host and USB device. On OpenHarmony, you can use the port service to switch between the host mode and device mode. In host mode, you can obtain the list of connected USB devices, manage device access permissions, and perform bulk transfer or control transfer between the host and connected devices. In device mode, you can switch between functions including HDC (debugging), ACM (serial port), and ECM (Ethernet port).
### Basic Concepts
- USB service
An abstraction of underlying hardware-based USB devices. Your application can access the USB devices via the USB service. With the APIs provided by the USB service, you can obtain the list of connected USB devices, manage device access permissions, and perform data transfer or control transfer between the host and connected devices.
- USB API
A collection of JS APIs provided for the upper layer through NAPI. Your application can use USB APIs to implement various basic functions, for example, query of the USB device list, USB device plug notification, USB host and device mode switching, bulk transfer, control transfer, right management, and function switching in device mode.
- USB Service layer
A layer implemented by using the C++ programming language. It consists of four modules: Host, Device, Port, and Right. HDI-based APIs provided by USB Service are mainly used to implement management of USB device list, USB functions, USB ports, and USB device access permissions. The USB Service layer interacts with the HAL layer to receive, parse, and distribute data, manages foreground and background policies, and performs USB device management and right control.
- USB HAL layer
A layer implemented by using the C programming language. Based on the Host Driver Development Kit (SDK) and Device DDK, USB HAL encapsulates basic USB device operations, provides C++ APIs for the upper layer, and receives information from the kernel through the Hardware Driver Foundation (HDF) framework.
### Working Principles
The USB subsystem logically consists of three parts: USB API, USB Service, and USB HAL. The following figure shows how the USB service is implemented.
**Figure 1** USB service architecture
![USB service architecture](figures/en-us_image_0000001267088285.png)
- USB API: provides USB APIs that implement various basic functions, for example, query of the USB device list, bulk data transfer, control transfer, and right management.
- USB Service: receives, parses, and distributes Hardware Abstraction Layer (HAL) data, manages and controls foreground and background policies, and manages devices.
- USB HAL: provides driver capability APIs that can be directly called in user mode.
## Usage Guidelines
### When to Use
In Host mode, you can obtain the list of connected devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer.
### APIs
**Table 1** Host-specific APIs
| API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| int32_t OpenDevice(const UsbDevice &device, USBDevicePipe &pip); | Opens a USB device to set up a connection. |
| bool HasRight(std::string deviceName); | Checks whether the application has the permission to access the device. |
| int32_t RequestRight(std::string deviceName); | Requests the temporary permission for a given application to access the USB device. |
| int32_t GetDevices(std::vector &deviceList); | Obtains the USB device list. |
| int32_t ClaimInterface(USBDevicePipe &pip, const UsbInterface &interface, bool force); | Claims a USB interface exclusively. This must be done before data transfer. |
| int32_t ReleaseInterface(USBDevicePipe &pip, const UsbInterface &interface); | Releases a USB interface. This is usually done after data transfer. |
| int32_t BulkTransfer(USBDevicePipe &pip, const USBEndpoint &endpoint, std::vector &vdata, int32_t timeout); | Performs a bulk transfer on a specified endpoint. The data transfer direction is determined by the endpoint direction.|
| int32_t ControlTransfer(USBDevicePipe &pip, const UsbCtrlTransfer &ctrl, std::vector &vdata); | Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the request type. |
| int32_t SetConfiguration(USBDevicePipe &pip, const USBConfig &config); | Sets the current configuration of the USB device. |
| int32_t SetInterface(USBDevicePipe &pipe, const UsbInterface &interface); | Sets the alternate settings for the specified USB interface. This allows you to switch between two interfaces with the same ID but different alternate settings.|
| int32_t GetRawDescriptors(std::vector &vdata); | Obtains the raw USB descriptor. |
| int32_t GetFileDescriptor(); | Obtains the file descriptor. |
| bool Close(const USBDevicePipe &pip); | Closes a USB device to release all system resources related to the device. |
| int32_t PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req); | Obtains the isochronous transfer result. |
| int32_t RequestInitialize(UsbRequest &request); | Initializes the isochronous transfer request. |
| int32_t RequestFree(UsbRequest &request); | Frees the isochronous transfer request. |
| int32_t RequestAbort(UsbRequest &request); | Cancels the data transfer request to be processed. |
| int32_t RequestQueue(UsbRequest &request); | Sends or receives requests for isochronous transfer on a specified endpoint. The data transfer direction is determined by the endpoint direction.|
| int32_t RegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint, const sptr<IRemoteObject> &cb); | Registers an asynchronous callback for bulk transfer. |
| int32_t UnRegBulkCallback(USBDevicePipe &pip, const USBEndpoint &endpoint); | Unregisters the asynchronous callback for bulk transfer. |
| int32_t BulkRead(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem); | Reads data asynchronously during bulk transfer. |
| int32_t BulkWrite(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr<Ashmem> &ashmem); | Writes data asynchronously during bulk transfer. |
| int32_t BulkCancel(USBDevicePipe &pip, const USBEndpoint &endpoint); | Cancels bulk transfer. The asynchronous read and write operations on the current USB interface will be cancelled. |
**Table 2** Device-specific APIs
| API | Description |
| -------------------------------------------------- | ------------------------------------------------------ |
| int32_t GetCurrentFunctions(int32_t &funcs); | Obtains the numeric mask combination for the current USB function list in Device mode. |
| int32_t SetCurrentFunctions(int32_t funcs); | Sets the current USB function list in Device mode. |
| int32_t UsbFunctionsFromString(std::string funcs); | Converts the string descriptor of a given USB function list to a numeric mask combination.|
| std::string UsbFunctionsToString(int32_t funcs); | Converts the numeric mask combination of a given USB function list to a string descriptor.|
**Table 3** Port-specific APIs
| API | Description |
| ------------------------------------------------------------ | -------------------------------------------------------- |
| int32_t GetSupportedModes(int32_t portId, int32_t &supportedModes); | Obtains the mask combination for the supported mode list of a given port. |
| int32_t SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole); | Sets the role types supported by a specified port, which can be **powerRole** (for charging) and **dataRole** (for data transfer).|
| int32_t GetPorts(std::vector &usbPorts); | Obtains the USB port descriptor list. |
### How to Use
The following uses bulk transfer as an example to illustrate the development procedure.
1. Obtain a USB service instance.
```cpp
static OHOS::USB::UsbSrvClient &g_usbClient = OHOS::USB::UsbSrvClient::GetInstance();
```
2. Obtain the USB device list.
```cpp
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = g_usbClient.GetDevices(deviceList);
```
3. Apply for device access permissions.
```cpp
int32_t ret = g_usbClient.RequestRight(device.GetName());
```
4. Open a camera device.
```cpp
USBDevicePipe pip;
int32_t et = g_usbClient.OpenDevice(device, pip);
```
5. Configure the USB interface.
```cpp
// interface indicates an interface of the USB device in deviceList.
ret = g_usbClient.ClaimInterface(pip, interface, true);
```
6. Perform data transfer.
```cpp
// pipe indicates the pipe for data transfer after the USB device is opened. endpoint indicates the endpoint for data transfer on the USB device. vdata indicates the binary data block to be transferred or read. timeout indicates the timeout duration of data transfer.
srvClient.BulkTransfer(pipe, endpoint, vdata, timeout);
```
7. Closes a device.
```cpp
ret = g_usbClient.Close(pip);
```
### Sample Code
```cpp
#include <cstdio>
#include <iostream>
#include <map>
#include <mutex>
#include <sstream>
#include <sys/time.h>
#include "if_system_ability_manager.h"
#include "ipc_skeleton.h"
#include "iremote_object.h"
#include "iservice_registry.h"
#include "iusb_srv.h"
#include "string_ex.h"
#include "system_ability_definition.h"
#include "usb_common.h"
#include "usb_device.h"
#include "usb_errors.h"
#include "usb_request.h"
#include "usb_server_proxy.h"
#include "usb_srv_client.h"
const int32_t REQUESTYPE = ((1 << 7) | (0 << 5) | (0 & 0x1f));
const int32_t REQUESTCMD = 6;
const int32_t VALUE = (2 << 8) + 0;
const int32_t TIMEOUT = 5000;
const int32_t ITFCLASS = 10;
const int32_t PRAMATYPE = 2;
const int32_t BUFFERLENGTH = 21;
void GetType(OHOS::USB::USBEndpoint &tep, OHOS::USB::USBEndpoint &outEp, bool &outEpFlg)
{
if ((tep.GetType() == PRAMATYPE)) {
if (tep.GetDirection() == 0) {
outEp = tep;
outEpFlg = true;
}
}
}
bool SelectEndpoint(OHOS::USB::USBConfig config,
std::vector<OHOS::USB::UsbInterface> interfaces,
OHOS::USB::UsbInterface &interface,
OHOS::USB::USBEndpoint &outEp,
bool &outEpFlg)
{
for (int32_t i = 0; i < config.GetInterfaceCount(); ++i) {
OHOS::USB::UsbInterface tif = interfaces[i];
std::vector<OHOS::USB::USBEndpoint> mEndpoints = tif.GetEndpoints();
for (int32_t j = 0; j < tif.GetEndpointCount(); ++j) {
OHOS::USB::USBEndpoint tep = mEndpoints[j];
if ((tif.GetClass() == ITFCLASS) && (tif.GetSubClass() == 0) && (tif.GetProtocol() == PRAMATYPE)) {
GetType(tep, outEp, outEpFlg);
}
}
if (outEpFlg) {
interface = interfaces[i];
return true;
}
std::cout << std::endl;
}
return false;
}
int OpenDeviceTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::UsbDevice device, OHOS::USB::USBDevicePipe &pip)
{
int ret = Instran.RequestRight(device.GetName());
std::cout << "device RequestRight ret = " << ret << std::endl;
if (0 != ret) {
std::cout << "device RequestRight failed = " << ret << std::endl;
}
ret = Instran.OpenDevice(device, pip);
return ret;
}
int CtrTransferTest(OHOS::USB::UsbSrvClient &Instran, OHOS::USB::USBDevicePipe &pip)
{
std::cout << "usb_device_test : << Control Transfer >> " << std::endl;
std::vector<uint8_t> vData;
const OHOS::USB::UsbCtrlTransfer tctrl = {REQUESTYPE, REQUESTCMD, VALUE, 0, TIMEOUT};
int ret = Instran.ControlTransfer(pip, tctrl, vData);
if (ret != 0) {
std::cout << "control message read failed width ret = " << ret << std::endl;
} else {
}
std::cout << "control message read success" << std::endl;
return ret;
}
int ClaimTest(OHOS::USB::UsbSrvClient &Instran,
OHOS::USB::USBDevicePipe &pip,
OHOS::USB::UsbInterface &interface,
bool interfaceFlg)
{
if (interfaceFlg) {
std::cout << "ClaimInterface InterfaceInfo:" << interface.ToString() << std::endl;
int ret = Instran.ClaimInterface(pip, interface, true);
if (ret != 0) {
std::cout << "ClaimInterface failed width ret = " << ret << std::endl;
} else {
std::cout << "ClaimInterface success" << std::endl;
}
}
return 0;
}
int BulkTransferTest(OHOS::USB::UsbSrvClient &Instran,
OHOS::USB::USBDevicePipe &pip,
OHOS::USB::USBEndpoint &outEp,
bool interfaceFlg,
bool outEpFlg)
{
if (interfaceFlg) {
std::cout << "usb_device_test : << Bulk transfer start >> " << std::endl;
if (outEpFlg) {
uint8_t buffer[50] = "hello world 123456789";
std::vector<uint8_t> vData(buffer, buffer + BUFFERLENGTH);
int ret = Instran.BulkTransfer(pip, outEp, vData, TIMEOUT);
if (ret != 0) {
std::cout << "Bulk transfer write failed width ret = " << ret << std::endl;
} else {
std::cout << "Bulk transfer write success" << std::endl;
}
return ret;
}
}
return 0;
}
int main(int argc, char **argv)
{
std::cout << "usb_device_test " << std::endl;
static OHOS::USB::UsbSrvClient &Instran = OHOS::USB::UsbSrvClient::GetInstance();
// GetDevices
std::vector<OHOS::USB::UsbDevice> deviceList;
int32_t ret = Instran.GetDevices(deviceList);
if (ret != 0) {
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
}
if (deviceList.empty()) {
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
}
OHOS::USB::UsbDevice device = deviceList[0];
std::vector<OHOS::USB::USBConfig> configs = device.GetConfigs();
OHOS::USB::USBConfig config = configs[0];
std::vector<OHOS::USB::UsbInterface> interfaces = config.GetInterfaces();
OHOS::USB::UsbInterface interface;
OHOS::USB::USBEndpoint outEp;
bool interfaceFlg = false;
bool outEpFlg = false;
interfaceFlg = SelectEndpoint(config, interfaces, interface, outEp, outEpFlg);
// OpenDevice
std::cout << "usb_device_test : << OpenDevice >> test begin -> " << std::endl;
OHOS::USB::USBDevicePipe pip;
ret = OpenDeviceTest(Instran, device, pip);
if (ret != 0) {
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
}
// ControlTransfer
CtrTransferTest(Instran, pip);
// ClaimInterface
ClaimTest(Instran, pip, interface, interfaceFlg);
// BulkTransferWrite
BulkTransferTest(Instran, pip, outEp, interfaceFlg, outEpFlg);
// CloseDevice
std::cout << "usb_device_test : << Close Device >> " << std::endl;
ret = Instran.Close(pip);
if (ret == 0) {
std::cout << "Close device failed width ret = " << ret << std::endl;
return OHOS::USB::UEC_SERVICE_INVALID_VALUE;
} else {
std::cout << "Close Device success" << std::endl;
}
return 0;
}
```
### Repositories Involved
[Driver subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/driver.md)
[drivers\_peripheral](https://gitee.com/openharmony/drivers_peripheral/blob/master/README_zh.md)
[drivers\_framework](https://gitee.com/openharmony/drivers_framework/blob/master/README_zh.md)
[drivers\_adapter](https://gitee.com/openharmony/drivers_adapter/blob/master/README_zh.md)
[drivers\_adapter\_khdf\_linux](https://gitee.com/openharmony/drivers_adapter_khdf_linux/blob/master/README_zh.md)
...@@ -195,9 +195,9 @@ The HCTest framework is used to support test cases developed with the C language ...@@ -195,9 +195,9 @@ The HCTest framework is used to support test cases developed with the C language
Test suites are built along with version build. The ACTS is built together with the debug version. Test suites are built along with version build. The ACTS is built together with the debug version.
>![](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> >
>The ACTS build middleware is a static library, which will be linked to the image. > The ACTS build middleware is a static library, which will be linked to the image.
### C-based Test Case Execution \(for the Mini System\) ### C-based Test Case Execution \(for the Mini System\)
...@@ -334,9 +334,9 @@ The HCPPTest framework is enhanced and adapted based on the open-source framewor ...@@ -334,9 +334,9 @@ The HCPPTest framework is enhanced and adapted based on the open-source framewor
Test suites are built along with the version build. The ACTS is built together with the debug version. Test suites are built along with the version build. The ACTS is built together with the debug version.
>![](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> >
>The ACTS for the small system is independently built to an executable file \(.bin\) and archived in the **suites\\acts** directory of the build result. > The ACTS for the small system is independently built to an executable file \(.bin\) and archived in the **suites\\acts** directory of the build result.
### C++-based Test Case Execution \(for Standard and Small Systems\) ### C++-based Test Case Execution \(for Standard and Small Systems\)
......
...@@ -39,7 +39,7 @@ AbilityStage功能如下(AbilityStage类,拥有context属性,具体的API ...@@ -39,7 +39,7 @@ AbilityStage功能如下(AbilityStage类,拥有context属性,具体的API
|onAcceptWant(want: Want): string|启动指定Ability时被调用。| |onAcceptWant(want: Want): string|启动指定Ability时被调用。|
|onConfigurationUpdated(config: Configuration): void|全局配置发生变更时被调用。| |onConfigurationUpdated(config: Configuration): void|全局配置发生变更时被调用。|
Ability功能如下(Ability类,具体的API详见[接口文档](../reference/apis/js-apis-application-ability.md)): Ability功能如下(Ability类,具体的API详见[接口文档](../reference/apis/js-apis-app-ability-uiAbility.md)):
**表2** Ability API接口功能介绍 **表2** Ability API接口功能介绍
...@@ -190,7 +190,7 @@ export default class EntryAbility extends UIAbility { ...@@ -190,7 +190,7 @@ export default class EntryAbility extends UIAbility {
``` ```
## 启动Ability ## 启动Ability
### 接口说明 ### 接口说明
Ability类拥有context属性,context属性为AbilityContext类,AbilityContext类拥有abilityInfo、currentHapModuleInfo等属性,启动Ability等方法。具体的API详见[接口文档](../reference/apis/js-apis-ability-context.md) Ability类拥有context属性,context属性为AbilityContext类,AbilityContext类拥有abilityInfo、currentHapModuleInfo等属性,启动Ability等方法。具体的API详见[接口文档](../reference/apis/js-apis-inner-application-uiAbilityContext.md)
**表3** AbilityContext API接口功能介绍 **表3** AbilityContext API接口功能介绍
|接口名|描述| |接口名|描述|
...@@ -207,7 +207,7 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte ...@@ -207,7 +207,7 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte
应用可以通过`this.context`获取Ability实例的上下文,进而使用AbilityContext中的StartAbility相关接口启动Ability。启动Ability可指定Want、StartOptions、accountId,通过callback形式或promise形式实现。具体示例代码如下: 应用可以通过`this.context`获取Ability实例的上下文,进而使用AbilityContext中的StartAbility相关接口启动Ability。启动Ability可指定Want、StartOptions、accountId,通过callback形式或promise形式实现。具体示例代码如下:
```ts ```ts
let context = this.context let context = this.context
var want = { let want = {
"deviceId": "", "deviceId": "",
"bundleName": "com.example.MyApplication", "bundleName": "com.example.MyApplication",
"abilityName": "EntryAbility" "abilityName": "EntryAbility"
...@@ -224,7 +224,7 @@ context.startAbility(want).then(() => { ...@@ -224,7 +224,7 @@ context.startAbility(want).then(() => {
跨设备场景下,需指定对端设备deviceId,具体示例代码如下: 跨设备场景下,需指定对端设备deviceId,具体示例代码如下:
```ts ```ts
let context = this.context let context = this.context
var want = { let want = {
"deviceId": getRemoteDeviceId(), "deviceId": getRemoteDeviceId(),
"bundleName": "com.example.MyApplication", "bundleName": "com.example.MyApplication",
"abilityName": "EntryAbility" "abilityName": "EntryAbility"
...@@ -239,9 +239,9 @@ context.startAbility(want).then(() => { ...@@ -239,9 +239,9 @@ context.startAbility(want).then(() => {
```ts ```ts
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
function getRemoteDeviceId() { function getRemoteDeviceId() {
if (typeof dmClass === 'object' && dmClass != null) { if (typeof dmClass === 'object' && dmClass !== null) {
var list = dmClass.getTrustedDeviceListSync(); let list = dmClass.getTrustedDeviceListSync();
if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') { if (typeof (list) === 'undefined' || typeof (list.length) === 'undefined') {
console.log("EntryAbility onButtonClick getRemoteDeviceId err: list is null"); console.log("EntryAbility onButtonClick getRemoteDeviceId err: list is null");
return; return;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
在应用开发的文档中,您可以获取到如下几方面的内容: 在应用开发的文档中,您可以获取到如下几方面的内容:
### 入门 ## 入门
[入门](quick-start/start-overview.md)可以帮助开发者了解应用开发的基本方法。 [入门](quick-start/start-overview.md)可以帮助开发者了解应用开发的基本方法。
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
开发的基础知识包含了OpenHarmony应用程序的包结构配置文件说明,以及资源文件的使用指导。 开发的基础知识包含了OpenHarmony应用程序的包结构配置文件说明,以及资源文件的使用指导。
### 开发 ## 开发
为了帮助开发者更好的理解OpenHarmony提供的能力,我们对重点功能提供了开发指导,辅助开发者完成应用的开发。 为了帮助开发者更好的理解OpenHarmony提供的能力,我们对重点功能提供了开发指导,辅助开发者完成应用的开发。
...@@ -32,39 +32,38 @@ ...@@ -32,39 +32,38 @@
- [网络与连接](connectivity/ipc-rpc-overview.md) - [网络与连接](connectivity/ipc-rpc-overview.md)
- [电话服务](telephony/telephony-overview.md) - [电话服务](telephony/telephony-overview.md)
- [数据管理](database/database-mdds-overview.md) - [数据管理](database/database-mdds-overview.md)
- [文件管理](file-management/medialibrary-overview.md)
- [任务管理](task-management/background-task-overview.md) - [任务管理](task-management/background-task-overview.md)
- [设备管理](device/usb-overview.md) - [设备管理](device/usb-overview.md)
- [设备使用信息统计](device-usage-statistics/device-usage-statistics-overview.md) - [设备使用信息统计](device-usage-statistics/device-usage-statistics-overview.md)
- [DFX](dfx/hiappevent-guidelines.md) - [DFX](dfx/hiappevent-guidelines.md)
- [国际化](internationalization/international-overview.md) - [国际化](internationalization/international-overview.md)
- [应用测试](application-test/arkxtest-guidelines.md) - [应用测试](application-test/arkxtest-guidelines.md)
- [一次开发,多端部署](key-features/multi-device-app-dev/foreword.md)
- [IDL工具规格及使用说明书](IDL/idl-guidelines.md) - [IDL工具规格及使用说明书](IDL/idl-guidelines.md)
- [Native API的相关指导](napi/napi-guidelines.md) - [Native API的相关指导](napi/napi-guidelines.md)
- [文件管理](file-management/medialibrary-overview.md)
- [一次开发,多端部署](key-features/multi-device-app-dev/foreword.md)
### 工具 ## 工具
DevEco Studio工具是OpenHarmony应用开发的推荐IDE工具。 DevEco Studio工具是OpenHarmony应用开发的推荐IDE工具。
[工具](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421)部分,讲解了DevEco Studio工具的详细用法,包括使用该工具进行工程创建、应用签名、应用调试、应用安装运行的指导。 [工具](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421)部分,讲解了DevEco Studio工具的详细用法,包括使用该工具进行工程创建、应用签名、应用调试、应用安装运行的指导。
### 示例教程 ## 示例教程
我们提供了[Sample工程](https://gitee.com/openharmony/applications_app_samples/blob/master/README_zh.md)[Codelab](https://gitee.com/openharmony/codelabs/blob/master/README.md)这两种形式的示例教程,为开发者提供更丰富的开发参考,辅助开发者理解功能逻辑,提升开发效率。 我们提供了[Sample工程](https://gitee.com/openharmony/applications_app_samples/blob/master/README_zh.md)[Codelab](https://gitee.com/openharmony/codelabs/blob/master/README.md)这两种形式的示例教程,为开发者提供更丰富的开发参考,辅助开发者理解功能逻辑,提升开发效率。
### API参考 ## API参考
API参考提供了OpenHarmony全量组件和接口的参考文档,可以帮助开发者快速查找到指定接口的详细描述和调用方法。 API参考提供了OpenHarmony全量组件和接口的参考文档,可以帮助开发者快速查找到指定接口的详细描述和调用方法。
内容包括: 内容包括:
- [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) - [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/ts-components-summary.md)
- [组件参考(兼容JS的类Web开发范式-ArkUI.Full)](reference/arkui-js/Readme-CN.md) - [组件参考(兼容JS的类Web开发范式-ArkUI.Full)](reference/arkui-js/js-components-common-attributes.md)
- [组件参考(兼容JS的类Web开发范式-ArkUI.Lite)](reference/arkui-js-lite/Readme-CN.md) - [组件参考(兼容JS的类Web开发范式-ArkUI.Lite)](reference/arkui-js-lite/js-framework-file.md)
- [JS服务卡片UI组件参考](reference/js-service-widget-ui/Readme-CN.md) - [JS服务卡片UI组件参考](reference/js-service-widget-ui/js-service-widget-file.md)
- [接口参考(JS及TS API)](reference/apis/js-apis-ability-dataUriUtils.md) - [接口参考(ArkTS及JS API)](reference/apis/development-intro.md)
- 接口参考(Native API) - 接口参考(Native API)
- [OpenHarmony Native API](reference/native-apis/_o_h___native_x_component.md) - [OpenHarmony Native API](reference/native-apis/_o_h___native_x_component.md)
- [Native API标准库](reference/native-lib/third_party_libc/musl.md) - [Native API标准库](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md) - [Node_API](reference/native-lib/third_party_napi/napi.md)
...@@ -76,22 +76,22 @@ FA模型中,可以通过featureAbility的getContext接口获取应用上下文 ...@@ -76,22 +76,22 @@ FA模型中,可以通过featureAbility的getContext接口获取应用上下文
通过getContext获取应用上下文并获取分布式目录的示例如下: 通过getContext获取应用上下文并获取分布式目录的示例如下:
```ts ```ts
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility';
import fileIo from '@ohos.fileio' import fs from '@ohos.file.fs';
(async () => { (async () => {
let dir: string let dir: string;
try { try {
console.info('Begin to getOrCreateDistributedDir') console.info('Begin to getOrCreateDistributedDir');
dir = await featureAbility.getContext().getOrCreateDistributedDir() dir = await featureAbility.getContext().getOrCreateDistributedDir();
console.info('distribute dir is ' + dir) console.info('distribute dir is ' + dir)
} catch (error) { } catch (error) {
console.error('getOrCreateDistributedDir failed with ' + error) console.error('getOrCreateDistributedDir failed with ' + error);
} }
let fd: number; let fd: number;
let path = dir + "/a.txt"; let path = dir + "/a.txt";
fd = fileIo.openSync(path, 0o2 | 0o100, 0o666); fd = fs.openSync(path, fs.OpenMode.READ_WRITE).fd;
fileIo.close(fd); fs.close(fd);
})() })()
``` ```
...@@ -17,17 +17,17 @@ onAdminEnabled:由企业管理员或者员工部署MDM应用,激活设备管 ...@@ -17,17 +17,17 @@ onAdminEnabled:由企业管理员或者员工部署MDM应用,激活设备管
onAdminDisabled:由系统或者员工去激活设备管理器,通知去激活DeviceAdmin权限,应用可以通知企业管理员设备已脱管。 onAdminDisabled:由系统或者员工去激活设备管理器,通知去激活DeviceAdmin权限,应用可以通知企业管理员设备已脱管。
onBundleAdded: 企业应用管理场景下,企业管理员订阅应用安装卸载事件,端侧应用安装和卸载事件通知MDM应用,MDM应用可以在回调函数中进行事件上报,通知企业管理员。 onBundleAdded: 企业应用管理场景下,企业管理员订阅应用安装事件,端侧应用安装和卸载事件通知MDM应用,MDM应用可以在回调函数中进行事件上报,通知企业管理员。
onBundleRemoved: 企业应用管理场景下,企业管理员取消订阅应用安装卸载事件 onBundleRemoved: 企业应用管理场景下,企业管理员订阅应用卸载事件,端侧应用安装和卸载事件通知MDM应用,MDM应用可以在回调函数中进行事件上报,通知企业管理员
### 接口说明 ### 接口说明
| 类名 | 接口名称 | 描述 | | 类名 | 接口名称 | 描述 |
| :------------------------------ | ----------------------------------------- | ---------------------------- | | :------------------------------ | ----------------------------------------- | ---------------------------- |
| EnterpriseAdminExtensionAbility | onAdminEnabled(): void | 设备管理器应用激活回调方法 |
| EnterpriseAdminExtensionAbility | onAdminDisabled(): void | 设备管理器应用去激活回调方法 | | EnterpriseAdminExtensionAbility | onAdminDisabled(): void | 设备管理器应用去激活回调方法 |
| EnterpriseAdminExtensionAbility | onBundleAdded(bundleName: string): void | 应用安装回调方法 | | EnterpriseAdminExtensionAbility | onBundleAdded(bundleName: string): void | 应用安装回调方法 |
| EnterpriseAdminExtensionAbility | onAdminEnabled(): void | 设备管理器应用激活回调方法 |
| EnterpriseAdminExtensionAbility | onBundleRemoved(bundleName: string): void | 应用卸载回调方法 | | EnterpriseAdminExtensionAbility | onBundleRemoved(bundleName: string): void | 应用卸载回调方法 |
### 开发步骤 ### 开发步骤
...@@ -76,10 +76,9 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil ...@@ -76,10 +76,9 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil
## 使用示例 ## 使用示例
通过@ohos.enterprise.adminManager模块中的subscribeManagedEvent接口和unsubscribeManagedEvent接口进行企业设备管理事件的订阅,订阅应用安装、卸载事件。当订阅成功后,端侧应用安装和卸载事件通知MDM应用,MDM应用可以在回调函数中进行事件上报,通知企业管理员 通过@ohos.enterprise.adminManager模块中的subscribeManagedEvent接口进行企业设备管理事件的订阅,订阅应用安装、卸载事件。当订阅成功后,端侧应用安装和卸载事件通知MDM应用,MDM应用可以在回调函数中进行事件上报,通知企业管理员。并可以通过unsubscribeManagedEvent接口进行企业设备管理事件的去订阅
```ts ```ts
@State managedEvents: Array<adminManager.ManagedEvent> = [0,1]
@State subscribeManagedEventMsg: string = "" @State subscribeManagedEventMsg: string = ""
@State unsubscribeManagedEventMsg: string = "" @State unsubscribeManagedEventMsg: string = ""
......
...@@ -189,7 +189,7 @@ Native Drawing模块提供了一系列的接口用于基本图形和字体的绘 ...@@ -189,7 +189,7 @@ Native Drawing模块提供了一系列的接口用于基本图形和字体的绘
OH_Drawing_CreateFontCollection()); OH_Drawing_CreateFontCollection());
OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle); OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);
// 设置文字内容 // 设置文字内容
const char* text = "OpenHarmony\n"; const char* text = "Hello World\n";
OH_Drawing_TypographyHandlerAddText(handler, text); OH_Drawing_TypographyHandlerAddText(handler, text);
OH_Drawing_TypographyHandlerPopTextStyle(handler); OH_Drawing_TypographyHandlerPopTextStyle(handler);
OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler); OH_Drawing_Typography* typography = OH_Drawing_CreateTypography(handler);
......
...@@ -11,7 +11,7 @@ FA模型与Stage模型不同之处在于HAP内部文件存放位置不同,FA ...@@ -11,7 +11,7 @@ FA模型与Stage模型不同之处在于HAP内部文件存放位置不同,FA
- assets是HAP所有的资源文件、库文件和代码文件的集合,内部可以分为entry和js文件夹。entry文件夹中存放的是resources目录和resources.index文件。 - assets是HAP所有的资源文件、库文件和代码文件的集合,内部可以分为entry和js文件夹。entry文件夹中存放的是resources目录和resources.index文件。
- resources目录用于存放应用的资源文件(字符串、图片等),便于开发者使用和维护,详见[资源文件的使用](../key-features/multi-device-app-dev/resource-usage.md) - resources目录用于存放应用的资源文件(字符串、图片等),便于开发者使用和维护,详见[资源文件的使用](resource-categories-and-access.md)
- resources.index是资源索引表,由IDE调用SDK工具生成。 - resources.index是资源索引表,由IDE调用SDK工具生成。
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- 打包后的HAP结构包括ets、libs、resources等文件夹和resources.index、module.json、pack.info等文件。 - 打包后的HAP结构包括ets、libs、resources等文件夹和resources.index、module.json、pack.info等文件。
- ets目录用于存放应用代码编译后的字节码文件。 - ets目录用于存放应用代码编译后的字节码文件。
- libs目录用于存放库文件。库文件是OpenHarmony应用依赖的第三方代码(.so二进制文件)。 - libs目录用于存放库文件。库文件是OpenHarmony应用依赖的第三方代码(.so二进制文件)。
- resources目录用于存放应用的资源文件(字符串、图片等),便于开发者使用和维护,详见[资源文件的使用](../key-features/multi-device-app-dev/resource-usage.md) - resources目录用于存放应用的资源文件(字符串、图片等),便于开发者使用和维护,详见[资源文件的使用](resource-categories-and-access.md)
- resources.index是资源索引表,由IDE编译工程时生成。 - resources.index是资源索引表,由IDE编译工程时生成。
- module.json是HAP的配置文件,内容由工程配置中的module.json5和app.json5组成,该文件是HAP中必不可少的文件。IDE会自动生成一部分默认配置,开发者按需修改其中的配置。详细字段请参见[应用配置文件](application-configuration-file-overview-stage.md) - module.json是HAP的配置文件,内容由工程配置中的module.json5和app.json5组成,该文件是HAP中必不可少的文件。IDE会自动生成一部分默认配置,开发者按需修改其中的配置。详细字段请参见[应用配置文件](application-configuration-file-overview-stage.md)
- pack.info是Bundle中用于描述每个HAP属性的文件,例如app中的bundleName和versionCode信息、module中的name、type和abilities等信息,由IDE工具生成Bundle包时自动生成。 - pack.info是Bundle中用于描述每个HAP属性的文件,例如app中的bundleName和versionCode信息、module中的name、type和abilities等信息,由IDE工具生成Bundle包时自动生成。
......
...@@ -26,5 +26,5 @@ ...@@ -26,5 +26,5 @@
## 替换SDK ## 替换SDK
full-SDK编译完成后需要在DevEcoStudio替换使用,具体请参考[full-SDK替换指南](../../application-dev/quick-start/full-sdk-switch-guide.md) full-SDK编译完成后需要在DevEcoStudio替换使用,具体请参考[full-SDK替换指南](full-sdk-switch-guide.md)
...@@ -793,6 +793,105 @@ Wi-Fi P2P群组信息已更改。 ...@@ -793,6 +793,105 @@ Wi-Fi P2P群组信息已更改。
- 值:usual.event.HTTP_PROXY_CHANGE - 值:usual.event.HTTP_PROXY_CHANGE
- 订阅者所需权限:无 - 订阅者所需权限:无
## COMMON_EVENT_SIM_STATE_CHANGED<sup>10+<sup>
提示SIM卡状态更新。
- 值:usual.event.SIM_STATE_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_SMS_RECEIVED_COMPLETED<sup>10+<sup>
提示短信接收完成。
- 值:usual.event.SMS_RECEIVED_COMPLETED
- 订阅者所需权限:ohos.permission.RECEIVE_SMS
## COMMON_EVENT_SMS_EMERGENCY_CB_RECEIVE_COMPLETED<sup>10+<sup>
提示紧急小区广播短信接收完成。
- 值:usual.event.SMS_EMERGENCY_CB_RECEIVE_COMPLETED
- 订阅者所需权限:ohos.permission.RECEIVE_SMS
## COMMON_EVENT_SMS_CB_RECEIVE_COMPLETED<sup>10+<sup>
提示小区广播短信接收完成。
- 值:usual.event.SMS_CB_RECEIVE_COMPLETED
- 订阅者所需权限:ohos.permission.RECEIVE_SMS
## COMMON_EVENT_STK_COMMAND<sup>10+<sup>
(预留事件,暂未支持)提示STK命令。
- 值:usual.event.STK_COMMAND
- 订阅者所需权限:无
## COMMON_EVENT_STK_SESSION_END<sup>10+<sup>
(预留事件,暂未支持)提示STK会话结束。
- 值:usual.event.STK_SESSION_END
- 订阅者所需权限:无
## COMMON_EVENT_STK_CARD_STATE_CHANGED<sup>10+<sup>
(预留事件,暂未支持)提示STK卡状态已更新。
- 值:usual.event.STK_CARD_STATE_CHANGED
- 订阅者所需权限:ohos.permission.
## COMMON_EVENT_STK_ALPHA_IDENTIFIER<sup>10+<sup>
(预留事件,暂未支持)提示STK ALPHA标识符。
- 值:usual.event.STK_ALPHA_IDENTIFIER
- 订阅者所需权限:无
## COMMON_EVENT_SMS_WAPPUSH_RECEIVE_COMPLETED<sup>10+<sup>
提示服务信息短信接收完成。
- 值:usual.event.SMS_WAPPUSH_RECEIVE_COMPLETED
- 订阅者所需权限:ohos.permission.RECEIVE_SMS
## COMMON_EVENT_OPERATOR_CONFIG_CHANGED<sup>10+<sup>
提示运营商配置已更新。
- 值:usual.event.OPERATOR_CONFIG_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_SIM_CARD_DEFAULT_SMS_SUBSCRIPTION_CHANGED<sup>10+<sup>
提示SIM卡默认短信主卡已更新。
- 值:usual.event.DEFAULT_SMS_SUBSCRIPTION_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_SIM_CARD_DEFAULT_DATA_SUBSCRIPTION_CHANGED<sup>10+<sup>
提示SIM卡默认数据主卡已更新。
- 值:usual.event.DEFAULT_DATA_SUBSCRIPTION_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_SIM_CARD_DEFAULT_MAIN_SUBSCRIPTION_CHANGED<sup>10+<sup>
提示SIM卡默认主卡已更新。
- 值:usual.event.SIM.DEFAULT_MAIN_SUBSCRIPTION_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_SIM_CARD_DEFAULT_VOICE_SUBSCRIPTION_CHANGED<sup>10+<sup>
提示SIM卡默认语音主卡已更新。
- 值:usual.event.DEFAULT_VOICE_SUBSCRIPTION_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_CALL_STATE_CHANGED<sup>10+<sup>
提示呼叫状态更新。
- 值:usual.event.CALL_STATE_CHANGED
- 订阅者所需权限:ohos.permission.GET_TELEPHONY_STATE
## COMMON_EVENT_CELLULAR_DATA_STATE_CHANGED<sup>10+<sup>
提示蜂窝数据状态更新。
- 值:usual.event.CELLULAR_DATA_STATE_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_NETWORK_STATE_CHANGED<sup>10+<sup>
提示网络状态更新。
- 值:usual.event.NETWORK_STATE_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_SIGNAL_INFO_CHANGED<sup>10+<sup>
提示信号信息更新。
- 值:usual.event.SIGNAL_INFO_CHANGED
- 订阅者所需权限:无
## COMMON_EVENT_INCOMING_CALL_MISSED<sup>10+<sup>
提示未接来电。
- 值:usual.event.INCOMING_CALL_MISSED
- 订阅者所需权限:ohos.permission.GET_TELEPHONY_STATE
## COMMON_EVENT_RADIO_STATE_CHANGE<sup>10+<sup>
提示设备modem上下电状态变化。
- 值:usual.event.RADIO_STATE_CHANGE
## COMMON_EVENT_SCREEN_LOCKED <sup>10+<sup> ## COMMON_EVENT_SCREEN_LOCKED <sup>10+<sup>
表示屏幕锁定的公共事件。 表示屏幕锁定的公共事件。
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## BundleStatusCallback<sup>(deprecated)<sup> ## BundleStatusCallback<sup>(deprecated)<sup>
> 从API version 9开始不再支持。建议使用[bundleMonitor](js-apis-bundleMonitor.md)替代。 > 从API version 9开始不再支持。建议使用[bundleMonitor](js-apis-bundleMonitor.md)替代。
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。
......
...@@ -34,7 +34,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -34,7 +34,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -62,7 +62,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -62,7 +62,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -94,7 +94,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -94,7 +94,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -121,7 +121,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -121,7 +121,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -153,7 +153,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -153,7 +153,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -179,7 +179,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -179,7 +179,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -210,7 +210,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -210,7 +210,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -236,7 +236,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -236,7 +236,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -267,7 +267,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -267,7 +267,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -293,7 +293,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -293,7 +293,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
......
...@@ -42,7 +42,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -42,7 +42,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -71,7 +71,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -71,7 +71,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -103,7 +103,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -103,7 +103,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -132,7 +132,7 @@ SystemCapability.BundleManager.DistributedBundleFramework ...@@ -132,7 +132,7 @@ SystemCapability.BundleManager.DistributedBundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
......
...@@ -426,7 +426,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -426,7 +426,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**返回值:** **返回值:**
...@@ -462,7 +462,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -462,7 +462,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -499,7 +499,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -499,7 +499,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -540,7 +540,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -540,7 +540,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -584,7 +584,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -584,7 +584,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -626,7 +626,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -626,7 +626,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -671,7 +671,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -671,7 +671,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -699,7 +699,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -699,7 +699,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -754,7 +754,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -754,7 +754,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
...@@ -794,7 +794,7 @@ SystemCapability.BundleManager.BundleFramework ...@@ -794,7 +794,7 @@ SystemCapability.BundleManager.BundleFramework
**系统API:** **系统API:**
此接口为系统接口,三方应用不支持调用 此接口为系统接口
**参数:** **参数:**
......
...@@ -158,6 +158,12 @@ saveAppState(context?: UIAbilityContext): boolean; ...@@ -158,6 +158,12 @@ saveAppState(context?: UIAbilityContext): boolean;
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md)| 否 | UIAbility上下文环境。 |
**返回值:** **返回值:**
| 类型 | 说明 | | 类型 | 说明 |
...@@ -182,6 +188,12 @@ setRestartWant(want: Want): void; ...@@ -182,6 +188,12 @@ setRestartWant(want: Want): void;
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core **系统能力**:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-want.md)| 是 | 通过设置Want中"bundleName"和"abilityName"字段来指定恢复重启的Ability。 |
**示例:** **示例:**
```ts ```ts
......
...@@ -148,7 +148,7 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC ...@@ -148,7 +148,7 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC
## ServiceExtensionAbility.onDisconnect ## ServiceExtensionAbility.onDisconnect
onDisconnect(want: Want): void | Promise<void>; onDisconnect(want: Want): void | Promise\<void>;
Extension的生命周期回调,客户端执行断开连接服务时回调。 Extension的生命周期回调,客户端执行断开连接服务时回调。
......
...@@ -130,11 +130,11 @@ import Want from '@ohos.app.ability.Want'; ...@@ -130,11 +130,11 @@ import Want from '@ohos.app.ability.Want';
``` ```
* 文件描述符(FD) * 文件描述符(FD)
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let fd; let fd;
try { try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png'); fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd;
} catch(e) { } catch(e) {
console.error('openSync fail: ${JSON.stringify(e)}'); console.error('openSync fail: ${JSON.stringify(e)}');
} }
......
...@@ -24,7 +24,7 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\<void> ...@@ -24,7 +24,7 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\<void>
**系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl **系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -75,7 +75,7 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo ...@@ -75,7 +75,7 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\<vo
**系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl **系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -122,7 +122,7 @@ getDisposedStatus(appId: string): Promise\<Want>; ...@@ -122,7 +122,7 @@ getDisposedStatus(appId: string): Promise\<Want>;
**系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl **系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -171,7 +171,7 @@ getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void; ...@@ -171,7 +171,7 @@ getDisposedStatus(appId: string, callback: AsyncCallback\<Want>): void;
**系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl **系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -216,7 +216,7 @@ deleteDisposedStatus(appId: string): Promise\<void> ...@@ -216,7 +216,7 @@ deleteDisposedStatus(appId: string): Promise\<void>
**系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl **系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -265,7 +265,7 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void ...@@ -265,7 +265,7 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\<void>) : void
**系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl **系统能力:** SystemCapability.BundleManager.BundleFramework.AppControl
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
......
...@@ -108,10 +108,10 @@ import Want from '@ohos.application.Want'; ...@@ -108,10 +108,10 @@ import Want from '@ohos.application.Want';
``` ```
* 文件描述符(FD) * 文件描述符(FD)
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let fd; let fd;
try { try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png'); fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd;
} catch(e) { } catch(e) {
console.error('openSync fail: ${JSON.stringify(e)}'); console.error('openSync fail: ${JSON.stringify(e)}');
} }
......
...@@ -689,21 +689,19 @@ async function createTonePlayerBefore(){ ...@@ -689,21 +689,19 @@ async function createTonePlayerBefore(){
| forceType | [InterruptForceType](#interruptforcetype9) | 是 | 操作是由系统执行或是由应用程序执行。 | | forceType | [InterruptForceType](#interruptforcetype9) | 是 | 操作是由系统执行或是由应用程序执行。 |
| hintType | [InterruptHint](#interrupthint) | 是 | 中断提示。 | | hintType | [InterruptHint](#interrupthint) | 是 | 中断提示。 |
## VolumeEvent<sup>8+</sup> ## VolumeEvent<sup>9+</sup>
音量改变时,应用接收的事件。 音量改变时,应用接收的事件。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume **系统能力:** SystemCapability.Multimedia.Audio.Volume
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | | ---------- | ----------------------------------- | ---- | -------------------------------------------------------- |
| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | | volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 |
| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | | volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 |
| updateUi | boolean | 是 | 在UI中显示音量变化。 | | updateUi | boolean | 是 | 在UI中显示音量变化。 |
| volumeGroupId<sup>9+</sup> | number | 是 | 音量组id。可用于getGroupManager入参 | | volumeGroupId | number | 是 | 音量组id。可用于getGroupManager入参。<br/>此接口为系统接口。 |
| networkId<sup>9+</sup> | string | 是 | 网络id。 | | networkId | string | 是 | 网络id。<br/>此接口为系统接口。 |
## MicStateChangeEvent<sup>9+</sup> ## MicStateChangeEvent<sup>9+</sup>
...@@ -1975,12 +1973,12 @@ audioManager.isMicrophoneMute().then((value) => { ...@@ -1975,12 +1973,12 @@ audioManager.isMicrophoneMute().then((value) => {
}); });
``` ```
### on('volumeChange')<sup>(deprecated)</sup> ### on('volumeChange')<sup>9+</sup>
on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
> **说明:** > **说明:**
> 从 API version 8 开始支持,从 API version 9 开始废弃,建议使用AudioVolumeManager中的[on('volumeChange')](#onvolumechange9)替代。 > 建议使用AudioVolumeManager中的[on('volumeChange')](#onvolumechange9)替代。
监听系统音量变化事件。 监听系统音量变化事件。
...@@ -1995,7 +1993,7 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void ...@@ -1995,7 +1993,7 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'(系统音量变化事件,检测到系统音量改变时,触发该事件)。 | | type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'(系统音量变化事件,检测到系统音量改变时,触发该事件)。 |
| callback | Callback<[VolumeEvent](#volumeevent8)> | 是 | 回调方法。 | | callback | Callback<[VolumeEvent](#volumeevent9)> | 是 | 回调方法。 |
**示例:** **示例:**
...@@ -2304,7 +2302,7 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void ...@@ -2304,7 +2302,7 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'。 | | type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'。 |
| callback | Callback<[VolumeEvent](#volumeevent8)> | 是 | 回调方法。 | | callback | Callback<[VolumeEvent](#volumeevent9)> | 是 | 回调方法。 |
**错误码:** **错误码:**
...@@ -4037,6 +4035,7 @@ audioRoutingManager.off('preferOutputDeviceChangeForRendererInfo', () => { ...@@ -4037,6 +4035,7 @@ audioRoutingManager.off('preferOutputDeviceChangeForRendererInfo', () => {
| clientUid | number | 是 | 否 | 音频渲染器客户端应用程序的Uid。<br/>此接口为系统接口。 | | clientUid | number | 是 | 否 | 音频渲染器客户端应用程序的Uid。<br/>此接口为系统接口。 |
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 否 | 音频渲染器信息。 | | rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 否 | 音频渲染器信息。 |
| rendererState | [AudioState](#audiostate) | 是 | 否 | 音频状态。<br/>此接口为系统接口。| | rendererState | [AudioState](#audiostate) | 是 | 否 | 音频状态。<br/>此接口为系统接口。|
| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 否 | 音频设备描述。|
**示例:** **示例:**
...@@ -4095,6 +4094,7 @@ audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => ...@@ -4095,6 +4094,7 @@ audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) =>
| clientUid | number | 是 | 否 | 音频采集器客户端应用程序的Uid。<br/>此接口为系统接口。 | | clientUid | number | 是 | 否 | 音频采集器客户端应用程序的Uid。<br/>此接口为系统接口。 |
| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | 是 | 否 | 音频采集器信息。 | | capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | 是 | 否 | 音频采集器信息。 |
| capturerState | [AudioState](#audiostate) | 是 | 否 | 音频状态。<br/>此接口为系统接口。| | capturerState | [AudioState](#audiostate) | 是 | 否 | 音频状态。<br/>此接口为系统接口。|
| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 否 | 音频设备描述。|
**示例:** **示例:**
......
...@@ -21,7 +21,7 @@ ohos.permission.INSTALL_BUNDLE ...@@ -21,7 +21,7 @@ ohos.permission.INSTALL_BUNDLE
SystemCapability.BundleManager.BundleFramework SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -71,7 +71,7 @@ ohos.permission.INSTALL_BUNDLE ...@@ -71,7 +71,7 @@ ohos.permission.INSTALL_BUNDLE
SystemCapability.BundleManager.BundleFramework SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -120,7 +120,7 @@ ohos.permission.INSTALL_BUNDLE ...@@ -120,7 +120,7 @@ ohos.permission.INSTALL_BUNDLE
SystemCapability.BundleManager.BundleFramework SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -161,7 +161,7 @@ bundle.getBundleInstaller().then(installer => { ...@@ -161,7 +161,7 @@ bundle.getBundleInstaller().then(installer => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | ------- | ---- | ---- | ------------------ | | ----------- | ------- | ---- | ---- | ------------------ |
...@@ -175,7 +175,7 @@ bundle.getBundleInstaller().then(installer => { ...@@ -175,7 +175,7 @@ bundle.getBundleInstaller().then(installer => {
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ | | ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ |
......
...@@ -11,7 +11,7 @@ LauncherAbilityInfo信息,通过接口[innerBundleManager.getLauncherAbilityIn ...@@ -11,7 +11,7 @@ LauncherAbilityInfo信息,通过接口[innerBundleManager.getLauncherAbilityIn
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口。
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ---- | -------------------------------------- | | --------------- | ---------------------------------------------------- | ---- | ---- | -------------------------------------- |
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ------ | ---- | ---- | -------------- | | -------------- | ------ | ---- | ---- | -------------- |
......
...@@ -14,7 +14,7 @@ remoteAbility信息。 ...@@ -14,7 +14,7 @@ remoteAbility信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.DistributedBundleFramework **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.DistributedBundleFramework
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | -------------------------------------------- | ---- | ---- | ----------------------- | | ----------- | -------------------------------------------- | ---- | ---- | ----------------------- |
......
# BundlePackInfo # BundlePackInfo
此接口为系统
> **说明:** > **说明:**
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
## ApiVersion ## ApiVersion
**系统接口:** 系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall **系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
......
# BusinessAbilityInfo
> **说明:**
> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
包含基本业务路由信息。
## BusinessAbilityInfo
**系统能力**: SystemCapability.BundleManager.BundleFramework.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | -------------------- |
| bundleName | string | 是 | 否 | 表示应用程序的bundleName。 |
| moduleName | string | 是 | 否 | 表示应用程序的moduleName。 |
| name | string | 是 | 否 | 业务路由ability名。 |
| labelId | number | 是 | 否 | 模块标签的资源id。 |
| descriptionId | number | 是 | 否 | 描述信息的资源id。 |
| iconId | number | 是 | 否 | 描述ability信息的图标id。 |
| businessType | [businessAbilityRouter.BusinessType](js-apis-businessAbilityRouter.md#businesstype) | 是 | 否 | 标识枚举业务类型。 |
| applicationInfo | Array\<[ApplicationInfo](js-apis-bundleManager-applicationInfo.md)> | 是 | 否 | 应用程序的信息。 |
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher。 **系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher。
**系统:** 系统接口,三方应用不支持调用 **系统:** 此接口为系统接口
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ----------------------------------------------------------- | ---- | ---- | ------------------------------------ | | --------------- | ----------------------------------------------------------- | ---- | ---- | ------------------------------------ |
......
...@@ -48,7 +48,7 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -48,7 +48,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用 **系统接口:** 此接口为系统接口
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ------------------------------------------------------------ |
...@@ -63,7 +63,7 @@ Ability组件信息标志,指示需要获取的Ability组件信息的内容。 ...@@ -63,7 +63,7 @@ Ability组件信息标志,指示需要获取的Ability组件信息的内容。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用 **系统接口:** 此接口为系统接口
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| --------------------------------- | ---------- | ------------------------------------------------------------ | | --------------------------------- | ---------- | ------------------------------------------------------------ |
...@@ -80,7 +80,7 @@ Ability组件信息标志,指示需要获取的Ability组件信息的内容。 ...@@ -80,7 +80,7 @@ Ability组件信息标志,指示需要获取的Ability组件信息的内容。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 系统接口,不支持三方应用调用 **系统接口:** 此接口为系统接口
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| ------------------------------------------- | ---------- | ------------------------------------------------------------ | | ------------------------------------------- | ---------- | ------------------------------------------------------------ |
......
...@@ -24,7 +24,7 @@ import bundleMonitor from '@ohos.bundle.bundleMonitor'; ...@@ -24,7 +24,7 @@ import bundleMonitor from '@ohos.bundle.bundleMonitor';
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| ---------- | ------ | ---- | ---- | -------------------------- | | ---------- | ------ | ---- | ---- | -------------------------- |
...@@ -39,7 +39,7 @@ on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void; ...@@ -39,7 +39,7 @@ on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
**需要权限:** ohos.permission.LISTEN_BUNDLE_CHANGE **需要权限:** ohos.permission.LISTEN_BUNDLE_CHANGE
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
...@@ -72,7 +72,7 @@ off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void; ...@@ -72,7 +72,7 @@ off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void;
**需要权限:** ohos.permission.LISTEN_BUNDLE_CHANGE **需要权限:** ohos.permission.LISTEN_BUNDLE_CHANGE
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
......
# @ohos.app.businessAbilityRouter (业务路由模块)
本模块用于查询当前设备上安装的各种应用程序的路由ability信息。通过业务路由提供标准的业务模板和业务管理能力,开发者可以按照指定的业务类别注册标准业务,丰富的业务形成一个庞大的超市。系统应用或者三方应用可以从业务路由中获取所需业务,并选择合适的业务使用。同时业务路由提供统一的跳转管控规则,控制应用与业务之间的合理跳转,杜绝前后台任意的跳转行为,避免三方应用通过跳转变相分发,解决安全弱、体验差的问题。
> **说明:**
>
> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
本模块接口为系统接口。
## 导入模块
``` ts
import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
```
## 权限列表
| 权限 | 权限等级 | 描述 |
| ------------------------------------------ | ------------ | -------------------- |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息。 |
权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)
## BusinessType
此枚举值用于标识过滤条件类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。
**系统接口:** 此接口为系统接口。
| 名称 | 值 | 说明 |
| ----------- | ---- | ------------------------------------ |
| SHARE | 0 | 标识具有共享类型的ability信息。 |
| UNSPECIFIED | 255 | 标识未指定类型的ability信息。 |
## BusinessAbilityFilter
此过滤值用于过滤查询的ability类型。
**系统能力:** SystemCapability.BundleManager.BundleFrameWork.FreeInstall
**系统接口:** 此接口为系统接口。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------------ | ------------ | ---- | ---- | -------------------------------------- |
| businessType | BusinessType | 是 | 否 | 标识ability信息的类型。 |
| mimeType | string | 是 | 否 | 标识支持mime类型的ability信息。 |
| uri | string | 是 | 否 | 标识ability信息支持的uri。 |
## businessAbilityRouter.queryBusinessAbilityInfo
queryBusinessAbilityInfo(filter: BusinessAbilityFilter, callback: AsyncCallback\<Array\<BusinessAbilityInfo\>\>): void;
以异步方法通过给定的过滤条件查询ability信息。使用callback异步回调。成功返回查询到的路由ability信息,失败返回对应错误信息。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统API:** 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | --------------------------------------- |
| filter | [BusinessAbilityFilter](#businessabilityfilter) | 是 | 支持按业务类型过滤的对象。 |
| callback | AsyncCallback\<Array\<[BusinessAbilityInfo](js-apis-bundleManager-businessAbilityInfo.md#businessabilityinfo)\>\> | 是 | 回调函数。返回查询到的ability信息,否则为错误对象。 |
**示例:**
```ts
import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
let filter = {businessType: businessAbilityRouter.BusinessType.SHARE};
try {
businessAbilityRouter.queryBusinessAbilityInfo(filter)
.then(() => {
console.info('queryBusinessAbilityInfo success');
}).catch((error) => {
console.error('queryBusinessAbilityInfo failed ' + error.message);
});
} catch (error) {
console.error('queryBusinessAbilityInfo failed ' + error.message);
}
```
## businessAbilityRouter.queryBusinessAbilityInfo
queryBusinessAbilityInfo(filter: BusinessAbilityFilter): Promise\<Array\<BusinessAbilityInfo\>\>;
以异步方法通过给定的过滤条件查询ability信息。使用Promise异步回调,成功返回查询到的路由ability信息,失败返回对应错误信息。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统API:** 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------------- | ---- | --------------------------------------- |
| filter | [BusinessAbilityFilter](#businessabilityfilter) | 是 | 包含要查询的ability信息的筛选类型。 |
**返回值:**
| 类型 | 说明 |
| ------------------------------------------------------------ | ------------------------------------------- |
| Promise\<Array\<[BusinessAbilityInfo](js-apis-bundleManager-businessAbilityInfo.md#businessabilityinfo)\>\> | Promise对象,返回符合过滤条件的ability信息。 |
**示例:**
```ts
import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
let filter = {businessType: businessAbilityRouter.BusinessType.SHARE};
try {
businessAbilityRouter.queryBusinessAbilityInfo(filter, (error, data) => {
if (error) {
console.error('queryBusinessAbilityInfo failed ' + error.message);
return;
}
console.info('queryBusinessAbilityInfo success');
});
} catch (error) {
console.error('queryBusinessAbilityInfo failed ' + error.message);
}
```
...@@ -109,7 +109,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo> ...@@ -109,7 +109,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo>
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -165,7 +165,7 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun ...@@ -165,7 +165,7 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -217,7 +217,7 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void ...@@ -217,7 +217,7 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -266,7 +266,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): ...@@ -266,7 +266,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number):
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -338,7 +338,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca ...@@ -338,7 +338,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -399,7 +399,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal ...@@ -399,7 +399,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -458,7 +458,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void> ...@@ -458,7 +458,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void>
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -508,7 +508,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v ...@@ -508,7 +508,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -559,7 +559,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void; ...@@ -559,7 +559,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void;
**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
......
...@@ -291,6 +291,63 @@ try { ...@@ -291,6 +291,63 @@ try {
} }
``` ```
## display.on('privateModeChange')<sup>10+</sup>
on(type: 'privateModeChange', callback: Callback&lt;boolean&gt;): void
开启屏幕隐私模式变化的监听。当屏幕前台有隐私窗口,则屏幕处于隐私模式,屏幕中的隐私窗口内容无法被截屏或录屏。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| type | string | 是 | 监听事件,固定为'privateModeChange',表示屏幕隐私模式状态发生变化。 |
| callback | Callback&lt;boolean&gt; | 是 | 回调函数。表示屏幕隐私模式是否改变。true表示屏幕由非隐私窗口模式变为隐私模式,false表示屏幕由隐私模式变为非隐私模式。 |
**示例:**
```js
let callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data));
};
try {
display.on("privateModeChange", callback);
} catch (exception) {
console.error('Failed to register callback. Code: ' + JSON.stringify(exception));
}
```
## display.off('privateModeChange')<sup>10+</sup>
off(type: 'privateModeChange', callback?: Callback&lt;boolean&gt;): void
关闭屏幕隐私模式变化的监听。当屏幕前台有隐私窗口,则屏幕处于隐私模式,屏幕中的隐私窗口内容无法被截屏或录屏。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- |------------------------------------------| ---- | ------------------------------------------------------- |
| type | string | 是 | 监听事件,固定为'privateModeChange',表示屏幕隐私模式状态发生变化。 |
| callback | Callback&lt;boolean&gt; | 否 | 回调函数。表示屏幕隐私模式是否改变。true表示屏幕由非隐私模式变为隐私模式,false表示屏幕由隐私模式变为非隐私模式。 |
**示例:**
```js
try {
display.off("privateModeChange");
} catch (exception) {
console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception));
}
```
## display.getDefaultDisplay<sup>(deprecated)</sup> ## display.getDefaultDisplay<sup>(deprecated)</sup>
getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void
......
...@@ -79,7 +79,7 @@ image.createPixelMap(color, opts, (error, pixelmap) => { ...@@ -79,7 +79,7 @@ image.createPixelMap(color, opts, (error, pixelmap) => {
## PixelMap<sup>7+</sup> ## PixelMap<sup>7+</sup>
图像像素类,用于读取或写入图像数据以及获取图像信息。在调用PixelMap的方法前,需要先通过createPixelMap创建一个PixelMap实例。 图像像素类,用于读取或写入图像数据以及获取图像信息。在调用PixelMap的方法前,需要先通过createPixelMap创建一个PixelMap实例。目前pixelmap序列化大小最大128MB,超过会送显失败。大小计算方式为(宽\*\*每像素占用字节数)。
### 属性 ### 属性
......
...@@ -41,12 +41,12 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传 ...@@ -41,12 +41,12 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
- 传递FD(文件描述符)数据(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象) - 传递FD(文件描述符)数据(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象)
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
// ... // ...
let fd; let fd;
try { try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png'); fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd;
} catch(e) { } catch(e) {
console.error('openSync fail: ${JSON.stringify(e)}'); console.error('openSync fail: ${JSON.stringify(e)}');
} }
......
...@@ -88,7 +88,7 @@ export default class EntryAbility extends UIAbility { ...@@ -88,7 +88,7 @@ export default class EntryAbility extends UIAbility {
} }
``` ```
## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback<void>) ## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback\<void>)
off(type: 'abilityLifecycle', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; off(type: 'abilityLifecycle', callbackId: **number**, callback: AsyncCallback<**void**>): **void**;
...@@ -206,7 +206,7 @@ export default class EntryAbility extends UIAbility { ...@@ -206,7 +206,7 @@ export default class EntryAbility extends UIAbility {
} }
``` ```
## ApplicationContext.off(type: 'environment', callbackId: number, callback: AsyncCallback<void>) ## ApplicationContext.off(type: 'environment', callbackId: number, callback: AsyncCallback\<void>)
off(type: 'environment', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; off(type: 'environment', callbackId: **number**, callback: AsyncCallback<**void**>): **void**;
......
...@@ -56,7 +56,7 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void; ...@@ -56,7 +56,7 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
| 16000009 | Can not start ability in wukong mode. | | 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. | | 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. | | 16000011 | Context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000051 | Network error. The network is abnormal. | | 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall | | 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. | | 16000053 | Not top ability. The application is not top ability. |
...@@ -128,7 +128,7 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>; ...@@ -128,7 +128,7 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>;
| 16000009 | Can not start ability in wukong mode. | | 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. | | 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. | | 16000011 | Context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000051 | Network error. The network is abnormal. | | 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall | | 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. | | 16000053 | Not top ability. The application is not top ability. |
...@@ -198,7 +198,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void& ...@@ -198,7 +198,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&
| 16000009 | Can not start ability in wukong mode. | | 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. | | 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. | | 16000011 | Context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000051 | Network error. The network is abnormal. | | 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall | | 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. | | 16000053 | Not top ability. The application is not top ability. |
...@@ -275,7 +275,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< ...@@ -275,7 +275,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
| 16000009 | Can not start ability in wukong mode. | | 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. | | 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. | | 16000011 | Context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000051 | Network error. The network is abnormal. | | 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall | | 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. | | 16000053 | Not top ability. The application is not top ability. |
...@@ -351,7 +351,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca ...@@ -351,7 +351,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
| 16000009 | Can not start ability in wukong mode. | | 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. | | 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. | | 16000011 | Context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000051 | Network error. The network is abnormal. | | 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall | | 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. | | 16000053 | Not top ability. The application is not top ability. |
...@@ -436,7 +436,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): ...@@ -436,7 +436,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
| 16000009 | Can not start ability in wukong mode. | | 16000009 | Can not start ability in wukong mode. |
| 16000010 | Can not operation with continue flag. | | 16000010 | Can not operation with continue flag. |
| 16000011 | Context does not exist. | | 16000011 | Context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000051 | Network error. The network is abnormal. | | 16000051 | Network error. The network is abnormal. |
| 16000052 | Free install not support. The application does not support freeinstall | | 16000052 | Free install not support. The application does not support freeinstall |
| 16000053 | Not top ability. The application is not top ability. | | 16000053 | Not top ability. The application is not top ability. |
...@@ -1330,7 +1330,7 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;; ...@@ -1330,7 +1330,7 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;;
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | | 16000007 | Service busyness. There are concurrent tasks, waiting for retry. |
| 16000008 | Crowdtest App Expiration. | | 16000008 | Crowdtest App Expiration. |
| 16000009 | Can not start ability in wukong mode. | | 16000009 | Can not start ability in wukong mode. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal Error. | | 16000050 | Internal Error. |
**示例:** **示例:**
......
...@@ -54,7 +54,7 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void; ...@@ -54,7 +54,7 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -118,7 +118,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void& ...@@ -118,7 +118,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -191,7 +191,7 @@ startAbility(want: Want, options?: StartOptions): Promise&lt;void&gt;; ...@@ -191,7 +191,7 @@ startAbility(want: Want, options?: StartOptions): Promise&lt;void&gt;;
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -260,7 +260,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback&lt;AbilityResult&gt;): ...@@ -260,7 +260,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback&lt;AbilityResult&gt;):
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -328,7 +328,7 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback ...@@ -328,7 +328,7 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -406,7 +406,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise&lt;AbilityRes ...@@ -406,7 +406,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise&lt;AbilityRes
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -477,7 +477,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC ...@@ -477,7 +477,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -549,7 +549,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp ...@@ -549,7 +549,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -629,7 +629,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO ...@@ -629,7 +629,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -1584,7 +1584,7 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;; ...@@ -1584,7 +1584,7 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;;
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -1691,7 +1691,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< ...@@ -1691,7 +1691,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -1763,7 +1763,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca ...@@ -1763,7 +1763,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
...@@ -1837,7 +1837,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): ...@@ -1837,7 +1837,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
| 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. | | 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. | | 16000011 | The context does not exist. |
| 16000012 | The previous ability is starting, wait start later. | | 16000017 | The previous ability is starting, wait start later. |
| 16000050 | Internal error. | | 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. | | 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. | | 16000055 | Installation-free timed out. |
......
...@@ -25,7 +25,7 @@ getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void; ...@@ -25,7 +25,7 @@ getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void;
获取BundleInstaller对象,使用callback形式返回结果。 获取BundleInstaller对象,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
...@@ -59,7 +59,7 @@ getBundleInstaller(): Promise\<BundleInstaller>; ...@@ -59,7 +59,7 @@ getBundleInstaller(): Promise\<BundleInstaller>;
获取BundleInstaller对象,使用callback形式返回结果。 获取BundleInstaller对象,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
...@@ -89,7 +89,7 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback: ...@@ -89,7 +89,7 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
以异步方法安装应用,使用callback形式返回结果。 以异步方法安装应用,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.INSTALL_BUNDLE **需要权限:** ohos.permission.INSTALL_BUNDLE
...@@ -120,6 +120,7 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback: ...@@ -120,6 +120,7 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. | | 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. |
| 17700036 | Failed to install the HSP because lacks appropriate permissions. | | 17700036 | Failed to install the HSP because lacks appropriate permissions. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. | | 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
**示例:** **示例:**
...@@ -149,13 +150,84 @@ try { ...@@ -149,13 +150,84 @@ try {
} }
``` ```
## BundleInstaller.install
install(hapFilePaths: Array\<string\>, installParam?: InstallParam) : Promise\<void\>;
以异步方法安装应用,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.INSTALL_BUNDLE
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
| hapFilePaths | Array\<string\> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP,且这些HAP的签名需要保持一致。 |
| installParam | [InstallParam](#installparam) | 否 | 指定安装所需的其他参数。 |
**返回值:**
| 类型 | 说明 |
| --------------- | -------------------------------------- |
| Promise\<void\> | Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700004 | The specified user ID is not found. |
| 17700010 | Failed to install the HAP because the HAP fails to be parsed. |
| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. |
| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. |
| 17700015 | Failed to install the HAPs because they have different configuration information. |
| 17700016 | Failed to install the HAP because of insufficient system disk space. |
| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. |
| 17700018 | Failed to install because the dependent module does not exist. |
| 17700031 | Failed to install the HAP because the overlay check of the HAP is failed. |
| 17700036 | Failed to install the HSP because lacks appropriate permissions. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
**示例:**
```ts
import installer from '@ohos.bundle.installer';
let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/'];
let installParam = {
userId: 100,
isKeepData: false,
installFlag: 1,
};
try {
installer.getBundleInstaller().then(data => {
data.install(hapFilePaths, installParam)
.then((data) => {
console.info('install success: ' + JSON.stringify(data));
}).catch((error) => {
console.error('install failed:' + err.message);
});
}).catch(error => {
console.error('getBundleInstaller failed. Cause: ' + error.message);
});
} catch (error) {
console.error('getBundleInstaller failed. Cause: ' + error.message);
}
```
## BundleInstaller.uninstall ## BundleInstaller.uninstall
uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallback&lt;void&gt;): void; uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallback&lt;void&gt;): void;
以异步方法卸载应用,使用callback形式返回结果。 以异步方法卸载应用,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.INSTALL_BUNDLE **需要权限:** ohos.permission.INSTALL_BUNDLE
...@@ -213,7 +285,7 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi ...@@ -213,7 +285,7 @@ uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void>) : voi
以异步方法卸载一个共享包,使用callback形式返回结果。 以异步方法卸载一个共享包,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.INSTALL_BUNDLE **需要权限:** ohos.permission.INSTALL_BUNDLE
...@@ -267,7 +339,7 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>; ...@@ -267,7 +339,7 @@ uninstall(uninstallParam: UninstallParam) : Promise\<void>;
以异步方法卸载一个共享包,使用Promise形式返回结果。 以异步方法卸载一个共享包,使用Promise形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.INSTALL_BUNDLE **需要权限:** ohos.permission.INSTALL_BUNDLE
...@@ -326,7 +398,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback& ...@@ -326,7 +398,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback&
以异步方法回滚应用,使用callback形式返回结果。 以异步方法回滚应用,使用callback形式返回结果。
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
**需要权限:** ohos.permission.INSTALL_BUNDLE **需要权限:** ohos.permission.INSTALL_BUNDLE
...@@ -382,7 +454,7 @@ try { ...@@ -382,7 +454,7 @@ try {
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---------------- | ---------------- | | ---------- | ------ | ---------------- | ---------------- |
...@@ -395,7 +467,7 @@ try { ...@@ -395,7 +467,7 @@ try {
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------------------------------ | ------------------------------ | ------------------ | ------------------ | | ------------------------------ | ------------------------------ | ------------------ | ------------------ |
...@@ -412,7 +484,7 @@ try { ...@@ -412,7 +484,7 @@ try {
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core **系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统接口:** 此接口为系统接口,三方应用不支持调用 **系统接口:** 此接口为系统接口
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ------------------------------------------------------------ | | ----------- | ------ | ---- | ------------------------------------------------------------ |
......
...@@ -64,7 +64,7 @@ openNfc(): boolean ...@@ -64,7 +64,7 @@ openNfc(): boolean
## controller.enableNfc<sup>9+</sup> ## controller.enableNfc<sup>9+</sup>
enableNfc(): boolean enableNfc(): void
打开NFC开关。 打开NFC开关。
...@@ -101,7 +101,7 @@ closeNfc(): boolean ...@@ -101,7 +101,7 @@ closeNfc(): boolean
## controller.disableNfc<sup>9+</sup> ## controller.disableNfc<sup>9+</sup>
disableNfc(): boolean disableNfc(): void
关闭NFC开关。 关闭NFC开关。
......
...@@ -114,7 +114,7 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b ...@@ -114,7 +114,7 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -170,7 +170,7 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b ...@@ -170,7 +170,7 @@ setOverlayEnabledByBundleName(bundleName:string, moduleName:string, isEnabled: b
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -394,7 +394,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promi ...@@ -394,7 +394,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName?: string): Promi
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -446,7 +446,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callbac ...@@ -446,7 +446,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, moduleName: string, callbac
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -496,7 +496,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\<Ar ...@@ -496,7 +496,7 @@ getOverlayModuleInfoByBundleName(bundleName: string, callback: AsyncCallback\<Ar
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -544,7 +544,7 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: s ...@@ -544,7 +544,7 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName?: s
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -596,7 +596,7 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: st ...@@ -596,7 +596,7 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, moduleName: st
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
...@@ -646,7 +646,7 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: Asyn ...@@ -646,7 +646,7 @@ getTargetOverlayModuleInfosByBundleName(targetBundleName: string, callback: Asyn
**系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay **系统能力:** SystemCapability.BundleManager.BundleFramework.Overlay
**系统API:** 此接口为系统接口,三方应用不支持调用 **系统API:** 此接口为系统接口
**参数:** **参数:**
......
...@@ -376,11 +376,11 @@ let record = pasteboard.createUriRecord('dataability:///com.example.myapplicatio ...@@ -376,11 +376,11 @@ let record = pasteboard.createUriRecord('dataability:///com.example.myapplicatio
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- |--------------------------------------------------------------------------------------------| | -------- | -------- | -------- | -------- |--------------------------------------------------------------------------------------------|
| additions<sup>7+</sup> | {[key:string]:object} | 是 | 是 | 设置的其他附加属性数据。 | | additions<sup>7+</sup> | {[key:string]:object} | 是 | 是 | 设置的其他附加属性数据, 暂不支持。 |
| mimeTypes<sup>7+</sup> | Array&lt;string&gt; | 是 | 否 | 剪贴板内容条目的数据类型,非重复的类型列表。 | | mimeTypes<sup>7+</sup> | Array&lt;string&gt; | 是 | 否 | 剪贴板内容条目的数据类型,非重复的类型列表。 |
| tag<sup>7+</sup> | string | 是 | 是 | 用户自定义标签。 | | tag<sup>7+</sup> | string | 是 | 是 | 用户自定义标签, 暂不支持。 |
| timestamp<sup>7+</sup> | number | 是 | 否 | 剪贴板数据的写入时间戳(单位:ms)。 | | timestamp<sup>7+</sup> | number | 是 | 否 | 剪贴板数据的写入时间戳(单位:ms)。 |
| localOnly<sup>7+</sup> | boolean | 是 | 是 | 配置剪贴板内容是否为“仅在本地”。默认值为true<br/>- 配置为true时,表示内容仅在本地,不会在设备之间传递。<br/>- 配置为false时,表示内容将在设备间传递。 | | localOnly<sup>7+</sup> | boolean | 是 | 是 | 配置剪贴板内容是否为“仅在本地”, 默认值为true。暂不支持, 推荐使用shareOption属性<br/>- 配置为true时,表示内容仅在本地,不会在设备之间传递。<br/>- 配置为false时,表示内容将在设备间传递。 |
| shareOption<sup>9+</sup> | [ShareOption](#shareoption9) | 是 | 是 | 指示剪贴板数据可以粘贴到的范围,如果未设置或设置不正确,则默认值为CROSSDEVICE。 | | shareOption<sup>9+</sup> | [ShareOption](#shareoption9) | 是 | 是 | 指示剪贴板数据可以粘贴到的范围,如果未设置或设置不正确,则默认值为CROSSDEVICE。 |
## PasteDataRecord<sup>7+</sup> ## PasteDataRecord<sup>7+</sup>
......
...@@ -183,8 +183,6 @@ isTagConnected(): boolean ...@@ -183,8 +183,6 @@ isTagConnected(): boolean
> **说明:** > **说明:**
> 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.isConnected](#tagsessionisconnected9)替代。 > 从 API version 7 开始支持,从 API version 9 开始废弃,建议使用[tagSession.isConnected](#tagsessionisconnected9)替代。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
...@@ -211,8 +209,6 @@ isConnected(): boolean ...@@ -211,8 +209,6 @@ isConnected(): boolean
检查是否已与标签建立连接。 检查是否已与标签建立连接。
**需要权限:** ohos.permission.NFC_TAG
**系统能力:** SystemCapability.Communication.NFC.Tag **系统能力:** SystemCapability.Communication.NFC.Tag
**返回值:** **返回值:**
......
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
- [背景模糊设置](ts-universal-attributes-backgroundBlurStyle.md) - [背景模糊设置](ts-universal-attributes-backgroundBlurStyle.md)
- [分布式迁移标识](ts-universal-attributes-restoreId.md) - [分布式迁移标识](ts-universal-attributes-restoreId.md)
- [前景色设置](ts-universal-attributes-foreground-color.md) - [前景色设置](ts-universal-attributes-foreground-color.md)
- [图像球面效果设置](ts-universal-attributes-sphericalEffect.md)
- [图像渐亮效果设置](ts-universal-attributes-lightUpEffect.md)
- [图像像素扩展效果设置](ts-universal-attributes-pixelStretchEffect.md)
- [文本通用属性](ts-universal-attributes-text-style.md) - [文本通用属性](ts-universal-attributes-text-style.md)
- 手势处理 - 手势处理
- [绑定手势方法](ts-gesture-settings.md) - [绑定手势方法](ts-gesture-settings.md)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
> **说明:** > **说明:**
> >
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
> 使用该组件时请设置高度值。
## 子组件 ## 子组件
......
...@@ -20,8 +20,8 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex ...@@ -20,8 +20,8 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ----------------------- | ---------------------------------------- | ---- | -------------- | | ----------------------- | ---------------------------------------- | ---- | -------------- |
| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本,输入内容后,提示文本不显示。 | | placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。输入内容后,提示文本不显示。 |
| text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。 | | text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。</br>当组件设置[stateStyles](ts-universal-attributes-polymorphic-style.md)等刷新属性时,建议通过onChange事件将状态变量与文本实时绑定,</br>避免组件刷新时TextArea中的文本内容异常。 |
| controller<sup>8+</sup> | [TextAreaController](#textareacontroller8) | 否 | 设置TextArea控制器。 | | controller<sup>8+</sup> | [TextAreaController](#textareacontroller8) | 否 | 设置TextArea控制器。 |
...@@ -102,6 +102,7 @@ struct TextAreaExample { ...@@ -102,6 +102,7 @@ struct TextAreaExample {
build() { build() {
Column() { Column() {
TextArea({ TextArea({
text: this.text,
placeholder: 'The text area can hold an unlimited amount of text. input your word...', placeholder: 'The text area can hold an unlimited amount of text. input your word...',
controller: this.controller controller: this.controller
}) })
......
...@@ -21,7 +21,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te ...@@ -21,7 +21,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ----------------------- | ---------------------------------------- | ---- | --------------- | | ----------------------- | ---------------------------------------- | ---- | --------------- |
| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。 | | placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。 |
| text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。 | | text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。</br>当组件设置[stateStyles](ts-universal-attributes-polymorphic-style.md)等刷新属性时,建议通过onChange事件将状态变量与文本实时绑定,</br>避免组件刷新时TextInput中的文本内容异常。 |
| controller<sup>8+</sup> | [TextInputController](#textinputcontroller8) | 否 | 设置TextInput控制器。 | | controller<sup>8+</sup> | [TextInputController](#textinputcontroller8) | 否 | 设置TextInput控制器。 |
...@@ -135,7 +135,7 @@ struct TextInputExample { ...@@ -135,7 +135,7 @@ struct TextInputExample {
build() { build() {
Column() { Column() {
TextInput({ placeholder: 'input your word...', controller: this.controller }) TextInput({ text: this.text, placeholder: 'input your word...', controller: this.controller })
.placeholderColor(Color.Grey) .placeholderColor(Color.Grey)
.placeholderFont({ size: 14, weight: 400 }) .placeholderFont({ size: 14, weight: 400 })
.caretColor(Color.Blue) .caretColor(Color.Blue)
......
...@@ -1232,7 +1232,7 @@ struct WebComponent { ...@@ -1232,7 +1232,7 @@ struct WebComponent {
} }
``` ```
### allowWindowOpenMethod<sup>9+</sup> ### allowWindowOpenMethod<sup>10+</sup>
allowWindowOpenMethod(flag: boolean) allowWindowOpenMethod(flag: boolean)
...@@ -2080,11 +2080,12 @@ onScaleChange(callback: (event: {oldScale: number, newScale: number}) => void) ...@@ -2080,11 +2080,12 @@ onScaleChange(callback: (event: {oldScale: number, newScale: number}) => void)
} }
``` ```
### onUrlLoadIntercept ### onUrlLoadIntercept<sup>(deprecated)</sup>
onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => boolean) onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => boolean)
当Web组件加载url之前触发该回调,用于判断是否阻止此次访问。默认允许加载。 当Web组件加载url之前触发该回调,用于判断是否阻止此次访问。默认允许加载。
从API version 10开始不在维护,建议使用[onLoadIntercept<sup>10+</sup>](#onloadintercept10)代替。
**参数:** **参数:**
...@@ -3100,7 +3101,7 @@ onAudioStateChanged(callback: (event: { playing: boolean }) => void) ...@@ -3100,7 +3101,7 @@ onAudioStateChanged(callback: (event: { playing: boolean }) => void)
### onLoadIntercept<sup>10+</sup> ### onLoadIntercept<sup>10+</sup>
onLoadIntercept(callback: (event?: { request: WebResourceRequest }) => boolean) onLoadIntercept(callback: (event?: { data: WebResourceRequest }) => boolean)
当Web组件加载url之前触发该回调,用于判断是否阻止此次访问。默认允许加载。 当Web组件加载url之前触发该回调,用于判断是否阻止此次访问。默认允许加载。
...@@ -3130,11 +3131,11 @@ onLoadIntercept(callback: (event?: { request: WebResourceRequest }) => boolean) ...@@ -3130,11 +3131,11 @@ onLoadIntercept(callback: (event?: { request: WebResourceRequest }) => boolean)
build() { build() {
Column() { Column() {
Web({ src: 'www.example.com', controller: this.controller }) Web({ src: 'www.example.com', controller: this.controller })
.onUrlLoadIntercept((event) => { .onLoadIntercept((event) => {
console.log('url:' + event.request.getRequestUrl()) console.log('url:' + event.data.getRequestUrl())
console.log('isMainFrame:' + event.request.isMainFrame()) console.log('isMainFrame:' + event.data.isMainFrame())
console.log('isRedirect:' + event.request.isRedirect()) console.log('isRedirect:' + event.data.isRedirect())
console.log('isRequestGesture:' + event.request.isRequestGesture()) console.log('isRequestGesture:' + event.data.isRequestGesture())
return true return true
}) })
} }
...@@ -3340,6 +3341,18 @@ isRequestGesture(): boolean ...@@ -3340,6 +3341,18 @@ isRequestGesture(): boolean
| ------- | -------------------- | | ------- | -------------------- |
| boolean | 返回资源请求是否与手势(如点击)相关联。 | | boolean | 返回资源请求是否与手势(如点击)相关联。 |
### getRequestMethod<sup>9+</sup>
getRequestMethod(): string
获取请求方法。
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| string | 返回请求方法。 |
## Header ## Header
Web组件返回的请求/响应头对象。 Web组件返回的请求/响应头对象。
......
...@@ -29,6 +29,8 @@ ColumnSplit() ...@@ -29,6 +29,8 @@ ColumnSplit()
> 与RowSplit相同,ColumnSplit的分割线最小能拖动到刚好包含子组件。 > 与RowSplit相同,ColumnSplit的分割线最小能拖动到刚好包含子组件。
> >
> 在真机中查看拖动效果,预览器中不支持拖动。 > 在真机中查看拖动效果,预览器中不支持拖动。
>
> 不支持clip、margin通用属性。
## 示例 ## 示例
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
> if/else/ForEach/LazyForEach发生变化以后,会更新子节点索引值。 > if/else/ForEach/LazyForEach发生变化以后,会更新子节点索引值。
> >
> Grid子组件的visibility属性设置为Hidden或None时依然会计算索引值。 > Grid子组件的visibility属性设置为Hidden或None时依然会计算索引值。
>
> Grid子组件的visibility属性设置为None时不显示,但依然会占用子组件对应的网格。
## 接口 ## 接口
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
> ListItemGroup作为一个整体计算一个索引值,ListItemGroup内部的ListItem不计算索引值。 > ListItemGroup作为一个整体计算一个索引值,ListItemGroup内部的ListItem不计算索引值。
> >
> List子组件visibility属性设置为Hidden或None依然会计算索引值。 > List子组件visibility属性设置为Hidden或None依然会计算索引值。
>
> List子组件的visibility属性设置为None时不显示,但该子组件上下的space还会生效。
## 接口 ## 接口
......
...@@ -26,7 +26,7 @@ ListItem(value?: string) ...@@ -26,7 +26,7 @@ ListItem(value?: string)
| -------- | -------- | -------- | | -------- | -------- | -------- |
| sticky<sup>(deprecated)</sup> | [Sticky](#stickydeprecated枚举说明) | 设置ListItem吸顶效果。<br/>默认值:Sticky.None<br/>从API version9开始废弃,推荐使用[List组件sticky属性](ts-container-list.md#属性)。 | | sticky<sup>(deprecated)</sup> | [Sticky](#stickydeprecated枚举说明) | 设置ListItem吸顶效果。<br/>默认值:Sticky.None<br/>从API version9开始废弃,推荐使用[List组件sticky属性](ts-container-list.md#属性)。 |
| editable<sup>(deprecated)</sup> | boolean&nbsp;\|&nbsp;[EditMode](#editmodedeprecated枚举说明) | 当前ListItem元素是否可编辑,进入编辑模式后可删除或移动列表项。<br/>从API version9开始废弃。<br/>默认值:false | | editable<sup>(deprecated)</sup> | boolean&nbsp;\|&nbsp;[EditMode](#editmodedeprecated枚举说明) | 当前ListItem元素是否可编辑,进入编辑模式后可删除或移动列表项。<br/>从API version9开始废弃。<br/>默认值:false |
| selectable<sup>8+</sup> | boolean | 当前ListItem元素是否可以被鼠标框选。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>外层List容器的鼠标框选开启时,ListItem的框选才生效。<br/>默认值:true | | selectable<sup>8+</sup> | boolean | 当前ListItem元素是否可以被鼠标框选。<br/>**说明:**<br/>外层List容器的鼠标框选开启时,ListItem的框选才生效。<br/>默认值:true |
| swipeAction<sup>9+</sup> | {<br/>start?:&nbsp;CustomBuilder,<br/>end?:CustomBuilder,<br/>edgeEffect?:&nbsp;[SwipeEdgeEffect](#swipeedgeeffect9枚举说明),<br/>} | 用于设置ListItem的划出组件。<br/>- start:&nbsp;ListItem向右划动时item左边的组件(List垂直布局时)或ListItem向下划动时item上方的组件(List水平布局时)。<br/>- end:&nbsp;ListItem向左划动时item右边的组件(List垂直布局时)或ListItem向上划动时item下方的组件(List水平布局时)。<br/>- edgeEffect:&nbsp;滑动效果。<br/>**说明:** <br/>start和end对应的@builder函数中顶层必须是单个组件,不能是if/else、ForEach、LazyForEach语句。 | | swipeAction<sup>9+</sup> | {<br/>start?:&nbsp;CustomBuilder,<br/>end?:CustomBuilder,<br/>edgeEffect?:&nbsp;[SwipeEdgeEffect](#swipeedgeeffect9枚举说明),<br/>} | 用于设置ListItem的划出组件。<br/>- start:&nbsp;ListItem向右划动时item左边的组件(List垂直布局时)或ListItem向下划动时item上方的组件(List水平布局时)。<br/>- end:&nbsp;ListItem向左划动时item右边的组件(List垂直布局时)或ListItem向上划动时item下方的组件(List水平布局时)。<br/>- edgeEffect:&nbsp;滑动效果。<br/>**说明:** <br/>start和end对应的@builder函数中顶层必须是单个组件,不能是if/else、ForEach、LazyForEach语句。 |
## Sticky<sup>(deprecated)</sup>枚举说明 ## Sticky<sup>(deprecated)</sup>枚举说明
...@@ -55,7 +55,7 @@ ListItem(value?: string) ...@@ -55,7 +55,7 @@ ListItem(value?: string)
| 名称 | 功能描述 | | 名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| onSelect(event:&nbsp;(isSelected:&nbsp;boolean)&nbsp;=&gt;&nbsp;void)<sup>8+</sup> | ListItem元素被鼠标框选的状态改变时触发回调。<br/>isSelected:进入鼠标框选范围即被选中返回true,&nbsp;移出鼠标框选范围即未被选中返回false。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | onSelect(event:&nbsp;(isSelected:&nbsp;boolean)&nbsp;=&gt;&nbsp;void)<sup>8+</sup> | ListItem元素被鼠标框选的状态改变时触发回调。<br/>isSelected:进入鼠标框选范围即被选中返回true,&nbsp;移出鼠标框选范围即未被选中返回false。 |
## 示例 ## 示例
......
...@@ -26,6 +26,8 @@ RowSplit() ...@@ -26,6 +26,8 @@ RowSplit()
> RowSplit的分割线最小能拖动到刚好包含子组件。 > RowSplit的分割线最小能拖动到刚好包含子组件。
> >
> 在真机中查看拖动效果,预览器中不支持拖动。 > 在真机中查看拖动效果,预览器中不支持拖动。
>
> 不支持clip、margin通用属性。
## 示例 ## 示例
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
包含[FlowItem](ts-container-flowitem.md)子组件。 包含[FlowItem](ts-container-flowitem.md)子组件。
> **说明:**
>
> WaterFlow子组件的visibility属性设置为None时不显示,但依然会占用子组件对应的网格。
## 接口 ## 接口
......
...@@ -12,17 +12,17 @@ ...@@ -12,17 +12,17 @@
| 名称 | 参数类型 | 参数描述 | | 名称 | 参数类型 | 参数描述 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| transition | TransitionOptions | 设置组件插入显示和删除隐藏的过渡效果。<br/>默认值:不设置任何过渡效果时,默认有透明度从0到1的过渡效果。若设置了其他过渡效果,以设置的过渡效果为准。<br/>**说明:** <br/>所有参数均为可选参数,详细描述见TransitionOptions参数说明。 | | transition | TransitionOptions | 设置组件插入显示和删除隐藏的过渡效果。<br/>默认值:不设置任何过渡效果时,默认有透明度从0到1的过渡效果。若设置了其他过渡效果,以设置的过渡效果为准。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>所有参数均为可选参数,详细描述见TransitionOptions参数说明。 |
## TransitionOptions参数说明 ## TransitionOptions参数说明
| 参数名称 | 参数类型 | 必填 | 参数描述 | | 参数名称 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | [TransitionType](ts-appendix-enums.md#transitiontype) | 否 | 默认包括组件新增和删除。<br/>默认值:TransitionType.All<br/>**说明:**<br/>不指定Type时说明插入删除使用同一种效果。 | | type | [TransitionType](ts-appendix-enums.md#transitiontype) | 否 | 默认包括组件新增和删除。<br/>默认值:TransitionType.All<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>不指定Type时说明插入删除使用同一种效果。 |
| opacity | number | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。<br/>默认值:1<br/>取值范围: [0, 1]<br/>**说明:** <br/>设置小于0的值时,按值为0处理;设置大于1的值时,按值为1处理。 | | opacity | number | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。<br/>默认值:1<br/>取值范围: [0, 1]<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>设置小于0的值时,按值为0处理;设置大于1的值时,按值为1处理。 |
| translate | {<br/>x?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>y?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>z?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置组件转场时的平移效果,为插入时起点和删除时终点的值。<br/>-x:横向的平移距离。<br/>-y:纵向的平移距离。<br/>-z:竖向的平移距离。 | | translate | {<br/>x?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>y?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>z?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置组件转场时的平移效果,为插入时起点和删除时终点的值。<br/>-x:横向的平移距离。<br/>-y:纵向的平移距离。<br/>-z:竖向的平移距离。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| scale | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number,<br/>centerX?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerY?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置组件转场时的缩放效果,为插入时起点和删除时终点的值。<br/>-x:横向放大倍数(或缩小比例)。<br/>-y:纵向放大倍数(或缩小比例)。<br/>-z:竖向放大倍数(或缩小比例)。<br/>-&nbsp;centerX、centerY指缩放中心点,centerX和centerY默认值是"50%"。<br/>-&nbsp;中心点为0时,默认的是组件的左上角。<br/> | | scale | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number,<br/>centerX?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerY?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置组件转场时的缩放效果,为插入时起点和删除时终点的值。<br/>-x:横向放大倍数(或缩小比例)。<br/>-y:纵向放大倍数(或缩小比例)。<br/>-z:竖向放大倍数(或缩小比例)。<br/>-&nbsp;centerX、centerY指缩放中心点,centerX和centerY默认值是"50%"。<br/>-&nbsp;中心点为0时,默认的是组件的左上角。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| rotate | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>angle?:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerX?:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerY?:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置组件转场时的旋转效果,为插入时起点和删除时终点的值。<br/>-x:横向的旋转向量。<br/>-y:纵向的旋转向量。<br/>-z:竖向的旋转向量。<br/>-&nbsp;centerX,centerY指旋转中心点,centerX和centerY默认值是"50%"。<br/>-&nbsp;中心点为(0,0)时,默认的是组件的左上角。 | | rotate | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>angle?:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerX?:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerY?:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置组件转场时的旋转效果,为插入时起点和删除时终点的值。<br/>-x:横向的旋转向量。<br/>-y:纵向的旋转向量。<br/>-z:竖向的旋转向量。<br/>-&nbsp;centerX,centerY指旋转中心点,centerX和centerY默认值是"50%"。<br/>-&nbsp;中心点为(0,0)时,默认的是组件的左上角。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
## 示例 ## 示例
......
...@@ -224,3 +224,13 @@ ...@@ -224,3 +224,13 @@
| ------------- | ---------------------- | ---------------------------------------- | | ------------- | ---------------------- | ---------------------------------------- |
| CustomBuilder | ()&nbsp;=&gt;&nbsp;any | 该方法类型必须使用@Builder装饰器修饰。具体用法见[@Builder](../../quick-start/arkts-dynamic-ui-elememt-building.md#builder)。 | | CustomBuilder | ()&nbsp;=&gt;&nbsp;any | 该方法类型必须使用@Builder装饰器修饰。具体用法见[@Builder](../../quick-start/arkts-dynamic-ui-elememt-building.md#builder)。 |
## PixelStretchEffectOptions<sup>10+</sup>
像素扩展属性集合,用于描述像素扩展的信息。
| 名称 | 类型 | 必填 | 说明 |
| ----------- | ------ | ---- | ---------- |
| left | [Length](#length) | 否 | 组件图像左边沿扩展距离。 |
| right | [Length](#length) | 否 | 组件图像右边沿像素扩展距离。 |
| top | [Length](#length) | 否 | 组件图像上边沿像素扩展距离。 |
| bottom | [Length](#length) | 否 | 组件图像下边沿像素扩展距离。 |
\ No newline at end of file
# 图像渐亮效果
设置组件的图像渐亮效果。
> **说明:**
>
> 从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。此接口为系统接口。
## 属性
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| lightUpEffect | [number]&nbsp;| 设置组件图像亮起程度。<br>取值范围:[0,1]。<br>如果value等于0则图像为全黑,如果value等于1则图像为全亮效果。0到1之间数值越大,表示图像亮度越高。`value < 0` 或者 `value > 1`为异常情况,`value < 0`按0处理,`value > 1`按1处理。 |
## 示例
### 示例1
```ts
// xxx.ets
@Entry
@Component
struct LightUpExample {
build() {
Stack() {
Text('This is the text content with letterSpacing 0.')
.letterSpacing(0)
.fontSize(12)
.border({ width: 1 })
.padding(10)
.width('50%')
.lightUpEffect(0.6)
}.alignContent(Alignment.Center).width("100%").height("100%")
}
}
```
效果图如下:
![textLightUp3](figures/textLightUp3.png)
修改lightUpEffect参数值为0.2:
![textLightUp2](figures/textLightUp2.png)
去掉lightUpEffect的设置,效果如下:
![textLightUp1](figures/textLightUp1.png)
### 示例2
```ts
// xxx.ets
@Entry
@Component
struct LightUpExample {
@State isLunar: boolean = false
private selectedDate: Date = new Date('2028-08-08')
build() {
Stack() {
DatePicker({
start: new Date('1970-1-1'),
end: new Date('2100-1-1'),
selected: this.selectedDate
})
.lunar(this.isLunar)
.onChange((value: DatePickerResult) => {
this.selectedDate.setFullYear(value.year, value.month, value.day)
console.info('select current date is: ' + JSON.stringify(value))
})
.lightUpEffect(0.6)
}.alignContent(Alignment.Center).width("100%").height("100%")
}
}
```
![datePickerLightUp2](figures/datePickerLightUp2.png)
去掉lightUpEffect的设置,效果如下:
![datePickerLightUp1](figures/datePickerLightUp1.png)
\ No newline at end of file
# 图像边缘像素扩展效果
设置组件的图像边缘像素扩展效果。
> **说明:**
>
> 从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。此接口为系统接口。
## 属性
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| pixelStretchEffect | [PixelStretchEffectOptions](ts-types.md#PixelStretchEffectOptions)&nbsp;| 设置组件的图像边缘像素扩展距离。<br>参数`options`包括上下左右四个方向的边缘像素扩展距离。<br>**说明:**<br>1、如果距离为正值,表示向外扩展,放大原来图像大小。上下左右四个方向分别用边缘像素填充,填充的距离即为设置的边缘扩展的距离。<br>2、如果距离为负值,表示内缩,但是最终图像大小不变。内缩方式:1、图像根据`options`的设置缩小,缩小大小为四个方向边缘扩展距离的绝对值。2、图像用边缘像素扩展到原来大小。<br>3、对`options`的输入约束:1、上下左右四个方向的扩展统一为非正值或者非负值。即四个边同时向外扩或者内缩,方向一致。2、所有方向的输入均为百分比或者具体值,不支持百分比和具体值混用。3、所有异常情况下,显示为{0,0,0,0}效果,即跟原图保持一致。|
## 示例
### 示例1
```ts
// xxx.ets
@Entry
@Component
struct PixelStretchExample {
build() {
Stack() {
Text('This is the text content with letterSpacing 0.')
.letterSpacing(0)
.fontSize(12)
.border({ width: 1 })
.padding(10)
.width('50%')
.pixelStretchEffect({top:10,left:10,right:10,bottom:10 })
}.alignContent(Alignment.Center).width("100%").height("100%")
}
}
```
效果图如下:
![textPixelStretch1](figures/textPixelStretch1.png)
去掉pixelStretchEffect的设置,原图效果如下:
![textPixelStretch2](figures/textPixelStretch2.png)
对比发现,如果边缘扩展距离设置为正值,图像向外扩展了边缘距离。
### 示例2
基于示例1,现在把边缘扩展距离改为非正值。
```ts
// xxx.ets
@Entry
@Component
struct PixelStretchExample {
build() {
Stack() {
Text('This is the text content with letterSpacing 0.')
.letterSpacing(0)
.fontSize(12)
.border({ width: 1 })
.padding(10)
.width('50%')
.pixelStretchEffect({top:-10,left:-10,right:-10,bottom:-10 })
}.alignContent(Alignment.Center).width("100%").height("100%")
}
}
```
效果图如下:
![textPixelStretch3](figures/textPixelStretch3.png)
跟原图对比发现,效果图分两步实现:<br>1、原图大小缩小,缩小后的大小为原图大小减去像素
收缩的距离。例如,原图大小为`100*100`,设置了`pixelStretchEffect({top:-10,left:-10,
right:-10,bottom:-10 })`,则缩小后的大小为`(100-10-10)*(100-10-10)`,即`80*80`<br>2、使用边缘像素扩展,将图像扩展为原图大小。
# 图像球面效果
设置组件的图像球面效果。
> **说明:**
>
> 从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。此接口为系统接口。
## 属性
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| sphericalEffect | [number]&nbsp;| 设置组件的图像球面化程度。<br>取值范围:[0,1]。<br>**说明:**<br>1、如果value等于0则图像保持原样,如果value等于1则图像为完全球面化效果。在0和1之间,数值越大,则球面化程度越高。<br>`value < 0 `或者` value > 1`为异常情况,`value < 0`按0处理,`value > 1`按1处理。<br> 2、如果组件的图像使用异步加载,则不支持球面效果。例如Image组件默认使用异步加载,如果要使用球面效果,就要设置`syncLoad``true`,但是这种做法不推荐。`backgroundImage`也是使用异步加载,所以如果设置了`backgroundImage`,不支持球面效果。<br>3、如果组件设置了阴影,不支持球面效果。|
## 示例
### 示例1
```ts
// xxx.ets
@Entry
@Component
struct SphericalEffectExample {
build() {
Stack() {
TextInput({ placeholder: "请输入变化范围百分比([0%,100%])"})
.width('50%')
.height(35)
.type(InputType.Number)
.enterKeyType(EnterKeyType.Done)
.caretColor(Color.Red)
.placeholderColor(Color.Blue)
.placeholderFont({
size: 20,
style: FontStyle.Italic,
weight: FontWeight.Bold
})
.sphericalEffect(0.5)
}.alignContent(Alignment.Center).width("100%").height("100%")
}
}
```
效果图如下:
![textInputSpherical1](figures/textInputSpherical1.png)
去掉sphericalEffect的设置,效果如下:
![textInputSpherical2](figures/textInputSpherical2.png)
\ No newline at end of file
...@@ -186,7 +186,7 @@ The context does not exist. ...@@ -186,7 +186,7 @@ The context does not exist.
请检查上下文对象是否可用。 请检查上下文对象是否可用。
## 16000012 上一个Ability未启动完成,先缓存在队列中等待后续启动。 ## 16000017 上一个Ability未启动完成,先缓存在队列中等待后续启动。
**错误信息** **错误信息**
......
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
- 附录 - 附录
- [Native api中没有导出的符号列表](third_party_libc/musl-peculiar-symbol.md) - [Native api中没有导出的符号列表](third_party_libc/musl-peculiar-symbol.md)
- [Native api中导出的EGL符号列表](third_party_opengl/egl-symbol.md) - [Native api中导出的EGL符号列表](third_party_opengl/egl-symbol.md)
- [Native api中导出的OpenGL ES 3.0符号列表](third_party_opengl/openglesv3-symbol.md) - [Native api中导出的OpenGL ES 3.0符号列表](third_party_opengl/openglesv3-symbol.md)
\ No newline at end of file - [Native api中支持的OpenSL ES接口列表](third_party_opensles/opensles.md)
\ No newline at end of file
...@@ -31,7 +31,7 @@ libdl:dlopen等动态链接器接口。 ...@@ -31,7 +31,7 @@ libdl:dlopen等动态链接器接口。
C标准函数库是在C语言程序设计中,所有符合标准的头文件的集合,以及常用的函数库实现程序(如I/O输入输出和字符串控制)。 C标准函数库是在C语言程序设计中,所有符合标准的头文件的集合,以及常用的函数库实现程序(如I/O输入输出和字符串控制)。
**<font size=5>musl</font>** **musl**
[native api中没有导出的符号列表](musl-peculiar-symbol.md) [native api中没有导出的符号列表](musl-peculiar-symbol.md)
...@@ -53,6 +53,10 @@ C++11、C++14标准已完全支持,C++17和C++20标准正在完善。 ...@@ -53,6 +53,10 @@ C++11、C++14标准已完全支持,C++17和C++20标准正在完善。
[OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/)是一个嵌入式跨平台的音频处理库。 [OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/)是一个嵌入式跨平台的音频处理库。
**支持的能力**
[Native api中支持的OpenSL ES接口列表](../third_party_opensles/opensles.md)
## zlib ## zlib
[Zlib](https://zlib.net/)是基于C/C++语言实现的一个通用的数据压缩库。 [Zlib](https://zlib.net/)是基于C/C++语言实现的一个通用的数据压缩库。
...@@ -75,4 +79,6 @@ OpenGL ES 3.0 ...@@ -75,4 +79,6 @@ OpenGL ES 3.0
**标准库中导出的符号列表** **标准库中导出的符号列表**
[native api中导出的OpenGL ES 3.0符号列表](../third_party_opengl/openglesv3-symbol.md) [native api中导出的OpenGL ES 3.0符号列表](../third_party_opengl/openglesv3-symbol.md)
\ No newline at end of file
<!--no_check-->
\ No newline at end of file
# Native api中支持的OpenSL ES接口列表
## 简介
OpenSL ES(Open Sound Library for Embedded System)即嵌入式音频加速标准。为开发者提供了标准化、高性能以及低响应时间的音频功能开发的对象和接口。相对于开源免费的OpenSL ES,OpenHarmony基于[OpenSL ES](https://www.khronos.org/opensles/) 1.0.1 API规范实现了部分Native API,相关接口开放情况介绍如下:
## 支持的API
|对象 |对外接口 |接口调用详情 |是否支持 |说明 |
| ------------------ | -------------------- | -------------------------------------------------------------------------------------|----------| -------------------- |
|SLEngineItf |CreateAudioPlayer |CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired) |是 |创建音频播放机。 |
|SLEngineItf |CreateAudioRecorder |reateAudioRecorder(SLEngineItf self, SLObjectItf *pRecorder, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|是 |创建音频录制器。 |
|SLEngineItf |CreateAudioOutputMix |CreateOutputMix(SLEngineItf self, SLObjectItf *pMix, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|是 |创建混音器。 |
|SLObjectItf |Realize |Realize(SLObjectItf self, SLboolean async) |是 |创建音频播放机。 |
|SLObjectItf |getState |GetState(SLObjectItf self, SLuint32 *state) |是 |获取状态。 |
|SLObjectItf |getInterface |GetInterface(SLObjectItf self, const SLInterfaceID iid, void *interface) |是 |获取接口。 |
|SLObjectItf |Destroy |Destroy(SLObjectItf self) |是 |销毁对象。 |
|SLOHBufferQueueItf |Enqueue |Enqueue(SLOHBufferQueueItf self, const void *buffer, SLuint32 size) |是 |将buffer加入实际队列中。|
|SLOHBufferQueueItf |clear |Clear(SLOHBufferQueueItf self) |是 |释放buffer队列 |
|SLOHBufferQueueItf |getState |GetState(SLOHBufferQueueItf self, SLOHBufferQueueState *state) |是 |获取BufferQueue状态。 |
|SLOHBufferQueueItf |getBuffer |GetBuffer(SLOHBufferQueueItf self, SLuint8 **buffer, SLuint32 *size) |是 |获取buffer。 |
|SLOHBufferQueueItf |RegisterCallback |RegisterCallback(SLOHBufferQueueItf self, SlOHBufferQueueCallback callback, void *pContext) |是 |注册回调函数。 |
|SLPlayItf |SetPlayState |SetPlayState(SLPlayItf self, SLuint32 state) |是 |设置播放状态。 |
|SLPlayItf |GetPlayState |GetPlayState(SLPlayItf self, SLuint32 *state) |是 |获取播放状态。 |
|SLRecordItf |SetRecordState |SetRecordState(SLRecordItf self, SLuint32 state) |是 |设置录制状态。 |
|SLRecordItf |GetRecordState |GetRecordState(SLRecordItf self, SLuint32 *pState) |是 |获取录制状态。 |
|SLVolumeItf |SetVolumeLevel |SetVolumeLevel(SLVolumeItf self, SLmillibel *level) |是 |设置音量。 |
|SLVolumeItf |GetVolumeLevel |GetVolumeLevel(SLVolumeItf self, SLmillibel level) |是 |获取音量。 |
|SLVolumeItf |GetMaxVolumeLevel |GetMaxVolumeLevel(SLVolumeItf self, SLmillibel *maxLevel) |是 |获取最大音量。 |
\ No newline at end of file
...@@ -38,7 +38,9 @@ ...@@ -38,7 +38,9 @@
- [音视频播放开发指导](subsys-multimedia-video-play-guide.md) - [音视频播放开发指导](subsys-multimedia-video-play-guide.md)
- [音视频录制开发指导](subsys-multimedia-video-record-guide.md) - [音视频录制开发指导](subsys-multimedia-video-record-guide.md)
- [公共基础库开发指导](subsys-utils-guide.md) - [公共基础库开发指导](subsys-utils-guide.md)
- [AI框架开发指导](subsys-ai-aiframework-devguide.md) - AI服务
- [AI框架开发指导](subsys-ai-aiframework-devguide.md)
- [NNRt开发指导](subsys-ai-nnrt-guide.md)
- Sensor服务 - Sensor服务
- [Sensor服务概述](subsys-sensor-overview.md) - [Sensor服务概述](subsys-sensor-overview.md)
- [Sensor服务使用指导](subsys-sensor-guide.md) - [Sensor服务使用指导](subsys-sensor-guide.md)
......
# NNRt设备开发指导
## 概述
### 功能简介
NNRt(Neural Network Runtime,神经网络运行时)是面向AI领域的跨芯片推理计算运行时,作为中间桥梁连通上层AI推理框架和底层加速芯片,实现AI模型的跨芯片推理计算。
NNRt开放了设备接口,芯片厂商通过设备接口将专有加速芯片接入NNRt,实现接入OpenHarmony的社区生态,以下将介绍芯片如何接入NNRt。
### 基本概念
在开发前,开发者需要先了解以下概念,以便更好地理解全文内容:
- HDI(Hardware Device Interface):OpenHarmony硬件设备接口,定义系统中跨进程通信的接口,实现服务间的跨进程通信。
- IDL(Interface Description Language):接口描述语言,是HDI接口的语言格式。
### 约束与限制
- 系统版本:OpenHarmony主干版本。
- 开发环境:Ubuntu 18.04及以上。
- 接入设备:具备AI计算能力的芯片。
### 运作机制
NNRt通过HDI接口实现与设备芯片的对接,由HDI接口实现跨进程通信。
**图1** NNRt架构图
![架构图](./figures/nnrt_arch_diagram.png)
整个架构主要分为三层,AI应用在应用层,AI推理框架和NNRt在系统层,设备服务在芯片层。AI应用如要使用专用加速芯片模型推理,需要经过AI推理框架和NNRt才能调用到底层专用加速芯片,而NNRt就是负责适配底层各种专用加速芯片,它开放了标准统一的设备接口,众多的第三方芯片设备都可以通过HDI接口接入OHOS。
程序运行时,AI应用、AI推理框架、NNRt都在用户进程中,底层设备服务在服务进程中,NNRt根据HDI接口实现了HDI Client,服务端也需要根据HDI接口实现HDI Service,使得两个进程间能够跨进程通信。
## NNRt开发指导
### 场景介绍
当需要将一款AI加速芯片接入NNRt的时候,可以参考下文,下文以rk3568芯片为例,展示rk3568 CPU如何通过HDI接口接入NNRt,并完成AI模型推理。
> 依赖说明:该教程展示的rk3568 CPU接入NNRt并没有实际去写CPU的驱动,而是借用了Mindspore-Lite的CPU算子,故会依赖MindSpore-Lite的动态库以及头文件,实际开发时并不需要依赖MindSpore-Lite的任何库或者头文件。
### 开发流程
专用加速芯片接入NNRt的整体流程如下:
**图2** 专用加速芯片接入NNRt流程
![开发流程](./figures/nnrt_dev_flow.png)
### 开发步骤
开发者具体可通过以下步骤实现芯片对接NNRt:
1. 开源社区下载OpenHarmony的代码,编译drivers_interface部件,生成HDI接口的头文件。
1. [下载源码](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
2. 编译接口IDL文件。
```shell
./build.sh --product-name productname –ccache --build-target drivers_interface_nnrt
```
> productname为产品名称,此处为rk3568.
编译完成后,在```out/rk3568/gen/drivers/interface/nnrt```目录下生成HDI头文件,默认语言类型为C++;若需要生成C类型的头文件,请在编译之前使用如下命令对```drivers/interface/nnrt/v1_0/BUILD.gn```文件中的```language```配置项进行设置。
```shell
language = "c"
```
生成头文件目录如下所示:
```text
out/rk3568/gen/drivers/interface/nnrt
└── v1_0
├── drivers_interface_nnrt__libnnrt_proxy_1.0_external_deps_temp.json
├── drivers_interface_nnrt__libnnrt_stub_1.0_external_deps_temp.json
├── innrt_device.h # 设备接口头文件
├── iprepared_model.h # 编译AI模型对象头文件
├── libnnrt_proxy_1.0__notice.d
├── libnnrt_stub_1.0__notice.d
├── model_types.cpp # AI模型结构定义实现文件
├── model_types.h # AI模型结构定义头文件
├── nnrt_device_driver.cpp # 设备驱动实现参考样例
├── nnrt_device_proxy.cpp
├── nnrt_device_proxy.h
├── nnrt_device_service.cpp # 设备服务端实现参考样例
├── nnrt_device_service.h # 设备服务端头文件
├── nnrt_device_stub.cpp
├── nnrt_device_stub.h
├── nnrt_types.cpp # 数据类型定义实现文件
├── nnrt_types.h # 数据类型定义头文件
├── node_attr_types.cpp # AI模型算子属性定义实现文件
├── node_attr_types.h # AI模型算子属性定义
├── prepared_model_proxy.cpp
├── prepared_model_proxy.h
├── prepared_model_service.cpp # 编译AI模型对象服务端实现参考样例
├── prepared_model_service.h # 编译AI模型对象服务端头文件
├── prepared_model_stub.cpp
└── prepared_model_stub.h
```
2. 实现HDI服务。
1. 在drivers/peripheral目录下新建开发目录,用于HDI服务开发,开发目录结构如下所示。
```text
drivers/peripheral/nnrt
├── BUILD.gn # 代码编译脚本文件
├── bundle.json
└── hdi_cpu_service # 自定义目录
├── BUILD.gn # 代码编译脚本文件
├── include
│   ├── nnrt_device_service.h # 设备服务端头文件
│   ├── node_functions.h # 非必须,由具体实现决定
│   ├── node_registry.h # 非必须,由具体实现决定
│   └── prepared_model_service.h # 编译AI模型对象服务端头文件
└── src
├── nnrt_device_driver.cpp # 设备驱动实现文件
├── nnrt_device_service.cpp # 设备服务端实现文件
├── nnrt_device_stub.cpp # 非必须,由具体实现决定
├── node_attr_types.cpp # 非必须,由具体实现决定
├── node_functions.cpp # 非必须,由具体实现决定
├── node_registry.cpp # 非必须,由具体实现决定
└── prepared_model_service.cpp # 编译AI模型对象服务端实现文件
```
2. 实现设备驱动,无特殊需求可直接使用步骤1中生成的nnrt_device_driver.cpp文件,否则根据具体驱动开发。
3. 实现服务接口,可参考nnrt_device_service.cpp和prepared_model_service.cpp实现文件,接口定义可以参考[NNRt的HDI接口定义](https://gitee.com/openharmony/drivers_interface/tree/master/nnrt)。
4. 编译驱动和服务的实现文件为共享库。
在```drivers/peripheral/nnrt/hdi_cpu_service/```下新建```BUILD.gn```文件,文件内容如下所示,相关参数配置内容可参考[Build教程](https://gitee.com/openharmony/build).
```shell
import("//build/ohos.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
ohos_shared_library("libnnrt_service_1.0") {
include_dirs = []
sources = [
"src/nnrt_device_service.cpp",
"src/prepared_model_service.cpp",
"src/node_registry.cpp",
"src/node_functions.cpp",
"src/node_attr_types.cpp"
]
public_deps = [ "//drivers/interface/nnrt/v1_0:nnrt_idl_headers" ]
external_deps = [
"hdf_core:libhdf_utils",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_single",
"c_utils:utils",
]
install_images = [ chipset_base_dir ]
subsystem_name = "hdf"
part_name = "drivers_peripheral_nnrt"
}
ohos_shared_library("libnnrt_driver") {
include_dirs = []
sources = [ "src/nnr_device_driver.cpp" ]
deps = [ "//drivers/peripheral/nnrt/hdi_cpu_service:libnnrt_service_1.0" ]
external_deps = [
"hdf_core:libhdf_host",
"hdf_core:libhdf_ipc_adapter",
"hdf_core:libhdf_utils",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_single",
"c_utils:utils",
]
install_images = [ chipset_base_dir ]
subsystem_name = "hdf"
part_name = "drivers_peripheral_nnrt"
}
group("hdf_nnrt_service") {
deps = [
":libnnrt_driver",
":libnnrt_service_1.0",
]
}
```
将```group("hdf_nnrt_service")```添加到```drivers/peripheral/nnrt/BUILD.gn```文件中,以便在更上目录层级就能引用。
```shell
if (defined(ohos_lite)) {
group("nnrt_entry") {
deps = [ ]
}
} else {
group("nnrt_entry") {
deps = [
"./hdi_cpu_service:hdf_nnrt_service",
]
}
}
```
新建```drivers/peripheral/nnrt/bundle.json```用于定义新增的```drivers_peripheral_nnrt```部件。
```json
{
"name": "drivers_peripheral_nnrt",
"description": "Neural network runtime device driver",
"version": "3.2",
"license": "Apache License 2.0",
"component": {
"name": "drivers_peripheral_nnrt",
"subsystem": "hdf",
"syscap": [""],
"adapter_system_type": ["standard"],
"rom": "1024KB",
"ram": "2048KB",
"deps": {
"components": [
"ipc",
"hdf_core",
"hiviewdfx_hilog_native",
"c_utils"
],
"third_part": [
"bounds_checking_function"
]
},
"build": {
"sub_component": [
"//drivers/peripheral/nnrt:nnrt_entry"
],
"test": [
],
"inner_kits": [
]
}
}
}
```
3. 声明HDI服务。
在对应产品的uhdf hcs配置文件中声明用户态驱动与服务,例如,针对rk3568服务需要在```vendor/hihope/rk3568/hdf_config/uhdf/device_info.hcs```文件中新增如下配置:
```text
nnrt :: host {
hostName = "nnrt_host";
priority = 50;
uid = "";
gid = "";
caps = ["DAC_OVERRIDE", "DAC_READ_SEARCH"];
nnrt_device :: device {
device0 :: deviceNode {
policy = 2;
priority = 100;
moduleName = "libnnrt_driver.z.so";
serviceName = "nnrt_device_service";
}
}
}
```
> 注意:修改hcs文件需要删除out目录重新编译,才能生效。
4. 配置host进程用户和组。
对于新增的nnrt_host进程的场景,需要配置对应进程的用户ID和组ID。 进程的用户ID在文件```base/startup/init/services/etc/passwd```中配置,进程的组ID在文件```base/startup/init/services/etc/group```中配置。
```text
# 在base/startup/init/services/etc/passwd新增
nnrt_host:x:3311:3311:::/bin/false
# 在base/startup/init/services/etc/group新增
nnrt_host:x:3311:
```
5. SeLinux配置。
OHOS已经开启SELinux特性,需要对新增的进程和服务配置相应的SELinux规则,用于运行host进程启动访问某些资源、发布HDI服务。
1. 在```base/security/selinux/sepolicy/ohos_policy/drivers/adapter/vendor/type.te```文件中配置nnrt_host进程安全上下文,新增配置如下:
```text
# 新增配置
type nnrt_host, hdfdomain, domain;
```
> nnrt_host为上文配置的进程名称。
2. 由于SeLinux是白名单访问的权限机制,需要根据实际权限需求配置,将服务启动起来之后,通过以下dmesg命令可能查看avc告警,
avc告警会给出缺少的权限,SeLinux的配置也可以参考[OpenHarmony SeLinux子系统的说明](https://gitee.com/openharmony/security_selinux/blob/master/README.md)。
```shell
hdc_std shell
dmesg | grep nnrt
```
3. 新建nnrt_host.te配置文件,将权限配置到nnrt_host.te文件中。
```shell
# 创建nnrt文件夹
mkdir base/security/selinux/sepolicy/ohos_policy/drivers/peripheral/nnrt
# 创建vendor文件夹
mkdir base/security/selinux/sepolicy/ohos_policy/drivers/peripheral/nnrt/vendor
# 创建nnrt_host.te文件
touch base/security/selinux/sepolicy/ohos_policy/drivers/peripheral/nnrt/vendor/nnrt_host.te
```
4. 将所需的权限写入nnrt_host.te文件中,比如:
```text
allow nnrt_host dev_hdf_kevent:chr_file { ioctl };
allow nnrt_host hilog_param:file { read };
allow nnrt_host sh:binder { transfer };
allow nnrt_host dev_ashmem_file:chr_file { open };
allow sh nnrt_host:fd { use };
```
6. 删除out目录编译整个系统。
```shell
# 删除out目录
rm -rf ./out
# 编译
./build.sh --product-name rk3568 –ccache --jobs=4
```
### 调测验证
服务开发完成后,可以使用XTS用例验证基本功能和兼容性,开发者可通过以下步骤进行验证:
1. 编译NNRt的hats用例,用例在```test/xts/hats/hdf/nnrt```目录下。
```shell
# 进入hats目录
cd test/xts/hats
# 编译hats测试用例
./build.sh suite=hats system_size=standard --product-name rk3568
# 回到代码根目录
cd -
```
编译好的测试用例会输出到相对代码根目录的```out/rk3568/suites/hats/testcases/HatsHdfNnrtFunctionTest```路径下。
2. 将测试用例push到设备上。
```shell
# 将测试用例可执行文件推送到设备上,HatsHdfNnrtFunctionTest是测试用例可执行文件。
hdc_std file send out/rk3568/suites/hats/testcases/HartsHdfNnrtFunctionTest /data/local/tmp/
# 给测试用例可执行文件加上权限。
hdc_std shell "chmod +x /data/local/tmp/HatsHdfNnrtFunctionTest"
```
3. 执行用例并查看结果。
```shell
# 执行测试用例
hdc_std shell "/data/local/tmp/HatsHdfNnrtFunctionTest"
```
所有hats用例执行成功,可以看到测试报告通过47个用例,说明服务通过了兼容性测试。
```text
...
[----------] Global test environment tear-down
Gtest xml output finished
[==========] 47 tests from 3 test suites ran. (515 ms total)
[ PASSED ] 47 tests.
```
### 开发实例
完整Demo代码可以参考[社区实现](https://gitee.com/openharmony/ai_neural_network_runtime/tree/master/example/drivers)
1. 拷贝```example/driver/nnrt```目录到```drivers/peripheral```路径下。
```shell
cp -r example/driver/nnrt drivers/peripheral
```
2. 补充bundle.json文件到```drivers/peripheral/nnrt```,bundle.json参考本教程上面的[开发步骤](#开发步骤)章节。
3. 由于Demo依赖MindSpore-Lite CPU算子,故需要添加MindSpore-Lite依赖文件。
- 下载MindSpore-Lite的头文件,[mindspore 1.5.0](https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.5.0/MindSpore/lite/release/linux/mindspore-lite-1.5.0-linux-x64.tar.gz)
-```drivers/peripheral/nnrt```目录下新建mindspore目录,用于存放mindspore依赖库和头文件。
```shell
mkdir drivers/peripheral/nnrt/mindspore
```
- 解压mindspore-lite-1.5.0-linux-x64.tar.gz文件,将```runtime/include```目录拷贝到```drivers/peripheral/nnrt/mindspore```目录下。
- Demo还依赖mindspore的schema文件。
```shell
# 创建mindspore_schema目录
mkdir drivers/peripheral/nnrt/hdi_cpu_service/include/mindspore_schema
# 拷贝mindspore schema文件
cp third_party/mindspore/mindspore/lite/schema/* drivers/peripheral/nnrt/hdi_cpu_service/include/mindspore_schema/
```
- 编译MindSpore-Lite的动态库,并将动态库放到mindspore目录下。
```shell
# 编译mindspore动态库
./build.sh --product-name rk3568 -ccaache --jobs 4 --build-target mindspore_lib
# 将mindspore动态库
mkdir drivers/peripheral/nnrt/mindspore/mindspore
# 将mindspore动态拷贝到drivers/peripheral/nnrt/mindspore/mindspore。
cp out/rk3568/package/phone/system/lib/libmindspore-lite.huawei.so drivers/peripheral/nnrt/mindspore/mindspore/
```
4. 其他配置请参考本教程上面的[开发步骤](#开发步骤)章节。
\ No newline at end of file
...@@ -105,7 +105,7 @@ bundle.json是定义部件的描述文件,包含了部件的根目录、名称 ...@@ -105,7 +105,7 @@ bundle.json是定义部件的描述文件,包含了部件的根目录、名称
| 字段 | 类型 | 看护手段 | | 字段 | 类型 | 看护手段 |
|---|---|---| |---|---|---|
|name|string。部件的HPM(鸿蒙包管理器)包名称,必填。命名规则:@{organization}/{component_name}。"component_name"为部件的名称,须满足规则1.1。|静态检查| |name|string。部件的HPM(OpenHarmony包管理器)包名称,必填。命名规则:@{organization}/{component_name}。"component_name"为部件的名称,须满足规则1.1。|静态检查|
|version|string。部件版本号,必填,命名和升级跟随OpenHarmony版本号。|静态检查| |version|string。部件版本号,必填,命名和升级跟随OpenHarmony版本号。|静态检查|
|destPath|string。部件源码的根目录,必填。部件的根目录须独立唯一,不允许存在多个根目录。|静态检查| |destPath|string。部件源码的根目录,必填。部件的根目录须独立唯一,不允许存在多个根目录。|静态检查|
|component:name|string。部件名,必填。须满足规则1.1。|静态检查| |component:name|string。部件名,必填。须满足规则1.1。|静态检查|
......
...@@ -84,6 +84,7 @@ HUKS Core作为向应用提供密钥库能力的基础,包括密钥管理及 ...@@ -84,6 +84,7 @@ HUKS Core作为向应用提供密钥库能力的基础,包括密钥管理及
| [HuksHdiGetKeyProperties()](#hukshdigetkeyproperties) | 获取密钥属性。 |无 | getKeyProperties(keyAlias: string, options: HuksOptions)| | [HuksHdiGetKeyProperties()](#hukshdigetkeyproperties) | 获取密钥属性。 |无 | getKeyProperties(keyAlias: string, options: HuksOptions)|
| [HuksHdiAttestKey()](#hukshdiattestkey) | 获取密钥证书。 |出参要遵循certChain格式 | attestKey(keyAlias: string, options: HuksOptions)| | [HuksHdiAttestKey()](#hukshdiattestkey) | 获取密钥证书。 |出参要遵循certChain格式 | attestKey(keyAlias: string, options: HuksOptions)|
| [HuksHdiExportChipsetPlatformPublicKey()](#hukshdiexportchipsetplatformpublickey) | 导出芯片平台级密钥对的公钥。 | 出参为ECC P256的x y轴值裸数据,各32字节 | 无 | | [HuksHdiExportChipsetPlatformPublicKey()](#hukshdiexportchipsetplatformpublickey) | 导出芯片平台级密钥对的公钥。 | 出参为ECC P256的x y轴值裸数据,各32字节 | 无 |
| [HuksHdiUpgradeKey()](#hukshdiupgradekey) | 升级密钥文件。 | 无 | 无 |
- - - - - -
...@@ -602,6 +603,40 @@ HUKS Core的初始化,包括锁,加密算法库,authtoken key和根密钥 ...@@ -602,6 +603,40 @@ HUKS Core的初始化,包括锁,加密算法库,authtoken key和根密钥
- - - - - -
#### HuksHdiUpgradeKey
**接口描述**
升级密钥文件。当密钥文件版本号小于最新版本号时,触发该升级能力。
**接口原型**
<pre><code>int32_t (*HuksHdiUpgradeKey)(const struct HksBlob *oldKey, const struct HksParamSet *paramSet, struct HksBlob *newKey);</code></pre>
<details>
<summary><strong>参数说明</strong></summary>
<pre>
<strong>const struct HksBlob *oldKey</strong>
待升级的密钥文件数据
<br></br>
<strong>const struct HksParamSet *paramSet</strong>
升级密钥文件数据的参数
<br></br>
<strong>struct HksBlob *newKey</strong>
出参,升级后的密钥文件数据
</pre>
</details>
<br></br>
<details>
<summary><strong>返回值</strong></summary>
- HKS_SUCCESS:成功
- 其他:失败
</details>
- - -
### 开发步骤 ### 开发步骤
HDI接口到HUKS Core的适配在以下目录中: HDI接口到HUKS Core的适配在以下目录中:
......
...@@ -417,7 +417,9 @@ ...@@ -417,7 +417,9 @@
- [音视频播放开发指导](subsystems/subsys-multimedia-video-play-guide.md) - [音视频播放开发指导](subsystems/subsys-multimedia-video-play-guide.md)
- [音视频录制开发指导](subsystems/subsys-multimedia-video-record-guide.md) - [音视频录制开发指导](subsystems/subsys-multimedia-video-record-guide.md)
- [公共基础库开发指导](subsystems/subsys-utils-guide.md) - [公共基础库开发指导](subsystems/subsys-utils-guide.md)
- [AI框架开发指导](subsystems/subsys-ai-aiframework-devguide.md) - AI服务
- [AI框架开发指导](subsystems/subsys-ai-aiframework-devguide.md)
- [NNRt开发指导](subsystems/subsys-ai-nnrt-guide.md)
- Sensor服务 - Sensor服务
- [Sensor服务概述](subsystems/subsys-sensor-overview.md) - [Sensor服务概述](subsystems/subsys-sensor-overview.md)
- [Sensor服务使用指导](subsystems/subsys-sensor-guide.md) - [Sensor服务使用指导](subsystems/subsys-sensor-guide.md)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## 简介<a name="section11660541593"></a> ## 简介<a name="section11660541593"></a>
方舟编译器\(ArkCompiler\)是为支持多种编程语言、多种芯片平台的联合编译、运行而设计的统一编译运行时平台。它支持包括动态类型和静态类型语言在内的多种编程语言,如JS、TS、ArkTS;它是支撑鸿蒙系统成为打通手机、PC、平板、电视、车机和智能穿戴等多种设备的操作系统的编译运行时底座。 方舟编译器\(ArkCompiler\)是为支持多种编程语言、多种芯片平台的联合编译、运行而设计的统一编译运行时平台。它支持包括动态类型和静态类型语言在内的多种编程语言,如JS、TS、ArkTS;它是支撑OpenHarmony系统成为打通手机、PC、平板、电视、车机和智能穿戴等多种设备的操作系统的编译运行时底座。
ArkCompiler主要分成两个部分:编译工具链与运行时. ArkCompiler主要分成两个部分:编译工具链与运行时.
...@@ -57,7 +57,7 @@ ArkCompiler运行时直接运行字节码文件,实现对应语言规范的语 ...@@ -57,7 +57,7 @@ ArkCompiler运行时直接运行字节码文件,实现对应语言规范的语
- 原生支持TypeScript: - 原生支持TypeScript:
ECMAScript规范没有提供并发语义表述;业界引擎,如浏览器或者Node.js,通常会提供基于Actor并发模型的Worker API来支持多线程开发。Actor模型下执行体之间不共享任何数据对象,通过消息机制进行通信。因此Web引擎或者Node.js引擎的Worker都有启动速度慢、内存占用高这些缺陷。 针对这些缺陷,ArkCompiler的运行时已经实现了Actor实例中的不可变或者不易变的对象(方法和字节码)的共享,较大程度地优化了Actor的启动性能和启动内存。 ECMAScript规范没有提供并发语义表述;业界引擎,如浏览器或者Node.js,通常会提供基于Actor并发模型的Worker API来支持多线程开发。Actor模型下执行体之间不共享任何数据对象,通过消息机制进行通信。因此Web引擎或者Node.js引擎的Worker都有启动速度慢、内存占用高这些缺陷。 针对这些缺陷,ArkCompiler的运行时已经实现了Actor实例中的不可变或者不易变的对象(方法和字节码)的共享,较大程度地优化了Actor的启动性能和启动内存。
方舟编译运行时不只提供了业界通用的Worker API,还提供了TaskPool作为并发API的增强。TaskPool是一个支持优先级调度、工作线程自动扩缩容的任务池功能库。开发者无需关心并发实例的生命周期,也无需关心任务负载变化时需要创建或者销毁并发实例,极大地简化了高性能多线程鸿蒙应用的开发。 方舟编译运行时不只提供了业界通用的Worker API,还提供了TaskPool作为并发API的增强。TaskPool是一个支持优先级调度、工作线程自动扩缩容的任务池功能库。开发者无需关心并发实例的生命周期,也无需关心任务负载变化时需要创建或者销毁并发实例,极大地简化了高性能多线程OpenHarmony应用的开发。
- 安全 - 安全
...@@ -75,7 +75,7 @@ ArkCompiler运行时直接运行字节码文件,实现对应语言规范的语 ...@@ -75,7 +75,7 @@ ArkCompiler运行时直接运行字节码文件,实现对应语言规范的语
## 使用指南<a name="section18393638195820"></a> ## 使用指南<a name="section18393638195820"></a>
[方舟运行时使用指南](https://gitee.com/openharmony/arkcompiler_ets_runtime/blob/master/docs/ARK-Runtime-Usage-Guide-zh.md) [方舟运行时使用指南](https://gitee.com/openharmony/arkcompiler_ets_runtime/blob/master/docs/README_zh.md)
## 相关仓<a name="section1371113476307"></a> ## 相关仓<a name="section1371113476307"></a>
......
# OpenHarmony JS和TS三方组件使用指导 # OpenHarmony JS和TS三方组件使用指导
## OpenHarmony JS和TS三方组件介绍 ## OpenHarmony JS和TS三方组件介绍
OpenHarmony JS和TS三方组件使用的是OpenHarmony静态共享包,即HAR(Harmony Archive),可以包含js/ts代码、c++库、资源和配置文件。通过HAR,可以实现多个模块或者多个工程共享ArkUI组件、资源等相关代码。HAR不同于HAP,不能独立安装运行在设备上,只能作为应用模块的依赖项被引用 OpenHarmony JS和TS三方组件是以OpenHarmony npm包的形式,在传统的npm三方组件的基础上,定义了OpenHarmony npm共享包特定的工程结构和配置文件,支持OpenHarmony页面组件相关API、资源的调用。通过OpenHarmony npm包,可以实现多个模块或者多个工程共享OpenHarmony页面、资源等相关代码。前往[npm官方文档](https://docs.npmjs.com/about-npm),可以了解和掌握npm的基础功能和机制
...@@ -11,164 +11,41 @@ OpenHarmony JS和TS三方组件使用的是OpenHarmony静态共享包,即HAR(H ...@@ -11,164 +11,41 @@ OpenHarmony JS和TS三方组件使用的是OpenHarmony静态共享包,即HAR(H
2. 访问[OpenHarmony官网](https://growing.openharmony.cn/mainPlay/tpc),通过类型,分类,以及关键字搜索需要的三方组件。 2. 访问[OpenHarmony官网](https://www.openharmony.cn/mainPlay/tpc),通过类型,分类,以及关键字搜索需要的三方组件。
![official-website.png](official-website.png) ![official-website.png](official-website.png)
## 安装并使用OpenHarmony JS和TS语言的三方组件 ## 安装并使用OpenHarmony JS和TS语言的三方组件
引用三方HAR,包括从仓库进行安装和从本地库模块中进行安装两种方式。 在应用开发的过程中,JS和TS语言的三方组件,通常以源码或OpenHarmony npm包的方式被引入使用。按照以下步骤即可将OpenHarmony npm包引入应用并使用,源码的具体引入及使用请参考各三方组件README.md指导介绍。
**引用仓库安装的HAR** 1. 配置OpenHarmony npm环境,详情请参考安装教程 [如何安装OpenHarmony npm包](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_npm_usage.md)
引用ohpm仓中的HAR,首先需要设置三方HAR的仓库信息,DevEco Studio默认仓库地址是"https://repo.harmonyos.com/ohpm/",如果您想设置自定义仓库,请在DevEco Studio的Terminal窗口执行如下命令进行设置(执行命令前,请确保将DevEco Studio中ohpm安装地址配置在“环境变量-系统变量-PATH”中): 2. 在Terminal项目终端中,进入entry目录,并执行目标组件命令进行安装。具体的下载命令详见OpenHarmony官网该三方组件的“下载安装“模块。
```
ohpm config set registry=your_registry1,your_registry2 以安装[vcard三方组件](https://growing.openharmony.cn/mainPlay/libraryMaps/vcard_595)为例,找到“下载安装”模块获取其安装命令,并执行该命令安装:
```
说明:ohpm支持多个仓库地址,采用英文逗号分隔。 ![npm-usage1.png](npm-usage1.png)
然后通过如下两种方式设置三方包依赖信息:
- 方式一:在Terminal窗口中,执行如下命令安装三方包,DevEco Studio会自动在工程的oh-package.json5中自动添加三方包依赖。 ![npm-usage2.png](npm-usage2.png)
```
ohpm install @ohos/lottie --save 3. 下载完成后在项目文件下自动生成node_modules文件,下载的三方库即node_modules目录下的@ohos\VCard。
```
- 方式二:在工程的oh-package.json5中设置三方包依赖,配置示例如下: ![npm-usage3.png](npm-usage3.png)
```
"dependencies": { "@ohos/lottie": "^2.0.0"} 4. 在package.json中会自动添加如下依赖:
```
依赖设置完成后,需要执行ohpm install命令安装依赖包,依赖包会存储在工程的oh_modules目录下。 ```
``` "dependencies": {
ohpm install "@ohos/vcard": "^2.0.5"
```
**引用本地库模块的文件和资源**
- 方式一:在Terminal窗口中,执行如下命令进行安装,并会在oh-package5.json中自动添加依赖。
```
ohpm install ../library --save
```
- 方式二:在工程的oh-package.json5中设置三方包依赖,配置示例如下:
```
"dependencies": {
"@ohos/library": "file:../library"
}
```
依赖设置完成后,需要执行ohpm install命令安装依赖包,依赖包会存储在工程的oh_modules目录下。
```
ohpm install
```
> **说明:**
>
> 在引用OpenHarmony HAR时,请注意以下事项
>- 当前只支持在模块和工程下的oh-package.json5文件中声明dependencies依赖,才会被当做OpenHarmony依赖使用,并在编译构建过程中进行相应的处理。
>- 引用的模块的compileSdkVersion不能低于其依赖的OpenHarmony ohpm三方包(可在oh_modules目录下,找到引用的ohpm包的src > main > module.json5 中查看)。
### 引用OpenHarmony HAR hml页面
在JS工程范式中,组件功能由hml承载,开发者可以在JS工程的hml页面通过<element>标签来引入OpenHarmony HAR中的共享hml页面,示例如下:
```
<element name="comp" src="@ohos/library/src/main/js/components/index/index.hml"></element>
```
其中,@ohos/library为OpenHarmony HAR的包名,hml页面的路径为OpenHarmony HAR中的相对路径。
随后便可以通过设置的name来使用该element元素,以引用OpenHarmony HAR中的hml页面,示例如下:
```typescript
<element name="comp" src="@ohos/library/src/main/js/components/index/index.hml"></element>
<div class="container">
<comp></comp>
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
```
### 引用OpenHarmony HAR ArkTS页面
ArkTS是TypeScript的扩展,因此导出和引入的语法与TypeScript一致。在OpenHarmony ohpm模块中,可以通过export导出ArkTS页面,示例如下:
```typescript
// library/src/main/ets/components/MainPage/MainPage.ets
@Entry
@Component
export struct MainPage {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
} .height('100%')
}
}
```
然后在其它模块中通过import引入导出的ArkTS页面,示例如下所示:
```typescript
// entry/MainAbility/pages/index.ets
import { MainPage } from "@ohos/library"
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Column() {
MainPage()
Row() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('10%')
}
}
```
引用OpenHarmony HAR内ts/js方法ts/js方法的导出和引用,与ArkTS页面的引用相同,即在OpenHarmony ohpm模块中,可以通过export导出ts/js方法,示例如下所示:
```typescript
// library/index.js
export function func() {
return "[ohpm] func1";
}
```
然后在其它的ts/js页面中,通过import引入导出的ts/js方法,示例如下所示:
```typescript
// entry/src/main/js/MainAbility/pages/index/index.js
import {func} from "@ohos/library"
export default {
data: {
title: ""
},
onInit() {
this.title = func();
}
}
```
引用OpenHarmony HAR内资源支持在OpenHarmony ohpm模块和依赖OpenHarmony ohpm的模块中引用OpenHarmony ohpm模块内的资源。例如在OpenHarmony ohpm模块的scr/main/resources里添加字符串资源(在string.json中定义,name:hello_ohpm)和图片资源(icon_ohpm.png)。然后在Entry模块中引用该字符串资源和图片资源的示例如下:
当前暂不支持类Web范式引用i18n文件中的国际化资源。
```typescript
// entry/src/main/ets/MainAbility/pages/index.ets
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Column() {
Row() {
Text($r("app.string.hello_ohpm")) // 字符串资源
.fontSize(40)
.fontWeight(FontWeight.Bold)
}
.width('50%')
Image($r("app.media.icon_ohpm")) // 图片资源
}
.height('100%')
} }
} ```
```
在编译构建HAP中,DevEco Studio会从HAP模块及依赖的模块中收集资源文件,如果不同模块的相同限定词目录下的资源文件出现重名冲突时,DevEco Studio会按照以下优先级进行覆盖(优先级由高到低): 5. 在需要使用该组件的文件中导入组件。
- AppScope(仅API 9的Stage模型支持)
- HAP包自身模块 ![npm-usage4.png](npm-usage4.png)
- 依赖的OpenHarmonyHarmony ohpm模块
\ No newline at end of file 6. 导入组件后直接使用方法即可。
![npm-usage5.png](npm-usage5.png)
\ No newline at end of file
# OpenHarmony三方组件 # OpenHarmony三方组件
OpenHarmony三方组件,是经过验证可在OpenHarmony系统上可重复使用的软件组件,可帮助开发者快速开发OpenHarmony系统或应用。根据其开发语言分为了2种,一种是使用JavaScript和TypeScript语言的三方组件,通常以源码或OpenHarmony HAR的方式引入,在应用开发中使用。另一种是C和C++语言的三方组件,通常以源码或OpenHarmony hpm包的方式引入,在应用开发中以NAPI的方式使用,或直接编译在OpenHarmony操作系统镜像中。 OpenHarmony三方组件,是经过验证可在OpenHarmony系统上可重复使用的软件组件,可帮助开发者快速开发OpenHarmony系统或应用。根据其开发语言分为了2种,一种是使用JavaScript和TypeScript语言的三方组件,通常以源码或OpenHarmony npm包的方式引入,在应用开发中使用。另一种是C和C++语言的三方组件,通常以源码或OpenHarmony hpm包的方式引入,在应用开发中以NAPI的方式使用,或直接编译在OpenHarmony操作系统镜像中。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册