1# CommonEvent 2 3 4## Overview 5 6Describes the common event capabilities provided by the **CommonEvent** for applications. 7 8**System capability**: SystemCapability.Notification.CommonEvent 9 10**Since**: 12 11 12 13## Summary 14 15 16### Files 17 18| Name| Description| 19| -------- | -------- | 20| [oh_commonevent.h](oh_commonevent_8h.md) | Defines the APIs for subscribing to and unsubscribing from common events.<br>**File to include**: <BasicServicesKit/oh_commonevent.h><br>**Library**: libohcommonevent.so| 21| [oh_commonevent_support.h](oh_commonevent_support_8h.md) | Provides common event constants defined by the system.<br>**File to include**: <BasicServicesKit/oh_commonevent_support.h><br>**Library**: libohcommonevent.so| 22 23 24### Types 25 26| Name| Description| 27| -------- | -------- | 28|[CommonEvent_SubscribeInfo](#commonevent_subscribeinfo) | Defines the subscriber information.| 29|[CommonEvent_Subscriber](#commonevent_subscriber) | Defines a subscriber.| 30|[CommonEvent_RcvData](#commonevent_rcvdata) | Defines the callback data of a common event.| 31|[CommonEvent_Parameters](#commonevent_parameters) | Defines the additional information about a common event.| 32|[CommonEvent_ReceiveCallback](#commonevent_receivecallback)| Defines the callback function of a common event.| 33 34### Enums 35 36| Name| Description| 37| -------- | -------- | 38| [CommonEvent_ErrCode](#commonevent_errcode) | Enumerates the error codes.| 39 40 41### Functions 42 43| Name| Description| 44| -------- | -------- | 45| [OH_CommonEvent_CreateSubscribeInfo](#oh_commonevent_createsubscribeinfo)| Creates the subscriber information.| 46| [OH_CommonEvent_SetPublisherPermission](#oh_commonevent_setpublisherpermission) | Sets the subscriber permission.| 47| [OH_CommonEvent_SetPublisherBundleName](#oh_commonevent_setpublisherbundlename) | Sets a bundle name of the subscriber.| 48| [OH_CommonEvent_DestroySubscribeInfo](#oh_commonevent_destroysubscribeinfo) | Destroys the subscriber information.| 49| [OH_CommonEvent_CreateSubscriber](#oh_commonevent_createsubscriber)| Creates a subscriber.| 50| [OH_CommonEvent_DestroySubscriber](#oh_commonevent_destroysubscriber) | Destroys a subscriber.| 51| [OH_CommonEvent_Subscribe](#oh_commonevent_subscribe) | Subscribes to a common event.| 52| [OH_CommonEvent_UnSubscribe](#oh_commonevent_unsubscribe) | Unsubscribes from a common event.| 53| [OH_CommonEvent_GetEventFromRcvData](#oh_commonevent_geteventfromrcvdata)| Obtains the name of a common event.| 54| [OH_CommonEvent_GetCodeFromRcvData](#oh_commonevent_getcodefromrcvdata) | Obtains the result code of a common event.| 55| [OH_CommonEvent_GetDataStrFromRcvData](#oh_commonevent_getdatastrfromrcvdata)| Obtains the custom result data of a common event.| 56| [OH_CommonEvent_GetBundleNameFromRcvData](#oh_commonevent_getbundlenamefromrcvdata)| Obtains the bundle name of a common event.| 57| [OH_CommonEvent_GetParametersFromRcvData](#oh_commonevent_getparametersfromrcvdata) | Obtains the additional information about a common event.| 58| [OH_CommonEvent_HasKeyInParameters](#oh_commonevent_haskeyinparameters) | Checks whether the additional information of a common event contains a key-value pair.| 59| [OH_CommonEvent_GetIntFromParameters](#oh_commonevent_getintfromparameters) | Obtains the **int** data information from the additional information of a common event.| 60| [OH_CommonEvent_GetIntArrayFromParameters](#oh_commonevent_getintarrayfromparameters)| Obtains the **int** array information from the additional information of a common event.| 61| [OH_CommonEvent_GetLongFromParameters](#oh_commonevent_getlongfromparameters)| Obtains the **long** data information from the additional information of a common event.| 62| [OH_CommonEvent_GetLongArrayFromParameters](#oh_commonevent_getlongarrayfromparameters)| Obtains the **long** array information from the additional information of a common event.| 63| [OH_CommonEvent_GetBoolFromParameters](#oh_commonevent_getboolfromparameters)| Obtains the **bool** data information from the additional information of a common event.| 64| [OH_CommonEvent_GetBoolArrayFromParameters](#oh_commonevent_getboolarrayfromparameters)| Obtains the **bool** array information from the additional information of a common event.| 65| [OH_CommonEvent_GetCharFromParameters](#oh_commonevent_getcharfromparameters)| Obtains the **char** data from the additional information of a common event.| 66| [OH_CommonEvent_GetCharArrayFromParameters](#oh_commonevent_getchararrayfromparameters)| Obtains the **char** array information from the additional information of a common event.| 67| [OH_CommonEvent_GetDoubleFromParameters](#oh_commonevent_getdoublefromparameters)| Obtains the **double** data information from the additional information of a common event.| 68| [OH_CommonEvent_GetDoubleArrayFromParameters](#oh_commonevent_getdoublearrayfromparameters)| Obtains the **double** array information from the additional information of a common event.| 69 70### Constants 71| Name| Description| 72| -------- | -------- | 73|static const char* const [COMMON_EVENT_SHUTDOWN](common_event/commonEventManager-definitions.md#common_event_shutdown) = "usual.event.SHUTDOWN" | Indicates the common event that the device is being shut down and the final shutdown will proceed.| 74|static const char* const [COMMON_EVENT_BATTERY_CHANGED](common_event/commonEventManager-definitions.md#common_event_battery_changed) = "usual.event.BATTERY_CHANGED" | Indicates the common event that the charging state, level, and other information about the battery have changed.| 75|static const char* const [COMMON_EVENT_BATTERY_LOW](common_event/commonEventManager-definitions.md#common_event_battery_low) = "usual.event.BATTERY_LOW"|Indicates the common event that the battery level is low.| 76|static const char* const [COMMON_EVENT_BATTERY_OKAY](common_event/commonEventManager-definitions.md#common_event_battery_okay) = "usual.event.BATTERY_OKAY"|Indicates the common event that the battery exits the low state.| 77|static const char* const [COMMON_EVENT_POWER_CONNECTED](common_event/commonEventManager-definitions.md#common_event_power_connected) = "usual.event.POWER_CONNECTED"|Indicates the common event that the device is connected to an external power supply.| 78|static const char* const [COMMON_EVENT_POWER_DISCONNECTED](common_event/commonEventManager-definitions.md#common_event_power_disconnected) = "usual.event.POWER_DISCONNECTED"|Indicates the common event that the device is disconnected from the external power supply.| 79|static const char* const [COMMON_EVENT_SCREEN_OFF](common_event/commonEventManager-definitions.md#common_event_screen_off) = "usual.event.SCREEN_OFF"| Indicates the common event that the device screen is off and the device is sleeping.| 80|static const char* const [COMMON_EVENT_SCREEN_ON](common_event/commonEventManager-definitions.md#common_event_screen_on) = "usual.event.SCREEN_ON"|Indicates the common event that the device screen is on and the device is in interactive state.| 81|static const char* const [COMMON_EVENT_THERMAL_LEVEL_CHANGED](common_event/commonEventManager-definitions.md#common_event_thermal_level_changed) = "usual.event.THERMAL_LEVEL_CHANGED"|Indicates the common event that the device's thermal level has changed.| 82|static const char* const [COMMON_EVENT_TIME_TICK](common_event/commonEventManager-definitions.md#common_event_time_tick) = "usual.event.TIME_TICK"|Indicates the common event that the system time has changed.| 83|static const char* const [COMMON_EVENT_TIME_CHANGED](common_event/commonEventManager-definitions.md#common_event_time_changed) = "usual.event.TIME_CHANGED"|Indicates the common event that the system time is reset.| 84|static const char* const [COMMON_EVENT_TIMEZONE_CHANGED](common_event/commonEventManager-definitions.md#common_event_timezone_changed) = "usual.event.TIMEZONE_CHANGED"|Indicates the common event that the system time zone has changed.| 85|static const char* const [COMMON_EVENT_PACKAGE_ADDED](common_event/commonEventManager-definitions.md#common_event_package_added) = "usual.event.PACKAGE_ADDED"| Indicates the common event that a new application package has been installed on the device.| 86|static const char* const [COMMON_EVENT_PACKAGE_REMOVED](common_event/commonEventManager-definitions.md#common_event_package_removed) = "usual.event.PACKAGE_REMOVED"| Indicates the common event that an installed application has been uninstalled from the device with the application data retained.| 87|static const char* const [COMMON_EVENT_BUNDLE_REMOVED](common_event/commonEventManager-definitions.md#common_event_bundle_removed) = "usual.event.BUNDLE_REMOVED"| Indicates the common event that an installed bundle has been uninstalled from the device with the application data retained.| 88|static const char* const [COMMON_EVENT_PACKAGE_FULLY_REMOVED](common_event/commonEventManager-definitions.md#common_event_package_fully_removed) = "usual.event.PACKAGE_FULLY_REMOVED"|Indicates the common event that an installed application, including both the application data and code, has been completely uninstalled from the device.| 89|static const char* const [COMMON_EVENT_PACKAGE_CHANGED](common_event/commonEventManager-definitions.md#common_event_package_changed) = "usual.event.PACKAGE_CHANGED"| Indicates the common event that an application package has been changed (for example, a component in the package has been enabled or disabled).| 90|static const char* const [COMMON_EVENT_PACKAGE_RESTARTED](common_event/commonEventManager-definitions.md#common_event_package_restarted) = "usual.event.PACKAGE_RESTARTED"| Indicates a common event that a user restarts an application package and kills all its processes.| 91|static const char* const [COMMON_EVENT_PACKAGE_DATA_CLEARED](common_event/commonEventManager-definitions.md#common_event_package_data_cleared) = "usual.event.PACKAGE_DATA_CLEARED"| Indicates the common event that the user has cleared the application package data.| 92|static const char* const [COMMON_EVENT_PACKAGE_CACHE_CLEARED](common_event/commonEventManager-definitions.md#common_event_package_cache_cleared) = "usual.event.PACKAGE_CACHE_CLEARED"|Indicates the common event that the user has cleared the application package data cache.| 93|static const char* const [COMMON_EVENT_PACKAGES_SUSPENDED](common_event/commonEventManager-definitions.md#common_event_packages_suspended) = "usual.event.PACKAGES_SUSPENDED"|Indicates the common event that application packages have been suspended.| 94|static const char* const [COMMON_EVENT_MY_PACKAGE_SUSPENDED](common_event/commonEventManager-definitions.md#common_event_my_package_suspended) = "usual.event.MY_PACKAGE_SUSPENDED"| Indicates the common event that can be sent to a suspended application package.| 95|static const char* const [COMMON_EVENT_MY_PACKAGE_UNSUSPENDED](common_event/commonEventManager-definitions.md#common_event_my_package_unsuspended) = "usual.event.MY_PACKAGE_UNSUSPENDED"| Indicates the common event that application packages have not been suspended.| 96|static const char* const [COMMON_EVENT_LOCALE_CHANGED](common_event/commonEventManager-definitions.md#common_event_locale_changed) = "usual.event.LOCALE_CHANGED"| Indicates the common event that the device locale has changed.| 97|static const char* const [COMMON_EVENT_MANAGE_PACKAGE_STORAGE](common_event/commonEventManager-definitions.md#common_event_manage_package_storage) = "usual.event.MANAGE_PACKAGE_STORAGE"| Indicates the common event that the device storage is insufficient.| 98|static const char* const [COMMON_EVENT_USER_UNLOCKED](common_event/commonEventManager-definitions.md#common_event_user_unlocked) = "usual.event.USER_UNLOCKED"| Indicates the common event that the credential-encrypted storage has become unlocked for the current user when the device is unlocked after being restarted.| 99|static const char* const [COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT](common_event/commonEventManager-definitions.md#common_event_distributed_account_logout) = "common.event.DISTRIBUTED_ACCOUNT_LOGOUT"|Indicates the common event that a distributed account is successfully logged out.| 100|static const char* const [COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID](common_event/commonEventManager-definitions.md#common_event_distributed_account_token_invalid) = "common.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID"|Indicates the common event that the token of a distributed account is invalid.| 101|static const char* const [COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF](common_event/commonEventManager-definitions.md#common_event_distributed_account_logoff) = "common.event.DISTRIBUTED_ACCOUNT_LOGOFF"| Indicates the common event that a distributed account is deregistered.| 102|static const char* const [COMMON_EVENT_WIFI_POWER_STATE](common_event/commonEventManager-definitions.md#common_event_wifi_power_state) = "usual.event.wifi.POWER_STATE"| Indicates the common event that the Wi-Fi state has changed, for example, enabled or disabled.| 103|static const char* const [COMMON_EVENT_WIFI_SCAN_FINISHED](common_event/commonEventManager-definitions.md#common_event_wifi_scan_finished) = "usual.event.wifi.SCAN_FINISHED"|Indicates the common event that the Wi-Fi access point has been scanned and proven to be available.| 104|static const char* const [COMMON_EVENT_WIFI_RSSI_VALUE](common_event/commonEventManager-definitions.md#common_event_wifi_rssi_value) = "usual.event.wifi.RSSI_VALUE"|Indicates the common event that the Wi-Fi signal strength (RSSI) has changed.| 105|static const char* const [COMMON_EVENT_WIFI_CONN_STATE](common_event/commonEventManager-definitions.md#common_event_wifi_conn_state) = "usual.event.wifi.CONN_STATE"| Indicates the common event that the Wi-Fi connection state has changed.| 106|static const char* const [COMMON_EVENT_WIFI_HOTSPOT_STATE](common_event/commonEventManager-definitions.md#common_event_wifi_hotspot_state) = "usual.event.wifi.HOTSPOT_STATE"| Indicates the common event that the Wi-Fi hotspot state has changed, for example, enabled or disabled.| 107|static const char* const [COMMON_EVENT_WIFI_AP_STA_JOIN](common_event/commonEventManager-definitions.md#common_event_wifi_ap_sta_join) = "usual.event.wifi.WIFI_HS_STA_JOIN"| Indicates the common event that a client has joined the Wi-Fi hotspot of the current device.| 108|static const char* const [COMMON_EVENT_WIFI_AP_STA_LEAVE](common_event/commonEventManager-definitions.md#common_event_wifi_ap_sta_leave) = "usual.event.wifi.WIFI_HS_STA_LEAVE"|Indicates the common event that a client has disconnected from the Wi-Fi hotspot of the current device.| 109|static const char* const [COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE](common_event/commonEventManager-definitions.md#common_event_wifi_mplink_state_change) = "usual.event.wifi.mplink.STATE_CHANGE"|Indicates the common event that the state of MPLINK (an enhanced Wi-Fi feature) has changed.| 110|static const char* const [COMMON_EVENT_WIFI_P2P_CONN_STATE](common_event/commonEventManager-definitions.md#common_event_wifi_p2p_conn_state) = "usual.event.wifi.p2p.CONN_STATE_CHANGE"|Indicates the common event that the Wi-Fi P2P connection state has changed.| 111|static const char* const [COMMON_EVENT_WIFI_P2P_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_wifi_p2p_state_changed) = "usual.event.wifi.p2p.STATE_CHANGE"|Indicates the common event that the Wi-Fi P2P state has changed, for example, enabled or disabled.| 112|static const char* const [COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_wifi_p2p_peers_state_changed) = "usual.event.wifi.p2p.DEVICES_CHANGE"|Indicates the common event that the state of the Wi-Fi P2P peer device has changed.| 113|static const char* const [COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_wifi_p2p_peers_discovery_state_changed) = "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE"|Indicates the common event that the Wi-Fi P2P discovery state has changed.| 114|static const char* const [COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_wifi_p2p_current_device_state_changed) = "usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE"|Indicates the common event that the state of the Wi-Fi P2P local device has changed.| 115|static const char* const [COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_wifi_p2p_group_state_changed) = "usual.event.wifi.p2p.GROUP_STATE_CHANGED"|Indicates the common event that the Wi-Fi P2P group information has changed.| 116|static const char* const [COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_nfc_action_adapter_state_changed) = "usual.event.nfc.action.ADAPTER_STATE_CHANGED"| Indicates the common event that the state of the device NFC adapter has changed.| 117|static const char* const [COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED](common_event/commonEventManager-definitions.md#common_event_nfc_action_rf_field_on_detected) = "usual.event.nfc.action.RF_FIELD_ON_DETECTED"|Indicates the common event that the NFC RF field is on.| 118|static const char* const [COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED](common_event/commonEventManager-definitions.md#common_event_nfc_action_rf_field_off_detected) = "usual.event.nfc.action.RF_FIELD_OFF_DETECTED"|Indicates the common event that the NFC RF field is off.| 119|static const char* const [COMMON_EVENT_DISCHARGING](common_event/commonEventManager-definitions.md#common_event_discharging) = "usual.event.DISCHARGING"| Indicates the common event that the system stops charging the battery.| 120|static const char* const [COMMON_EVENT_CHARGING](common_event/commonEventManager-definitions.md#common_event_charging) = "usual.event.CHARGING"|Indicates a common event that the system starts charging the battery.| 121|static const char* const [COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED](common_event/commonEventManager-definitions.md#common_event_device_idle_mode_changed) = "usual.event.DEVICE_IDLE_MODE_CHANGED"| Indicates the common event that the system standby mode has changed.| 122|static const char* const [COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED](common_event/commonEventManager-definitions.md#common_event_charge_idle_mode_changed10) = "usual.event.CHARGE_IDLE_MODE_CHANGED"|Indicates the common event that the device enters the charging idle mode.| 123|static const char* const [COMMON_EVENT_POWER_SAVE_MODE_CHANGED](common_event/commonEventManager-definitions.md#common_event_power_save_mode_changed) = "usual.event.POWER_SAVE_MODE_CHANGED"|Indicates the common event that the system power saving mode is changed.| 124|static const char* const [COMMON_EVENT_USB_STATE](common_event/commonEventManager-definitions.md#common_event_usb_state) = "usual.event.hardware.usb.action.USB_STATE"|Indicates the common event that the USB device state has changed.| 125|static const char* const [COMMON_EVENT_USB_PORT_CHANGED](common_event/commonEventManager-definitions.md#common_event_usb_port_changed) = "usual.event.hardware.usb.action.USB_PORT_CHANGED"|Indicates the common event that the USB port state of the user device has changed.| 126|static const char* const [COMMON_EVENT_USB_DEVICE_ATTACHED](common_event/commonEventManager-definitions.md#common_event_usb_device_attached) = "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED"|Indicates the common event that a USB device has been attached when the user device functions as a USB host.| 127|static const char* const [COMMON_EVENT_USB_DEVICE_DETACHED](common_event/commonEventManager-definitions.md#common_event_usb_device_detached) = "usual.event.hardware.usb.action.USB_DEVICE_DETACHED"|Indicates the common event that a USB device has been detached when the user device functions as a USB host.| 128|static const char* const [COMMON_EVENT_AIRPLANE_MODE_CHANGED](common_event/commonEventManager-definitions.md#common_event_airplane_mode_changed10) = "usual.event.AIRPLANE_MODE"| Indicates the common event that the airplane mode of the device has changed.| 129|static const char* const [COMMON_EVENT_SPLIT_SCREEN](common_event/commonEventManager-definitions.md#common_event_split_screen) = "common.event.SPLIT_SCREEN"| Indicates the common event of screen splitting.| 130|static const char* const [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](common_event/commonEventManager-definitions.md#common_event_quick_fix_apply_result) = "usual.event.QUICK_FIX_APPLY_RESULT"| Indicates the common event that a quick fix is applied to an application.| 131|static const char* const [COMMON_EVENT_QUICK_FIX_REVOKE_RESULT](common_event/commonEventManager-definitions.md#common_event_quick_fix_revoke_result10) = "usual.event.QUICK_FIX_REVOKE_RESULT"| Indicates the common event that a quick fix is canceled.| 132|static const char* const [COMMON_EVENT_USER_INFO_UPDATED](common_event/commonEventManager-definitions.md#common_event_user_info_updated) = "usual.event.USER_INFO_UPDATED"| Indicates the common event that the user information has been updated.| 133|static const char* const [COMMON_EVENT_SIM_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_sim_state_changed10) = "usual.event.SIM_STATE_CHANGED"|Indicates the common event that the SIM card state has been updated.| 134|static const char* const [COMMON_EVENT_CALL_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_call_state_changed10) = "usual.event.CALL_STATE_CHANGED"| Indicates the common event that the call state has been updated.| 135|static const char* const [COMMON_EVENT_NETWORK_STATE_CHANGED](common_event/commonEventManager-definitions.md#common_event_network_state_changed10) = "usual.event.NETWORK_STATE_CHANGED"| Indicates the common event that the network state has been updated.| 136|static const char* const [COMMON_EVENT_SIGNAL_INFO_CHANGED](common_event/commonEventManager-definitions.md#common_event_signal_info_changed10) = "usual.event.SIGNAL_INFO_CHANGED"|Indicates the common event that the signal information has been updated.| 137|static const char* const [COMMON_EVENT_SCREEN_UNLOCKED](common_event/commonEventManager-definitions.md#common_event_screen_unlocked) = "usual.event.SCREEN_UNLOCKED"|Indicates the common event that the screen has been unlocked.| 138|static const char* const [COMMON_EVENT_SCREEN_LOCKED](common_event/commonEventManager-definitions.md#common_event_screen_locked) = "usual.event.SCREEN_LOCKED"| Indicates the common event that the screen has been locked.| 139|static const char* const [COMMON_EVENT_HTTP_PROXY_CHANGE](common_event/commonEventManager-definitions.md#common_event_http_proxy_change10) = "usual.event.HTTP_PROXY_CHANGE"| Indicates the common event that the HTTP proxy configuration has changed.| 140|static const char* const [COMMON_EVENT_CONNECTIVITY_CHANGE](common_event/commonEventManager-definitions.md#common_event_connectivity_change10) = "usual.event.CONNECTIVITY_CHANGE"| Indicates the common event that the network connection state has changed.| 141|static const char* const [COMMON_EVENT_MINORSMODE_ON](common_event/commonEventManager-definitions.md#common_event_minorsmode_on12) = "usual.event.MINORSMODE_ON"|Indicates the common event that the minor mode is enabled.| 142|static const char* const [COMMON_EVENT_MINORSMODE_OFF](common_event/commonEventManager-definitions.md#common_event_minorsmode_off12) = "usual.event.MINORSMODE_OFF"| Indicates the common event that the minor mode is disabled.| 143## Type Description 144 145### CommonEvent_SubscribeInfo 146 147```c 148typedef struct CommonEvent_SubscribeInfo CommonEvent_SubscribeInfo 149``` 150 151**Description** 152 153Defines the subscriber information. 154 155**Since**: 12 156 157### CommonEvent_Subscriber 158 159```c 160typedef void CommonEvent_Subscriber 161``` 162 163**Description** 164 165Defines a subscriber. 166 167**Since**: 12 168 169### CommonEvent_RcvData 170 171```c 172typedef struct CommonEvent_RcvData CommonEvent_RcvData 173``` 174 175**Description** 176 177Defines the callback data of a common event. 178 179**Since**: 12 180 181### CommonEvent_Parameters 182 183```c 184typedef void CommonEvent_Parameters 185``` 186 187**Description** 188 189Defines the additional information about a common event. 190 191**Since**: 12 192 193### CommonEvent_ReceiveCallback 194 195```c 196typedef void (*CommonEvent_ReceiveCallback)(const CommonEvent_RcvData *data) 197``` 198 199**Description** 200 201Defines the callback function of a common event. 202 203**Since**: 12 204 205 206## Enum Description 207 208### CommonEvent_ErrCode 209**Description** 210 211Enumerates the error codes. 212 213**Since**: 12 214 215| Value| Description| 216| -------- | -------- | 217| COMMONEVENT_ERR_OK = 0 |The operation is successful.| 218| COMMONEVENT_ERR_PERMISSION_ERROR = 201 |Permission denied.| 219| COMMONEVENT_ERR_INVALID_PARAMETER = 401 |Invalid parameter.| 220| COMMONEVENT_ERR_SENDING_REQUEST_FAILED = 1500007 |Failed to send an IPC request.| 221| COMMONEVENT_ERR_INIT_UNDONE = 1500008|The service is not initialized.| 222| COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED = 1500010|The number of subscribers exceeds 200.| 223| COMMONEVENT_ERR_ALLOC_MEMORY_FAILED = 1500011|The system failed to allocate memory.| 224 225## Constant Description 226 227### COMMON_EVENT_SHUTDOWN 228 229```c 230static const char* const COMMON_EVENT_SHUTDOWN = "usual.event.SHUTDOWN" 231``` 232 233**Description** 234 235Indicates the common event that the device is being shut down and the final shutdown will proceed. 236 237**Since**: 12 238 239### COMMON_EVENT_BATTERY_CHANGED 240 241```c 242static const char* const COMMON_EVENT_BATTERY_CHANGED = "usual.event.BATTERY_CHANGED" 243``` 244 245**Description** 246 247Indicates the common event that the charging state, level, and other information about the battery have changed. 248 249**Since**: 12 250 251### COMMON_EVENT_BATTERY_LOW 252 253```c 254static const char* const COMMON_EVENT_BATTERY_LOW = "usual.event.BATTERY_LOW" 255``` 256 257**Description** 258 259Indicates the common event that the battery level is low. 260 261**Since**: 12 262 263### COMMON_EVENT_BATTERY_OKAY 264 265```c 266static const char* const COMMON_EVENT_BATTERY_OKAY = "usual.event.BATTERY_OKAY" 267``` 268 269**Description** 270 271Indicates the common event that the battery exits the low state. 272 273**Since**: 12 274 275### COMMON_EVENT_POWER_CONNECTED 276 277```c 278static const char* const COMMON_EVENT_POWER_CONNECTED = "usual.event.POWER_CONNECTED" 279``` 280 281**Description** 282 283Indicates the common event that the device is connected to an external power supply. 284 285**Since**: 12 286 287### COMMON_EVENT_POWER_DISCONNECTED 288 289```c 290static const char* const COMMON_EVENT_POWER_DISCONNECTED = "usual.event.POWER_DISCONNECTED" 291``` 292 293**Description** 294 295Indicates the common event that the device is disconnected from the external power supply. 296 297**Since**: 12 298 299### COMMON_EVENT_SCREEN_OFF 300 301```c 302static const char* const COMMON_EVENT_SCREEN_OFF = "usual.event.SCREEN_OFF" 303``` 304 305**Description** 306 307Indicates the common event that the device screen is off and the device is sleeping. 308 309**Since**: 12 310 311### COMMON_EVENT_SCREEN_ON 312 313```c 314static const char* const COMMON_EVENT_SCREEN_ON = "usual.event.SCREEN_ON" 315``` 316 317**Description** 318 319Indicates the common event that the device screen is on and the device is in interactive state. 320 321**Since**: 12 322 323### COMMON_EVENT_THERMAL_LEVEL_CHANGED 324 325```c 326static const char* const COMMON_EVENT_THERMAL_LEVEL_CHANGED = "usual.event.THERMAL_LEVEL_CHANGED" 327``` 328 329**Description** 330 331Indicates the common event that the device's thermal level has changed. 332 333**Since**: 12 334 335### COMMON_EVENT_TIME_TICK 336 337```c 338static const char* const COMMON_EVENT_TIME_TICK = "usual.event.TIME_TICK" 339``` 340 341**Description** 342 343Indicates the common event that the system time has changed. 344 345**Since**: 12 346 347### COMMON_EVENT_TIME_CHANGED 348 349```c 350static const char* const COMMON_EVENT_TIME_CHANGED = "usual.event.TIME_CHANGED" 351``` 352 353**Description** 354 355Indicates the common event that the system time is reset. 356 357**Since**: 12 358 359### COMMON_EVENT_TIMEZONE_CHANGED 360 361```c 362static const char* const COMMON_EVENT_TIMEZONE_CHANGED = "usual.event.TIMEZONE_CHANGED" 363``` 364 365**Description** 366 367Indicates the common event that the system time zone has changed. 368 369**Since**: 12 370 371### COMMON_EVENT_PACKAGE_ADDED 372 373```c 374static const char* const COMMON_EVENT_PACKAGE_ADDED = "usual.event.PACKAGE_ADDED" 375``` 376 377**Description** 378 379Indicates the common event that a new application package has been installed on the device. 380 381**Since**: 12 382 383### COMMON_EVENT_PACKAGE_REMOVED 384 385```c 386static const char* const COMMON_EVENT_PACKAGE_REMOVED = "usual.event.PACKAGE_REMOVED" 387``` 388 389**Description** 390 391Indicates the common event that an installed application has been uninstalled from the device with the application data retained. 392 393**Since**: 12 394 395### COMMON_EVENT_BUNDLE_REMOVED 396 397```c 398static const char* const COMMON_EVENT_BUNDLE_REMOVED = "usual.event.BUNDLE_REMOVED" 399``` 400 401**Description** 402 403Indicates the common event that an installed bundle has been uninstalled from the device with the application data retained. 404 405**Since**: 12 406 407### COMMON_EVENT_PACKAGE_FULLY_REMOVED 408 409```c 410static const char* const COMMON_EVENT_PACKAGE_FULLY_REMOVED = "usual.event.PACKAGE_FULLY_REMOVED" 411``` 412 413**Description** 414 415Indicates the common event that an installed application, including both the application data and code, has been completely uninstalled from the device. 416 417**Since**: 12 418 419### COMMON_EVENT_PACKAGE_CHANGED 420 421```c 422static const char* const COMMON_EVENT_PACKAGE_CHANGED = "usual.event.PACKAGE_CHANGED" 423``` 424 425**Description** 426 427Indicates the common event that an application package has been changed (for example, a component in the package has been enabled or disabled). 428 429**Since**: 12 430 431### COMMON_EVENT_PACKAGE_RESTARTED 432 433```c 434static const char* const COMMON_EVENT_PACKAGE_RESTARTED = "usual.event.PACKAGE_RESTARTED" 435``` 436 437**Description** 438 439Indicates a common event that a user restarts an application package and kills all its processes. 440 441**Since**: 12 442 443### COMMON_EVENT_PACKAGE_DATA_CLEARED 444 445```c 446static const char* const COMMON_EVENT_PACKAGE_DATA_CLEARED = "usual.event.PACKAGE_DATA_CLEARED" 447``` 448 449**Description** 450 451Indicates the common event that the user has cleared the application package data. 452 453**Since**: 12 454 455### COMMON_EVENT_PACKAGE_CACHE_CLEARED 456 457```c 458static const char* const COMMON_EVENT_PACKAGE_CACHE_CLEARED = "usual.event.PACKAGE_CACHE_CLEARED" 459``` 460 461**Description** 462 463Indicates the common event that the user has cleared the application package data cache. 464 465**Since**: 12 466 467### COMMON_EVENT_PACKAGES_SUSPENDED 468 469```c 470static const char* const COMMON_EVENT_PACKAGES_SUSPENDED = "usual.event.PACKAGES_SUSPENDED" 471``` 472 473**Description** 474 475Indicates the common event that application packages have been suspended. 476 477**Since**: 12 478 479### COMMON_EVENT_MY_PACKAGE_SUSPENDED 480 481```c 482static const char* const COMMON_EVENT_MY_PACKAGE_SUSPENDED = "usual.event.MY_PACKAGE_SUSPENDED" 483``` 484 485**Description** 486 487Indicates the common event that can be sent to a suspended application package. 488 489**Since**: 12 490 491### COMMON_EVENT_MY_PACKAGE_UNSUSPENDED 492 493```c 494static const char* const COMMON_EVENT_MY_PACKAGE_UNSUSPENDED = "usual.event.MY_PACKAGE_UNSUSPENDED" 495``` 496 497**Description** 498 499Indicates the common event that application packages have not been suspended. 500 501**Since**: 12 502 503### COMMON_EVENT_LOCALE_CHANGED 504 505```c 506static const char* const COMMON_EVENT_LOCALE_CHANGED = "usual.event.LOCALE_CHANGED" 507``` 508 509**Description** 510 511Indicates the common event that the device locale has changed. 512 513**Since**: 12 514 515### COMMON_EVENT_MANAGE_PACKAGE_STORAGE 516 517```c 518static const char* const COMMON_EVENT_MANAGE_PACKAGE_STORAGE = "usual.event.MANAGE_PACKAGE_STORAGE" 519``` 520 521**Description** 522 523Indicates the common event that the device storage is insufficient. 524 525**Since**: 12 526 527### COMMON_EVENT_USER_UNLOCKED 528 529```c 530static const char* const COMMON_EVENT_USER_UNLOCKED = "usual.event.USER_UNLOCKED" 531``` 532 533**Description** 534 535Indicates the common event that the credential-encrypted storage has become unlocked for the current user when the device is unlocked after being restarted. 536 537**Since**: 12 538 539### COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT 540 541```c 542static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT = "common.event.DISTRIBUTED_ACCOUNT_LOGOUT" 543``` 544 545**Description** 546 547Indicates the common event that a distributed account is successfully logged out. 548 549**Since**: 12 550 551### COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID 552 553```c 554static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID = "common.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID" 555``` 556 557**Description** 558 559Indicates the common event that the token of a distributed account is invalid. 560 561**Since**: 12 562 563### COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF 564 565```c 566static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF = "common.event.DISTRIBUTED_ACCOUNT_LOGOFF" 567``` 568 569**Description** 570 571Indicates the common event that a distributed account is deregistered. 572 573**Since**: 12 574 575### COMMON_EVENT_WIFI_POWER_STATE 576 577```c 578static const char* const COMMON_EVENT_WIFI_POWER_STATE = "usual.event.wifi.POWER_STATE" 579``` 580 581**Description** 582 583Indicates the common event that the Wi-Fi state has changed, for example, enabled or disabled. 584 585**Since**: 12 586 587### COMMON_EVENT_WIFI_SCAN_FINISHED 588 589```c 590static const char* const COMMON_EVENT_WIFI_SCAN_FINISHED = "usual.event.wifi.SCAN_FINISHED" 591``` 592 593**Description** 594 595Indicates the common event that the Wi-Fi access point has been scanned and proven to be available. 596 597**Since**: 12 598 599### COMMON_EVENT_WIFI_RSSI_VALUE 600 601```c 602static const char* const COMMON_EVENT_WIFI_RSSI_VALUE = "usual.event.wifi.RSSI_VALUE" 603``` 604 605**Description** 606 607Indicates the common event that the Wi-Fi signal strength (RSSI) has changed. 608 609**Since**: 12 610 611### COMMON_EVENT_WIFI_CONN_STATE 612 613```c 614static const char* const COMMON_EVENT_WIFI_CONN_STATE = "usual.event.wifi.CONN_STATE" 615``` 616 617**Description** 618 619Indicates the common event that the Wi-Fi connection state has changed. 620 621**Since**: 12 622 623### COMMON_EVENT_WIFI_HOTSPOT_STATE 624 625```c 626static const char* const COMMON_EVENT_WIFI_HOTSPOT_STATE = "usual.event.wifi.HOTSPOT_STATE" 627``` 628 629**Description** 630 631Indicates a common event of the Wi-Fi hotspot state. 632 633**Since**: 12 634 635### COMMON_EVENT_WIFI_AP_STA_JOIN 636 637```c 638static const char* const COMMON_EVENT_WIFI_AP_STA_JOIN = "usual.event.wifi.WIFI_HS_STA_JOIN" 639``` 640 641**Description** 642 643Indicates the common event that a client has joined the Wi-Fi hotspot of the current device. 644 645**Since**: 12 646 647### COMMON_EVENT_WIFI_AP_STA_LEAVE 648 649```c 650static const char* const COMMON_EVENT_WIFI_AP_STA_LEAVE = "usual.event.wifi.WIFI_HS_STA_LEAVE" 651``` 652 653**Description** 654 655Indicates the common event that a client has disconnected from the Wi-Fi hotspot of the current device. 656 657**Since**: 12 658 659### COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE 660 661```c 662static const char* const COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE = "usual.event.wifi.mplink.STATE_CHANGE" 663``` 664 665**Description** 666 667Indicates the common event that the state of MPLINK (an enhanced Wi-Fi feature) has changed. 668 669**Since**: 12 670 671### COMMON_EVENT_WIFI_P2P_CONN_STATE 672 673```c 674static const char* const COMMON_EVENT_WIFI_P2P_CONN_STATE = "usual.event.wifi.p2p.CONN_STATE_CHANGE" 675``` 676 677**Description** 678 679Indicates the common event that the Wi-Fi P2P connection state has changed. 680 681**Since**: 12 682 683### COMMON_EVENT_WIFI_P2P_STATE_CHANGED 684 685```c 686static const char* const COMMON_EVENT_WIFI_P2P_STATE_CHANGED = "usual.event.wifi.p2p.STATE_CHANGE" 687``` 688 689**Description** 690 691Indicates the common event that the Wi-Fi P2P state has changed, for example, enabled or disabled. 692 693### COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED 694 695```c 696static const char* const COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED = "usual.event.wifi.p2p.DEVICES_CHANGE" 697``` 698 699**Description** 700 701Indicates the common event that the state of the Wi-Fi P2P peer device has changed. 702 703**Since**: 12 704 705### COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED 706 707```c 708static const char* const COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED = "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE" 709``` 710 711**Description** 712 713Indicates the common event that the Wi-Fi P2P discovery state has changed. 714 715**Since**: 12 716 717### COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED 718 719```c 720static const char* const COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED = "usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE" 721``` 722 723**Description** 724 725Indicates the common event that the state of the Wi-Fi P2P local device has changed. 726 727**Since**: 12 728 729### COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED 730 731```c 732static const char* const COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED = "usual.event.wifi.p2p.GROUP_STATE_CHANGED" 733``` 734 735**Description** 736 737Indicates the common event that the Wi-Fi P2P group information has changed. 738 739**Since**: 12 740 741### COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED 742 743```c 744static const char* const COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED = "usual.event.nfc.action.ADAPTER_STATE_CHANGED" 745``` 746 747**Description** 748 749Indicates the common event that the state of the device NFC adapter has changed. 750 751**Since**: 12 752 753### COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED 754 755```c 756static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED = "usual.event.nfc.action.RF_FIELD_ON_DETECTED" 757``` 758 759**Description** 760 761Indicates the common event that the NFC RF field is on. 762 763**Since**: 12 764 765### COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED 766 767```c 768static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED = "usual.event.nfc.action.RF_FIELD_OFF_DETECTED" 769``` 770 771**Description** 772 773Indicates the common event that the NFC RF field is off. 774 775**Since**: 12 776 777### COMMON_EVENT_DISCHARGING 778 779```c 780static const char* const COMMON_EVENT_DISCHARGING = "usual.event.DISCHARGING" 781``` 782 783**Description** 784 785Indicates the common event that the system stops charging the battery. 786 787**Since**: 12 788 789### COMMON_EVENT_CHARGING 790 791```c 792static const char* const COMMON_EVENT_CHARGING = "usual.event.CHARGING" 793``` 794 795**Description** 796 797Indicates a common event that the system starts charging the battery. 798 799### COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED 800 801```c 802static const char* const COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED = "usual.event.DEVICE_IDLE_MODE_CHANGED" 803``` 804 805**Description** 806 807Indicates the common event that the system standby mode has changed. 808 809**Since**: 12 810 811### COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED 812 813```c 814static const char* const COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED = "usual.event.CHARGE_IDLE_MODE_CHANGED" 815``` 816 817**Description** 818 819Indicates the common event that the device enters the charging idle mode. 820 821**Since**: 12 822 823### COMMON_EVENT_POWER_SAVE_MODE_CHANGED 824 825```c 826static const char* const COMMON_EVENT_POWER_SAVE_MODE_CHANGED = "usual.event.POWER_SAVE_MODE_CHANGED" 827``` 828 829**Description** 830 831Indicates the common event that the system power saving mode is changed. 832 833**Since**: 12 834 835### COMMON_EVENT_USB_STATE 836 837```c 838static const char* const COMMON_EVENT_USB_STATE = "usual.event.hardware.usb.action.USB_STATE" 839``` 840 841**Description** 842 843Indicates the common event that the USB device state has changed. 844 845**Since**: 12 846 847### COMMON_EVENT_USB_PORT_CHANGED 848 849```c 850static const char* const COMMON_EVENT_USB_PORT_CHANGED = "usual.event.hardware.usb.action.USB_PORT_CHANGED" 851``` 852 853**Description** 854 855Indicates the common event that the USB port state of the user device has changed. 856 857**Since**: 12 858 859### COMMON_EVENT_USB_DEVICE_ATTACHED 860 861```c 862static const char* const COMMON_EVENT_USB_DEVICE_ATTACHED = "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED" 863``` 864 865**Description** 866 867Indicates the common event that a USB device has been attached when the user device functions as a USB host. 868 869**Since**: 12 870 871### COMMON_EVENT_USB_DEVICE_DETACHED 872 873```c 874static const char* const COMMON_EVENT_USB_DEVICE_DETACHED = "usual.event.hardware.usb.action.USB_DEVICE_DETACHED" 875``` 876 877**Description** 878 879Indicates the common event that a USB device has been detached when the user device functions as a USB host. 880 881**Since**: 12 882 883### COMMON_EVENT_AIRPLANE_MODE_CHANGED 884 885```c 886static const char* const COMMON_EVENT_AIRPLANE_MODE_CHANGED = "usual.event.AIRPLANE_MODE" 887``` 888 889**Description** 890 891Indicates the common event that the airplane mode of the device has changed. 892 893**Since**: 12 894 895### COMMON_EVENT_SPLIT_SCREEN 896 897```c 898static const char* const COMMON_EVENT_SPLIT_SCREEN = "common.event.SPLIT_SCREEN" 899``` 900 901**Description** 902 903Indicates the common event of screen splitting. 904 905**Since**: 12 906 907### COMMON_EVENT_QUICK_FIX_APPLY_RESULT 908 909```c 910static const char* const COMMON_EVENT_QUICK_FIX_APPLY_RESULT = "usual.event.QUICK_FIX_APPLY_RESULT" 911``` 912 913**Description** 914 915Indicates the common event that a quick fix is applied to an application. 916 917**Since**: 12 918 919### COMMON_EVENT_QUICK_FIX_REVOKE_RESULT 920 921```c 922static const char* const COMMON_EVENT_QUICK_FIX_REVOKE_RESULT = "usual.event.QUICK_FIX_REVOKE_RESULT" 923``` 924 925**Description** 926 927Indicates the common event that a quick fix is canceled. 928 929**Since**: 12 930 931### COMMON_EVENT_USER_INFO_UPDATED 932 933```c 934static const char* const COMMON_EVENT_USER_INFO_UPDATED = "usual.event.USER_INFO_UPDATED" 935``` 936 937**Description** 938 939Indicates the common event that the user information has been updated. 940 941**Since**: 12 942 943### COMMON_EVENT_SIM_STATE_CHANGED 944 945```c 946static const char* const COMMON_EVENT_SIM_STATE_CHANGED = "usual.event.SIM_STATE_CHANGED" 947``` 948 949**Description** 950 951Indicates the common event that the SIM card state has been updated. 952 953**Since**: 12 954 955### COMMON_EVENT_CALL_STATE_CHANGED 956 957```c 958static const char* const COMMON_EVENT_CALL_STATE_CHANGED = "usual.event.CALL_STATE_CHANGED" 959``` 960 961**Description** 962 963Indicates the common event that the call state has been updated. 964 965**Since**: 12 966 967### COMMON_EVENT_NETWORK_STATE_CHANGED 968 969```c 970static const char* const COMMON_EVENT_NETWORK_STATE_CHANGED = "usual.event.NETWORK_STATE_CHANGED" 971``` 972 973**Description** 974 975Indicates the common event that the network state has been updated. 976 977**Since**: 12 978 979### COMMON_EVENT_SIGNAL_INFO_CHANGED 980 981```c 982static const char* const COMMON_EVENT_SIGNAL_INFO_CHANGED = "usual.event.SIGNAL_INFO_CHANGED" 983``` 984 985**Description** 986 987Indicates the common event that the signal information has been updated. 988 989**Since**: 12 990 991### COMMON_EVENT_SCREEN_UNLOCKED 992 993```c 994static const char* const COMMON_EVENT_SCREEN_UNLOCKED = "usual.event.SCREEN_UNLOCKED" 995``` 996 997**Description** 998 999Indicates the common event that the screen has been unlocked. 1000 1001**Since**: 12 1002 1003### COMMON_EVENT_SCREEN_LOCKED 1004 1005```c 1006static const char* const COMMON_EVENT_SCREEN_LOCKED = "usual.event.SCREEN_LOCKED" 1007``` 1008 1009**Description** 1010 1011Indicates the common event that the screen has been locked. 1012 1013**Since**: 12 1014 1015### COMMON_EVENT_HTTP_PROXY_CHANGE 1016 1017```c 1018static const char* const COMMON_EVENT_HTTP_PROXY_CHANGE = "usual.event.HTTP_PROXY_CHANGE" 1019``` 1020 1021**Description** 1022 1023Indicates the common event that the HTTP proxy configuration has changed. 1024 1025**Since**: 12 1026 1027### COMMON_EVENT_CONNECTIVITY_CHANGE 1028 1029```c 1030static const char* const COMMON_EVENT_CONNECTIVITY_CHANGE = "usual.event.CONNECTIVITY_CHANGE" 1031``` 1032 1033**Description** 1034 1035Indicates the common event that the network connection state has changed. 1036 1037**Since**: 12 1038 1039### COMMON_EVENT_MINORSMODE_ON 1040 1041```c 1042static const char* const COMMON_EVENT_MINORSMODE_ON = "usual.event.MINORSMODE_ON" 1043``` 1044 1045**Description** 1046 1047Indicates that the minor mode is enabled. 1048 1049**Since**: 12 1050 1051### COMMON_EVENT_MINORSMODE_OFF 1052 1053```c 1054static const char* const COMMON_EVENT_MINORSMODE_OFF = "usual.event.MINORSMODE_OFF" 1055``` 1056 1057**Description** 1058 1059Indicates the common event that the minor mode is disabled. 1060 1061**Since**: 12 1062 1063## Function Description 1064 1065### OH_CommonEvent_CreateSubscribeInfo 1066 1067```cpp 1068CommonEvent_SubscribeInfo* OH_CommonEvent_CreateSubscribeInfo(const char* events[], int32_t eventsNum) 1069``` 1070 1071**Description** 1072 1073Creates the subscriber information. 1074 1075**Since**: 12 1076 1077**Parameters** 1078 1079| Name| Description| 1080| -------- | -------- | 1081| events | Events you have subscribed to.| 1082| eventsNum | Number of events| 1083 1084**Returns** 1085 1086Returns the subscriber information. 1087 1088### OH_CommonEvent_SetPublisherPermission 1089 1090```cpp 1091CommonEvent_ErrCode OH_CommonEvent_SetPublisherPermission(CommonEvent_SubscribeInfo* info, const char* permission) 1092``` 1093 1094**Description** 1095 1096Sets the subscriber permission. 1097 1098**Since**: 12 1099 1100**Parameters** 1101 1102| Name| Description| 1103| -------- | -------- | 1104| info | Subscriber information.| 1105| permission | Name of the permission.| 1106 1107**Returns** 1108 1109Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if **info** is a null pointer. 1110 1111### OH_CommonEvent_SetPublisherBundleName 1112 1113```cpp 1114CommonEvent_ErrCode OH_CommonEvent_SetPublisherBundleName(CommonEvent_SubscribeInfo* info, const char* bundleName) 1115``` 1116 1117**Description** 1118 1119Sets a bundle name of the subscriber. 1120 1121**Since**: 12 1122 1123**Parameters** 1124 1125| Name| Description| 1126| -------- | -------- | 1127| info | Subscriber information.| 1128| bundleName | Bundle name.| 1129 1130**Returns** 1131 1132Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if **info** is a null pointer. 1133 1134### OH_CommonEvent_DestroySubscribeInfo 1135 1136```cpp 1137void OH_CommonEvent_DestroySubscribeInfo(CommonEvent_SubscribeInfo* info) 1138``` 1139 1140**Description** 1141 1142Destroys the subscriber information. 1143 1144**Since**: 12 1145 1146**Parameters** 1147 1148| Name| Description| 1149| -------- | -------- | 1150| info | Subscriber information.| 1151 1152### OH_CommonEvent_CreateSubscriber 1153 1154```cpp 1155CommonEvent_Subscriber* OH_CommonEvent_CreateSubscriber(const CommonEvent_SubscribeInfo* info, CommonEvent_ReceiveCallback callback) 1156``` 1157 1158**Description** 1159 1160Creates a subscriber. 1161 1162**Since**: 12 1163 1164**Parameters** 1165 1166| Name| Description| 1167| -------- | -------- | 1168| info | Subscriber information.| 1169| callback | Event callback.| 1170 1171**Returns** 1172 1173Returns the subscriber. 1174 1175### OH_CommonEvent_DestroySubscriber 1176 1177```cpp 1178void OH_CommonEvent_DestroySubscriber(CommonEvent_Subscriber* subscriber) 1179``` 1180 1181**Description** 1182 1183Destroys a subscriber. 1184 1185**Since**: 12 1186 1187**Parameters** 1188 1189| Name| Description| 1190| -------- | -------- | 1191| subscriber | Subscriber.| 1192 1193### OH_CommonEvent_Subscribe 1194 1195```cpp 1196CommonEvent_ErrCode OH_CommonEvent_Subscribe(const CommonEvent_Subscriber* subscriber) 1197``` 1198 1199**Description** 1200 1201Subscribes to a common event. 1202 1203**Since**: 12 1204 1205**Parameters** 1206 1207| Name| Description| 1208| -------- | -------- | 1209| subscriber | Subscriber.| 1210 1211**Returns** 1212 1213Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the **subscriber** is a null parameter.<br>Returns **COMMONEVENT_ERR_SENDING_REQUEST_FAILED** if the IPC fails to be sent.<br>Returns **COMMONEVENT_ERR_INIT_UNDONE** if the common event service is not initialized.<br>Returns **COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED** if the number of subscribers in the current process exceeds 200.<br>Returns **COMMONEVENT_ERR_ALLOC_MEMORY_FAILED** if the system fails to allocate memory. 1214 1215### OH_CommonEvent_UnSubscribe 1216 1217```cpp 1218CommonEvent_ErrCode OH_CommonEvent_UnSubscribe(const CommonEvent_Subscriber* subscriber) 1219``` 1220 1221**Description** 1222 1223Unsubscribes from a common event. 1224 1225**Since**: 12 1226 1227**Parameters** 1228 1229| Name| Description| 1230| -------- | -------- | 1231| subscriber | Subscriber.| 1232 1233**Returns** 1234 1235Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the **subscriber** is a null parameter.<br>Returns **COMMONEVENT_ERR_SENDING_REQUEST_FAILED** if the IPC fails to be sent.<br>Returns **COMMONEVENT_ERR_INIT_UNDONE** if the common event service is not initialized. 1236 1237### OH_CommonEvent_GetEventFromRcvData 1238 1239```cpp 1240const char* OH_CommonEvent_GetEventFromRcvData(const CommonEvent_RcvData* rcvData) 1241``` 1242 1243**Description** 1244 1245Obtains the name of a callback common event. 1246 1247**Since**: 12 1248 1249**Parameters** 1250 1251| Name| Description| 1252| -------- | -------- | 1253| rcvData | Callback data of a common event.| 1254 1255**Returns** 1256 1257Returns the name of a common event. 1258 1259### OH_CommonEvent_GetCodeFromRcvData 1260 1261```cpp 1262int32_t OH_CommonEvent_GetCodeFromRcvData(const CommonEvent_RcvData* rcvData) 1263``` 1264 1265**Description** 1266 1267Obtains the result code of the callback common event. 1268 1269**Since**: 12 1270 1271**Parameters** 1272 1273| Name| Description| 1274| -------- | -------- | 1275| rcvData | Callback data of a common event.| 1276 1277**Returns** 1278 1279Returns the result code of a common event. The default value is **0**. 1280 1281### OH_CommonEvent_GetDataStrFromRcvData 1282 1283```cpp 1284const char* OH_CommonEvent_GetDataStrFromRcvData(const CommonEvent_RcvData* rcvData) 1285``` 1286 1287**Description** 1288 1289Obtains the custom result data of a common event. 1290 1291**Since**: 12 1292 1293**Parameters** 1294 1295| Name| Description| 1296| -------- | -------- | 1297| rcvData | Callback data of a common event.| 1298 1299**Returns** 1300 1301Returns the custom result data of a common event. The default value is **null**. 1302 1303### OH_CommonEvent_GetBundleNameFromRcvData 1304 1305```cpp 1306const char* OH_CommonEvent_GetBundleNameFromRcvData(const CommonEvent_RcvData* rcvData) 1307``` 1308 1309**Description** 1310 1311Obtains the bundle name of a callback common event. 1312 1313**Since**: 12 1314 1315**Parameters** 1316 1317| Name| Description| 1318| -------- | -------- | 1319| rcvData | Callback data of a common event.| 1320 1321**Returns** 1322 1323Returns the bundle name of a common event. The default value is **null**. 1324 1325### OH_CommonEvent_GetParametersFromRcvData 1326 1327```cpp 1328const CommonEvent_Parameters* OH_CommonEvent_GetParametersFromRcvData(const CommonEvent_RcvData* rcvData) 1329``` 1330 1331**Description** 1332 1333Obtains the additional information about a callback common event. 1334 1335**Since**: 12 1336 1337**Parameters** 1338 1339| Name| Description| 1340| -------- | -------- | 1341| rcvData | Callback data of a common event.| 1342 1343**Returns** 1344 1345Returns the additional information about a common event. The default value is **null**. 1346 1347### OH_CommonEvent_HasKeyInParameters 1348 1349```cpp 1350bool OH_CommonEvent_HasKeyInParameters(const CommonEvent_Parameters* para, const char* key) 1351``` 1352 1353**Description** 1354 1355Checks whether the additional information of a common event contains a key-value pair. 1356 1357**Since**: 12 1358 1359**Parameters** 1360 1361| Name| Description| 1362| -------- | -------- | 1363| para | Additional information about a common event.| 1364| key | Key.| 1365 1366**Returns** 1367 1368Returns **true** if the key-value pair exists; returns **false** otherwise. 1369 1370### OH_CommonEvent_GetIntFromParameters 1371 1372```cpp 1373int OH_CommonEvent_GetIntFromParameters(const CommonEvent_Parameters* para, const char* key, const int defaultValue) 1374``` 1375 1376**Description** 1377 1378Obtains the **int** data with a specific key from the additional information of a common event. 1379 1380**Since**: 12 1381 1382**Parameters** 1383 1384| Name| Description| 1385| -------- | -------- | 1386| para | Additional information about a common event.| 1387| key | Key.| 1388| defaultValue | Default value to be returned.| 1389 1390### OH_CommonEvent_GetIntArrayFromParameters 1391 1392```cpp 1393int32_t OH_CommonEvent_GetIntArrayFromParameters(const CommonEvent_Parameters* para, const char* key, int** array) 1394``` 1395 1396**Description** 1397 1398Obtains the **int** array with a specific key from the additional information of a common event. 1399 1400**Since**: 12 1401 1402**Parameters** 1403 1404| Name| Description| 1405| -------- | -------- | 1406| para | Additional information about a common event.| 1407| key | Key.| 1408| array | **Int** array to receive data.| 1409 1410**Returns** 1411 1412Returns the length of an array. 1413 1414### OH_CommonEvent_GetLongFromParameters 1415 1416```cpp 1417long OH_CommonEvent_GetLongFromParameters(const CommonEvent_Parameters* para, const char* key, const long defaultValue) 1418``` 1419 1420**Description** 1421 1422Obtains the **long** data with a specific key from the additional information of a common event. 1423 1424**Since**: 12 1425 1426**Parameters** 1427 1428| Name| Description| 1429| -------- | -------- | 1430| para | Additional information about a common event.| 1431| key | Key.| 1432| defaultValue | Default value to be returned.| 1433 1434### OH_CommonEvent_GetLongArrayFromParameters 1435 1436```cpp 1437int32_t OH_CommonEvent_GetLongArrayFromParameters(const CommonEvent_Parameters* para, const char* key, long** array) 1438``` 1439 1440**Description** 1441 1442Obtains the **long** array with a specific key from the additional information of a common event. 1443 1444**Since**: 12 1445 1446**Parameters** 1447 1448| Name| Description| 1449| -------- | -------- | 1450| para | Additional information about a common event.| 1451| key | Key.| 1452| array | **long** array to receive data.| 1453 1454**Returns** 1455 1456Returns the length of an array. 1457 1458### OH_CommonEvent_GetBoolFromParameters 1459 1460```cpp 1461bool OH_CommonEvent_GetBoolFromParameters(const CommonEvent_Parameters* para, const char* key, const bool defaultValue) 1462``` 1463 1464**Description** 1465 1466Obtains the **bool** data with a specific key from the additional information of a common event. 1467 1468**Since**: 12 1469 1470**Parameters** 1471 1472| Name| Description| 1473| -------- | -------- | 1474| para | Additional information about a common event.| 1475| key | Key.| 1476| defaultValue | Default value to be returned.| 1477 1478### OH_CommonEvent_GetBoolArrayFromParameters 1479 1480```cpp 1481int32_t OH_CommonEvent_GetBoolArrayFromParameters(const CommonEvent_Parameters* para, const char* key, bool** array) 1482``` 1483 1484**Description** 1485 1486Obtains the **bool** array with a specific key from the additional information of a common event. 1487 1488**Since**: 12 1489 1490**Parameters** 1491 1492| Name| Description| 1493| -------- | -------- | 1494| para | Additional information about a common event.| 1495| key | Key.| 1496| array | **long** array to receive data.| 1497 1498**Returns** 1499 1500Returns the length of an array. 1501 1502### OH_CommonEvent_GetCharFromParameters 1503 1504```cpp 1505char OH_CommonEvent_GetCharFromParameters(const CommonEvent_Parameters* para, const char* key, const char defaultValue) 1506``` 1507 1508**Description** 1509 1510Obtains the **char** data with a specific key from the additional information of a common event. 1511 1512**Since**: 12 1513 1514**Parameters** 1515 1516| Name| Description| 1517| -------- | -------- | 1518| para | Additional information about a common event.| 1519| key | Key.| 1520| defaultValue | Default value to be returned.| 1521 1522### OH_CommonEvent_GetCharArrayFromParameters 1523 1524```cpp 1525int32_t OH_CommonEvent_GetCharArrayFromParameters(const CommonEvent_Parameters* para, const char* key, char** array) 1526``` 1527 1528**Description** 1529 1530Obtains the **char** array with a specific key from the additional information of a common event. 1531 1532**Since**: 12 1533 1534**Parameters** 1535 1536| Name| Description| 1537| -------- | -------- | 1538| para | Additional information about a common event.| 1539| key | Key.| 1540| array | **char** array to receive data.| 1541 1542**Returns** 1543 1544Returns the length of an array. 1545 1546### OH_CommonEvent_GetDoubleFromParameters 1547 1548```cpp 1549double OH_CommonEvent_GetDoubleFromParameters(const CommonEvent_Parameters* para, const char* key, const double defaultValue) 1550``` 1551 1552**Description** 1553 1554Obtains the **double** data with a specific key from the additional information of a common event. 1555 1556**Since**: 12 1557 1558**Parameters** 1559 1560| Name| Description| 1561| -------- | -------- | 1562| para | Additional information about a common event.| 1563| key | Key.| 1564| defaultValue | Default value to be returned.| 1565 1566### OH_CommonEvent_GetDoubleArrayFromParameters 1567 1568```cpp 1569int32_t OH_CommonEvent_GetDoubleArrayFromParameters(const CommonEvent_Parameters* para, const char* key, double** array) 1570``` 1571 1572**Description** 1573 1574Obtains the **double** array with a specific key from the additional information of a common event. 1575 1576**Since**: 12 1577 1578**Parameters** 1579 1580| Name| Description| 1581| -------- | -------- | 1582| para | Additional information about a common event.| 1583| key | Key.| 1584| array | **char** array to receive data.| 1585 1586**Returns** 1587 1588Returns the length of an array. The default value is **0**. 1589