• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 a struct for the subscriber information.|
29|[CommonEvent_Subscriber](#commonevent_subscriber) | Defines a subscriber.|
30|[CommonEvent_RcvData](#commonevent_rcvdata) | Defines a struct for 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 a callback to be invoked when a common event is triggered.|
33|[CommonEvent_PublishInfo](#commonevent_publishinfo)| Defines a struct for an attribute object used for publishing a custom common event.|
34
35### Enums
36
37| Name| Description|
38| -------- | -------- |
39| [CommonEvent_ErrCode](#commonevent_errcode) | Enumerates the error codes.|
40
41
42### Functions
43
44| Name| Description|
45| -------- | -------- |
46| [OH_CommonEvent_CreateSubscribeInfo](#oh_commonevent_createsubscribeinfo)| Creates the subscriber information.|
47| [OH_CommonEvent_SetPublisherPermission](#oh_commonevent_setpublisherpermission) | Sets the subscriber permission.|
48| [OH_CommonEvent_SetPublisherBundleName](#oh_commonevent_setpublisherbundlename) | Sets a bundle name of the subscriber.|
49| [OH_CommonEvent_DestroySubscribeInfo](#oh_commonevent_destroysubscribeinfo) | Destroys the subscriber information.|
50| [OH_CommonEvent_CreateSubscriber](#oh_commonevent_createsubscriber)| Creates a subscriber.|
51| [OH_CommonEvent_DestroySubscriber](#oh_commonevent_destroysubscriber) | Destroys a subscriber.|
52| [OH_CommonEvent_Subscribe](#oh_commonevent_subscribe) | Subscribes to a common event.|
53| [OH_CommonEvent_UnSubscribe](#oh_commonevent_unsubscribe) | Unsubscribes from a common event.|
54| [OH_CommonEvent_GetEventFromRcvData](#oh_commonevent_geteventfromrcvdata)| Obtains the name of a common event.|
55| [OH_CommonEvent_GetCodeFromRcvData](#oh_commonevent_getcodefromrcvdata) | Obtains the result code of a common event.|
56| [OH_CommonEvent_GetDataStrFromRcvData](#oh_commonevent_getdatastrfromrcvdata)| Obtains the custom result data of a common event.|
57| [OH_CommonEvent_GetBundleNameFromRcvData](#oh_commonevent_getbundlenamefromrcvdata)| Obtains the bundle name of a common event.|
58| [OH_CommonEvent_GetParametersFromRcvData](#oh_commonevent_getparametersfromrcvdata) | Obtains the additional information about a common event.|
59| [OH_CommonEvent_HasKeyInParameters](#oh_commonevent_haskeyinparameters) | Checks whether the additional information of a common event contains a key-value pair.|
60| [OH_CommonEvent_GetIntFromParameters](#oh_commonevent_getintfromparameters) | Obtains the int data from the additional information of a common event.|
61| [OH_CommonEvent_GetIntArrayFromParameters](#oh_commonevent_getintarrayfromparameters)| Obtains the int array from the additional information of a common event.|
62| [OH_CommonEvent_GetLongFromParameters](#oh_commonevent_getlongfromparameters)| Obtains the long data from the additional information of a common event.|
63| [OH_CommonEvent_GetLongArrayFromParameters](#oh_commonevent_getlongarrayfromparameters)| Obtains the long array from the additional information of a common event.|
64| [OH_CommonEvent_GetBoolFromParameters](#oh_commonevent_getboolfromparameters)| Obtains the Boolean data from the additional information of a common event.|
65| [OH_CommonEvent_GetBoolArrayFromParameters](#oh_commonevent_getboolarrayfromparameters)| Obtains the Boolean array from the additional information of a common event.|
66| [OH_CommonEvent_GetCharFromParameters](#oh_commonevent_getcharfromparameters)| Obtains the character data from the additional information of a common event.|
67| [OH_CommonEvent_GetCharArrayFromParameters](#oh_commonevent_getchararrayfromparameters)| Obtains the character array from the additional information of a common event.|
68| [OH_CommonEvent_GetDoubleFromParameters](#oh_commonevent_getdoublefromparameters)| Obtains the double data from the additional information of a common event.|
69| [OH_CommonEvent_GetDoubleArrayFromParameters](#oh_commonevent_getdoublearrayfromparameters)| Obtains the double array from the additional information of a common event.|
70| [OH_CommonEvent_CreateParameters](#oh_commonevent_createparameters)| Creates an additional information object of a common event.|
71| [OH_CommonEvent_DestroyParameters](#oh_commonevent_destroyparameters)| Destroys an additional information object of a common event.|
72| [OH_CommonEvent_SetIntToParameters](#oh_commonevent_setinttoparameters)| Sets the additional information of a common event. The value is the content of the int type.|
73| [OH_CommonEvent_SetIntArrayToParameters](#oh_commonevent_setintarraytoparameters)| Sets the additional information of a common event. The value is the content of the int array type.|
74| [OH_CommonEvent_SetLongToParameters](#oh_commonevent_setlongtoparameters)| Sets the additional information of a common event. The value is the content of the long type.|
75| [OH_CommonEvent_SetLongArrayToParameters](#oh_commonevent_setlongarraytoparameters)| Sets the additional information of a common event. The value is the content of the long array type.|
76| [OH_CommonEvent_SetDoubleToParameters](#oh_commonevent_setdoubletoparameters)| Sets the additional information of a common event. The value is the content of the double type.|
77| [OH_CommonEvent_SetDoubleArrayToParameters](#oh_commonevent_setdoublearraytoparameters)| Sets the additional information of a common event. The value is the content of the double array type.|
78| [OH_CommonEvent_SetBoolToParameters](#oh_commonevent_setbooltoparameters)| Sets the additional information of a common event. The value is the content of the Boolean type.|
79| [OH_CommonEvent_SetBoolArrayToParameters](#oh_commonevent_setboolarraytoparameters)| Sets the additional information of a common event. The value is the content of the Boolean array type.|
80| [OH_CommonEvent_SetCharToParameters](#oh_commonevent_setchartoparameters)| Sets the additional information of a common event. The value is the content of the character type.|
81| [OH_CommonEvent_SetCharArrayToParameters](#oh_commonevent_setchararraytoparameters)| Sets the additional information of a common event. The value is the content of the character array type.|
82| [OH_CommonEvent_CreatePublishInfo](#oh_commonevent_createpublishinfo)| Creates an attribute object of a common event.|
83| [OH_CommonEvent_DestroyPublishInfo](#oh_commonevent_destroypublishinfo)| Destroys an attribute object of a common event.|
84| [OH_CommonEvent_SetPublishInfoBundleName](#oh_commonevent_setpublishinfobundlename)| Sets the bundle name of a common event.|
85| [OH_CommonEvent_SetPublishInfoPermissions](#oh_commonevent_setpublishinfopermissions)| Sets the common event permissions.|
86| [OH_CommonEvent_SetPublishInfoCode](#oh_commonevent_setpublishinfocode)| Sets the result code of a common event.|
87| [OH_CommonEvent_SetPublishInfoData](#oh_commonevent_setpublishinfodata)| Sets the result data of a common event.|
88| [OH_CommonEvent_SetPublishInfoParameters](#oh_commonevent_setpublishinfoparameters)| Sets the additional information of a common event.|
89| [OH_CommonEvent_Publish](#oh_commonevent_publish)| Publishes a custom common event.|
90| [OH_CommonEvent_PublishWithInfo](#oh_commonevent_publishwithinfo)| Publishes a custom common event with specified attributes.|
91| [OH_CommonEvent_IsOrderedCommonEvent](#oh_commonevent_isorderedcommonevent)| Checks whether a common event is an ordered common event.|
92| [OH_CommonEvent_FinishCommonEvent](#oh_commonevent_finishcommonevent)| Finishes an ordered common event.|
93| [OH_CommonEvent_GetAbortCommonEvent](#oh_commonevent_getabortcommonevent)| Checks whether an ordered common event is aborted.|
94| [OH_CommonEvent_AbortCommonEvent](#oh_commonevent_abortcommonevent)| Aborts an ordered common event.|
95| [OH_CommonEvent_ClearAbortCommonEvent](#oh_commonevent_clearabortcommonevent)| Clears the aborted state of an ordered common event.|
96| [OH_CommonEvent_GetCodeFromSubscriber](#oh_commonevent_getcodefromsubscriber)| Obtains the result code of an ordered common event.|
97| [OH_CommonEvent_GetDataFromSubscriber](#oh_commonevent_getdatafromsubscriber)| Obtains the result data of an ordered common event.|
98| [OH_CommonEvent_SetCodeToSubscriber](#oh_commonevent_setcodetosubscriber)| Sets the result code of an ordered common event.|
99| [OH_CommonEvent_SetDataToSubscriber](#oh_commonevent_setdatatosubscriber)| Sets the result data of an ordered common event.|
100
101### Constants
102| Name| Description|
103| -------- | -------- |
104|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.|
105|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.|
106|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.|
107|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.|
108|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.|
109|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.|
110|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.|
111|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.|
112|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.|
113|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.|
114|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.|
115|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.|
116|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.|
117|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.|
118|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.|
119|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.|
120|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).|
121|static const char* const [COMMON_EVENT_PACKAGE_RESTARTED](common_event/commonEventManager-definitions.md#common_event_package_restarted) = "usual.event.PACKAGE_RESTARTED"| Indicates the common event that a user restarts an application package and kills all its processes.|
122|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.|
123|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.|
124|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.|
125|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.|
126|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.|
127|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.|
128|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.|
129|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.|
130|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.|
131|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.|
132|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.|
133|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.|
134|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.|
135|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.|
136|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.|
137|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.|
138|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.|
139|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.|
140|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.|
141|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.|
142|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.|
143|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.|
144|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.|
145|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.|
146|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.|
147|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.|
148|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.|
149|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.|
150|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.|
151|static const char* const [COMMON_EVENT_CHARGING](common_event/commonEventManager-definitions.md#common_event_charging) = "usual.event.CHARGING"|Indicates the common event that the system starts charging the battery.|
152|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.|
153|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.|
154|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.|
155|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.|
156|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.|
157|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.|
158|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.|
159|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.|
160|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.|
161|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.|
162|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.|
163|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.|
164|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.|
165|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.|
166|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.|
167|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.|
168|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.|
169|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.|
170|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.|
171|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.|
172|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.|
173|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.|
174## Type Description
175
176### CommonEvent_SubscribeInfo
177
178```c
179typedef struct CommonEvent_SubscribeInfo CommonEvent_SubscribeInfo
180```
181
182**Description**
183
184Defines a struct for the subscriber information.
185
186**Since**: 12
187
188### CommonEvent_Subscriber
189
190```c
191typedef void CommonEvent_Subscriber
192```
193
194**Description**
195
196Defines a subscriber.
197
198**Since**: 12
199
200### CommonEvent_RcvData
201
202```c
203typedef struct CommonEvent_RcvData CommonEvent_RcvData
204```
205
206**Description**
207
208Defines a struct for the callback data of a common event.
209
210**Since**: 12
211
212### CommonEvent_Parameters
213
214```c
215typedef void CommonEvent_Parameters
216```
217
218**Description**
219
220Defines the additional information about a common event.
221
222**Since**: 12
223
224### CommonEvent_ReceiveCallback
225
226```c
227typedef void (*CommonEvent_ReceiveCallback)(const CommonEvent_RcvData *data)
228```
229
230**Description**
231
232Defines a callback to be invoked when a common event is triggered.
233
234**Since**: 12
235
236### CommonEvent_PublishInfo
237
238```c
239typedef struct CommonEvent_PublishInfo CommonEvent_PublishInfo
240```
241
242**Description**
243
244Defines a struct for an attribute object used for publishing a custom common event.
245
246**Since**: 18
247
248## Enum Description
249
250### CommonEvent_ErrCode
251**Description**
252
253Enumerates the error codes.
254
255**Since**: 12
256
257| Value| Description|
258| -------- | -------- |
259| COMMONEVENT_ERR_OK = 0 |The operation is successful.|
260| COMMONEVENT_ERR_PERMISSION_ERROR = 201 |Permission denied.|
261| COMMONEVENT_ERR_INVALID_PARAMETER = 401 |Invalid parameter.|
262| COMMONEVENT_ERR_SENDING_REQUEST_FAILED = 1500007 |Failed to send an IPC request.|
263| COMMONEVENT_ERR_INIT_UNDONE = 1500008|The service is not initialized.|
264| COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED = 1500010|The number of subscribers exceeds 200.|
265| COMMONEVENT_ERR_ALLOC_MEMORY_FAILED = 1500011|The system failed to allocate memory.|
266
267## Constant Description
268
269### COMMON_EVENT_SHUTDOWN
270
271```c
272static const char* const COMMON_EVENT_SHUTDOWN = "usual.event.SHUTDOWN"
273```
274
275**Description**
276
277Indicates the common event that the device is being shut down and the final shutdown will proceed.
278
279**Since**: 12
280
281### COMMON_EVENT_BATTERY_CHANGED
282
283```c
284static const char* const COMMON_EVENT_BATTERY_CHANGED = "usual.event.BATTERY_CHANGED"
285```
286
287**Description**
288
289Indicates the common event that the charging state, level, and other information about the battery have changed.
290
291**Since**: 12
292
293### COMMON_EVENT_BATTERY_LOW
294
295```c
296static const char* const COMMON_EVENT_BATTERY_LOW = "usual.event.BATTERY_LOW"
297```
298
299**Description**
300
301Indicates the common event that the battery level is low.
302
303**Since**: 12
304
305### COMMON_EVENT_BATTERY_OKAY
306
307```c
308static const char* const COMMON_EVENT_BATTERY_OKAY = "usual.event.BATTERY_OKAY"
309```
310
311**Description**
312
313Indicates the common event that the battery exits the low state.
314
315**Since**: 12
316
317### COMMON_EVENT_POWER_CONNECTED
318
319```c
320static const char* const COMMON_EVENT_POWER_CONNECTED = "usual.event.POWER_CONNECTED"
321```
322
323**Description**
324
325Indicates the common event that the device is connected to an external power supply.
326
327**Since**: 12
328
329### COMMON_EVENT_POWER_DISCONNECTED
330
331```c
332static const char* const COMMON_EVENT_POWER_DISCONNECTED = "usual.event.POWER_DISCONNECTED"
333```
334
335**Description**
336
337Indicates the common event that the device is disconnected from the external power supply.
338
339**Since**: 12
340
341### COMMON_EVENT_SCREEN_OFF
342
343```c
344static const char* const COMMON_EVENT_SCREEN_OFF = "usual.event.SCREEN_OFF"
345```
346
347**Description**
348
349Indicates the common event that the device screen is off and the device is sleeping.
350
351**Since**: 12
352
353### COMMON_EVENT_SCREEN_ON
354
355```c
356static const char* const COMMON_EVENT_SCREEN_ON = "usual.event.SCREEN_ON"
357```
358
359**Description**
360
361Indicates the common event that the device screen is on and the device is in interactive state.
362
363**Since**: 12
364
365### COMMON_EVENT_THERMAL_LEVEL_CHANGED
366
367```c
368static const char* const COMMON_EVENT_THERMAL_LEVEL_CHANGED = "usual.event.THERMAL_LEVEL_CHANGED"
369```
370
371**Description**
372
373Indicates the common event that the device's thermal level has changed.
374
375**Since**: 12
376
377### COMMON_EVENT_TIME_TICK
378
379```c
380static const char* const COMMON_EVENT_TIME_TICK = "usual.event.TIME_TICK"
381```
382
383**Description**
384
385Indicates the common event that the system time has changed.
386
387**Since**: 12
388
389### COMMON_EVENT_TIME_CHANGED
390
391```c
392static const char* const COMMON_EVENT_TIME_CHANGED = "usual.event.TIME_CHANGED"
393```
394
395**Description**
396
397Indicates the common event that the system time is reset.
398
399**Since**: 12
400
401### COMMON_EVENT_TIMEZONE_CHANGED
402
403```c
404static const char* const COMMON_EVENT_TIMEZONE_CHANGED = "usual.event.TIMEZONE_CHANGED"
405```
406
407**Description**
408
409Indicates the common event that the system time zone has changed.
410
411**Since**: 12
412
413### COMMON_EVENT_PACKAGE_ADDED
414
415```c
416static const char* const COMMON_EVENT_PACKAGE_ADDED = "usual.event.PACKAGE_ADDED"
417```
418
419**Description**
420
421Indicates the common event that a new application package has been installed on the device.
422
423**Since**: 12
424
425### COMMON_EVENT_PACKAGE_REMOVED
426
427```c
428static const char* const COMMON_EVENT_PACKAGE_REMOVED = "usual.event.PACKAGE_REMOVED"
429```
430
431**Description**
432
433Indicates the common event that an installed application has been uninstalled from the device with the application data retained.
434
435**Since**: 12
436
437### COMMON_EVENT_BUNDLE_REMOVED
438
439```c
440static const char* const COMMON_EVENT_BUNDLE_REMOVED = "usual.event.BUNDLE_REMOVED"
441```
442
443**Description**
444
445Indicates the common event that an installed bundle has been uninstalled from the device with the application data retained.
446
447**Since**: 12
448
449### COMMON_EVENT_PACKAGE_FULLY_REMOVED
450
451```c
452static const char* const COMMON_EVENT_PACKAGE_FULLY_REMOVED = "usual.event.PACKAGE_FULLY_REMOVED"
453```
454
455**Description**
456
457Indicates the common event that an installed application, including both the application data and code, has been completely uninstalled from the device.
458
459**Since**: 12
460
461### COMMON_EVENT_PACKAGE_CHANGED
462
463```c
464static const char* const COMMON_EVENT_PACKAGE_CHANGED = "usual.event.PACKAGE_CHANGED"
465```
466
467**Description**
468
469Indicates the common event that an application package has been changed (for example, a component in the package has been enabled or disabled).
470
471**Since**: 12
472
473### COMMON_EVENT_PACKAGE_RESTARTED
474
475```c
476static const char* const COMMON_EVENT_PACKAGE_RESTARTED = "usual.event.PACKAGE_RESTARTED"
477```
478
479**Description**
480
481Indicates the common event that a user restarts an application package and kills all its processes.
482
483**Since**: 12
484
485### COMMON_EVENT_PACKAGE_DATA_CLEARED
486
487```c
488static const char* const COMMON_EVENT_PACKAGE_DATA_CLEARED = "usual.event.PACKAGE_DATA_CLEARED"
489```
490
491**Description**
492
493Indicates the common event that the user has cleared the application package data.
494
495**Since**: 12
496
497### COMMON_EVENT_PACKAGE_CACHE_CLEARED
498
499```c
500static const char* const COMMON_EVENT_PACKAGE_CACHE_CLEARED = "usual.event.PACKAGE_CACHE_CLEARED"
501```
502
503**Description**
504
505Indicates the common event that the user has cleared the application package data cache.
506
507**Since**: 12
508
509### COMMON_EVENT_PACKAGES_SUSPENDED
510
511```c
512static const char* const COMMON_EVENT_PACKAGES_SUSPENDED = "usual.event.PACKAGES_SUSPENDED"
513```
514
515**Description**
516
517Indicates the common event that application packages have been suspended.
518
519**Since**: 12
520
521### COMMON_EVENT_MY_PACKAGE_SUSPENDED
522
523```c
524static const char* const COMMON_EVENT_MY_PACKAGE_SUSPENDED = "usual.event.MY_PACKAGE_SUSPENDED"
525```
526
527**Description**
528
529Indicates the common event that can be sent to a suspended application package.
530
531**Since**: 12
532
533### COMMON_EVENT_MY_PACKAGE_UNSUSPENDED
534
535```c
536static const char* const COMMON_EVENT_MY_PACKAGE_UNSUSPENDED = "usual.event.MY_PACKAGE_UNSUSPENDED"
537```
538
539**Description**
540
541Indicates the common event that application packages have not been suspended.
542
543**Since**: 12
544
545### COMMON_EVENT_LOCALE_CHANGED
546
547```c
548static const char* const COMMON_EVENT_LOCALE_CHANGED = "usual.event.LOCALE_CHANGED"
549```
550
551**Description**
552
553Indicates the common event that the device locale has changed.
554
555**Since**: 12
556
557### COMMON_EVENT_MANAGE_PACKAGE_STORAGE
558
559```c
560static const char* const COMMON_EVENT_MANAGE_PACKAGE_STORAGE = "usual.event.MANAGE_PACKAGE_STORAGE"
561```
562
563**Description**
564
565Indicates the common event that the device storage is insufficient.
566
567**Since**: 12
568
569### COMMON_EVENT_USER_UNLOCKED
570
571```c
572static const char* const COMMON_EVENT_USER_UNLOCKED = "usual.event.USER_UNLOCKED"
573```
574
575**Description**
576
577Indicates the common event that the credential-encrypted storage has become unlocked for the current user when the device is unlocked after being restarted.
578
579**Since**: 12
580
581### COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT
582
583```c
584static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT = "common.event.DISTRIBUTED_ACCOUNT_LOGOUT"
585```
586
587**Description**
588
589Indicates the common event that a distributed account is successfully logged out.
590
591**Since**: 12
592
593### COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID
594
595```c
596static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID = "common.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID"
597```
598
599**Description**
600
601Indicates the common event that the token of a distributed account is invalid.
602
603**Since**: 12
604
605### COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF
606
607```c
608static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF = "common.event.DISTRIBUTED_ACCOUNT_LOGOFF"
609```
610
611**Description**
612
613Indicates the common event that a distributed account is deregistered.
614
615**Since**: 12
616
617### COMMON_EVENT_WIFI_POWER_STATE
618
619```c
620static const char* const COMMON_EVENT_WIFI_POWER_STATE = "usual.event.wifi.POWER_STATE"
621```
622
623**Description**
624
625Indicates the common event that the Wi-Fi state has changed, for example, enabled or disabled.
626
627**Since**: 12
628
629### COMMON_EVENT_WIFI_SCAN_FINISHED
630
631```c
632static const char* const COMMON_EVENT_WIFI_SCAN_FINISHED = "usual.event.wifi.SCAN_FINISHED"
633```
634
635**Description**
636
637Indicates the common event that the Wi-Fi access point has been scanned and proven to be available.
638
639**Since**: 12
640
641### COMMON_EVENT_WIFI_RSSI_VALUE
642
643```c
644static const char* const COMMON_EVENT_WIFI_RSSI_VALUE = "usual.event.wifi.RSSI_VALUE"
645```
646
647**Description**
648
649Indicates the common event that the Wi-Fi signal strength (RSSI) has changed.
650
651**Since**: 12
652
653### COMMON_EVENT_WIFI_CONN_STATE
654
655```c
656static const char* const COMMON_EVENT_WIFI_CONN_STATE = "usual.event.wifi.CONN_STATE"
657```
658
659**Description**
660
661Indicates the common event that the Wi-Fi connection state has changed.
662
663**Since**: 12
664
665### COMMON_EVENT_WIFI_HOTSPOT_STATE
666
667```c
668static const char* const COMMON_EVENT_WIFI_HOTSPOT_STATE = "usual.event.wifi.HOTSPOT_STATE"
669```
670
671**Description**
672
673Indicates the common event of the Wi-Fi hotspot state.
674
675**Since**: 12
676
677### COMMON_EVENT_WIFI_AP_STA_JOIN
678
679```c
680static const char* const COMMON_EVENT_WIFI_AP_STA_JOIN = "usual.event.wifi.WIFI_HS_STA_JOIN"
681```
682
683**Description**
684
685Indicates the common event that a client has joined the Wi-Fi hotspot of the current device.
686
687**Since**: 12
688
689### COMMON_EVENT_WIFI_AP_STA_LEAVE
690
691```c
692static const char* const COMMON_EVENT_WIFI_AP_STA_LEAVE = "usual.event.wifi.WIFI_HS_STA_LEAVE"
693```
694
695**Description**
696
697Indicates the common event that a client has disconnected from the Wi-Fi hotspot of the current device.
698
699**Since**: 12
700
701### COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE
702
703```c
704static const char* const COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE = "usual.event.wifi.mplink.STATE_CHANGE"
705```
706
707**Description**
708
709Indicates the common event that the state of MPLINK (an enhanced Wi-Fi feature) has changed.
710
711**Since**: 12
712
713### COMMON_EVENT_WIFI_P2P_CONN_STATE
714
715```c
716static const char* const COMMON_EVENT_WIFI_P2P_CONN_STATE = "usual.event.wifi.p2p.CONN_STATE_CHANGE"
717```
718
719**Description**
720
721Indicates the common event that the Wi-Fi P2P connection state has changed.
722
723**Since**: 12
724
725### COMMON_EVENT_WIFI_P2P_STATE_CHANGED
726
727```c
728static const char* const COMMON_EVENT_WIFI_P2P_STATE_CHANGED = "usual.event.wifi.p2p.STATE_CHANGE"
729```
730
731**Description**
732
733Indicates the common event that the Wi-Fi P2P state has changed, for example, enabled or disabled.
734
735### COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED
736
737```c
738static const char* const COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED = "usual.event.wifi.p2p.DEVICES_CHANGE"
739```
740
741**Description**
742
743Indicates the common event that the state of the Wi-Fi P2P peer device has changed.
744
745**Since**: 12
746
747### COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED
748
749```c
750static const char* const COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED = "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE"
751```
752
753**Description**
754
755Indicates the common event that the Wi-Fi P2P discovery state has changed.
756
757**Since**: 12
758
759### COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED
760
761```c
762static const char* const COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED = "usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE"
763```
764
765**Description**
766
767Indicates the common event that the state of the Wi-Fi P2P local device has changed.
768
769**Since**: 12
770
771### COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED
772
773```c
774static const char* const COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED = "usual.event.wifi.p2p.GROUP_STATE_CHANGED"
775```
776
777**Description**
778
779Indicates the common event that the Wi-Fi P2P group information has changed.
780
781**Since**: 12
782
783### COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED
784
785```c
786static const char* const COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED = "usual.event.nfc.action.ADAPTER_STATE_CHANGED"
787```
788
789**Description**
790
791Indicates the common event that the state of the device NFC adapter has changed.
792
793**Since**: 12
794
795### COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED
796
797```c
798static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED = "usual.event.nfc.action.RF_FIELD_ON_DETECTED"
799```
800
801**Description**
802
803Indicates the common event that the NFC RF field is on.
804
805**Since**: 12
806
807### COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED
808
809```c
810static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED = "usual.event.nfc.action.RF_FIELD_OFF_DETECTED"
811```
812
813**Description**
814
815Indicates the common event that the NFC RF field is off.
816
817**Since**: 12
818
819### COMMON_EVENT_DISCHARGING
820
821```c
822static const char* const COMMON_EVENT_DISCHARGING = "usual.event.DISCHARGING"
823```
824
825**Description**
826
827Indicates the common event that the system stops charging the battery.
828
829**Since**: 12
830
831### COMMON_EVENT_CHARGING
832
833```c
834static const char* const COMMON_EVENT_CHARGING = "usual.event.CHARGING"
835```
836
837**Description**
838
839Indicates the common event that the system starts charging the battery.
840
841### COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED
842
843```c
844static const char* const COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED = "usual.event.DEVICE_IDLE_MODE_CHANGED"
845```
846
847**Description**
848
849Indicates the common event that the system standby mode has changed.
850
851**Since**: 12
852
853### COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED
854
855```c
856static const char* const COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED = "usual.event.CHARGE_IDLE_MODE_CHANGED"
857```
858
859**Description**
860
861Indicates the common event that the device enters the charging idle mode.
862
863**Since**: 12
864
865### COMMON_EVENT_POWER_SAVE_MODE_CHANGED
866
867```c
868static const char* const COMMON_EVENT_POWER_SAVE_MODE_CHANGED = "usual.event.POWER_SAVE_MODE_CHANGED"
869```
870
871**Description**
872
873Indicates the common event that the system power saving mode is changed.
874
875**Since**: 12
876
877### COMMON_EVENT_USB_STATE
878
879```c
880static const char* const COMMON_EVENT_USB_STATE = "usual.event.hardware.usb.action.USB_STATE"
881```
882
883**Description**
884
885Indicates the common event that the USB device state has changed.
886
887**Since**: 12
888
889### COMMON_EVENT_USB_PORT_CHANGED
890
891```c
892static const char* const COMMON_EVENT_USB_PORT_CHANGED = "usual.event.hardware.usb.action.USB_PORT_CHANGED"
893```
894
895**Description**
896
897Indicates the common event that the USB port state of the user device has changed.
898
899**Since**: 12
900
901### COMMON_EVENT_USB_DEVICE_ATTACHED
902
903```c
904static const char* const COMMON_EVENT_USB_DEVICE_ATTACHED = "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED"
905```
906
907**Description**
908
909Indicates the common event that a USB device has been attached when the user device functions as a USB host.
910
911**Since**: 12
912
913### COMMON_EVENT_USB_DEVICE_DETACHED
914
915```c
916static const char* const COMMON_EVENT_USB_DEVICE_DETACHED = "usual.event.hardware.usb.action.USB_DEVICE_DETACHED"
917```
918
919**Description**
920
921Indicates the common event that a USB device has been detached when the user device functions as a USB host.
922
923**Since**: 12
924
925### COMMON_EVENT_AIRPLANE_MODE_CHANGED
926
927```c
928static const char* const COMMON_EVENT_AIRPLANE_MODE_CHANGED = "usual.event.AIRPLANE_MODE"
929```
930
931**Description**
932
933Indicates the common event that the airplane mode of the device has changed.
934
935**Since**: 12
936
937### COMMON_EVENT_SPLIT_SCREEN
938
939```c
940static const char* const COMMON_EVENT_SPLIT_SCREEN = "common.event.SPLIT_SCREEN"
941```
942
943**Description**
944
945Indicates the common event of screen splitting.
946
947**Since**: 12
948
949### COMMON_EVENT_QUICK_FIX_APPLY_RESULT
950
951```c
952static const char* const COMMON_EVENT_QUICK_FIX_APPLY_RESULT = "usual.event.QUICK_FIX_APPLY_RESULT"
953```
954
955**Description**
956
957Indicates the common event that a quick fix is applied to an application.
958
959**Since**: 12
960
961### COMMON_EVENT_QUICK_FIX_REVOKE_RESULT
962
963```c
964static const char* const COMMON_EVENT_QUICK_FIX_REVOKE_RESULT = "usual.event.QUICK_FIX_REVOKE_RESULT"
965```
966
967**Description**
968
969Indicates the common event that a quick fix is canceled.
970
971**Since**: 12
972
973### COMMON_EVENT_USER_INFO_UPDATED
974
975```c
976static const char* const COMMON_EVENT_USER_INFO_UPDATED = "usual.event.USER_INFO_UPDATED"
977```
978
979**Description**
980
981Indicates the common event that the user information has been updated.
982
983**Since**: 12
984
985### COMMON_EVENT_SIM_STATE_CHANGED
986
987```c
988static const char* const COMMON_EVENT_SIM_STATE_CHANGED = "usual.event.SIM_STATE_CHANGED"
989```
990
991**Description**
992
993Indicates the common event that the SIM card state has been updated.
994
995**Since**: 12
996
997### COMMON_EVENT_CALL_STATE_CHANGED
998
999```c
1000static const char* const COMMON_EVENT_CALL_STATE_CHANGED = "usual.event.CALL_STATE_CHANGED"
1001```
1002
1003**Description**
1004
1005Indicates the common event that the call state has been updated.
1006
1007**Since**: 12
1008
1009### COMMON_EVENT_NETWORK_STATE_CHANGED
1010
1011```c
1012static const char* const COMMON_EVENT_NETWORK_STATE_CHANGED = "usual.event.NETWORK_STATE_CHANGED"
1013```
1014
1015**Description**
1016
1017Indicates the common event that the network state has been updated.
1018
1019**Since**: 12
1020
1021### COMMON_EVENT_SIGNAL_INFO_CHANGED
1022
1023```c
1024static const char* const COMMON_EVENT_SIGNAL_INFO_CHANGED = "usual.event.SIGNAL_INFO_CHANGED"
1025```
1026
1027**Description**
1028
1029Indicates the common event that the signal information has been updated.
1030
1031**Since**: 12
1032
1033### COMMON_EVENT_SCREEN_UNLOCKED
1034
1035```c
1036static const char* const COMMON_EVENT_SCREEN_UNLOCKED = "usual.event.SCREEN_UNLOCKED"
1037```
1038
1039**Description**
1040
1041Indicates the common event that the screen has been unlocked.
1042
1043**Since**: 12
1044
1045### COMMON_EVENT_SCREEN_LOCKED
1046
1047```c
1048static const char* const COMMON_EVENT_SCREEN_LOCKED = "usual.event.SCREEN_LOCKED"
1049```
1050
1051**Description**
1052
1053Indicates the common event that the screen has been locked.
1054
1055**Since**: 12
1056
1057### COMMON_EVENT_HTTP_PROXY_CHANGE
1058
1059```c
1060static const char* const COMMON_EVENT_HTTP_PROXY_CHANGE = "usual.event.HTTP_PROXY_CHANGE"
1061```
1062
1063**Description**
1064
1065Indicates the common event that the HTTP proxy configuration has changed.
1066
1067**Since**: 12
1068
1069### COMMON_EVENT_CONNECTIVITY_CHANGE
1070
1071```c
1072static const char* const COMMON_EVENT_CONNECTIVITY_CHANGE = "usual.event.CONNECTIVITY_CHANGE"
1073```
1074
1075**Description**
1076
1077Indicates the common event that the network connection state has changed.
1078
1079**Since**: 12
1080
1081### COMMON_EVENT_MINORSMODE_ON
1082
1083```c
1084static const char* const COMMON_EVENT_MINORSMODE_ON = "usual.event.MINORSMODE_ON"
1085```
1086
1087**Description**
1088
1089Indicates that the minor mode is enabled.
1090
1091**Since**: 12
1092
1093### COMMON_EVENT_MINORSMODE_OFF
1094
1095```c
1096static const char* const COMMON_EVENT_MINORSMODE_OFF = "usual.event.MINORSMODE_OFF"
1097```
1098
1099**Description**
1100
1101Indicates the common event that the minor mode is disabled.
1102
1103**Since**: 12
1104
1105## Function Description
1106
1107### OH_CommonEvent_CreateSubscribeInfo
1108
1109```cpp
1110CommonEvent_SubscribeInfo* OH_CommonEvent_CreateSubscribeInfo(const char* events[], int32_t eventsNum)
1111```
1112
1113**Description**
1114
1115Creates the subscriber information.
1116
1117**Since**: 12
1118
1119**Parameters**
1120
1121| Name| Description|
1122| -------- | -------- |
1123| events | Events you have subscribed to.|
1124| eventsNum | Number of events|
1125
1126**Returns**
1127
1128Returns the subscriber information.
1129
1130### OH_CommonEvent_SetPublisherPermission
1131
1132```cpp
1133CommonEvent_ErrCode OH_CommonEvent_SetPublisherPermission(CommonEvent_SubscribeInfo* info, const char* permission)
1134```
1135
1136**Description**
1137
1138Sets the subscriber permission.
1139
1140**Since**: 12
1141
1142**Parameters**
1143
1144| Name| Description|
1145| -------- | -------- |
1146| info | Subscriber information.|
1147| permission | Name of the permission.|
1148
1149**Returns**
1150
1151Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if **info** is a null pointer.
1152
1153### OH_CommonEvent_SetPublisherBundleName
1154
1155```cpp
1156CommonEvent_ErrCode OH_CommonEvent_SetPublisherBundleName(CommonEvent_SubscribeInfo* info, const char* bundleName)
1157```
1158
1159**Description**
1160
1161Sets a bundle name of the subscriber.
1162
1163**Since**: 12
1164
1165**Parameters**
1166
1167| Name| Description|
1168| -------- | -------- |
1169| info | Subscriber information.|
1170| bundleName | Bundle name.|
1171
1172**Returns**
1173
1174Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if **info** is a null pointer.
1175
1176### OH_CommonEvent_DestroySubscribeInfo
1177
1178```cpp
1179void OH_CommonEvent_DestroySubscribeInfo(CommonEvent_SubscribeInfo* info)
1180```
1181
1182**Description**
1183
1184Destroys the subscriber information.
1185
1186**Since**: 12
1187
1188**Parameters**
1189
1190| Name| Description|
1191| -------- | -------- |
1192| info | Subscriber information.|
1193
1194### OH_CommonEvent_CreateSubscriber
1195
1196```cpp
1197CommonEvent_Subscriber* OH_CommonEvent_CreateSubscriber(const CommonEvent_SubscribeInfo* info, CommonEvent_ReceiveCallback callback)
1198```
1199
1200**Description**
1201
1202Creates a subscriber.
1203
1204**Since**: 12
1205
1206**Parameters**
1207
1208| Name| Description|
1209| -------- | -------- |
1210| info | Subscriber information.|
1211| callback | Event callback.|
1212
1213**Returns**
1214
1215Returns the subscriber.
1216
1217### OH_CommonEvent_DestroySubscriber
1218
1219```cpp
1220void OH_CommonEvent_DestroySubscriber(CommonEvent_Subscriber* subscriber)
1221```
1222
1223**Description**
1224
1225Destroys a subscriber.
1226
1227**Since**: 12
1228
1229**Parameters**
1230
1231| Name| Description|
1232| -------- | -------- |
1233| subscriber | Subscriber.|
1234
1235### OH_CommonEvent_Subscribe
1236
1237```cpp
1238CommonEvent_ErrCode OH_CommonEvent_Subscribe(const CommonEvent_Subscriber* subscriber)
1239```
1240
1241**Description**
1242
1243Subscribes to a common event.
1244
1245**Since**: 12
1246
1247**Parameters**
1248
1249| Name| Description|
1250| -------- | -------- |
1251| subscriber | Subscriber.|
1252
1253**Returns**
1254
1255Returns **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.
1256
1257### OH_CommonEvent_UnSubscribe
1258
1259```cpp
1260CommonEvent_ErrCode OH_CommonEvent_UnSubscribe(const CommonEvent_Subscriber* subscriber)
1261```
1262
1263**Description**
1264
1265Unsubscribes from a common event.
1266
1267**Since**: 12
1268
1269**Parameters**
1270
1271| Name| Description|
1272| -------- | -------- |
1273| subscriber | Subscriber.|
1274
1275**Returns**
1276
1277Returns **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.
1278
1279### OH_CommonEvent_GetEventFromRcvData
1280
1281```cpp
1282const char* OH_CommonEvent_GetEventFromRcvData(const CommonEvent_RcvData* rcvData)
1283```
1284
1285**Description**
1286
1287Obtains the name of a callback common event.
1288
1289**Since**: 12
1290
1291**Parameters**
1292
1293| Name| Description|
1294| -------- | -------- |
1295| rcvData | Callback data of a common event.|
1296
1297**Returns**
1298
1299Returns the name of a common event.
1300
1301### OH_CommonEvent_GetCodeFromRcvData
1302
1303```cpp
1304int32_t OH_CommonEvent_GetCodeFromRcvData(const CommonEvent_RcvData* rcvData)
1305```
1306
1307**Description**
1308
1309Obtains the result code of the callback common event.
1310
1311**Since**: 12
1312
1313**Parameters**
1314
1315| Name| Description|
1316| -------- | -------- |
1317| rcvData | Callback data of a common event.|
1318
1319**Returns**
1320
1321Returns the result code of a common event. The default value is **0**.
1322
1323### OH_CommonEvent_GetDataStrFromRcvData
1324
1325```cpp
1326const char* OH_CommonEvent_GetDataStrFromRcvData(const CommonEvent_RcvData* rcvData)
1327```
1328
1329**Description**
1330
1331Obtains the custom result data of a common event.
1332
1333**Since**: 12
1334
1335**Parameters**
1336
1337| Name| Description|
1338| -------- | -------- |
1339| rcvData | Callback data of a common event.|
1340
1341**Returns**
1342
1343Returns the custom result data of a common event. The default value is **null**.
1344
1345### OH_CommonEvent_GetBundleNameFromRcvData
1346
1347```cpp
1348const char* OH_CommonEvent_GetBundleNameFromRcvData(const CommonEvent_RcvData* rcvData)
1349```
1350
1351**Description**
1352
1353Obtains the bundle name of a callback common event.
1354
1355**Since**: 12
1356
1357**Parameters**
1358
1359| Name| Description|
1360| -------- | -------- |
1361| rcvData | Callback data of a common event.|
1362
1363**Returns**
1364
1365Returns the bundle name of a common event. The default value is **null**.
1366
1367### OH_CommonEvent_GetParametersFromRcvData
1368
1369```cpp
1370const CommonEvent_Parameters* OH_CommonEvent_GetParametersFromRcvData(const CommonEvent_RcvData* rcvData)
1371```
1372
1373**Description**
1374
1375Obtains the additional information about a callback common event.
1376
1377**Since**: 12
1378
1379**Parameters**
1380
1381| Name| Description|
1382| -------- | -------- |
1383| rcvData | Callback data of a common event.|
1384
1385**Returns**
1386
1387Returns the additional information of a common event. The default value is **null**.
1388
1389### OH_CommonEvent_HasKeyInParameters
1390
1391```cpp
1392bool OH_CommonEvent_HasKeyInParameters(const CommonEvent_Parameters* para, const char* key)
1393```
1394
1395**Description**
1396
1397Checks whether the additional information of a common event contains a key-value pair.
1398
1399**Since**: 12
1400
1401**Parameters**
1402
1403| Name| Description|
1404| -------- | -------- |
1405| para | Additional information about a common event.|
1406| key | Key.|
1407
1408**Returns**
1409
1410Returns **true** if the key-value pair exists; returns **false** otherwise.
1411
1412### OH_CommonEvent_GetIntFromParameters
1413
1414```cpp
1415int OH_CommonEvent_GetIntFromParameters(const CommonEvent_Parameters* para, const char* key, const int defaultValue)
1416```
1417
1418**Description**
1419
1420Obtains the int data with a specific key from the additional information of a common event.
1421
1422**Since**: 12
1423
1424**Parameters**
1425
1426| Name| Description|
1427| -------- | -------- |
1428| para | Additional information about a common event.|
1429| key | Key.|
1430| defaultValue | Default value to be returned.|
1431
1432### OH_CommonEvent_GetIntArrayFromParameters
1433
1434```cpp
1435int32_t OH_CommonEvent_GetIntArrayFromParameters(const CommonEvent_Parameters* para, const char* key, int** array)
1436```
1437
1438**Description**
1439
1440Obtains the int array with a specific key from the additional information of a common event.
1441
1442**Since**: 12
1443
1444**Parameters**
1445
1446| Name| Description|
1447| -------- | -------- |
1448| para | Additional information about a common event.|
1449| key | Key.|
1450| array | The **int** array to receive data.|
1451
1452**Returns**
1453
1454Returns the length of an array.
1455
1456### OH_CommonEvent_GetLongFromParameters
1457
1458```cpp
1459long OH_CommonEvent_GetLongFromParameters(const CommonEvent_Parameters* para, const char* key, const long defaultValue)
1460```
1461
1462**Description**
1463
1464Obtains the long data with a specific key from the additional information of a common event.
1465
1466**Since**: 12
1467
1468**Parameters**
1469
1470| Name| Description|
1471| -------- | -------- |
1472| para | Additional information about a common event.|
1473| key | Key.|
1474| defaultValue | Default value to be returned.|
1475
1476### OH_CommonEvent_GetLongArrayFromParameters
1477
1478```cpp
1479int32_t OH_CommonEvent_GetLongArrayFromParameters(const CommonEvent_Parameters* para, const char* key, long** array)
1480```
1481
1482**Description**
1483
1484Obtains the long array with a specific key from the additional information of a common event.
1485
1486**Since**: 12
1487
1488**Parameters**
1489
1490| Name| Description|
1491| -------- | -------- |
1492| para | Additional information about a common event.|
1493| key | Key.|
1494| array | The **long** array to receive data.|
1495
1496**Returns**
1497
1498Returns the length of an array.
1499
1500### OH_CommonEvent_GetBoolFromParameters
1501
1502```cpp
1503bool OH_CommonEvent_GetBoolFromParameters(const CommonEvent_Parameters* para, const char* key, const bool defaultValue)
1504```
1505
1506**Description**
1507
1508Obtains the Boolean data with a specific key from the additional information of a common event.
1509
1510**Since**: 12
1511
1512**Parameters**
1513
1514| Name| Description|
1515| -------- | -------- |
1516| para | Additional information about a common event.|
1517| key | Key.|
1518| defaultValue | Default value to be returned.|
1519
1520### OH_CommonEvent_GetBoolArrayFromParameters
1521
1522```cpp
1523int32_t OH_CommonEvent_GetBoolArrayFromParameters(const CommonEvent_Parameters* para, const char* key, bool** array)
1524```
1525
1526**Description**
1527
1528Obtains the Boolean array with a specific key from the additional information of a common event.
1529
1530**Since**: 12
1531
1532**Parameters**
1533
1534| Name| Description|
1535| -------- | -------- |
1536| para | Additional information about a common event.|
1537| key | Key.|
1538| array | The Boolean array to receive data.|
1539
1540**Returns**
1541
1542Returns the length of an array.
1543
1544### OH_CommonEvent_GetCharFromParameters
1545
1546```cpp
1547char OH_CommonEvent_GetCharFromParameters(const CommonEvent_Parameters* para, const char* key, const char defaultValue)
1548```
1549
1550**Description**
1551
1552Obtains the character data with a specific key from the additional information of a common event.
1553
1554**Since**: 12
1555
1556**Parameters**
1557
1558| Name| Description|
1559| -------- | -------- |
1560| para | Additional information about a common event.|
1561| key | Key.|
1562| defaultValue | Default value to be returned.|
1563
1564### OH_CommonEvent_GetCharArrayFromParameters
1565
1566```cpp
1567int32_t OH_CommonEvent_GetCharArrayFromParameters(const CommonEvent_Parameters* para, const char* key, char** array)
1568```
1569
1570**Description**
1571
1572Obtains the character array with a specific key from the additional information of a common event.
1573
1574**Since**: 12
1575
1576**Parameters**
1577
1578| Name| Description|
1579| -------- | -------- |
1580| para | Additional information about a common event.|
1581| key | Key.|
1582| array | The character array to receive data.|
1583
1584**Returns**
1585
1586Returns the length of an array.
1587
1588### OH_CommonEvent_GetDoubleFromParameters
1589
1590```cpp
1591double OH_CommonEvent_GetDoubleFromParameters(const CommonEvent_Parameters* para, const char* key, const double defaultValue)
1592```
1593
1594**Description**
1595
1596Obtains the double data with a specific key from the additional information of a common event.
1597
1598**Since**: 12
1599
1600**Parameters**
1601
1602| Name| Description|
1603| -------- | -------- |
1604| para | Additional information about a common event.|
1605| key | Key.|
1606| defaultValue | Default value to be returned.|
1607
1608### OH_CommonEvent_GetDoubleArrayFromParameters
1609
1610```cpp
1611int32_t OH_CommonEvent_GetDoubleArrayFromParameters(const CommonEvent_Parameters* para, const char* key, double** array)
1612```
1613
1614**Description**
1615
1616Obtains the double array with a specific key from the additional information of a common event.
1617
1618**Since**: 12
1619
1620**Parameters**
1621
1622| Name| Description|
1623| -------- | -------- |
1624| para | Additional information about a common event.|
1625| key | Key.|
1626| array | The double array to receive data.|
1627
1628**Returns**
1629
1630Returns the length of an array. The default value is **0**.
1631
1632### OH_CommonEvent_CreateParameters
1633
1634```cpp
1635CommonEvent_Parameters* OH_CommonEvent_CreateParameters()
1636```
1637
1638**Description**
1639
1640Creates an additional information object of a common event.
1641
1642**Since**: 18
1643
1644**Parameters**
1645
1646None.
1647
1648**Returns**
1649
1650Returns additional information of the common event if operation is successful; returns **null** otherwise.
1651
1652### OH_CommonEvent_DestroyParameters
1653
1654```cpp
1655void OH_CommonEvent_DestroyParameters(CommonEvent_Parameters* param)
1656```
1657
1658**Description**
1659
1660Destroys an additional information object of a common event.
1661
1662**Since**: 18
1663
1664**Parameters**
1665
1666| Name| Description|
1667| -------- | -------- |
1668| param | Additional information about a common event.|
1669
1670**Returns**
1671
1672None.
1673
1674### OH_CommonEvent_SetIntToParameters
1675
1676```cpp
1677CommonEvent_ErrCode OH_CommonEvent_SetIntToParameters(CommonEvent_Parameters* param, const char* key, int value)
1678```
1679
1680**Description**
1681
1682Sets the additional information of a common event. The value is the content of the int type.
1683
1684**Since**: 18
1685
1686**Parameters**
1687
1688| Name| Description|
1689| -------- | -------- |
1690| param | Additional information about a common event.|
1691| key | Key.|
1692| value | Content of the int type.|
1693
1694**Returns**
1695
1696Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
1697
1698### OH_CommonEvent_SetIntArrayToParameters
1699
1700```cpp
1701CommonEvent_ErrCode OH_CommonEvent_SetIntArrayToParameters(CommonEvent_Parameters* param, const char* key, const int* value, size_t num)
1702```
1703
1704**Description**
1705
1706Sets the additional information of a common event. The value is the content of the int array type.
1707
1708**Since**: 18
1709
1710**Parameters**
1711
1712| Name| Description|
1713| -------- | -------- |
1714| param | Additional information about a common event.|
1715| key | Key.|
1716| value | Content of the int array type.|
1717| num | Number of elements in the content.|
1718
1719**Returns**
1720
1721Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.<br>Returns **COMMONEVENT_ERR_ALLOC_MEMORY_FAILED** if memory allocation fails.
1722
1723### OH_CommonEvent_SetLongToParameters
1724
1725```cpp
1726CommonEvent_ErrCode OH_CommonEvent_SetLongToParameters(CommonEvent_Parameters* param, const char* key, long value)
1727```
1728
1729**Description**
1730
1731Sets the additional information of a common event. The value is the content of the long type.
1732
1733**Since**: 18
1734
1735**Parameters**
1736
1737| Name| Description|
1738| -------- | -------- |
1739| param | Additional information about a common event.|
1740| key | Key.|
1741| value | Content of the long type.|
1742
1743**Returns**
1744
1745Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
1746
1747### OH_CommonEvent_SetLongArrayToParameters
1748
1749```cpp
1750CommonEvent_ErrCode OH_CommonEvent_SetLongArrayToParameters(CommonEvent_Parameters* param, const char* key, const long* value, size_t num)
1751```
1752
1753**Description**
1754
1755Sets the additional information of a common event. The value is the content of the long array type.
1756
1757**Since**: 18
1758
1759**Parameters**
1760
1761| Name| Description|
1762| -------- | -------- |
1763| param | Additional information about a common event.|
1764| key | Key.|
1765| value | Content of the long array type.|
1766| num | Number of elements in the content.|
1767
1768**Returns**
1769
1770Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.<br>Returns **COMMONEVENT_ERR_ALLOC_MEMORY_FAILED** if memory allocation fails.
1771
1772### OH_CommonEvent_SetDoubleToParameters
1773
1774```cpp
1775CommonEvent_ErrCode OH_CommonEvent_SetDoubleToParameters(CommonEvent_Parameters* param, const char* key, double value)
1776```
1777
1778**Description**
1779
1780Sets the additional information of a common event. The value is the content of the double type.
1781
1782**Since**: 18
1783
1784**Parameters**
1785
1786| Name| Description|
1787| -------- | -------- |
1788| param | Additional information about a common event.|
1789| key | Key.|
1790| value | Content of the double type.|
1791
1792**Returns**
1793
1794Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
1795
1796### OH_CommonEvent_SetDoubleArrayToParameters
1797
1798```cpp
1799CommonEvent_ErrCode OH_CommonEvent_SetDoubleArrayToParameters(CommonEvent_Parameters* param, const char* key, const double* value, size_t num)
1800```
1801
1802**Description**
1803
1804Sets the additional information of a common event. The value is the content of the double array type.
1805
1806**Since**: 18
1807
1808**Parameters**
1809
1810| Name| Description|
1811| -------- | -------- |
1812| param | Additional information about a common event.|
1813| key | Key.|
1814| value | Content of the double array type.|
1815| num | Number of elements in the content.|
1816
1817**Returns**
1818
1819Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.<br>Returns **COMMONEVENT_ERR_ALLOC_MEMORY_FAILED** if memory allocation fails.
1820
1821### OH_CommonEvent_SetBoolToParameters
1822
1823```cpp
1824CommonEvent_ErrCode OH_CommonEvent_SetBoolToParameters(CommonEvent_Parameters* param, const char* key, bool value)
1825```
1826
1827**Description**
1828
1829Sets the additional information of a common event. The value is the content of the Boolean type.
1830
1831**Since**: 18
1832
1833**Parameters**
1834
1835| Name| Description|
1836| -------- | -------- |
1837| param | Additional information about a common event.|
1838| key | Key.|
1839| value | Content of the Boolean type.|
1840
1841**Returns**
1842
1843Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
1844
1845### OH_CommonEvent_SetBoolArrayToParameters
1846
1847```cpp
1848CommonEvent_ErrCode OH_CommonEvent_SetBoolArrayToParameters(CommonEvent_Parameters* param, const char* key, const bool* value, size_t num)
1849```
1850
1851**Description**
1852
1853Sets the additional information of a common event. The value is the content of the Boolean array type.
1854
1855**Since**: 18
1856
1857**Parameters**
1858
1859| Name| Description|
1860| -------- | -------- |
1861| param | Additional information about a common event.|
1862| key | Key.|
1863| value | Content of the Boolean array type.|
1864| num | Number of elements in the content.|
1865
1866**Returns**
1867
1868Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.<br>Returns **COMMONEVENT_ERR_ALLOC_MEMORY_FAILED** if memory allocation fails.
1869
1870### OH_CommonEvent_SetCharToParameters
1871
1872```cpp
1873CommonEvent_ErrCode OH_CommonEvent_SetCharToParameters(CommonEvent_Parameters* param, const char* key, char value)
1874```
1875
1876**Description**
1877
1878Sets the additional information of a common event. The value is the content of the character type.
1879
1880**Since**: 18
1881
1882**Parameters**
1883
1884| Name| Description|
1885| -------- | -------- |
1886| param | Additional information about a common event.|
1887| key | Key.|
1888| value | Content of the character type.|
1889
1890**Returns**
1891
1892Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
1893
1894### OH_CommonEvent_SetCharArrayToParameters
1895
1896```cpp
1897CommonEvent_ErrCode OH_CommonEvent_SetCharArrayToParameters(CommonEvent_Parameters* param, const char* key, const char* value, size_t num)
1898```
1899
1900**Description**
1901
1902Sets the additional information of a common event. The value is the content of the character array type.
1903
1904**Since**: 18
1905
1906**Parameters**
1907
1908| Name| Description|
1909| -------- | -------- |
1910| param | Additional information about a common event.|
1911| key | Key.|
1912| value | Content of the character array type.|
1913| num | Number of elements in the content.|
1914
1915**Returns**
1916
1917Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.<br>Returns **COMMONEVENT_ERR_ALLOC_MEMORY_FAILED** if memory allocation fails.
1918
1919### OH_CommonEvent_CreatePublishInfo
1920
1921```cpp
1922CommonEvent_PublishInfo* OH_CommonEvent_CreatePublishInfo(bool ordered)
1923```
1924
1925**Description**
1926
1927Creates an attribute object of a common event.
1928
1929**Since**: 18
1930
1931**Parameters**
1932
1933| Name| Description|
1934| -------- | -------- |
1935| ordered | Whether the event is an ordered common event.<br>**true**: ordered common event.<br> **false**: unordered common event.|
1936
1937**Returns**
1938
1939Returns the attribute object if the operation is successful; returns **null** otherwise.
1940
1941### OH_CommonEvent_DestroyPublishInfo
1942
1943```cpp
1944void OH_CommonEvent_DestroyPublishInfo(CommonEvent_PublishInfo* info)
1945```
1946
1947**Description**
1948
1949Destroys an attribute object of a common event.
1950
1951**Since**: 18
1952
1953**Parameters**
1954
1955| Name| Description|
1956| -------- | -------- |
1957| info | Attribute object of the common event to destroy.|
1958
1959**Returns**
1960
1961None.
1962
1963### OH_CommonEvent_SetPublishInfoBundleName
1964
1965```cpp
1966CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoBundleName(CommonEvent_PublishInfo* info, const char* bundleName)
1967```
1968
1969**Description**
1970
1971Sets the bundle name of a common event.
1972
1973**Since**: 18
1974
1975**Parameters**
1976
1977| Name| Description|
1978| -------- | -------- |
1979| info | Attribute object of the common event.|
1980| bundleName | Bundle name to set.|
1981
1982**Returns**
1983
1984Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
1985
1986### OH_CommonEvent_SetPublishInfoPermissions
1987
1988```cpp
1989CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoPermissions(CommonEvent_PublishInfo* info, const char* permissions[], int32_t num)
1990```
1991
1992**Description**
1993
1994Sets the common event permissions.
1995
1996**Since**: 18
1997
1998**Parameters**
1999
2000| Name| Description|
2001| -------- | -------- |
2002| info | Attribute object of the common event.|
2003| permissions | Permission name array.|
2004| num | Number of permissions.|
2005
2006**Returns**
2007
2008Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
2009
2010### OH_CommonEvent_SetPublishInfoCode
2011
2012```cpp
2013CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoCode(CommonEvent_PublishInfo* info, int32_t code)
2014```
2015
2016**Description**
2017
2018Sets the result code of a common event.
2019
2020**Since**: 18
2021
2022**Parameters**
2023
2024| Name| Description|
2025| -------- | -------- |
2026| info | Attribute object of the common event.|
2027| code | Result code to set.|
2028
2029**Returns**
2030
2031Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
2032
2033### OH_CommonEvent_SetPublishInfoData
2034
2035```cpp
2036CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoData(CommonEvent_PublishInfo* info, const char* data, size_t length)
2037```
2038
2039**Description**
2040
2041Sets the result data for the publishing information of a common event.
2042
2043**Since**: 18
2044
2045**Parameters**
2046
2047| Name| Description|
2048| -------- | -------- |
2049| info | Attribute object of the common event.|
2050| data | Result data to set.|
2051| length | Length of the result data.|
2052
2053**Returns**
2054
2055Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
2056
2057### OH_CommonEvent_SetPublishInfoParameters
2058
2059```cpp
2060CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoParameters(CommonEvent_PublishInfo* info, CommonEvent_Parameters* param)
2061```
2062
2063**Description**
2064
2065Sets the additional information of a common event.
2066
2067**Since**: 18
2068
2069**Parameters**
2070
2071| Name| Description|
2072| -------- | -------- |
2073| info | Attribute object of the common event.|
2074| param | Additional information to set.|
2075
2076**Returns**
2077
2078Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.
2079
2080### OH_CommonEvent_Publish
2081
2082```cpp
2083CommonEvent_ErrCode OH_CommonEvent_Publish(const char* event)
2084```
2085
2086**Description**
2087
2088Publishes a custom common event.
2089
2090**Since**: 18
2091
2092**Parameters**
2093
2094| Name| Description|
2095| -------- | -------- |
2096| event | Name of the common event.|
2097
2098**Returns**
2099
2100Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.<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.
2101
2102### OH_CommonEvent_PublishWithInfo
2103
2104```cpp
2105CommonEvent_ErrCode OH_CommonEvent_PublishWithInfo(const char* event, const CommonEvent_PublishInfo* info)
2106```
2107
2108**Description**
2109
2110Publishes a custom common event with specified attributes.
2111
2112**Since**: 18
2113
2114**Parameters**
2115
2116| Name| Description|
2117| -------- | -------- |
2118| event | Name of the common event.|
2119| info | Attribute object of the common event.|
2120
2121**Returns**
2122
2123Returns **COMMONEVENT_ERR_OK** if the operation is successful.<br>Returns **COMMONEVENT_ERR_INVALID_PARAMETER** if the parameter is invalid.<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.
2124
2125### OH_CommonEvent_IsOrderedCommonEvent
2126
2127```cpp
2128bool OH_CommonEvent_IsOrderedCommonEvent(const CommonEvent_Subscriber* subscriber)
2129```
2130
2131**Description**
2132
2133Checks whether a common event is an ordered common event.
2134
2135**Since**: 18
2136
2137**Parameters**
2138
2139| Name| Description|
2140| -------- | -------- |
2141| subscriber | Subscriber object of the common event.|
2142
2143**Returns**
2144
2145Returns **true** if the common event is an ordered one; returns **false** otherwise.
2146
2147### OH_CommonEvent_FinishCommonEvent
2148
2149```cpp
2150bool OH_CommonEvent_FinishCommonEvent(CommonEvent_Subscriber* subscriber)
2151```
2152
2153**Description**
2154
2155Finishes an ordered common event.
2156
2157**Since**: 18
2158
2159**Parameters**
2160
2161| Name| Description|
2162| -------- | -------- |
2163| subscriber | Subscriber object of the common event.|
2164
2165**Returns**
2166
2167Returns **true** if the operation is successful; returns **false** otherwise.
2168
2169### OH_CommonEvent_GetAbortCommonEvent
2170
2171```cpp
2172bool OH_CommonEvent_GetAbortCommonEvent(const CommonEvent_Subscriber* subscriber)
2173```
2174
2175**Description**
2176
2177Checks whether an ordered common event is aborted.
2178
2179**Since**: 18
2180
2181**Parameters**
2182
2183| Name| Description|
2184| -------- | -------- |
2185| subscriber | Subscriber object of the common event.|
2186
2187**Returns**
2188
2189Returns **true** if the ordered common event is aborted; returns **false** otherwise.
2190
2191### OH_CommonEvent_AbortCommonEvent
2192
2193```cpp
2194bool OH_CommonEvent_AbortCommonEvent(CommonEvent_Subscriber* subscriber)
2195```
2196
2197**Description**
2198
2199Aborts an ordered common event when used with **OH_CommonEvent_FinishCommonEvent**. After the abort, the common event is not sent to the next subscriber.
2200
2201**Since**: 18
2202
2203**Parameters**
2204
2205| Name| Description|
2206| -------- | -------- |
2207| subscriber | Subscriber object of the common event.|
2208
2209**Returns**
2210
2211Returns **true** if the operation is successful; returns **false** otherwise.
2212
2213### OH_CommonEvent_ClearAbortCommonEvent
2214
2215```cpp
2216bool OH_CommonEvent_ClearAbortCommonEvent(CommonEvent_Subscriber* subscriber)
2217```
2218
2219**Description**
2220
2221Clears the aborted state of an ordered common event when used with **OH_CommonEvent_FinishCommonEvent**. After the clearance, the common event is sent to the next subscriber.
2222
2223**Since**: 18
2224
2225**Parameters**
2226
2227| Name| Description|
2228| -------- | -------- |
2229| subscriber | Subscriber object of the common event.|
2230
2231**Returns**
2232
2233Returns **true** if the operation is successful; returns **false** otherwise.
2234
2235### OH_CommonEvent_GetCodeFromSubscriber
2236
2237```cpp
2238int32_t OH_CommonEvent_GetCodeFromSubscriber(const CommonEvent_Subscriber* subscriber)
2239```
2240
2241**Description**
2242
2243Obtains the result code of an ordered common event.
2244
2245**Since**: 18
2246
2247**Parameters**
2248
2249| Name| Description|
2250| -------- | -------- |
2251| subscriber | Subscriber object of the common event.|
2252
2253**Returns**
2254
2255Returns the code of the ordered common event. If the code cannot be obtained, **0** is returned.
2256
2257### OH_CommonEvent_GetDataFromSubscriber
2258
2259```cpp
2260const char* OH_CommonEvent_GetDataFromSubscriber(const CommonEvent_Subscriber* subscriber)
2261```
2262
2263**Description**
2264
2265Obtains the result data of an ordered common event.
2266
2267**Since**: 18
2268
2269**Parameters**
2270
2271| Name| Description|
2272| -------- | -------- |
2273| subscriber | Subscriber object of the common event.|
2274
2275**Returns**
2276
2277Returns the data of the ordered common event. If the data cannot be obtained, **null** is returned.
2278
2279### OH_CommonEvent_SetCodeToSubscriber
2280
2281```cpp
2282bool OH_CommonEvent_SetCodeToSubscriber(CommonEvent_Subscriber* subscriber, int32_t code)
2283```
2284
2285**Description**
2286
2287Sets the result code of an ordered common event.
2288
2289**Since**: 18
2290
2291**Parameters**
2292
2293| Name| Description|
2294| -------- | -------- |
2295| subscriber | Subscriber object of the common event.|
2296| code | Common event code.|
2297
2298**Returns**
2299
2300Returns **true** if the operation is successful; returns **false** otherwise.
2301
2302### OH_CommonEvent_SetDataToSubscriber
2303
2304```cpp
2305bool OH_CommonEvent_SetDataToSubscriber(CommonEvent_Subscriber* subscriber, const char* data, size_t length)
2306```
2307
2308**Description**
2309
2310Sets the result data of an ordered common event.
2311
2312**Since**: 18
2313
2314**Parameters**
2315
2316| Name| Description|
2317| -------- | -------- |
2318| subscriber | Subscriber object of the common event.|
2319| data | Common event data.|
2320| length | Data length.|
2321
2322**Returns**
2323
2324Returns **true** if the operation is successful; returns **false** otherwise.
2325