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