提交 a240fe58 编写于 作者: E ester.zhou

update doc

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 1a57f3be
...@@ -5,62 +5,62 @@ ...@@ -5,62 +5,62 @@
## Required Permissions ## Required Permissions
| Common Event Macro| Common Event Name| Subscriber Permissions| | Common Event Macro | Common Event Name | Subscriber Permissions |
| ------------ | ------------------ | ---------------------- | | ------------ | ------------------ | ---------------------- |
| COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | | COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED |
| COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | N/A| | COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | N/A |
| COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | N/A| | COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | N/A |
| COMMON_EVENT_BATTERY_LOW | usual.event.BATTERY_LOW | N/A| | COMMON_EVENT_BATTERY_LOW | usual.event.BATTERY_LOW | N/A |
| COMMON_EVENT_BATTERY_OKAY | usual.event.BATTERY_OKAY | N/A| | COMMON_EVENT_BATTERY_OKAY | usual.event.BATTERY_OKAY | N/A |
| COMMON_EVENT_POWER_CONNECTED | usual.event.POWER_CONNECTED | N/A| | COMMON_EVENT_POWER_CONNECTED | usual.event.POWER_CONNECTED | N/A |
| COMMON_EVENT_POWER_DISCONNECTED | usual.event.POWER_DISCONNECTED | N/A| | COMMON_EVENT_POWER_DISCONNECTED | usual.event.POWER_DISCONNECTED | N/A |
| COMMON_EVENT_SCREEN_OFF | usual.event.SCREEN_OFF | N/A| | COMMON_EVENT_SCREEN_OFF | usual.event.SCREEN_OFF | N/A |
| COMMON_EVENT_SCREEN_ON | usual.event.SCREEN_ON | N/A| | COMMON_EVENT_SCREEN_ON | usual.event.SCREEN_ON | N/A |
| COMMON_EVENT_USER_PRESENT | usual.event.USER_PRESENT | N/A| | COMMON_EVENT_USER_PRESENT | usual.event.USER_PRESENT | N/A |
| COMMON_EVENT_TIME_TICK | usual.event.TIME_TICK | N/A| | COMMON_EVENT_TIME_TICK | usual.event.TIME_TICK | N/A |
| COMMON_EVENT_TIME_CHANGED | usual.event.TIME_CHANGED | N/A| | COMMON_EVENT_TIME_CHANGED | usual.event.TIME_CHANGED | N/A |
| COMMON_EVENT_DATE_CHANGED | usual.event.DATE_CHANGED | N/A| | COMMON_EVENT_DATE_CHANGED | usual.event.DATE_CHANGED | N/A |
| COMMON_EVENT_TIMEZONE_CHANGED | usual.event.TIMEZONE_CHANGED | N/A| | COMMON_EVENT_TIMEZONE_CHANGED | usual.event.TIMEZONE_CHANGED | N/A |
| COMMON_EVENT_CLOSE_SYSTEM_DIALOGS | usual.event.CLOSE_SYSTEM_DIALOGS | N/A| | COMMON_EVENT_CLOSE_SYSTEM_DIALOGS | usual.event.CLOSE_SYSTEM_DIALOGS | N/A |
| COMMON_EVENT_PACKAGE_ADDED | usual.event.PACKAGE_ADDED | N/A| | COMMON_EVENT_PACKAGE_ADDED | usual.event.PACKAGE_ADDED | N/A |
| COMMON_EVENT_PACKAGE_REPLACED | usual.event.PACKAGE_REPLACED | N/A| | COMMON_EVENT_PACKAGE_REPLACED | usual.event.PACKAGE_REPLACED | N/A |
| COMMON_EVENT_MY_PACKAGE_REPLACED | usual.event.MY_PACKAGE_REPLACED | N/A| | COMMON_EVENT_MY_PACKAGE_REPLACED | usual.event.MY_PACKAGE_REPLACED | N/A |
| COMMON_EVENT_PACKAGE_REMOVED | usual.event.PACKAGE_REMOVED | N/A| | COMMON_EVENT_PACKAGE_REMOVED | usual.event.PACKAGE_REMOVED | N/A |
| COMMON_EVENT_PACKAGE_FULLY_REMOVED | usual.event.PACKAGE_FULLY_REMOVED | N/A| | COMMON_EVENT_PACKAGE_FULLY_REMOVED | usual.event.PACKAGE_FULLY_REMOVED | N/A |
| COMMON_EVENT_PACKAGE_CHANGED | usual.event.PACKAGE_CHANGED | N/A| | COMMON_EVENT_PACKAGE_CHANGED | usual.event.PACKAGE_CHANGED | N/A |
| COMMON_EVENT_PACKAGE_RESTARTED | usual.event.PACKAGE_RESTARTED | N/A| | COMMON_EVENT_PACKAGE_RESTARTED | usual.event.PACKAGE_RESTARTED | N/A |
| COMMON_EVENT_PACKAGE_DATA_CLEARED | usual.event.PACKAGE_DATA_CLEARED | N/A| | COMMON_EVENT_PACKAGE_DATA_CLEARED | usual.event.PACKAGE_DATA_CLEARED | N/A |
| COMMON_EVENT_PACKAGES_SUSPENDED | usual.event.PACKAGES_SUSPENDED | N/A| | COMMON_EVENT_PACKAGES_SUSPENDED | usual.event.PACKAGES_SUSPENDED | N/A |
| COMMON_EVENT_PACKAGES_UNSUSPENDED | usual.event.PACKAGES_UNSUSPENDED | N/A| | COMMON_EVENT_PACKAGES_UNSUSPENDED | usual.event.PACKAGES_UNSUSPENDED | N/A |
| COMMON_EVENT_MY_PACKAGE_SUSPENDED | usual.event.MY_PACKAGE_SUSPENDED | N/A| | COMMON_EVENT_MY_PACKAGE_SUSPENDED | usual.event.MY_PACKAGE_SUSPENDED | N/A |
| COMMON_EVENT_MY_PACKAGE_UNSUSPENDED | usual.event.MY_PACKAGE_UNSUSPENDED | N/A| | COMMON_EVENT_MY_PACKAGE_UNSUSPENDED | usual.event.MY_PACKAGE_UNSUSPENDED | N/A |
| COMMON_EVENT_UID_REMOVED | usual.event.UID_REMOVED | N/A| | COMMON_EVENT_UID_REMOVED | usual.event.UID_REMOVED | N/A |
| COMMON_EVENT_PACKAGE_FIRST_LAUNCH | usual.event.PACKAGE_FIRST_LAUNCH | N/A| | COMMON_EVENT_PACKAGE_FIRST_LAUNCH | usual.event.PACKAGE_FIRST_LAUNCH | N/A |
| COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION | usual.event.PACKAGE_NEEDS_VERIFICATION | N/A| | COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION | usual.event.PACKAGE_NEEDS_VERIFICATION | N/A |
| COMMON_EVENT_PACKAGE_VERIFIED | usual.event.PACKAGE_VERIFIED | N/A| | COMMON_EVENT_PACKAGE_VERIFIED | usual.event.PACKAGE_VERIFIED | N/A |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE | usual.event.EXTERNAL_APPLICATIONS_AVAILABLE | N/A| | COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE | usual.event.EXTERNAL_APPLICATIONS_AVAILABLE | N/A |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE | usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE | N/A| | COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE | usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE | N/A |
| COMMON_EVENT_CONFIGURATION_CHANGED | usual.event.CONFIGURATION_CHANGED | N/A| | COMMON_EVENT_CONFIGURATION_CHANGED | usual.event.CONFIGURATION_CHANGED | N/A |
| COMMON_EVENT_LOCALE_CHANGED | usual.event.LOCALE_CHANGED | N/A| | COMMON_EVENT_LOCALE_CHANGED | usual.event.LOCALE_CHANGED | N/A |
| COMMON_EVENT_MANAGE_PACKAGE_STORAGE | usual.event.MANAGE_PACKAGE_STORAGE | N/A| | COMMON_EVENT_MANAGE_PACKAGE_STORAGE | usual.event.MANAGE_PACKAGE_STORAGE | N/A |
| COMMON_EVENT_DRIVE_MODE | common.event.DRIVE_MODE | N/A| | COMMON_EVENT_DRIVE_MODE | common.event.DRIVE_MODE | N/A |
| COMMON_EVENT_HOME_MODE | common.event.HOME_MODE | N/A| | COMMON_EVENT_HOME_MODE | common.event.HOME_MODE | N/A |
| COMMON_EVENT_OFFICE_MODE | common.event.OFFICE_MODE | N/A| | COMMON_EVENT_OFFICE_MODE | common.event.OFFICE_MODE | N/A |
| COMMON_EVENT_USER_STARTED | usual.event.USER_STARTED | N/A| | COMMON_EVENT_USER_STARTED | usual.event.USER_STARTED | N/A |
| COMMON_EVENT_USER_BACKGROUND | usual.event.USER_BACKGROUND | N/A| | COMMON_EVENT_USER_BACKGROUND | usual.event.USER_BACKGROUND | N/A |
| COMMON_EVENT_USER_FOREGROUND | usual.event.USER_FOREGROUND | N/A| | COMMON_EVENT_USER_FOREGROUND | usual.event.USER_FOREGROUND | N/A |
| COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_USERS | | COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_USERS |
| COMMON_EVENT_USER_UNLOCKED | usual.event.USER_UNLOCKED | N/A| | COMMON_EVENT_USER_UNLOCKED | usual.event.USER_UNLOCKED | N/A |
| COMMON_EVENT_USER_STOPPED | usual.event.USER_STOPPED | N/A| | COMMON_EVENT_USER_STOPPED | usual.event.USER_STOPPED | N/A |
| COMMON_EVENT_HWID_LOGIN | common.event.HWID_LOGIN | N/A| | COMMON_EVENT_HWID_LOGIN | common.event.HWID_LOGIN | N/A |
| COMMON_EVENT_HWID_LOGOUT | common.event.HWID_LOGOUT | N/A| | COMMON_EVENT_HWID_LOGOUT | common.event.HWID_LOGOUT | N/A |
| COMMON_EVENT_HWID_TOKEN_INVALID | common.event.HWID_TOKEN_INVALID | N/A| | COMMON_EVENT_HWID_TOKEN_INVALID | common.event.HWID_TOKEN_INVALID | N/A |
| COMMON_EVENT_HWID_LOGOFF | common.event.HWID_LOGOFF | N/A| | COMMON_EVENT_HWID_LOGOFF | common.event.HWID_LOGOFF | N/A |
| COMMON_EVENT_WIFI_POWER_STATE | usual.event.wifi.POWER_STATE | N/A| | COMMON_EVENT_WIFI_POWER_STATE | usual.event.wifi.POWER_STATE | N/A |
| COMMON_EVENT_WIFI_SCAN_FINISHED | usual.event.wifi.SCAN_FINISHED | ohos.permission.LOCATION | | COMMON_EVENT_WIFI_SCAN_FINISHED | usual.event.wifi.SCAN_FINISHED | ohos.permission.LOCATION |
| COMMON_EVENT_WIFI_RSSI_VALUE | usual.event.wifi.RSSI_VALUE | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_RSSI_VALUE | usual.event.wifi.RSSI_VALUE | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_WIFI_CONN_STATE | usual.event.wifi.CONN_STATE | N/A| | COMMON_EVENT_WIFI_CONN_STATE | usual.event.wifi.CONN_STATE | N/A |
| COMMON_EVENT_WIFI_HOTSPOT_STATE | usual.event.wifi.HOTSPOT_STATE | N/A| | COMMON_EVENT_WIFI_HOTSPOT_STATE | usual.event.wifi.HOTSPOT_STATE | N/A |
| COMMON_EVENT_WIFI_AP_STA_JOIN | usual.event.wifi.WIFI_HS_STA_JOIN | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_AP_STA_JOIN | usual.event.wifi.WIFI_HS_STA_JOIN | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_WIFI_AP_STA_LEAVE | usual.event.wifi.WIFI_HS_STA_LEAVE | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_AP_STA_LEAVE | usual.event.wifi.WIFI_HS_STA_LEAVE | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_WIFI_P2P_CONN_STATE | usual.event.wifi.p2p.CONN_STATE_CHANGE | ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION | | COMMON_EVENT_WIFI_P2P_CONN_STATE | usual.event.wifi.p2p.CONN_STATE_CHANGE | ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION |
...@@ -70,45 +70,45 @@ ...@@ -70,45 +70,45 @@
| COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED | usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED | usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED | usual.event.wifi.p2p.GROUP_STATE_CHANGED | ohos.permission.GET_WIFI_INFO | | COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED | usual.event.wifi.p2p.GROUP_STATE_CHANGED | ohos.permission.GET_WIFI_INFO |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | | COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT | usual.event.bluetooth.remotedevice.SDP_RESULT | N/A| | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT | usual.event.bluetooth.remotedevice.SDP_RESULT | N/A |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL | usual.event.bluetooth.remotedevice.PAIRING_CANCEL | N/A| | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL | usual.event.bluetooth.remotedevice.PAIRING_CANCEL | N/A |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ | usual.event.bluetooth.remotedevice.CONNECT_REQ | N/A| | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ | usual.event.bluetooth.remotedevice.CONNECT_REQ | N/A |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY | usual.event.bluetooth.remotedevice.CONNECT_REPLY | N/A| | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY | usual.event.bluetooth.remotedevice.CONNECT_REPLY | N/A |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL | usual.event.bluetooth.remotedevice.CONNECT_CANCEL | N/A| | COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL | usual.event.bluetooth.remotedevice.CONNECT_CANCEL | N/A |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE | N/A| | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE | N/A |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE | N/A| | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE | N/A |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT | usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT | N/A| | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT | usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT | N/A |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE | N/A| | COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE | N/A |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE | usual.event.bluetooth.host.REQ_DISCOVERABLE | N/A| | COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE | usual.event.bluetooth.host.REQ_DISCOVERABLE | N/A |
| COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED | usual.event.nfc.action.ADAPTER_STATE_CHANGED | N/A| | COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED | usual.event.nfc.action.ADAPTER_STATE_CHANGED | N/A |
| COMMON_EVENT_DISCHARGING | usual.event.DISCHARGING | N/A| | COMMON_EVENT_DISCHARGING | usual.event.DISCHARGING | N/A |
| COMMON_EVENT_CHARGING | usual.event.CHARGING | N/A| | COMMON_EVENT_CHARGING | usual.event.CHARGING | N/A |
| COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED | usual.event.DEVICE_IDLE_MODE_CHANGED | N/A| | COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED | usual.event.DEVICE_IDLE_MODE_CHANGED | N/A |
| COMMON_EVENT_POWER_SAVE_MODE_CHANGED | usual.event.POWER_SAVE_MODE_CHANGED | N/A| | COMMON_EVENT_POWER_SAVE_MODE_CHANGED | usual.event.POWER_SAVE_MODE_CHANGED | N/A |
| COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_USERS | | COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_USERS |
| COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_USERS | | COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_USERS |
| COMMON_EVENT_LOCATION_MODE_STATE_CHANGED | usual.event.location.MODE_STATE_CHANGED | N/A| | COMMON_EVENT_LOCATION_MODE_STATE_CHANGED | usual.event.location.MODE_STATE_CHANGED | N/A |
| COMMON_EVENT_IVI_SLEEP | common.event.IVI_SLEEP | N/A| | COMMON_EVENT_IVI_SLEEP | common.event.IVI_SLEEP | N/A |
| COMMON_EVENT_IVI_PAUSE | common.event.IVI_PAUSE | N/A| | COMMON_EVENT_IVI_PAUSE | common.event.IVI_PAUSE | N/A |
| COMMON_EVENT_IVI_STANDBY | common.event.IVI_STANDBY | N/A| | COMMON_EVENT_IVI_STANDBY | common.event.IVI_STANDBY | N/A |
| COMMON_EVENT_IVI_LASTMODE_SAVE | common.event.IVI_LASTMODE_SAVE | N/A| | COMMON_EVENT_IVI_LASTMODE_SAVE | common.event.IVI_LASTMODE_SAVE | N/A |
| COMMON_EVENT_IVI_VOLTAGE_ABNORMAL | common.event.IVI_VOLTAGE_ABNORMAL | N/A| | COMMON_EVENT_IVI_VOLTAGE_ABNORMAL | common.event.IVI_VOLTAGE_ABNORMAL | N/A |
| COMMON_EVENT_IVI_HIGH_TEMPERATURE | common.event.IVI_HIGH_TEMPERATURE | N/A| | COMMON_EVENT_IVI_HIGH_TEMPERATURE | common.event.IVI_HIGH_TEMPERATURE | N/A |
| COMMON_EVENT_IVI_EXTREME_TEMPERATURE | common.event.IVI_EXTREME_TEMPERATURE | N/A| | COMMON_EVENT_IVI_EXTREME_TEMPERATURE | common.event.IVI_EXTREME_TEMPERATURE | N/A |
| COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL | common.event.IVI_TEMPERATURE_ABNORMAL | N/A| | COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL | common.event.IVI_TEMPERATURE_ABNORMAL | N/A |
| COMMON_EVENT_IVI_VOLTAGE_RECOVERY | common.event.IVI_VOLTAGE_RECOVERY | N/A| | COMMON_EVENT_IVI_VOLTAGE_RECOVERY | common.event.IVI_VOLTAGE_RECOVERY | N/A |
| COMMON_EVENT_IVI_TEMPERATURE_RECOVERY | common.event.IVI_TEMPERATURE_RECOVERY | N/A| | COMMON_EVENT_IVI_TEMPERATURE_RECOVERY | common.event.IVI_TEMPERATURE_RECOVERY | N/A |
| COMMON_EVENT_IVI_ACTIVE | common.event.IVI_ACTIVE | N/A| | COMMON_EVENT_IVI_ACTIVE | common.event.IVI_ACTIVE | N/A |
| COMMON_EVENT_USB_DEVICE_ATTACHED | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED | N/A| | COMMON_EVENT_USB_DEVICE_ATTACHED | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED | N/A |
| COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | N/A| | COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | N/A |
| COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | N/A| | COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | N/A |
| COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | N/A| | COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | N/A |
| COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_BAD_REMOVAL | usual.event.data.DISK_BAD_REMOVAL | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_BAD_REMOVAL | usual.event.data.DISK_BAD_REMOVAL | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_EJECT | usual.event.data.DISK_EJECT | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE| | COMMON_EVENT_DISK_EJECT | usual.event.data.DISK_EJECT | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | N/A| | COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | N/A |
## Modules to Import ## Modules to Import
...@@ -116,35 +116,35 @@ ...@@ -116,35 +116,35 @@
import CommonEvent from '@ohos.commonEvent'; import CommonEvent from '@ohos.commonEvent';
``` ```
## System Capabilities
```js
SystemCapability.Notification.CommonEvent
```
## CommonEvent.publish ## CommonEvent.publish
publish(event: string, callback: AsyncCallback\<void>): void publish(event: string, callback: AsyncCallback\<void>): void
Publishes a common event. This method uses a callback to return the result. Publishes a common event. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | -------------------- | ---- | ---------------------- | | -------- | -------- | -------------------- | ---- | ---------------------- |
| event | Read-only| string | Yes| Name of the common event to publish.| | event | Read-only | string | Yes | Name of the common event to publish.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
// Callback for common event publication // Callback for common event publication
function PublishCallBack(err) { function PublishCallBack(err) {
console.info("==========================>PublishCallBack=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("publish failed " + JSON.stringify(err));
} else {
console.info("publish");
}
} }
// Publish a common event. // Publish a common event.
CommonEvent.publish("publish_event", PublishCallBack); CommonEvent.publish("event", PublishCallBack);
``` ```
...@@ -155,13 +155,15 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ ...@@ -155,13 +155,15 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\
Publishes a common event with given attributes. This method uses a callback to return the result. Publishes a common event with given attributes. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | ---------------------- | ---- | ---------------------- | | -------- | -------- | ---------------------- | ---- | ---------------------- |
| event | Read-only| string | Yes| Name of the common event to publish.| | event | Read-only | string | Yes | Name of the common event to publish. |
| options | Read-only| [CommonEventPublishData](#commoneventpublishdata) | Yes| Attributes of the common event to publish.| | options | Read-only | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -170,15 +172,21 @@ Publishes a common event with given attributes. This method uses a callback to r ...@@ -170,15 +172,21 @@ Publishes a common event with given attributes. This method uses a callback to r
// Attributes of a common event. // Attributes of a common event.
var options = { var options = {
code: 0, // Result code of the common event code: 0, // Result code of the common event
data: "initial data",// Result data of the common event data: "initial data";// Result data of the common event
isOrdered: true // The common event is an ordered one. isOrdered: true // The common event is an ordered one.
} }
// Callback for common event publication // Callback for common event publication
function PublishCallBack(err) { function PublishCallBack(err) {
console.info("==========================>PublishCallBack=======================>"); if (err.code) {
console.error("publish failed " + JSON.stringify(err));
} else {
console.info("publish");
}
} }
// Publish a common event. // Publish a common event.
CommonEvent.publish("publish_event", options, PublishCallBack); CommonEvent.publish("event", options, PublishCallBack);
``` ```
...@@ -189,13 +197,15 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): vo ...@@ -189,13 +197,15 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): vo
Publishes a common event to a specific user. This method uses a callback to return the result. Publishes a common event to a specific user. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | -------------------- | ---- | ---------------------------------- | | -------- | -------- | -------------------- | ---- | ---------------------------------- |
| event | Read-only| string | Yes| Name of the common event to publish.| | event | Read-only | string | Yes | Name of the common event to publish. |
| userId | Read-only| number | Yes| User ID.| | userId | Read-only | number | Yes | User ID.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -203,15 +213,17 @@ Publishes a common event to a specific user. This method uses a callback to retu ...@@ -203,15 +213,17 @@ Publishes a common event to a specific user. This method uses a callback to retu
// Callback for common event publication // Callback for common event publication
function PublishAsUserCallBack(err) { function PublishAsUserCallBack(err) {
if (err.code) { if (err.code) {
console.info("publishAsUser failed " + JSON.stringify(err)); console.error("publishAsUser failed " + JSON.stringify(err));
} else { } else {
console.info("publishAsUser"); console.info("publishAsUser");
} }
} }
// Specify the user to whom the common event will be published. // Specify the user to whom the common event will be published.
var userId = 100; var userId = 100;
// Publish a common event. // Publish a common event.
CommonEvent.publish("publish_event", userId, PublishAsUserCallBack); CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack);
``` ```
...@@ -222,14 +234,16 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca ...@@ -222,14 +234,16 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca
Publishes a common event with given attributes to a specific user. This method uses a callback to return the result. Publishes a common event with given attributes to a specific user. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| -------- | -------- | ---------------------- | ---- | ---------------------- | | -------- | -------- | ---------------------- | ---- | ---------------------- |
| event | Read-only| string | Yes| Name of the common event to publish.| | event | Read-only | string | Yes | Name of the common event to publish. |
| userId | Read-only| number | Yes| User ID.| | userId | Read-only| number | Yes| User ID.|
| options | Read-only| [CommonEventPublishData](#commoneventpublishdata) | Yes| Attributes of the common event to publish.| | options | Read-only | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -240,18 +254,21 @@ var options = { ...@@ -240,18 +254,21 @@ var options = {
code: 0; // Result code of the common event code: 0; // Result code of the common event
data: "initial data";// Result data of the common event data: "initial data";// Result data of the common event
} }
// Callback for common event publication // Callback for common event publication
function PublishAsUserCallBack(err) { function PublishAsUserCallBack(err) {
if (err.code) { if (err.code) {
console.info("publishAsUser failed " + JSON.stringify(err)); console.error("publishAsUser failed " + JSON.stringify(err));
} else { } else {
console.info("publishAsUser"); console.info("publishAsUser");
} }
} }
// Specify the user to whom the common event will be published. // Specify the user to whom the common event will be published.
var userId = 100; var userId = 100;
// Publish a common event. // Publish a common event.
CommonEvent.publish("publish_event", userId, options, PublishAsUserCallBack); CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack);
``` ```
...@@ -262,27 +279,36 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac ...@@ -262,27 +279,36 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac
Creates a subscriber. This method uses a callback to return the result. Creates a subscriber. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ------------- | -------- | ------------------------------------------------------------ | ---- | -------------------------- | | ------------- | -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| subscribeInfo | Read-only| [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes| Subscriber information.| | subscribeInfo | Read-only | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information. |
| callback | Read-only| AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | Yes| Callback used to return the result.| | callback | Read-only | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
// Callback for subscriber creation // Callback for subscriber creation
function CreateSubscriberCallBack(err, data) { function CreateSubscriberCallBack(err, commonEventSubscriber) {
console.info("==========================>CreateSubscriberCallBack=======================>"); if (err.code) {
subscriber = data; console.error("createSubscriber failed " + JSON.stringify(err));
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
}
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
``` ```
...@@ -295,14 +321,16 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS ...@@ -295,14 +321,16 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS
Creates a subscriber. This method uses a promise to return the result. Creates a subscriber. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ------------- | -------- | ----------------------------------------------------- | ---- | -------------- | | ------------- | -------- | ----------------------------------------------------- | ---- | -------------- |
| subscribeInfo | Read-only| [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes| Subscriber information.| | subscribeInfo | Read-only | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| --------------------------------------------------------- | ---------------- | | --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | Promise used to return the subscriber object.| | Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | Promise used to return the subscriber object.|
...@@ -310,14 +338,18 @@ Creates a subscriber. This method uses a promise to return the result. ...@@ -310,14 +338,18 @@ Creates a subscriber. This method uses a promise to return the result.
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo).then((data) => { CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
console.info("==========================>createSubscriberPromise=======================>"); console.info("createSubscriber");
subscriber = data; subscriber = commonEventSubscriber;
}).catch((err) => {
console.error("createSubscriber failed " + JSON.stringify(err));
}); });
``` ```
...@@ -329,12 +361,14 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven ...@@ -329,12 +361,14 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven
Subscribes to common events. This method uses a callback to return the result. Subscribes to common events. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | --------------------------------------------------- | ---- | -------------------------------- | | ---------- | -------- | --------------------------------------------------- | ---- | -------------------------------- |
| subscriber | Read-only| [CommonEventSubscriber](#commoneventsubscriber) | Yes| Subscriber object.| | subscriber | Read-only | [CommonEventSubscriber](#commoneventsubscriber) | Yes | Subscriber object. |
| callback | Read-only| AsyncCallback\<[CommonEventData](#commoneventdata)> | Yes| Callback used to return the result.| | callback | Read-only | AsyncCallback\<[CommonEventData](#commoneventdata)> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -342,21 +376,33 @@ Unordered common event: ...@@ -342,21 +376,33 @@ Unordered common event:
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
// Callback for common event subscription // Callback for common event subscription
function SubscribeCallBack(err, data) { function SubscribeCallBack(err, data) {
console.info("==========================>SubscribeCallBack=======================>"); if (err.code) {
console.error("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe " + JSON.stringify(data));
}
} }
// Callback for subscriber creation // Callback for subscriber creation
function CreateSubscriberCallBack(err, data) { function CreateSubscriberCallBack(err, commonEventSubscriber) {
console.info("==========================>CreateSubscriberCallBack=======================>"); if (err.code) {
subscriber = data; console.error("createSubscriber failed " + JSON.stringify(err));
// Subscribe to a common event. } else {
CommonEvent.subscribe(subscriber, SubscribeCallBack); console.info("createSubscriber");
subscriber = commonEventSubscriber;
// Subscribe to a common event.
CommonEvent.subscribe(subscriber, SubscribeCallBack);
}
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
``` ```
...@@ -365,6 +411,7 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ...@@ -365,6 +411,7 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
...@@ -372,40 +419,63 @@ var subscribeInfo = { ...@@ -372,40 +419,63 @@ var subscribeInfo = {
// Callback for result code setting of an ordered common event // Callback for result code setting of an ordered common event
function SetCodeCallBack(err) { function SetCodeCallBack(err) {
console.info("==========================>SetCodeCallBack=======================>"); if (err.code) {
console.error("setCode failed " + JSON.stringify(err));
} else {
console.info("setCode");
}
} }
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function SetDataCallBack(err) { function SetDataCallBack(err) {
console.info("==========================>SetDataCallBack=======================>"); if (err.code) {
console.error("setData failed " + JSON.stringify(err));
} else {
console.info("setData");
}
} }
// Callback for ordered common event processing // Callback for ordered common event processing
function FinishCommonEventCallBack(err) { function FinishCommonEventCallBack(err) {
console.info("==========================>FinishCommonEventCallBack=======================>"); if (err.code) {
console.error("finishCommonEvent failed " + JSON.stringify(err));
} else {
console.info("finishCommonEvent");
}
} }
// Callback for common event subscription // Callback for common event subscription
function SubscribeCallBack(err, data) { function SubscribeCallBack(err, data) {
console.info("==========================>SubscribeCallBack=======================>"); if (err.code) {
// Set the result code for the ordered common event. console.error("subscribe failed " + JSON.stringify(err));
subscriber.setCode(0, SetCodeCallBack); } else {
// Set the result data for the ordered common event. console.info("subscribe " + JSON.stringify(data));
subscriber.setData("publish_data_changed", SetDataCallBack); // Set the result code for the ordered common event.
// Complete the processing of the ordered common event. subscriber.setCode(0, SetCodeCallBack);
subscriber.finishCommonEvent(FinishCommonEventCallBack) // Set the result data for the ordered common event.
subscriber.setData("publish_data_changed", SetDataCallBack);
// Complete the processing of the ordered common event.
subscriber.finishCommonEvent(FinishCommonEventCallBack)
}
} }
// Callback for subscriber creation // Callback for subscriber creation
function CreateSubscriberCallBack(err, data) { function CreateSubscriberCallBack(err, commonEventSubscriber) {
console.info("==========================>CreateSubscriberCallBack=======================>"); if (err.code) {
subscriber = data; console.error("createSubscriber failed " + JSON.stringify(err));
// Subscribe to a common event. } else {
CommonEvent.subscribe(subscriber, SubscribeCallBack); console.info("createSubscriber");
subscriber = commonEventSubscriber;
// Subscribe to a common event.
CommonEvent.subscribe(subscriber, SubscribeCallBack);
}
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
``` ```
## CommonEvent.unsubscribe ## CommonEvent.unsubscribe
...@@ -413,72 +483,92 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): ...@@ -413,72 +483,92 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>):
Unsubscribes from common events. This method uses a callback to return the result. Unsubscribes from common events. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | --------------------- | ---- | ------------------------ | | ---------- | -------- | --------------------- | ---- | ------------------------ |
| subscriber | Read-only| CommonEventSubscriber | Yes| Subscriber object.| | subscriber | Read-only | CommonEventSubscriber | Yes | Subscriber object. |
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information // Subscriber information
var subscribeInfo = { var subscribeInfo = {
events: ["event"] events: ["event"]
}; };
// Callback for common event subscription // Callback for common event subscription
function SubscribeCallBack(err, data) { function SubscribeCallBack(err, data) {
console.info("==========================>SubscribeCallBack=======================>"); if (err.code) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe " + JSON.stringify(data));
}
} }
// Callback for subscriber creation // Callback for subscriber creation
function CreateSubscriberCallBack(err, data) { function CreateSubscriberCallBack(err, commonEventSubscriber) {
console.info("==========================>CreateSubscriberCallBack=======================>"); if (err.code) {
subscriber = data; console.info("createSubscriber failed " + JSON.stringify(err));
// Subscribe to a common event. } else {
CommonEvent.subscribe(subscriber, SubscribeCallBack); console.info("createSubscriber");
subscriber = commonEventSubscriber;
// Subscribe to a common event.
CommonEvent.subscribe(subscriber, SubscribeCallBack);
}
} }
// Callback for common event unsubscription // Callback for common event unsubscription
function UnsubscribeCallBack(err) { function UnsubscribeCallBack(err) {
console.info("==========================>UnsubscribeCallBack=======================>"); if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err));
} else {
console.info("unsubscribe");
}
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
// Unsubscribe from the common event. // Unsubscribe from the common event.
CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
``` ```
## CommonEventPublishData ## CommonEventPublishData
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| --------------------- | -------- | -------------------- | ---- | ---------------------------- | | --------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| bundleName | Read-only| string | No| Bundle name.| | bundleName | Read-only | string | No | Bundle name.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| code | Read-only| number | No| Result code of the common event.| | code | Read-only | number | No | Result code of the common event.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| data | Read-only| string | No| Custom result data of the common event.| | data | Read-only | string | No | Custom result data of the common event.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| subscriberPermissions | Read-only| Array\<string> | No| Permissions required for subscribers to receive the common event.| | subscriberPermissions | Read-only | Array\<string> | No | Permissions required for subscribers to receive the common event.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| isOrdered | Read-only| boolean | No| Whether the common event is an ordered one.| | isOrdered | Read-only | boolean | No | Whether the common event is an ordered one.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| parameters | Read-only| {[key: string]: any} | No| Additional information about the common event.| | parameters | Read-only | {[key: string]: any} | No | Additional information about the common event.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
## CommonEventSubscribeInfo ## CommonEventSubscribeInfo
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ | | ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ |
| events | Read-only| Array\<string> | Yes| Common events to subscribe to.| | events | Read-only | Array\<string> | Yes | Common events to subscribe to.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| publisherPermission | Read-only| string | No| Permission required for the publisher.| | publisherPermission | Read-only | string | No | Permission required for the publisher.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| publisherDeviceId | Read-only| string | No| Device ID. The value must be the ID of an existing device on the same network.| | publisherDeviceId | Read-only | string | No | Device ID. The value must be the ID of an existing device on the same network.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| userId | Read-only| number | No| User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.| | userId | Read-only | number | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| priority | Read-only| number | No| Subscriber priority. The value ranges from -100 to 1000.| | priority | Read-only | number | No | Subscriber priority. The value ranges from -100 to 1000.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
## CommonEventData ## CommonEventData
| Name| Readable/Writable| Type| Mandatory| Description| | Name | Readable/Writable| Type | Mandatory| Description |
| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------ | | ---------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| event | Read-only| string | Yes| Name of the common event to subscribe to.| | event | Read-only | string | Yes | Name of the common event to subscribe to.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| bundleName | Read-only| string | No| Bundle name.| | bundleName | Read-only | string | No | Bundle name.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| code | Read-only| number | No| Result code of the common event, which is used to transfer data of the int type.| | code | Read-only | number | No | Result code of the common event, which is used to transfer data of the int type.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| data | Read-only| string | No| Custom result data of the common event, which is used to transfer data of the string type.| | data | Read-only | string | No | Custom result data of the common event, which is used to transfer data of the string type.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
| parameters | Read-only| {[key: string]: any} | No| Additional information about the common event.| | parameters | Read-only | {[key: string]: any} | No | Additional information about the common event.<br>**System capabilities**: SystemCapability.Notification.CommonEvent|
## CommonEventSubscriber ## CommonEventSubscriber
...@@ -488,21 +578,27 @@ getCode(callback: AsyncCallback\<number>): void ...@@ -488,21 +578,27 @@ getCode(callback: AsyncCallback\<number>): void
Obtains the result code of this common event. This method uses a callback to return the result. Obtains the result code of this common event. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------ | | -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<number> | Yes| Callback used to return the result code.| | callback | AsyncCallback\<number> | Yes | Callback used to return the result code.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getCodeCallback(err, data) { getCode() {
console.info("==========================>getCodeCallback=======================>"); function getCodeCallback(err, Code) {
console.info("==========================>err:=======================>", err.code); if (err.code) {
console.info("==========================>code:=======================>", data); console.error("getCode failed " + JSON.stringify(err));
} else {
console.info("getCode " + JSON.stringify(Code));
}
} }
subscriber.getCode(getCodeCallback); subscriber.getCode(getCodeCallback);
``` ```
...@@ -513,19 +609,23 @@ getCode(): Promise\<number> ...@@ -513,19 +609,23 @@ getCode(): Promise\<number>
Obtains the result code of this common event. This method uses a promise to return the result. Obtains the result code of this common event. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Return value** **Return value**
| Type| Description| | Type | Description |
| ---------------- | -------------------- | | ---------------- | -------------------- |
| Promise\<number> | Promise used to return the result code.| | Promise\<number> | Promise used to return the result code.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.getCode().then((data) => {
console.info("==========================>getCodePromise=======================>"); subscriber.getCode().then((Code) => {
console.info("==========================>code:=======================>", data); console.info("getCode " + JSON.stringify(Code));
}).catch((err) => {
console.error("getCode failed " + JSON.stringify(err));
}); });
``` ```
...@@ -535,21 +635,27 @@ setCode(code: number, callback: AsyncCallback\<void>): void ...@@ -535,21 +635,27 @@ setCode(code: number, callback: AsyncCallback\<void>): void
Sets the result code for this common event. This method uses a callback to return the result. Sets the result code for this common event. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- | | -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes| Result code of the common event.| | code | number | Yes | Result code of the common event. |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setCodeCallback(err) { function setCodeCallback(err) {
console.info("==========================>setCodeCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("setCode failed " + JSON.stringify(err));
} else {
console.info("setCode");
}
} }
subscriber.setCode(1, setCodeCallback); subscriber.setCode(1, setCodeCallback);
``` ```
...@@ -560,18 +666,23 @@ setCode(code: number): Promise\<void> ...@@ -560,18 +666,23 @@ setCode(code: number): Promise\<void>
Sets the result code for this common event. This method uses a promise to return the result. Sets the result code for this common event. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| code | number | Yes| Callback used to return the result code.| | code | number | Yes | Callback used to return the result code.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.setCode(1).then(() => { subscriber.setCode(1).then(() => {
console.info("==========================>setCodePromise=======================>"); console.info("setCode");
}).catch((err) => {
console.error("setCode failed " + JSON.stringify(err));
}); });
``` ```
...@@ -581,21 +692,26 @@ getData(callback: AsyncCallback\<string>): void ...@@ -581,21 +692,26 @@ getData(callback: AsyncCallback\<string>): void
Obtains the result data of this common event. This method uses a callback to return the result. Obtains the result data of this common event. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- | | -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes| Callback used to return the result data.| | callback | AsyncCallback\<string> | Yes | Callback used to return the result data.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getDataCallback(err, data) { function getDataCallback(err, Data) {
console.info("==========================>getDataCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("getData failed " + JSON.stringify(err));
console.info("==========================>data:=======================>", data); } else {
console.info("getData " + JSON.stringify(Data));
}
} }
subscriber.getData(getDataCallback); subscriber.getData(getDataCallback);
``` ```
...@@ -606,19 +722,23 @@ getData(): Promise\<string> ...@@ -606,19 +722,23 @@ getData(): Promise\<string>
Obtains the result data of this common event. This method uses a promise to return the result. Obtains the result data of this common event. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Return value** **Return value**
| Type| Description| | Type | Description |
| ---------------- | ------------------ | | ---------------- | ------------------ |
| Promise\<string> | Promise used to return the result data.| | Promise\<string> | Promise used to return the result data.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.getData().then((data) => {
console.info("==========================>getDataPromise=======================>"); subscriber.getData().then((Data) => {
console.info("==========================>data:=======================>", data); console.info("getData " + JSON.stringify(Data));
}).catch((err) => {
console.error("getData failed " + JSON.stringify(err));
}); });
``` ```
...@@ -628,21 +748,27 @@ setData(data: string, callback: AsyncCallback\<void>): void ...@@ -628,21 +748,27 @@ setData(data: string, callback: AsyncCallback\<void>): void
Sets the result data for this common event. This method uses a callback to return the result. Sets the result data for this common event. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | -------------------- |
| data | string | Yes| Result data of the common event.| | data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setDataCallback(err) { function setDataCallback(err) {
console.info("==========================>setDataCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("setData failed " + JSON.stringify(err));
} else {
console.info("setData");
}
} }
subscriber.setData("publish_data_changed", setDataCallback); subscriber.setData("publish_data_changed", setDataCallback);
``` ```
...@@ -653,18 +779,23 @@ setData(data: string): Promise\<void> ...@@ -653,18 +779,23 @@ setData(data: string): Promise\<void>
Sets the result data for this common event. This method uses a promise to return the result. Sets the result data for this common event. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- | | ------ | ------ | ---- | -------------------- |
| data | string | Yes| Callback used to return the result data.| | data | string | Yes | Callback used to return the result data.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.setData("publish_data_changed").then(() => { subscriber.setData("publish_data_changed").then(() => {
console.info("==========================>setDataPromise=======================>"); console.info("setData");
}).catch((err) => {
console.error("setData failed " + JSON.stringify(err));
}); });
``` ```
...@@ -674,22 +805,28 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void ...@@ -674,22 +805,28 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
Sets the result code and result data for this common event. This method uses a callback to return the result. Sets the result code and result data for this common event. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- | | -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes| Result code of the common event.| | code | number | Yes | Result code of the common event. |
| data | string | Yes| Result data of the common event.| | data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setCodeDataCallback(err) { function setCodeDataCallback(err) {
console.info("==========================>setCodeDataCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("setCodeAndData failed " + JSON.stringify(err));
} else {
console.info("setCodeDataCallback");
}
} }
subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback); subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback);
``` ```
...@@ -700,19 +837,24 @@ setCodeAndData(code: number, data: string): Promise\<void> ...@@ -700,19 +837,24 @@ setCodeAndData(code: number, data: string): Promise\<void>
Sets the result code and result data for this common event. This method uses a promise to return the result. Sets the result code and result data for this common event. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- | | ------ | ------ | ---- | -------------------- |
| code | number | Yes| Result code of the common event.| | code | number | Yes | Result code of the common event.|
| data | string | Yes| Callback used to return the result data.| | data | string | Yes | Callback used to return the result data.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.setCodeAndData(1, "publish_data_changed").then(() => { subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("==========================>setCodeAndData=======================>"); console.info("setCodeAndData");
}).catch((err) => {
console.info("setCodeAndData failed " + JSON.stringify(err));
}); });
``` ```
...@@ -722,21 +864,26 @@ isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void ...@@ -722,21 +864,26 @@ isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is an ordered one. This method uses a callback to return the result. Checks whether this common event is an ordered one. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes| Returns **true** if the common event is an ordered one; returns **false** otherwise.| | callback | AsyncCallback\<boolean> | Yes | Returns **true** if the common event is an ordered one; returns **false** otherwise.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function isOrderedCallback(err, data) { function isOrderedCallback(err, isOrdered) {
console.info("==========================>isOrderedCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("isOrderedCommonEvent failed " + JSON.stringify(err));
console.info("==========================>isOrdered:=======================>", data); } else {
console.info("isOrdered " + JSON.stringify(isOrdered));
}
} }
subscriber.isOrderedCommonEvent(isOrderedCallback); subscriber.isOrderedCommonEvent(isOrderedCallback);
``` ```
...@@ -747,18 +894,23 @@ isOrderedCommonEvent(): Promise\<boolean> ...@@ -747,18 +894,23 @@ isOrderedCommonEvent(): Promise\<boolean>
Checks whether this common event is an ordered one. This method uses a promise to return the result. Checks whether this common event is an ordered one. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Return value** **Return value**
| Type| Description| | Type | Description |
| ----------------- | -------------------------------- | | ----------------- | -------------------------------- |
| Promise\<boolean> | Returns **true** if the common event is an ordered one; returns **false** otherwise.| | Promise\<boolean> | Returns **true** if the common event is an ordered one; returns **false** otherwise.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.isOrderedCommonEvent().then((data) => {
console.info("==========================>isOrdered:=======================>", data); subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => {
console.error("isOrdered failed " + JSON.stringify(err));
}); });
``` ```
...@@ -768,20 +920,26 @@ abortCommonEvent(callback: AsyncCallback\<void>): void ...@@ -768,20 +920,26 @@ abortCommonEvent(callback: AsyncCallback\<void>): void
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a callback to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function abortCallback(err) { function abortCallback(err) {
console.info("==========================>abortCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("abortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("abortCommonEvent");
}
} }
subscriber.abortCommonEvent(abortCallback); subscriber.abortCommonEvent(abortCallback);
``` ```
...@@ -792,12 +950,17 @@ abortCommonEvent(): Promise\<void> ...@@ -792,12 +950,17 @@ abortCommonEvent(): Promise\<void>
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a promise to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.abortCommonEvent().then(() => { subscriber.abortCommonEvent().then(() => {
console.info("==========================>abortCommonEvent:=======================>"); console.info("abortCommonEvent");
}).catch((err) => {
console.error("abortCommonEvent failed " + JSON.stringify(err));
}); });
``` ```
...@@ -807,20 +970,26 @@ clearAbortCommonEvent(callback: AsyncCallback\<void>): void ...@@ -807,20 +970,26 @@ clearAbortCommonEvent(callback: AsyncCallback\<void>): void
Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a callback to return the result. Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function clearAbortCallback(err) { function clearAbortCallback(err) {
console.info("==========================>clearAbortCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("clearAbortCommonEvent");
}
} }
subscriber.clearAbortCommonEvent(clearAbortCallback); subscriber.clearAbortCommonEvent(clearAbortCallback);
``` ```
...@@ -831,12 +1000,17 @@ clearAbortCommonEvent(): Promise\<void> ...@@ -831,12 +1000,17 @@ clearAbortCommonEvent(): Promise\<void>
Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a promise to return the result. Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.clearAbortCommonEvent().then(() => { subscriber.clearAbortCommonEvent().then(() => {
console.info("==========================>clearAbortCommonEvent:=======================>"); console.info("clearAbortCommonEvent");
}).catch((err) => {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
}); });
``` ```
...@@ -846,21 +1020,26 @@ getAbortCommonEvent(callback: AsyncCallback\<boolean>): void ...@@ -846,21 +1020,26 @@ getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a callback to return the result. Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes| Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.| | callback | AsyncCallback\<boolean> | Yes | Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getAbortCallback(err, data) { function getAbortCallback(err, AbortCommonEvent) {
console.info("==========================>getAbortCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("getAbortCommonEvent failed " + JSON.stringify(err));
console.info("==========================>abort:=======================>", data); } else {
console.info("AbortCommonEvent " + AbortCommonEvent)
}
} }
subscriber.getAbortCommonEvent(getAbortCallback); subscriber.getAbortCommonEvent(getAbortCallback);
``` ```
...@@ -871,19 +1050,23 @@ getAbortCommonEvent(): Promise\<void> ...@@ -871,19 +1050,23 @@ getAbortCommonEvent(): Promise\<void>
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a promise to return the result. Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Return value** **Return value**
| Type| Description| | Type | Description |
| ----------------- | ---------------------------------- | | ----------------- | ---------------------------------- |
| Promise\<boolean> | Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.| | Promise\<boolean> | Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.getAbortCommonEvent().then((data) => {
console.info("==========================>getAbortCommonEvent:=======================>"); subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
console.info("==========================>abort:=======================>", data); console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent));
}).catch((err) => {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
}); });
``` ```
...@@ -893,21 +1076,26 @@ getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void ...@@ -893,21 +1076,26 @@ getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
Obtains the subscriber information. This method uses a callback to return the result. Obtains the subscriber information. This method uses a callback to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- | | -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes| Callback used to return the subscriber information.| | callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes | Callback used to return the subscriber information.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getSubscribeInfoCallback(err, data) { function getSubscribeInfoCallback(err, SubscribeInfo) {
console.info("==========================>getSubscribeInfoCallback=======================>"); if (err.code) {
console.info("==========================>err:=======================>", err.code); console.error("getSubscribeInfo failed " + JSON.stringify(err));
console.info("==========================>priority:=======================>", data.priority); } else {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}
} }
subscriber.getSubscribeInfo(getSubscribeInfoCallback); subscriber.getSubscribeInfo(getSubscribeInfoCallback);
``` ```
...@@ -918,18 +1106,22 @@ getSubscribeInfo(): Promise\<CommonEventSubscribeInfo> ...@@ -918,18 +1106,22 @@ getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
Obtains the subscriber information. This method uses a promise to return the result. Obtains the subscriber information. This method uses a promise to return the result.
**System capabilities**: SystemCapability.Notification.CommonEvent
**Return value** **Return value**
| Type| Description| | Type | Description |
| ------------------------------------------------------------ | ---------------------- | | ------------------------------------------------------------ | ---------------------- |
| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise used to return the subscriber information.| | Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise used to return the subscriber information.|
**Example** **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Subscriber object successfully created
subscriber.getSubscribeInfo().then((data) => {
console.info("==========================>getSubscribeInfo:=======================>"); subscriber.getSubscribeInfo().then((SubscribeInfo) => {
console.info("==========================>priority:=======================>", data.priority); console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}).catch((err) => {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
}); });
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册