diff --git a/en/application-dev/connectivity/net-sharing.md b/en/application-dev/connectivity/net-sharing.md index d81e8f59ecfb538ececb78afc83941d52f330eda..d5bc9cf2f8817723f0f23d666c45997a6735f706 100644 --- a/en/application-dev/connectivity/net-sharing.md +++ b/en/application-dev/connectivity/net-sharing.md @@ -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. - sharing.startSharing(SharingIfaceType.SHARING_WIFI, (error) => { + sharing.startSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => { console.log(JSON.stringify(error)); }); ``` @@ -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. - sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => { + sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => { console.log(JSON.stringify(error)); }); ``` @@ -107,7 +107,7 @@ For the complete list of APIs and example code, see [Network Sharing](../referen import sharing from '@ohos.net.sharing' // 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)); }); @@ -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. - sharing.stopSharing(SharingIfaceType.SHARING_WIFI, (error) => { + sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI, (error) => { console.log(JSON.stringify(error)); }); diff --git a/en/application-dev/connectivity/socket-connection.md b/en/application-dev/connectivity/socket-connection.md index 68e3433597881d891c87abd60b6f81abfc876028..b0c6fcd63d49a6cf9b77662d8340cadc8f82735d 100644 --- a/en/application-dev/connectivity/socket-connection.md +++ b/en/application-dev/connectivity/socket-connection.md @@ -190,7 +190,7 @@ TLS Socket connection process on the client: let tlsTwoWay = socket.constructTLSSocketInstance(); // Subscribe to TLS Socket connection events. - tcp.on('message', value => { + tlsTwoWay.on('message', value => { console.log("on message") let buffer = value.message let dataView = new DataView(buffer) @@ -200,10 +200,10 @@ TLS Socket connection process on the client: } console.log("on connect received:" + str) }); - tcp.on('connect', () => { + tlsTwoWay.on('connect', () => { console.log("on connect") }); - tcp.on('close', () => { + tlsTwoWay.on('close', () => { console.log("on close") }); @@ -246,23 +246,23 @@ TLS Socket connection process on the client: console.log(data); }); - // Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events. - tls.close((err) => { + // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events. + tlsTwoWay.close((err) => { if (err) { console.log("close callback error = " + err); } else { console.log("close success"); } - tls.off('message'); - tls.off('connect'); - tls.off('close'); + tlsTwoWay.off('message'); + tlsTwoWay.off('connect'); + tlsTwoWay.off('close'); }); // Create a TLS Socket connection (for one-way authentication). let tlsOneWay = socket.constructTLSSocketInstance(); // One way authentication // Subscribe to TLS Socket connection events. - tcp.on('message', value => { + tlsTwoWay.on('message', value => { console.log("on message") let buffer = value.message let dataView = new DataView(buffer) @@ -272,10 +272,10 @@ TLS Socket connection process on the client: } console.log("on connect received:" + str) }); - tcp.on('connect', () => { + tlsTwoWay.on('connect', () => { console.log("on connect") }); - tcp.on('close', () => { + tlsTwoWay.on('close', () => { console.log("on close") }); @@ -307,16 +307,16 @@ TLS Socket connection process on the client: console.log(data); }); - // Enable the TLS Socket connection to be automatically closed after use. Then, disable listening for TLS Socket connection events. - tls.close((err) => { + // Enable the TCP Socket connection to be automatically closed after use. Then, disable listening for TCP Socket connection events. + tlsTwoWay.close((err) => { if (err) { console.log("close callback error = " + err); } else { console.log("close success"); } - tls.off('message'); - tls.off('connect'); - tls.off('close'); + tlsTwoWay.off('message'); + tlsTwoWay.off('connect'); + tlsTwoWay.off('close'); }); ``` diff --git a/en/application-dev/dfx/apprecovery-guidelines.md b/en/application-dev/dfx/apprecovery-guidelines.md index 58fa2b0be72f59311bef16793380488bf0add781..5709d309a65a5a7e84d61770b4a69b2194e63311 100644 --- a/en/application-dev/dfx/apprecovery-guidelines.md +++ b/en/application-dev/dfx/apprecovery-guidelines.md @@ -1,4 +1,4 @@ -# Development of Application Recovery +# Application Recovery Development ## When to Use @@ -15,11 +15,11 @@ The application recovery APIs are provided by the **appRecovery** module, which ### Available APIs -| API | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void; | Enables the application recovery function. | -| saveAppState(): boolean; | Saves the ability status of an 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.| +| API | Description | +| ------------------------------------------------------------ | ---------------------------------------------------- | +| enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void; | Enables the application recovery function.| +| saveAppState(): boolean; | Saves the ability status of an 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.| The APIs are used for troubleshooting and do not return any exception. Therefore, you need to be familiar with when they are used. @@ -40,21 +40,24 @@ Fault management is an important way for applications to deliver a better user e - 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 [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) It is recommended that you call [errorManager](../reference/apis/js-apis-app-ability-errorManager.md) to process the exception. After the processing is complete, you can call the status saving API and restart the application. + 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 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-app-ability-uiAbility.md#uiabilityonsavestate) of [Ability](../reference/apis/js-apis-app-ability-uiAbility.md) is called back. Finally, the application is restarted. ### Scenarios Supported by Application Fault Management APIs 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| -| ------------------------------------------------------------ | -------- | -------- | -------- | -------- | -| [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 | -| [CPP_CRASH](../reference/apis/js-apis-faultLogger.md#faulttype) | Not supported | Not supported | Not supported | Supported | +| Fault | Fault Listening | Status Saving| Automatic Restart| Log Query| +| ----------|--------- |--------- |--------- |--------- | +| [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| +| [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. @@ -95,7 +98,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant' #### Actively Saving Status and Restoring Data -- Define and register the [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) callback. +- Define and register the [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) callback. ```ts var registerId = -1; @@ -108,7 +111,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant' } 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] MainAbility onWindowStageCreate") globalThis.registerObserver = (() => { @@ -125,7 +128,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state, ```ts onSaveState(state, wantParams) { - // Save application data. + // Ability has called to save app data console.log("[Demo] MainAbility onSaveState") wantParams["myData"] = "my1234567"; return AbilityConstant.onSaveResult.ALL_AGREE; @@ -150,11 +153,11 @@ onCreate(want, launchParam) { } ``` -- Deregister **ErrorObserver callback**. +- Unregister **ErrorObserver callback**. ```ts onWindowStageDestroy() { - // Main window is destroyed to release UI resources. + // Main window is destroyed, release UI related resources console.log("[Demo] MainAbility onWindowStageDestroy") globalThis.unRegisterObserver = (() => { @@ -184,7 +187,7 @@ export default class MainAbility extends Ability { } onSaveState(state, wantParams) { - // Save application data. + // Ability has called to save app data console.log("[Demo] MainAbility onSaveState") wantParams["myData"] = "my1234567"; return AbilityConstant.onSaveResult.ALL_AGREE; diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index 616be22d2788a907bad5db836a0b8a76ac54f6f2..55133a9529b47340379bcc0933c9351eea5844ea 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -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 [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 @@ -111,7 +111,7 @@ The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities throug 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 let options = {dateStyle: "full", timeStyle: "full"}; @@ -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"} ``` -## Number Formatting +## Formatting Numbers [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 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 let options = {compactDisplay: "short", notation: "compact"}; @@ -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"} ``` -## 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. @@ -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" ``` -## 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. diff --git a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md index d9d9db6fdfe71ed60275638085b17c314233882c..a2cb64620ffe61ca7acf18efe847ec51c59d6c49 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md @@ -148,7 +148,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal ## ServiceExtensionAbility.onDisconnect -onDisconnect(want: Want): void | Promise; +onDisconnect(want: Want): void | Promise\; Called when a client is disconnected from this ServiceExtensionAbility. diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 487f395f07e81936693d7d0bf9a275926ede4c26..8c8be8e633e1d86f38b342be5a1c8586e1b62fac 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -133,11 +133,12 @@ Initiates a call. This API uses an asynchronous callback to return the result. **Parameters** | Name | Type | Mandatory| Description | -| ----------- | ---------------------------- | ---- | --------------------------------------- | +| ----------- | ---------------------------- | ---- | -------------------------------------- | | phoneNumber | string | Yes | Phone number. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -152,8 +153,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.dialCall("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.dialCall("138xxxxxxxx", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -173,12 +174,13 @@ Initiates a call. You can set call options as needed. This API uses an asynchron **Parameters** | Name | Type | Mandatory| Description | -| ----------- | ----------------------------------- | ---- | ------------------------------------ | +| ----------- | ----------------------------------- | ---- | ----------------------------------- | | phoneNumber | string | Yes | Phone number. | | options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -198,8 +200,8 @@ call.dialCall("138xxxxxxxx", { videoState: 0, dialScene: 0, dialType: 0, -}, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -218,18 +220,19 @@ Initiates a call. You can set call options as needed. This API uses a promise to **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | ----------------------------------- | ---- |-------------------| -| phoneNumber | string | Yes | Phone number. | +| Name | Type | Mandatory| Description | +| ----------- | ----------------------------------- | ---- | -------------------------------------- | +| phoneNumber | string | Yes | Phone number. | | options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.| **Return value** -| Type | Description | -| ---------------------- | ------------------------------------------------------------ | -| Promise<void> | Promise used to return the result. | +| Type | Description | +| ---------------------- | ---------------------------- | +| Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -245,20 +248,15 @@ For details about the following error codes, see [Telephony Error Codes](../../r ```js let promise = call.dialCall("138xxxxxxxx", { - call.dialCall('138xxxxxxxx'); accountId: 0, videoState: 0, dialScene: 0, dialType: 0, }); -promise.then(data => { - console.log(`dialCall success, promise: data->${JSON.stringify(data)}`); - console.log(`dialCall success, promise: data->${JSON.stringify(data)}`); -} catch (error) { -}).catch(err => { - console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`); +promise.then(() => { + console.log(`dialCall success.`); +}).catch((err) => { console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`); -} }); ``` @@ -279,6 +277,7 @@ Launches the call screen and displays the dialed number. This API uses an asynch | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -319,6 +318,7 @@ Launches the call screen and displays the dialed number. This API uses a promise | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -472,6 +472,7 @@ Checks whether the called number is an emergency number. This API uses an asynch | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -508,6 +509,7 @@ Checks whether the called number is an emergency number based on the phone numbe | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -549,6 +551,7 @@ Checks whether the called number is an emergency number based on the phone numbe | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -588,6 +591,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. | callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -625,6 +629,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. | callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -670,6 +675,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. | Promise<string> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -712,6 +718,7 @@ The phone number must match the specified country code. For example, for a China | callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -757,6 +764,7 @@ All country codes are supported. | Promise<string> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -797,10 +805,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **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. | @@ -810,8 +820,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.muteRinger((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.muteRinger((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -835,13 +845,12 @@ Mutes the ringtone while it is playing. It does not work if the ringtone has bee | Promise<void> | Promise used to return the result.| **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. | @@ -849,10 +858,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.muteRinger(); -promise.then(data => { - console.log(`muteRinger success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.muteRinger().then(() => { + console.log(`muteRinger success.`); +}).catch((err) => { console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -878,6 +886,7 @@ Answers a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -892,8 +901,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.answerCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.answerCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -923,6 +932,7 @@ Answers a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -937,10 +947,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.answerCall(1); -promise.then(data => { - console.log(`answerCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.answerCall(1).then(() => { + console.log(`answerCall success.`); +}).catch((err) => { console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -965,6 +974,7 @@ Answers a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -979,8 +989,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.answerCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.answerCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1005,6 +1015,7 @@ Ends a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1019,8 +1030,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.hangUpCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.hangUpCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1050,6 +1061,7 @@ Ends a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1064,10 +1076,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.hangUpCall(1); -promise.then(data => { - console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.hangUpCall(1).then(() => { + console.log(`hangUpCall success.`); +}).catch((err) => { console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1092,6 +1103,7 @@ Ends a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1107,13 +1119,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.hangUpCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.hangUpCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` -## call.rejectCall7+ +## call.rejectCall9+ rejectCall(callId: number, callback: AsyncCallback\): void @@ -1133,6 +1145,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1148,8 +1161,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.rejectCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1175,6 +1188,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1192,8 +1206,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r let rejectMessageOptions={ messageContent: "Unknown number blocked" } -call.rejectCall(1, rejectMessageOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(1, rejectMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1224,6 +1238,7 @@ Rejects a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1241,11 +1256,10 @@ For details about the following error codes, see [Telephony Error Codes](../../r let rejectMessageOptions={ messageContent: "Unknown number blocked" } -let promise = call.rejectCall(1, rejectMessageOptions); -promise.then(data => { - console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { - console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`); +call.reject(1, rejectMessageOptions).then(() => { + console.log(`reject success.`); +}).catch((err) => { + console.error(`reject fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1269,6 +1283,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1283,8 +1298,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.rejectCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1309,6 +1324,7 @@ Rejects a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1326,8 +1342,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r let rejectMessageOptions={ messageContent: "Unknown number blocked" } -call.rejectCall(rejectMessageOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.rejectCall(rejectMessageOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1352,6 +1368,7 @@ Holds a call based on the specified call ID. This API uses an asynchronous callb | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1366,8 +1383,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.holdCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.holdCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1397,6 +1414,7 @@ Holds a call based on the specified call ID. This API uses a promise to return t | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1411,10 +1429,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.holdCall(1); -promise.then(data => { - console.log(`holdCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.holdCall(1).then(() => { + console.log(`holdCall success.`); +}).catch((err) => { console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1439,6 +1456,7 @@ Unholds a call based on the specified call ID. This API uses an asynchronous cal | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1453,8 +1471,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.unHoldCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.unHoldCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1484,6 +1502,7 @@ Unholds a call based on the specified call ID. This API uses a promise to return | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1498,10 +1517,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.unHoldCall(1); -promise.then(data => { - console.log(`unHoldCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.unHoldCall(1).then(() => { + console.log(`unHoldCall success.`); +}).catch((err) => { console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1526,6 +1544,7 @@ Switches a call. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1540,8 +1559,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.switchCall(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.switchCall(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1571,6 +1590,7 @@ Switches a call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1585,10 +1605,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.switchCall(1); -promise.then(data => { - console.log(`switchCall success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.switchCall(1).then(() => { + console.log(`switchCall success.`); +}).catch((err) => { console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1611,6 +1630,7 @@ Combines two calls into a conference call. This API uses an asynchronous callbac | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1624,8 +1644,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.combineConference(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.combineConference(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -1653,6 +1673,7 @@ Combines two calls into a conference call. This API uses a promise to return the | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1666,10 +1687,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.combineConference(1); -promise.then(data => { - console.log(`combineConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.combineConference(1).then(() => { + console.log(`combineConference success.`); +}).catch((err) => { console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1692,6 +1712,7 @@ Obtains the main call ID. This API uses an asynchronous callback to return the r | callback | AsyncCallback<number> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1735,6 +1756,7 @@ Obtains the main call ID. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1774,6 +1796,7 @@ Obtains the list of subcall IDs. This API uses an asynchronous callback to retur | callback | AsyncCallback\> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1816,6 +1839,7 @@ Obtains the list of subcall IDs. This API uses a promise to return the result. | Promise<Array> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1855,6 +1879,7 @@ Obtains the list of call IDs in a conference. This API uses an asynchronous call | callback | AsyncCallback<Array> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1897,6 +1922,7 @@ Obtains the list of call IDs in a conference. This API uses a promise to return | Promise<Array> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1938,6 +1964,7 @@ Obtains the call waiting status. This API uses an asynchronous callback to retur | callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.

- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -1983,6 +2010,7 @@ Obtains the call waiting status. This API uses a promise to return the result. | Promise<[CallWaitingStatus](#callwaitingstatus7)> | Promise used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2026,6 +2054,7 @@ Sets the call waiting switch. This API uses an asynchronous callback to return t | callback | AsyncCallback | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2040,8 +2069,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.setCallWaiting(0, true, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallWaiting(0, true, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2072,6 +2101,7 @@ Sets the call waiting switch. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2086,10 +2116,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.setCallWaiting(0, true); -promise.then(data => { - console.log(`setCallWaiting success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallWaiting(0, true).then(() => { + console.log(`setCallWaiting success.`); +}).catch((err) => { console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2113,6 +2142,7 @@ Enables DTMF. This API uses an asynchronous callback to return the result. | callback | AsyncCallback | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2126,8 +2156,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.startDTMF(1, "0", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.startDTMF(1, "0", (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2156,6 +2186,7 @@ Enables DTMF. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2169,10 +2200,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.startDTMF(1, "0"); -promise.then(data => { - console.log(`startDTMF success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.startDTMF(1, "0").then(() => { + console.log(`startDTMF success.`); +}).catch((err) => { console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2195,6 +2225,7 @@ Stops DTMF. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2208,8 +2239,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.stopDTMF(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.stopDTMF(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2237,6 +2268,7 @@ Stops DTMF. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2250,10 +2282,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.stopDTMF(1); -promise.then(data => { - console.log(`stopDTMF success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.stopDTMF(1).then(() => { + console.log(`stopDTMF success.`); +}).catch((err) => { console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2277,6 +2308,7 @@ Checks whether a call is an emergency call. This API uses an asynchronous callba | callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2316,6 +2348,7 @@ Checks whether a call is an emergency call. This API uses a promise to return th | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2354,10 +2387,11 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------- | ---- | -------------------------- | -| type | string | Yes | Call details change.| -| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. | +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2393,10 +2427,11 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | -------------------------- | -| type | string | Yes | Call event change.| +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2432,10 +2467,11 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------ | ---- | -------------------------- | -| type | string | Yes | Call disconnection cause.| +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2471,10 +2507,11 @@ Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback t | Name | Type | Mandatory| Description | | -------- | -------------------------------------------- | ---- | --------------------- | -| type | string | Yes | Man-machine interface (MMI) code result.| +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2510,10 +2547,11 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca | Name | Type | Mandatory| Description | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- | -| type | string | Yes | IMS registration status change.| +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2549,10 +2587,11 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ---------------------------------- | -| type | string | Yes | Call event change.| +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2587,11 +2626,12 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou **Parameters** | Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------------------- | ---- | -------------------- | -| type | 'callDisconnectedCause' | Yes | Call disconnection cause.| -| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. | +| -------- | ---------------------------------------------------------- | ---- | ------------------- | +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2625,12 +2665,13 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ----------- | -| type | 'mmiCodeResult' | Yes | Defines the MMI code result.| -| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. | +| 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. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2667,6 +2708,7 @@ Checks whether a new call is allowed. This API uses an asynchronous callback to | callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2703,6 +2745,7 @@ Checks whether a new call is allowed. This API uses a promise to return the resu | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2742,6 +2785,7 @@ Separates calls from a conference call. This API uses an asynchronous callback t | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2755,8 +2799,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.separateConference(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.separateConference(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2784,6 +2828,7 @@ Separates calls from a conference call. This API uses a promise to return the re | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2797,10 +2842,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.separateConference(1); -promise.then(data => { - console.log(`separateConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.separateConference(1).then(() => { + console.log(`separateConference success.`); +}).catch((err) => { console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -2826,6 +2870,7 @@ Obtains the call restriction status. This API uses an asynchronous callback to r | callback | AsyncCallback<[RestrictionStatus](#restrictionstatus8)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2872,6 +2917,7 @@ Obtains the call restriction status. This API uses a promise to return the resul | Promise<[RestrictionStatus](#restrictionstatus8)> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2915,6 +2961,7 @@ Sets the call restriction status. This API uses an asynchronous callback to retu | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2934,8 +2981,8 @@ let callRestrictionInfo={ password: "123456", mode: 1 } -call.setCallRestriction(0, callRestrictionInfo, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallRestriction(0, callRestrictionInfo, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -2966,6 +3013,7 @@ Sets the call restriction status. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -2985,10 +3033,9 @@ let callRestrictionInfo={ password: "123456", mode: 1 } -let promise = call.setCallRestriction(0, callRestrictionInfo); -promise.then(data => { - console.log(`setCallRestriction success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallRestriction(0, callRestrictionInfo).then(() => { + console.log(`setCallRestriction success.`); +}).catch((err) => { console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3014,6 +3061,7 @@ Obtains call transfer information. This API uses an asynchronous callback to ret | callback | AsyncCallback<[CallTransferResult](#calltransferresult8)> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3060,6 +3108,7 @@ Obtains call transfer information. This API uses a promise to return the result. | Promise<[CallTransferResult](#calltransferresult8)> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3103,6 +3152,7 @@ Sets call transfer information. This API uses an asynchronous callback to return | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3122,8 +3172,8 @@ let callTransferInfo={ type: 1, settingType: 1 } -call.setCallTransfer(0, callTransferInfo, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setCallTransfer(0, callTransferInfo, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3154,6 +3204,7 @@ Sets call transfer information. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3173,10 +3224,9 @@ let callTransferInfo={ type: 1, settingType: 1 } -let promise = call.setCallTransfer(0, callTransferInfo); -promise.then(data => { - console.log(`setCallTransfer success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setCallTransfer(0, callTransferInfo).then(() => { + console.log(`setCallTransfer success.`); +}).catch((err) => { console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3200,6 +3250,7 @@ Checks whether the ringtone is playing. This API uses an asynchronous callback t | callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3239,6 +3290,7 @@ Checks whether the ringtone is playing. This API uses a promise to return the re | Promise<boolean> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3278,6 +3330,7 @@ Sets call muting. This API uses an asynchronous callback to return the result. | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3291,8 +3344,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.setMuted((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setMuted((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3314,6 +3367,7 @@ Sets call muting. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3327,10 +3381,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.setMuted(); -promise.then(data => { - console.log(`setMuted success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setMuted().then(() => { + console.log(`setMuted success.`); +}).catch((err) => { console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3352,6 +3405,7 @@ Cancels call muting. This API uses an asynchronous callback to return the result | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3365,8 +3419,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.cancelMuted((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.cancelMuted((err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3388,6 +3442,7 @@ Cancels call muting. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3401,10 +3456,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.cancelMuted(); -promise.then(data => { - console.log(`cancelMuted success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.cancelMuted().then(() => { + console.log(`cancelMuted success.`); +}).catch((err) => { console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3427,6 +3481,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3440,8 +3495,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.setAudioDevice(1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setAudioDevice(1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3465,6 +3520,7 @@ Sets the audio device for a call based on the specified options. This API uses a | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3481,8 +3537,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, audioDeviceOptions, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.setAudioDevice(1, audioDeviceOptions, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3511,6 +3567,7 @@ Sets the audio device for a call based on the specified options. This API uses a | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3527,10 +3584,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -let promise = call.setAudioDevice(1, audioDeviceOptions); -promise.then(data => { - console.log(`setAudioDevice success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.setAudioDevice(1, audioDeviceOptions).then(() => { + console.log(`setAudioDevice success.`); +}).catch((err) => { console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3554,6 +3610,7 @@ Joins a conference call. This API uses an asynchronous callback to return the re | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3570,8 +3627,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r let callNumberList: Array = [ "138XXXXXXXX" ]; -call.joinConference(1, callNumberList, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.joinConference(1, callNumberList, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3599,6 +3656,7 @@ Joins a conference call. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3615,10 +3673,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r let callNumberList: Array = [ "138XXXXXXXX" ]; -let promise = call.joinConference(1, callNumberList); -promise.then(data => { - console.log(`joinConference success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.joinConference(1, callNumberList).then(() => { + console.log(`joinConference success.`); +}).catch((err) => { console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3642,6 +3699,7 @@ Updates the IMS call mode. This API uses an asynchronous callback to return the | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3655,8 +3713,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.updateImsCallMode(1, 1, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.updateImsCallMode(1, 1, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3684,6 +3742,7 @@ Updates the IMS call mode. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3697,10 +3756,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.updateImsCallMode(1, 1); -promise.then(data => { - console.log(`updateImsCallMode success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.updateImsCallMode(1, 1).then(() => { + console.log(`updateImsCallMode success.`); +}).catch((err) => { console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3725,6 +3783,7 @@ Enables the IMS switch. This API uses an asynchronous callback to return the res | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3739,8 +3798,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.enableImsSwitch(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.enableImsSwitch(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3769,6 +3828,7 @@ Enables the IMS switch. This API uses a promise to return the result. | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3783,10 +3843,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.enableImsSwitch(0); -promise.then(data => { - console.log(`enableImsSwitch success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.enableImsSwitch(0).then(() => { + console.log(`enableImsSwitch success.`); +}).catch((err) => { console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3811,6 +3870,7 @@ Disables the IMS switch. This API uses an asynchronous callback to return the re | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3825,8 +3885,8 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.disableImsSwitch(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.disableImsSwitch(0, (err) => { + console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3844,20 +3904,21 @@ Disables the IMS switch. This API uses a promise to return the result. **Parameters** -| Name| Type | Mandatory| Description | +| Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------------- | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | **Return value** -| Type | Description | +| Type | Description | | ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| Promise<void> | Promise used to return the result. | **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. | @@ -3869,10 +3930,9 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -let promise = call.disableImsSwitch(0); -promise.then(data => { - console.log(`disableImsSwitch success, promise: data->${JSON.stringify(data)}`); -}).catch(err => { +call.disableImsSwitch(0).then(() => { + console.log(`disableImsSwitch success.`); +}).catch((err) => { console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`); }); ``` @@ -3895,6 +3955,7 @@ Checks whether the IMS switch is enabled. This API uses an asynchronous callback | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. | **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -3936,6 +3997,7 @@ Checks whether the IMS switch is enabled. This API uses a promise to return the | Promise<void> | Promise used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index a2eaa213bdc0f10c65374802189eef0d26ac2c10..4f4145109457145016853dc67e6b1d546289aaa8 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -5,7 +5,7 @@ The **fileio** module provides APIs for file storage and management, including b > **NOTE** > > - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> - The APIs provided by this module are deprecated since API version 9. You are advised to use [@ohos.file.fs](./js-apis-file-fs.md). +> - The APIs provided by this module are deprecated since API version 9. You are advised to use [@ohos.file.fs](js-apis-file-fs.md). ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md index 260c8c541809f723cee63a3cf7f7ce9374ff886d..14456d1bec7aa82fcc0aaf30f415034ec3012aaa 100644 --- a/en/application-dev/reference/apis/js-apis-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiappevent.md @@ -1,6 +1,6 @@ # @ohos.hiAppEvent (Application Event Logging) -The HiAppEvent module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. +The **hiAppEvent** module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. > **NOTE** > - The APIs provided by this module are deprecated since API version 9. You are advised to use [`@ohos.hiviewdfx.hiAppEvent`](js-apis-hiviewdfx-hiappevent.md) instead. @@ -19,7 +19,7 @@ Before using application event logging, you need to understand the requirements **Event Name** -An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_). +An event name is a string that contains a maximum of 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_). **Event Type** @@ -30,9 +30,10 @@ An event type is an enumerated value of [EventType](#eventtype). An event parameter is an object in key-value pair format, where the key is the parameter name and the value is the parameter value. The requirements are as follows: - A parameter name is a string that contains a maximum of 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (\_). -- The parameter value is a string, number, boolean, or array. -- When the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be truncated. -- When the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded. +- The parameter value can be of the string, number, boolean, or array type. +- If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. +- If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. +- If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded. - The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded. **Event Callback** diff --git a/en/application-dev/reference/apis/js-apis-hilog.md b/en/application-dev/reference/apis/js-apis-hilog.md index 54355b12b723cf9cad06f5a4064568d5d772bea5..2ec65d87b5e74e5b8541057012f2e1352b435d7d 100644 --- a/en/application-dev/reference/apis/js-apis-hilog.md +++ b/en/application-dev/reference/apis/js-apis-hilog.md @@ -69,7 +69,7 @@ DEBUG logs are not recorded in official versions by default. They are available | ------ | ------ | ---- | ------------------------------------------------------------ | | domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -100,7 +100,7 @@ Prints INFO logs. | ------ | ------ | ---- | ------------------------------------------------------------ | | domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -131,7 +131,7 @@ Prints WARN logs. | ------ | ------ | ---- | ------------------------------------------------------------ | | domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -162,7 +162,7 @@ Prints ERROR logs. | ------ | ------ | ---- | ------------------------------------------------------------ | | domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -193,7 +193,7 @@ Prints FATAL logs. | ------ | ------ | ---- | ------------------------------------------------------------ | | domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md index 86e09db17bda0e6efa68bbeeb973a26f4a4ff467..03cad26cfecb5295b611d48fbc9f69862895ddb0 100644 --- a/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiviewdfx-hiappevent.md @@ -2,7 +2,8 @@ The **hiAppEvent** module provides application event-related functions, including flushing application events to a disk, querying and clearing application events, and customizing application event logging configuration. -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -119,12 +120,12 @@ Defines parameters for an **AppEventInfo** object. **System capability**: SystemCapability.HiviewDFX.HiAppEvent -| Name | Type | Mandatory| Description | -| --------- | ----------------------- | ---- | ---------- | -| domain | string | Yes | Event domain.| -| name | string | Yes | Event name.| -| eventType | [EventType](#eventtype) | Yes | Event type.| -| params | object | Yes | Event parameters.| +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ------------------------------------------------------------ | +| domain | string | Yes | Event domain. Event domain name, which is a string of up to 32 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).| +| name | string | Yes | Event name. Event name, which is a string of up to 48 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).| +| eventType | [EventType](#eventtype) | Yes | Event type. | +| params | object | Yes | Event parameter object, which consists of a parameter name and a parameter value. The specifications are as follows:
- The parameter name is a string of up to 16 characters, including digits (0 to 9), letters (a to z), and underscores (\_). It must start with a lowercase letter and cannot end with an underscore (_).
- The parameter value can be a string, number, boolean, or array. If the parameter value is a string, its maximum length is 8*1024 characters. If this limit is exceeded, excess characters will be discarded. If the parameter value is a number, the value must be within the range of **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. Otherwise, uncertain values may be generated. If the parameter value is an array, the elements in the array must be of the same type, which can only be string, number, or boolean. In addition, the number of elements must be less than 100. If this limit is exceeded, excess elements will be discarded.
- The maximum number of parameters is 32. If this limit is exceeded, excess parameters will be discarded.| ## hiAppEvent.configure @@ -447,27 +448,27 @@ Enumerates event types. | BEHAVIOR | 4 | Behavior event.| -## Event +## event Provides constants that define the names of all predefined events. **System capability**: SystemCapability.HiviewDFX.HiAppEvent -| Name | Type | Readable| Writable| Description | -| ------------------------- | ------ | ---- | ---- | -------------------- | -| USER_LOGIN | string | Yes | No | User login event. | -| USER_LOGOUT | string | Yes | No | User logout event. | -| DISTRIBUTED_SERVICE_START | string | Yes | No | Distributed service startup event.| +| Name | Type | Description | +| ------------------------- | ------ | -------------------- | +| USER_LOGIN | string | User login event. | +| USER_LOGOUT | string | User logout event. | +| DISTRIBUTED_SERVICE_START | string | Distributed service startup event.| -## Param +## param Provides constants that define the names of all predefined event parameters. **System capability**: SystemCapability.HiviewDFX.HiAppEvent -| Name | Type | Readable| Writable| Description | -| ------------------------------- | ------ | ---- | ---- | ------------------ | -| USER_ID | string | Yes | No | Custom user ID. | -| DISTRIBUTED_SERVICE_NAME | string | Yes | No | Distributed service name. | -| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes | No | Distributed service instance ID.| +| Name | Type | Description | +| ------------------------------- | ------ | ------------------ | +| USER_ID | string | Custom user ID. | +| DISTRIBUTED_SERVICE_NAME | string | Distributed service name. | +| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Distributed service instance ID.| diff --git a/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md b/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md index 09fbe19dbb6379ebef604cb4d88d9d40a305937e..22a07b41fa5a3ca98b55678350dceb7e92970fa7 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md @@ -88,7 +88,7 @@ export default class EntryAbility extends UIAbility { } ``` -## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback) +## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback\) off(type: 'abilityLifecycle', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; @@ -202,7 +202,7 @@ export default class EntryAbility extends UIAbility { } ``` -## ApplicationContext.off(type: 'environment', callbackId: number, callback: AsyncCallback) +## ApplicationContext.off(type: 'environment', callbackId: number, callback: AsyncCallback\) off(type: 'environment', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; @@ -327,7 +327,7 @@ applicationContext.getRunningProcessInformation((err, data) => { ## ApplicationContext.killProcessesBySelf9+ -killProcessesBySelf(): Promise; +killProcessesBySelf(): Promise\; Kills all the processes where the application is located. This API uses a promise to return the result. @@ -352,7 +352,7 @@ applicationContext.killProcessesBySelf().then((data) => { ## ApplicationContext.killProcessesBySelf9+ -killProcessesBySelf(callback: AsyncCallback); +killProcessesBySelf(callback: AsyncCallback\); Kills all the processes where the application is located. This API uses an asynchronous callback to return the result. diff --git a/en/application-dev/reference/apis/js-apis-inputconsumer.md b/en/application-dev/reference/apis/js-apis-inputconsumer.md index 4de59dd1322f1cc83203ad38bc63746c81d56e8a..2ffe21c960047907385c86d93ce353df0dc4f21d 100644 --- a/en/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/en/application-dev/reference/apis/js-apis-inputconsumer.md @@ -106,7 +106,7 @@ Represents combination key options. | Name | Type | Readable | Writable | Description | | --------- | ------ | ---- | ---- | ------- | -| preKeys | Array | Yes | No| Front key set. The number of front keys ranges from 0 to 4. There is no requirement on the sequence of the keys.| +| preKeys | Array\ | Yes | No| Front key set. The number of front keys ranges from 0 to 4. There is no requirement on the sequence of the keys.| | finalKey | number | Yes | No| Final key. This parameter is mandatory. A callback function is triggered by the final key.| | isFinalKeyDown | boolean | Yes | No| Whether the final key is pressed.| | finalKeyDownDuration | number | Yes | No| Duration within which the final key is pressed. If the value is **0**, the callback function is triggered immediately. If the value is greater than **0** and the value of **isFinalKeyDown** is **true**, the callback function is triggered when the key press duration is longer than the value of this parameter. If the value of **isFinalKeyDown** is **false**, the callback function is triggered when the duration from key press to key release is less than the value of this parameter. | diff --git a/en/application-dev/reference/apis/js-apis-net-ethernet.md b/en/application-dev/reference/apis/js-apis-net-ethernet.md index 3445952a9c818fad947373508accb50322e8cf59..d86e3904ec9c8789a645fde87492da5f5cd0c250 100644 --- a/en/application-dev/reference/apis/js-apis-net-ethernet.md +++ b/en/application-dev/reference/apis/js-apis-net-ethernet.md @@ -114,9 +114,9 @@ ethernet.setIfaceConfig("eth0", { dnsServers: "1.1.1.1", domain: "2.2.2.2" }).then(() => { - console.log("setIfaceConfig promiss ok "); + console.log("setIfaceConfig promise ok "); }).catch(error => { - console.log("setIfaceConfig promiss error = " + JSON.stringify(error)); + console.log("setIfaceConfig promise error = " + JSON.stringify(error)); }); ``` @@ -207,15 +207,15 @@ Obtains the configuration of a network interface. This API uses a promise to ret ```js ethernet.getIfaceConfig("eth0").then((data) => { - console.log("getIfaceConfig promiss mode = " + JSON.stringify(data.mode)); - console.log("getIfaceConfig promiss ipAddr = " + JSON.stringify(data.ipAddr)); - console.log("getIfaceConfig promiss route = " + JSON.stringify(data.route)); - console.log("getIfaceConfig promiss gateway = " + JSON.stringify(data.gateway)); - console.log("getIfaceConfig promiss netMask = " + JSON.stringify(data.netMask)); - console.log("getIfaceConfig promiss dnsServers = " + JSON.stringify(data.dnsServers)); - console.log("getIfaceConfig promiss domain = " + JSON.stringify(data.domain)); + console.log("getIfaceConfig promise mode = " + JSON.stringify(data.mode)); + console.log("getIfaceConfig promise ipAddr = " + JSON.stringify(data.ipAddr)); + console.log("getIfaceConfig promise route = " + JSON.stringify(data.route)); + console.log("getIfaceConfig promise gateway = " + JSON.stringify(data.gateway)); + console.log("getIfaceConfig promise netMask = " + JSON.stringify(data.netMask)); + console.log("getIfaceConfig promise dnsServers = " + JSON.stringify(data.dnsServers)); + console.log("getIfaceConfig promise domain = " + JSON.stringify(data.domain)); }).catch(error => { - console.log("getIfaceConfig promiss error = " + JSON.stringify(error)); + console.log("getIfaceConfig promise error = " + JSON.stringify(error)); }); ``` @@ -300,9 +300,9 @@ Checks whether a network interface is active. This API uses a promise to return ```js ethernet.isIfaceActive("eth0").then((data) => { - console.log("isIfaceActive promiss = " + JSON.stringify(data)); + console.log("isIfaceActive promise = " + JSON.stringify(data)); }).catch(error => { - console.log("isIfaceActive promiss error = " + JSON.stringify(error)); + console.log("isIfaceActive promise error = " + JSON.stringify(error)); }); ``` @@ -377,12 +377,12 @@ Obtains the list of all active network interfaces. This API uses a promise to re ```js ethernet.getAllActiveIfaces().then((data) => { - console.log("getAllActiveIfaces promiss data.length = " + JSON.stringify(data.length)); + console.log("getAllActiveIfaces promise data.length = " + JSON.stringify(data.length)); for (let i = 0; i < data.length; i++) { - console.log("getAllActiveIfaces promiss = " + JSON.stringify(data[i])); + console.log("getAllActiveIfaces promise = " + JSON.stringify(data[i])); } }).catch(error => { - console.log("getAllActiveIfaces promiss error = " + JSON.stringify(error)); + console.log("getAllActiveIfaces promise error = " + JSON.stringify(error)); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-observer.md b/en/application-dev/reference/apis/js-apis-observer.md index 2d56d02d2ec4e0f2117266569cb5bfd905f1b338..b0e30e22190f5242d16e4be0b815bcf4c4109f30 100644 --- a/en/application-dev/reference/apis/js-apis-observer.md +++ b/en/application-dev/reference/apis/js-apis-observer.md @@ -10,7 +10,7 @@ The **observer** module provides event subscription management functions. You ca ## Modules to Import ``` -import observer from '@ohos.telephony.observer' +import observer from '@ohos.telephony.observer'; ``` ## observer.on('networkStateChange') @@ -25,12 +25,13 @@ Registers an observer for network status change events. This API uses an asynchr **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Network status change event. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------------------- | +| 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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -45,7 +46,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('networkStateChange', data =>{ +observer.on('networkStateChange', data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); }); ``` @@ -63,13 +64,14 @@ Registers an observer for network status change events of the SIM card in the sp **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------------------------- | -| type | string | Yes | Network status change event. | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------------------- | +| type | string | Yes | Network status change event. This field has a fixed value of **networkStateChange**. | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -84,7 +86,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('networkStateChange', {slotId: 0}, data =>{ +observer.on('networkStateChange', {slotId: 0}, data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); }); ``` @@ -106,7 +108,7 @@ Unregisters the observer for network status change events. This API uses an asyn | 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).| | ID| Error Message | @@ -140,11 +142,12 @@ Registers an observer for signal status change events. This API uses an asynchro **Parameters** | 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\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -159,7 +162,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('signalInfoChange', data =>{ +observer.on('signalInfoChange', data => { console.log("on signalInfoChange, data:" + JSON.stringify(data)); }); ``` @@ -175,13 +178,14 @@ Registers an observer for signal status change events of the SIM card in the spe **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------------------------------- | -| type | string | Yes | Signal information change event. | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | string | Yes | Signal status change event. This field has a fixed value of **signalInfoChange**. | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | | callback | Callback\> | Yes | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -196,7 +200,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('signalInfoChange', {slotId: 0}, data =>{ +observer.on('signalInfoChange', {slotId: 0}, data => { console.log("on signalInfoChange, data:" + JSON.stringify(data)); }); ``` @@ -218,10 +222,11 @@ Unregisters the observer for signal status change events. This API uses an async | 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\> | No | Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#signalinformation).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -244,6 +249,125 @@ observer.off('signalInfoChange', callback); observer.off('signalInfoChange'); ``` +## observer.on('cellInfoChange')8+ + +on\(type: \'cellInfoChange\', callback: Callback\): void; + +Registers an observer for cell information change events. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- |------------------------------------------------------------| +| 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.| + +**Error codes** + +| 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** + +```js +observer.on('cellInfoChange', data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('cellInfoChange')8+ + +on\(type: \'cellInfoChange\', options: { slotId: number }, callback: Callback\): void; + +Registers an observer for signal status change events of the SIM card in the specified slot. This API uses an asynchronous callback to return the execution result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ |--------------------------------------------------| ---- |------------------------------------------------------------| +| type | string | Yes | Cell information change event. This field has a fixed value of **cellInfoChange**. | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | Yes | Callback used to return the result.| + +**Error codes** + +| 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** + +```js +observer.on('cellInfoChange', {slotId: 0}, data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('cellInfoChange')8+ + +off\(type: \'cellInfoChange\', callback?: Callback\): void; + +Unregisters the observer for cell information change events. This API uses an asynchronous callback to return the result. + +>**NOTE** +> +>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Cell information change event. This field has a fixed value of **cellInfoChange**. | +| callback | Callback\<[CellInformation](js-apis-radio.md#cellinformation8)\> | No | Callback used to return the result.| + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let callback = data => { + console.log("on cellInfoChange, data:" + JSON.stringify(data)); +} +observer.on('cellInfoChange', 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. +observer.off('cellInfoChange', callback); +observer.off('cellInfoChange'); +``` ## observer.on('callStateChange') @@ -256,11 +380,12 @@ Registers an observer for call status change events. This API uses an asynchrono **Parameters** | 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.
**number**: phone number.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -274,7 +399,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('callStateChange', value =>{ +observer.on('callStateChange', value => { console.log("on callStateChange, state:" + value.state + ", number:" + value.number); }); ``` @@ -291,12 +416,13 @@ Registers an observer for call status change events. This API uses an asynchrono **Parameters** | 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.
- **0**: card slot 1
- **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.
**number**: phone number.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -310,7 +436,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('callStateChange', {slotId: 0}, value =>{ +observer.on('callStateChange', {slotId: 0}, value => { console.log("on callStateChange, state:" + value.state + ", number:" + value.number); }); ``` @@ -331,11 +457,12 @@ Unregisters the observer for call status change events. This API uses an asynchr **Parameters** | 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.
**number**: phone number.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -371,10 +498,11 @@ Registers an observer for connection status change events of the cellular data l | 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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -388,7 +516,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataConnectionStateChange', value =>{ +observer.on('cellularDataConnectionStateChange', value => { console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); }); ``` @@ -406,11 +534,12 @@ Registers an observer for connection status change events of the cellular data l | 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.
- **0**: card slot 1
- **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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -424,7 +553,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{ +observer.on('cellularDataConnectionStateChange', {slotId: 0}, value => { console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); }); ``` @@ -446,10 +575,11 @@ Unregisters the observer for connection status change events of the cellular dat | 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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -485,10 +615,11 @@ Registers an observer for the uplink and downlink data flow status change events | 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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -502,7 +633,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataFlowChange', data =>{ +observer.on('cellularDataFlowChange', data => { console.log("on networkStateChange, data:" + JSON.stringify(data)); }); ``` @@ -520,11 +651,12 @@ Registers an observer for the uplink and downlink data flow status change events | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Uplink and downlink data flow status change event of the cellular data service. | -| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | +| type | string | Yes | Cellular data flow change event. This field has a fixed value of **cellularDataFlowChange**. | +| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -538,7 +670,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('cellularDataFlowChange', {slotId: 0}, data =>{ +observer.on('cellularDataFlowChange', {slotId: 0}, data => { console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); }); ``` @@ -558,12 +690,13 @@ Unregisters the observer for the uplink and downlink data flow status change eve **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Uplink and downlink data flow status change event of the cellular data service. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| 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).| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -598,11 +731,12 @@ Registers an observer for SIM card status change events. This API uses an asynch **Parameters** | 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.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -616,7 +750,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('simStateChange', data =>{ +observer.on('simStateChange', data => { console.log("on simStateChange, data:" + JSON.stringify(data)); }); ``` @@ -634,11 +768,12 @@ Registers an observer for status change events of the SIM card in the specified | 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.
- **0**: card slot 1
- **1**: card slot 2 | | callback | Callback\<[SimStateData](#simstatedata7)\> | Yes | Callback used to return the result.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -652,7 +787,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -observer.on('simStateChange', {slotId: 0}, data =>{ +observer.on('simStateChange', {slotId: 0}, data => { console.log("on simStateChange, data:" + JSON.stringify(data)); }); ``` @@ -674,10 +809,11 @@ Unregisters the observer for SIM card status change events. This API uses an asy | 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.| **Error codes** + For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). | ID| Error Message | @@ -732,6 +868,6 @@ Enumerates SIM card types and states. | Name | Type | Mandatory| Description | | ------------------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| type | [CardType](js-apis-sim.md#cardtype) | Yes | SIM card type. For details, see [CardType](js-apis-sim.md#cardtype).| -| state | [SimState](js-apis-sim.md#simstate) | Yes | SIM card status. For details, see [SimState](js-apis-sim.md#simstate).| +| type | [CardType](js-apis-sim.md#cardtype7) | Yes | SIM card type.| +| state | [SimState](js-apis-sim.md#simstate) | Yes | SIM card state.| | reason8+ | [LockReason](#lockreason8) | Yes | SIM card lock type. | diff --git a/en/application-dev/reference/errorcodes/errorcode-hiappevent.md b/en/application-dev/reference/errorcodes/errorcode-hiappevent.md index eb6d5000d0c0f82d5dddfa4f6985b1f308677b4a..46256b87f89e224891a4428c9cc429bec0781bf6 100644 --- a/en/application-dev/reference/errorcodes/errorcode-hiappevent.md +++ b/en/application-dev/reference/errorcodes/errorcode-hiappevent.md @@ -15,6 +15,7 @@ This error code is reported if the **write** API is called to perform applicatio The application event logging function is disabled. **Solution** + Invoke the **configure** API to enable the application event logging function. ```js @@ -41,6 +42,7 @@ The specified event domain name does not comply with the following rules: - The event domain name is not empty and contains a maximum of 32 characters. **Solution** + Specify a valid event domain name. ## 11101002 Invalid Event Name diff --git a/en/contribute/documentation-contribution.md b/en/contribute/documentation-contribution.md index 8901080d124e33855949e5594f1a0e2fb3fd5a46..caae52944c7e8b8ea312d094d5b461846d97015c 100755 --- a/en/contribute/documentation-contribution.md +++ b/en/contribute/documentation-contribution.md @@ -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. 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?** -> ->- 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. ->- 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. ->- 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. +> **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. +> - 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. +> - 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 diff --git a/en/contribute/writing-instructions.md b/en/contribute/writing-instructions.md index f1ff49c6bd1e3e066a5883c5d65e2e0aad7a7dbf..fb64cf3f30579491985ae6c4f08d95510fb23c52 100755 --- a/en/contribute/writing-instructions.md +++ b/en/contribute/writing-instructions.md @@ -60,8 +60,8 @@ Pictures used in **OpenHarmony\_DOCUMENTS/docs/quick-start/writing-instructions Use relative paths to reference pictures in the document. ->![](public_sys-resources/icon-caution.gif) **CAUTION:** ->Use the original pictures to avoid intellectual property infringement risks. +> **CAUTION** +> 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. - 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. - 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. ->![](public_sys-resources/icon-note.gif) **NOTE:** ->Reference: ->!\[\]\(./pic/pic-standard.png\) +> **NOTE** +> Reference: +> !\[\]\(./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. diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index 3a759af34a5afb96e07d844317a2a99f3cf20f50..7dd8216273a99eff11577851a9622d10eb8011b5 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -53,10 +53,6 @@ - [Sensor Overview](subsys-sensor-overview.md) - [Sensor Usage Guidelines](subsys-sensor-guide.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 Overview](subsys-application-framework-overview.md) - [Setting Up a Development Environment](subsys-application-framework-envbuild.md) diff --git a/en/device-dev/subsystems/subsys-usbservice-demo.md b/en/device-dev/subsystems/subsys-usbservice-demo.md deleted file mode 100644 index e78028f32a2f5b20d27267809d35b6bdcd1a0369..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-usbservice-demo.md +++ /dev/null @@ -1,185 +0,0 @@ -# USB Usage Example - - -```cpp -#include -#include -#include -#include -#include -#include -#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 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 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 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 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 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 configs = device.GetConfigs(); - OHOS::USB::USBConfig config = configs[0]; - std::vector 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; -} -``` diff --git a/en/device-dev/subsystems/subsys-usbservice-guide.md b/en/device-dev/subsystems/subsys-usbservice-guide.md deleted file mode 100644 index 8f95d32cb3f671474f961ffc728729a86585c6dd..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-usbservice-guide.md +++ /dev/null @@ -1,55 +0,0 @@ -# USB Usage Guidelines - - -The following procedure uses bulk transfer as an example. - -## 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 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); -``` diff --git a/en/device-dev/subsystems/subsys-usbservice-overview.md b/en/device-dev/subsystems/subsys-usbservice-overview.md deleted file mode 100644 index e4cc9c9ccd95ee4f8d72f949b778360cae860c1a..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-usbservice-overview.md +++ /dev/null @@ -1,338 +0,0 @@ -# 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 &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); | Reads data asynchronously during bulk transfer. | -| int32_t BulkWrite(USBDevicePipe &pip, const USBEndpoint &endpoint, sptr &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 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 -#include -#include -#include -#include -#include -#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 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 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 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 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 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 configs = device.GetConfigs(); - OHOS::USB::USBConfig config = configs[0]; - std::vector 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) diff --git a/en/readme/xts.md b/en/readme/xts.md index 042f4e197ce6d59cfda94e0cd7c72d22fc0ecc79..c317bc53e5f7335fe3d2f2911812db99bc8aad7d 100644 --- a/en/readme/xts.md +++ b/en/readme/xts.md @@ -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. - >![](public_sys-resources/icon-note.gif) **NOTE** - > - >The ACTS build middleware is a static library, which will be linked to the image. + > **NOTE** + > + > The ACTS build middleware is a static library, which will be linked to the image. ### 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 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** - > - >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. + > **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. ### C++-based Test Case Execution \(for Standard and Small Systems\)