提交 e5f45fdf 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 b237cb2c
...@@ -12,12 +12,10 @@ The following table provides only a brief description of related APIs. For detai ...@@ -12,12 +12,10 @@ The following table provides only a brief description of related APIs. For detai
**Table 1** APIs for application event logging **Table 1** APIs for application event logging
| API | Description | | API | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ | | ------------------------------------------------------------ | ---------------------------------------------------- |
| write(string eventName, EventType type, object keyValues, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result. | | write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(string eventName, EventType type, object keyValues): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. | | write(AppEventInfo info): Promise\<void> | Logs application events in asynchronous mode. This API uses a promise to return the result. |
| write(AppEventInfo info, AsyncCallback\<void> callback): void | Logs application events by domain in asynchronous mode. This API uses an asynchronous callback to return the result.|
| write(AppEventInfo info): Promise\<void> | Logs application events by domain in asynchronous mode. This API uses a promise to return the result.|
When an asynchronous callback is used, the return value can be processed directly in the callback. When an asynchronous callback is used, the return value can be processed directly in the callback.
...@@ -49,12 +47,12 @@ For details about the result codes, see [Event Verification Result Codes](#event ...@@ -49,12 +47,12 @@ For details about the result codes, see [Event Verification Result Codes](#event
| Result Code| Cause | Verification Rules | Handling Method | | Result Code| Cause | Verification Rules | Handling Method |
| ------ | ----------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------- | | ------ | ----------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------- |
| 0 | N/A | Event verification is successful. | Event logging is normal. No action is required. | | 0 | N/A | Event verification is successful. | Event logging is normal. No action is required. |
| -1 | Invalid event name | The name is not empty and contains a maximum of 48 characters.<br>The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore \(_).<br>The name does not start with a digit or underscore \(_).| Ignore this event and do not perform logging. | | -1 | Invalid event name | The name is not empty and contains a maximum of 48 characters.<br>The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).<br>The name does not start with a digit or underscore (\_).| Ignore this event and do not perform logging. |
| -2 | Invalid event parameter type | The event name must be a string.<br>The event type must be a number.<br>The event parameter must be an object.| Ignore this event and do not perform logging. | | -2 | Invalid event parameter type | The event name must be a string.<br>The event type must be a number.<br>The event parameter must be an object.| Ignore this event and do not perform logging. |
| -4 | Invalid event domain name | The name is not empty and contains a maximum of 32 characters.<br>The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore \(_).<br>The name does not start with a digit or underscore \(_).| Ignore this event and do not perform logging. | | -4 | Invalid event domain name | The name is not empty and contains a maximum of 32 characters.<br>The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).<br>The name does not start with a digit or underscore (\_).| Ignore this event and do not perform logging. |
| -99 | Application event logging disabled | Application event logging is disabled. | Ignore this event and do not perform logging. | | -99 | Application event logging disabled | Application event logging is disabled. | Ignore this event and do not perform logging. |
| -100 | Unknown error | None. | Ignore this event and do not perform logging. | | -100 | Unknown error | None. | Ignore this event and do not perform logging. |
| 1 | Invalid key name | The name is not empty and contains a maximum of 16 characters.<br>The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore \(_).<br>The name does not start with a digit or underscore \(_).<br>The name does not end with an underscore \(_).| Ignore the key-value pair and continue to perform logging. | | 1 | Invalid key name | The name is not empty and contains a maximum of 16 characters.<br>The name consists of only the following characters: digits (0 to 9), letters (a to z), and underscore (\_).<br>The name does not start with a digit or underscore (\_).<br>The name does not end with an underscore (\_).| Ignore the key-value pair and continue to perform logging. |
| 2 | Invalid key type | The key must be a string. | Ignore the key-value pair and continue to perform logging. | | 2 | Invalid key type | The key must be a string. | Ignore the key-value pair and continue to perform logging. |
| 3 | Invalid value type | The supported value types vary depending on the programming language:<br>boolean, number, string, or Array [basic element]| Ignore the key-value pair and continue to perform logging. | | 3 | Invalid value type | The supported value types vary depending on the programming language:<br>boolean, number, string, or Array [basic element]| Ignore the key-value pair and continue to perform logging. |
| 4 | Invalid length for values of the string type| For a value of the string type, the maximum length is 8*1024 characters. | Truncate the value with the first 8*1024 characters retained, and continue to perform logging.| | 4 | Invalid length for values of the string type| For a value of the string type, the maximum length is 8*1024 characters. | Truncate the value with the first 8*1024 characters retained, and continue to perform logging.|
...@@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -84,6 +82,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button("1 writeTest").onClick(()=>{ Button("1 writeTest").onClick(()=>{
// Perform event logging based on the input event parameters.
hiAppEvent.write({ hiAppEvent.write({
domain: "test_domain", domain: "test_domain",
name: "test_event", name: "test_event",
...@@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -100,6 +99,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
}) })
Button("2 addWatcherTest").onClick(()=>{ Button("2 addWatcherTest").onClick(()=>{
// Add an event watcher based on the input subscription parameters.
hiAppEvent.addWatcher({ hiAppEvent.addWatcher({
name: "watcher1", name: "watcher1",
appEventFilters: [{ domain: "test_domain" }], appEventFilters: [{ domain: "test_domain" }],
...@@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -109,17 +109,23 @@ The following uses a one-time event watcher as an example to illustrate the deve
timeOut: 2 timeOut: 2
}, },
onTrigger: function (curRow, curSize, holder) { onTrigger: function (curRow, curSize, holder) {
// If the holder object is null, return an error after recording it in the log.
if (holder == null) { if (holder == null) {
console.error("HiAppEvent holder is null"); console.error("HiAppEvent holder is null");
return; return;
} }
// Set the size threshold to 1,000 bytes for obtaining an event package.
holder.setSize(1000);
let eventPkg = null; let eventPkg = null;
// Obtain the event package based on the configured size threshold. If returned event package is null, all event data has been obtained.
while ((eventPkg = holder.takeNext()) != null) { while ((eventPkg = holder.takeNext()) != null) {
console.info("HiAppEvent eventPkg.packageId=" + eventPkg.packageId); // Parse the obtained event package and display the result on the Log page.
console.info("HiAppEvent eventPkg.row=" + eventPkg.row); console.info('HiAppEvent eventPkg.packageId=' + eventPkg.packageId);
console.info("HiAppEvent eventPkg.size=" + eventPkg.size); console.info('HiAppEvent eventPkg.row=' + eventPkg.row);
console.info('HiAppEvent eventPkg.size=' + eventPkg.size);
// Traverse and parse event string arrays in the obtained event package.
for (const eventInfo of eventPkg.data) { for (const eventInfo of eventPkg.data) {
console.info("HiAppEvent eventPkg.data=" + eventInfo); console.info('HiAppEvent eventPkg.data=' + eventInfo);
} }
} }
} }
...@@ -127,6 +133,7 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -127,6 +133,7 @@ The following uses a one-time event watcher as an example to illustrate the deve
}) })
Button("3 removeWatcherTest").onClick(()=>{ Button("3 removeWatcherTest").onClick(()=>{
// Remove the specified event watcher.
hiAppEvent.removeWatcher({ hiAppEvent.removeWatcher({
name: "watcher1" name: "watcher1"
}) })
...@@ -157,9 +164,3 @@ The following uses a one-time event watcher as an example to illustrate the deve ...@@ -157,9 +164,3 @@ The following uses a one-time event watcher as an example to illustrate the deve
``` ```
5. On the application UI, touch button 3 to remove the event watcher. Then, touch button 1 for multiple times to perform application event logging. In such a case, there will be no log information about the callback invoked by the event watcher. 5. On the application UI, touch button 3 to remove the event watcher. Then, touch button 1 for multiple times to perform application event logging. In such a case, there will be no log information about the callback invoked by the event watcher.
## Samples
The following sample is provided to help you better understand how to develop the application event logging feature:
- [`JsDotTest` (JS) (API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/DFX/JsDotTest)
...@@ -834,7 +834,7 @@ promise.then(data => { ...@@ -834,7 +834,7 @@ promise.then(data => {
## call.reject<sup>7+</sup> ## call.reject<sup>7+</sup>
reject\(callId: number, options: RejectMessageOption, callback: AsyncCallback<void\>\): void reject\(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result. Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result.
......
...@@ -194,8 +194,8 @@ Updates a contact based on the specified contact information and attributes. Thi ...@@ -194,8 +194,8 @@ Updates a contact based on the specified contact information and attributes. Thi
contact.updateContact({ contact.updateContact({
fullName: {fullName: 'xxx'}, fullName: {fullName: 'xxx'},
phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] phoneNumbers: [{phoneNumber: '138xxxxxxxx'}]
},{ }, {
attributes:[contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}, (err) => { }, (err) => {
if (err) { if (err) {
console.log('updateContact callback: err->${JSON.stringify(err)}'); console.log('updateContact callback: err->${JSON.stringify(err)}');
...@@ -449,7 +449,7 @@ Queries my card based on the specified contact attributes. This API uses a promi ...@@ -449,7 +449,7 @@ Queries my card based on the specified contact attributes. This API uses a promi
```js ```js
let promise = contact.queryMyCard({ let promise = contact.queryMyCard({
attributes:['ATTR_EMAIL', 'ATTR_NAME'] attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME]
}); });
promise.then((data) => { promise.then((data) => {
console.log(`queryMyCard success: data->${JSON.stringify(data)}`); console.log(`queryMyCard success: data->${JSON.stringify(data)}`);
...@@ -467,7 +467,7 @@ Selects a contact. This API uses an asynchronous callback to return the result. ...@@ -467,7 +467,7 @@ Selects a contact. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.READ_CONTACTS **Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData **System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.Contacts
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
...@@ -495,7 +495,7 @@ Selects a contact. This API uses a promise to return the result. ...@@ -495,7 +495,7 @@ Selects a contact. This API uses a promise to return the result.
**Permission required**: ohos.permission.READ_CONTACTS **Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Applications.Contacts and SystemCapability.Applications.ContactsData **System capability**: SystemCapability.Applications.Contacts
**Return Value** **Return Value**
| Type | Description | | Type | Description |
......
...@@ -207,7 +207,7 @@ let ret = hiSysEvent.addWatcher(watcher) ...@@ -207,7 +207,7 @@ let ret = hiSysEvent.addWatcher(watcher)
## hiSysEvent.removeWatcher ## hiSysEvent.removeWatcher
removeWatcher(wathcer: Watcher): number removeWatcher(watcher: Watcher): number
Removes a watcher used for event subscription. Removes a watcher used for event subscription.
......
...@@ -67,6 +67,8 @@ hasDefaultNet(callback: AsyncCallback\<boolean>): void ...@@ -67,6 +67,8 @@ hasDefaultNet(callback: AsyncCallback\<boolean>): void
Checks whether the default data network is activated. This API uses an asynchronous callback to return the result. Checks whether the default data network is activated. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Parameters** **Parameters**
...@@ -90,6 +92,8 @@ hasDefaultNet(): Promise\<boolean> ...@@ -90,6 +92,8 @@ hasDefaultNet(): Promise\<boolean>
Checks whether the default data network is activated. This API uses a promise to return the result. Checks whether the default data network is activated. This API uses a promise to return the result.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Communication.NetManager.Core **System capability**: SystemCapability.Communication.NetManager.Core
**Return Value** **Return Value**
......
...@@ -384,6 +384,27 @@ promise.then(data => { ...@@ -384,6 +384,27 @@ promise.then(data => {
}); });
``` ```
## radio.isNrSupported<sup>7+</sup>
isNrSupported\(\): boolean
Checks whether the current device supports 5G \(NR\).
**System capability**: SystemCapability.Telephony.CoreService
**Return value**
| Type | Description |
| ------- | -------------------------------- |
| boolean | - **true**: The current device supports 5G \(NR\).<br>- **false**: The current device does not support 5G \(NR\).|
**Example**
```js
let result = radio.isNrSupported();
console.log("Result: "+ result);
``
## radio.isNrSupported<sup>8+</sup> ## radio.isNrSupported<sup>8+</sup>
......
...@@ -2657,8 +2657,6 @@ getOpKey(slotId: number, callback: AsyncCallback<string\>): void ...@@ -2657,8 +2657,6 @@ getOpKey(slotId: number, callback: AsyncCallback<string\>): void
Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
...@@ -2683,8 +2681,6 @@ getOpKey(slotId: number): Promise<string\> ...@@ -2683,8 +2681,6 @@ getOpKey(slotId: number): Promise<string\>
Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result. Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
...@@ -2716,8 +2712,6 @@ getOpName(slotId: number, callback: AsyncCallback<string\>): void ...@@ -2716,8 +2712,6 @@ getOpName(slotId: number, callback: AsyncCallback<string\>): void
Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
...@@ -2742,8 +2736,6 @@ getOpName(slotId: number): Promise<string\> ...@@ -2742,8 +2736,6 @@ getOpName(slotId: number): Promise<string\>
Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result. Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
**Parameters** **Parameters**
......
...@@ -79,7 +79,7 @@ This is a system API. ...@@ -79,7 +79,7 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -90,6 +90,29 @@ data.setDefaultCellularDataSlotId(0,(err, data) => { ...@@ -90,6 +90,29 @@ data.setDefaultCellularDataSlotId(0,(err, data) => {
}); });
``` ```
## data.getDefaultCellularDataSlotIdSync
getDefaultCellularDataSlotIdSync(): number
Obtains the default SIM card used for mobile data.
**Required permission**: ohos.permission.GET_NETWORK_INFO
**System capability**: SystemCapability.Telephony.CellularData
**Return value**
| Type | Description |
| ------ | -------------------------------------------------- |
| number | Card slot ID.<br>**0**: card slot 1<br>**1**: card slot 2 |
**Example**
```js
console.log("Result: "+ data.getDefaultCellularDataSlotIdSync())
```
## data.setDefaultCellularDataSlotId ## data.setDefaultCellularDataSlotId
setDefaultCellularDataSlotId(slotId: number): Promise\<void\> setDefaultCellularDataSlotId(slotId: number): Promise\<void\>
...@@ -104,13 +127,13 @@ This is a system API. ...@@ -104,13 +127,13 @@ This is a system API.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------------- | | -------------- | ------------------------------- |
| Promise<\void\> | Promise used to return the result. | | Promise<\void\> | Promise used to return the result. |
...@@ -135,7 +158,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u ...@@ -135,7 +158,7 @@ Obtains the cellular data flow type, which can be uplink or downlink. This API u
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | ---------- | | -------- | ---------------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<[DataFlowType](#dataflowtype)\> | Yes | Callback used to return the result.|
...@@ -204,7 +227,7 @@ Obtains the connection status of the PS domain. This API uses a promise to retur ...@@ -204,7 +227,7 @@ Obtains the connection status of the PS domain. This API uses a promise to retur
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------------ | ------------------------------------- | | ------------------------------------------------ | ------------------------------------- |
| Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.| | Promise\<[DataConnectState](#dataconnectstate)\> | Promise used to return the result.|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册