harmony 鸿蒙CommonEvent
CommonEvent
Overview
Describes the common event capabilities provided by the CommonEvent for applications.
System capability: SystemCapability.Notification.CommonEvent
Since: 12
Summary
Files
Name | Description |
---|---|
oh_commonevent.h | Defines the APIs for subscribing to and unsubscribing from common events. File to include: Library: libohcommonevent.so |
oh_commonevent_support.h | Provides common event constants defined by the system. File to include: Library: libohcommonevent.so |
Types
Name | Description |
---|---|
CommonEvent_SubscribeInfo | Defines a struct for the subscriber information. |
CommonEvent_Subscriber | Defines a subscriber. |
CommonEvent_RcvData | Defines a struct for the callback data of a common event. |
CommonEvent_Parameters | Defines the additional information about a common event. |
CommonEvent_ReceiveCallback | Defines a callback to be invoked when a common event is triggered. |
CommonEvent_PublishInfo | Defines a struct for an attribute object used for publishing a custom common event. |
Enums
Name | Description |
---|---|
CommonEvent_ErrCode | Enumerates the error codes. |
Functions
Name | Description |
---|---|
OH_CommonEvent_CreateSubscribeInfo | Creates the subscriber information. |
OH_CommonEvent_SetPublisherPermission | Sets the subscriber permission. |
OH_CommonEvent_SetPublisherBundleName | Sets a bundle name of the subscriber. |
OH_CommonEvent_DestroySubscribeInfo | Destroys the subscriber information. |
OH_CommonEvent_CreateSubscriber | Creates a subscriber. |
OH_CommonEvent_DestroySubscriber | Destroys a subscriber. |
OH_CommonEvent_Subscribe | Subscribes to a common event. |
OH_CommonEvent_UnSubscribe | Unsubscribes from a common event. |
OH_CommonEvent_GetEventFromRcvData | Obtains the name of a common event. |
OH_CommonEvent_GetCodeFromRcvData | Obtains the result code of a common event. |
OH_CommonEvent_GetDataStrFromRcvData | Obtains the custom result data of a common event. |
OH_CommonEvent_GetBundleNameFromRcvData | Obtains the bundle name of a common event. |
OH_CommonEvent_GetParametersFromRcvData | Obtains the additional information about a common event. |
OH_CommonEvent_HasKeyInParameters | Checks whether the additional information of a common event contains a key-value pair. |
OH_CommonEvent_GetIntFromParameters | Obtains the int data from the additional information of a common event. |
OH_CommonEvent_GetIntArrayFromParameters | Obtains the int array from the additional information of a common event. |
OH_CommonEvent_GetLongFromParameters | Obtains the long data from the additional information of a common event. |
OH_CommonEvent_GetLongArrayFromParameters | Obtains the long array from the additional information of a common event. |
OH_CommonEvent_GetBoolFromParameters | Obtains the Boolean data from the additional information of a common event. |
OH_CommonEvent_GetBoolArrayFromParameters | Obtains the Boolean array from the additional information of a common event. |
OH_CommonEvent_GetCharFromParameters | Obtains the character data from the additional information of a common event. |
OH_CommonEvent_GetCharArrayFromParameters | Obtains the character array from the additional information of a common event. |
OH_CommonEvent_GetDoubleFromParameters | Obtains the double data from the additional information of a common event. |
OH_CommonEvent_GetDoubleArrayFromParameters | Obtains the double array from the additional information of a common event. |
OH_CommonEvent_CreateParameters | Creates an additional information object of a common event. |
OH_CommonEvent_DestroyParameters | Destroys an additional information object of a common event. |
OH_CommonEvent_SetIntToParameters | Sets the additional information of a common event. The value is the content of the int type. |
OH_CommonEvent_SetIntArrayToParameters | Sets the additional information of a common event. The value is the content of the int array type. |
OH_CommonEvent_SetLongToParameters | Sets the additional information of a common event. The value is the content of the long type. |
OH_CommonEvent_SetLongArrayToParameters | Sets the additional information of a common event. The value is the content of the long array type. |
OH_CommonEvent_SetDoubleToParameters | Sets the additional information of a common event. The value is the content of the double type. |
OH_CommonEvent_SetDoubleArrayToParameters | Sets the additional information of a common event. The value is the content of the double array type. |
OH_CommonEvent_SetBoolToParameters | Sets the additional information of a common event. The value is the content of the Boolean type. |
OH_CommonEvent_SetBoolArrayToParameters | Sets the additional information of a common event. The value is the content of the Boolean array type. |
OH_CommonEvent_SetCharToParameters | Sets the additional information of a common event. The value is the content of the character type. |
OH_CommonEvent_SetCharArrayToParameters | Sets the additional information of a common event. The value is the content of the character array type. |
OH_CommonEvent_CreatePublishInfo | Creates an attribute object of a common event. |
OH_CommonEvent_DestroyPublishInfo | Destroys an attribute object of a common event. |
OH_CommonEvent_SetPublishInfoBundleName | Sets the bundle name of a common event. |
OH_CommonEvent_SetPublishInfoPermissions | Sets the common event permissions. |
OH_CommonEvent_SetPublishInfoCode | Sets the result code of a common event. |
OH_CommonEvent_SetPublishInfoData | Sets the result data of a common event. |
OH_CommonEvent_SetPublishInfoParameters | Sets the additional information of a common event. |
OH_CommonEvent_Publish | Publishes a custom common event. |
OH_CommonEvent_PublishWithInfo | Publishes a custom common event with specified attributes. |
OH_CommonEvent_IsOrderedCommonEvent | Checks whether a common event is an ordered common event. |
OH_CommonEvent_FinishCommonEvent | Finishes an ordered common event. |
OH_CommonEvent_GetAbortCommonEvent | Checks whether an ordered common event is aborted. |
OH_CommonEvent_AbortCommonEvent | Aborts an ordered common event. |
OH_CommonEvent_ClearAbortCommonEvent | Clears the aborted state of an ordered common event. |
OH_CommonEvent_GetCodeFromSubscriber | Obtains the result code of an ordered common event. |
OH_CommonEvent_GetDataFromSubscriber | Obtains the result data of an ordered common event. |
OH_CommonEvent_SetCodeToSubscriber | Sets the result code of an ordered common event. |
OH_CommonEvent_SetDataToSubscriber | Sets the result data of an ordered common event. |
Constants
Name | Description |
---|---|
static const char* const COMMON_EVENT_SHUTDOWN = “usual.event.SHUTDOWN” | Indicates the common event that the device is being shut down and the final shutdown will proceed. |
static const char* const 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. |
static const char* const COMMON_EVENT_BATTERY_LOW = “usual.event.BATTERY_LOW” | Indicates the common event that the battery level is low. |
static const char* const COMMON_EVENT_BATTERY_OKAY = “usual.event.BATTERY_OKAY” | Indicates the common event that the battery exits the low state. |
static const char* const COMMON_EVENT_POWER_CONNECTED = “usual.event.POWER_CONNECTED” | Indicates the common event that the device is connected to an external power supply. |
static const char* const COMMON_EVENT_POWER_DISCONNECTED = “usual.event.POWER_DISCONNECTED” | Indicates the common event that the device is disconnected from the external power supply. |
static const char* const COMMON_EVENT_SCREEN_OFF = “usual.event.SCREEN_OFF” | Indicates the common event that the device screen is off and the device is sleeping. |
static const char* const 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. |
static const char* const COMMON_EVENT_THERMAL_LEVEL_CHANGED = “usual.event.THERMAL_LEVEL_CHANGED” | Indicates the common event that the device’s thermal level has changed. |
static const char* const COMMON_EVENT_TIME_TICK = “usual.event.TIME_TICK” | Indicates the common event that the system time has changed. |
static const char* const COMMON_EVENT_TIME_CHANGED = “usual.event.TIME_CHANGED” | Indicates the common event that the system time is reset. |
static const char* const COMMON_EVENT_TIMEZONE_CHANGED = “usual.event.TIMEZONE_CHANGED” | Indicates the common event that the system time zone has changed. |
static const char* const COMMON_EVENT_PACKAGE_ADDED = “usual.event.PACKAGE_ADDED” | Indicates the common event that a new application package has been installed on the device. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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). |
static const char* const COMMON_EVENT_PACKAGE_RESTARTED = “usual.event.PACKAGE_RESTARTED” | Indicates the common event that a user restarts an application package and kills all its processes. |
static const char* const COMMON_EVENT_PACKAGE_DATA_CLEARED = “usual.event.PACKAGE_DATA_CLEARED” | Indicates the common event that the user has cleared the application package data. |
static const char* const COMMON_EVENT_PACKAGE_CACHE_CLEARED = “usual.event.PACKAGE_CACHE_CLEARED” | Indicates the common event that the user has cleared the application package data cache. |
static const char* const COMMON_EVENT_PACKAGES_SUSPENDED = “usual.event.PACKAGES_SUSPENDED” | Indicates the common event that application packages have been suspended. |
static const char* const COMMON_EVENT_MY_PACKAGE_SUSPENDED = “usual.event.MY_PACKAGE_SUSPENDED” | Indicates the common event that can be sent to a suspended application package. |
static const char* const COMMON_EVENT_MY_PACKAGE_UNSUSPENDED = “usual.event.MY_PACKAGE_UNSUSPENDED” | Indicates the common event that application packages have not been suspended. |
static const char* const COMMON_EVENT_LOCALE_CHANGED = “usual.event.LOCALE_CHANGED” | Indicates the common event that the device locale has changed. |
static const char* const COMMON_EVENT_MANAGE_PACKAGE_STORAGE = “usual.event.MANAGE_PACKAGE_STORAGE” | Indicates the common event that the device storage is insufficient. |
static const char* const 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. |
static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT = “common.event.DISTRIBUTED_ACCOUNT_LOGOUT” | Indicates the common event that a distributed account is successfully logged out. |
static const char* const 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. |
static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF = “common.event.DISTRIBUTED_ACCOUNT_LOGOFF” | Indicates the common event that a distributed account is deregistered. |
static const char* const 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. |
static const char* const 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. |
static const char* const COMMON_EVENT_WIFI_RSSI_VALUE = “usual.event.wifi.RSSI_VALUE” | Indicates the common event that the Wi-Fi signal strength (RSSI) has changed. |
static const char* const COMMON_EVENT_WIFI_CONN_STATE = “usual.event.wifi.CONN_STATE” | Indicates the common event that the Wi-Fi connection state has changed. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const COMMON_EVENT_DISCHARGING = “usual.event.DISCHARGING” | Indicates the common event that the system stops charging the battery. |
static const char* const COMMON_EVENT_CHARGING = “usual.event.CHARGING” | Indicates the common event that the system starts charging the battery. |
static const char* const COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED = “usual.event.DEVICE_IDLE_MODE_CHANGED” | Indicates the common event that the system standby mode has changed. |
static const char* const COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED = “usual.event.CHARGE_IDLE_MODE_CHANGED” | Indicates the common event that the device enters the charging idle mode. |
static const char* const COMMON_EVENT_POWER_SAVE_MODE_CHANGED = “usual.event.POWER_SAVE_MODE_CHANGED” | Indicates the common event that the system power saving mode is changed. |
static const char* const COMMON_EVENT_USB_STATE = “usual.event.hardware.usb.action.USB_STATE” | Indicates the common event that the USB device state has changed. |
static const char* const 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. |
static const char* const 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. |
static const char* const 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. |
static const char* const COMMON_EVENT_AIRPLANE_MODE_CHANGED = “usual.event.AIRPLANE_MODE” | Indicates the common event that the airplane mode of the device has changed. |
static const char* const COMMON_EVENT_SPLIT_SCREEN = “common.event.SPLIT_SCREEN” | Indicates the common event of screen splitting. |
static const char* const 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. |
static const char* const COMMON_EVENT_QUICK_FIX_REVOKE_RESULT = “usual.event.QUICK_FIX_REVOKE_RESULT” | Indicates the common event that a quick fix is canceled. |
static const char* const COMMON_EVENT_USER_INFO_UPDATED = “usual.event.USER_INFO_UPDATED” | Indicates the common event that the user information has been updated. |
static const char* const COMMON_EVENT_SIM_STATE_CHANGED = “usual.event.SIM_STATE_CHANGED” | Indicates the common event that the SIM card state has been updated. |
static const char* const COMMON_EVENT_CALL_STATE_CHANGED = “usual.event.CALL_STATE_CHANGED” | Indicates the common event that the call state has been updated. |
static const char* const COMMON_EVENT_NETWORK_STATE_CHANGED = “usual.event.NETWORK_STATE_CHANGED” | Indicates the common event that the network state has been updated. |
static const char* const COMMON_EVENT_SIGNAL_INFO_CHANGED = “usual.event.SIGNAL_INFO_CHANGED” | Indicates the common event that the signal information has been updated. |
static const char* const COMMON_EVENT_SCREEN_UNLOCKED = “usual.event.SCREEN_UNLOCKED” | Indicates the common event that the screen has been unlocked. |
static const char* const COMMON_EVENT_SCREEN_LOCKED = “usual.event.SCREEN_LOCKED” | Indicates the common event that the screen has been locked. |
static const char* const COMMON_EVENT_HTTP_PROXY_CHANGE = “usual.event.HTTP_PROXY_CHANGE” | Indicates the common event that the HTTP proxy configuration has changed. |
static const char* const COMMON_EVENT_CONNECTIVITY_CHANGE = “usual.event.CONNECTIVITY_CHANGE” | Indicates the common event that the network connection state has changed. |
static const char* const COMMON_EVENT_MINORSMODE_ON = “usual.event.MINORSMODE_ON” | Indicates the common event that the minor mode is enabled. |
static const char* const COMMON_EVENT_MINORSMODE_OFF = “usual.event.MINORSMODE_OFF” | Indicates the common event that the minor mode is disabled. |
Type Description
CommonEvent_SubscribeInfo
typedef struct CommonEvent_SubscribeInfo CommonEvent_SubscribeInfo
Description
Defines a struct for the subscriber information.
Since: 12
CommonEvent_Subscriber
typedef void CommonEvent_Subscriber
Description
Defines a subscriber.
Since: 12
CommonEvent_RcvData
typedef struct CommonEvent_RcvData CommonEvent_RcvData
Description
Defines a struct for the callback data of a common event.
Since: 12
CommonEvent_Parameters
typedef void CommonEvent_Parameters
Description
Defines the additional information about a common event.
Since: 12
CommonEvent_ReceiveCallback
typedef void (*CommonEvent_ReceiveCallback)(const CommonEvent_RcvData *data)
Description
Defines a callback to be invoked when a common event is triggered.
Since: 12
CommonEvent_PublishInfo
typedef struct CommonEvent_PublishInfo CommonEvent_PublishInfo
Description
Defines a struct for an attribute object used for publishing a custom common event.
Since: 18
Enum Description
CommonEvent_ErrCode
Description
Enumerates the error codes.
Since: 12
Value | Description |
---|---|
COMMONEVENT_ERR_OK = 0 | The operation is successful. |
COMMONEVENT_ERR_PERMISSION_ERROR = 201 | Permission denied. |
COMMONEVENT_ERR_INVALID_PARAMETER = 401 | Invalid parameter. |
COMMONEVENT_ERR_NOT_SYSTEM_SERVICE = 1500004 | The application fails to send system common events. |
COMMONEVENT_ERR_SENDING_REQUEST_FAILED = 1500007 | Failed to send an IPC request. |
COMMONEVENT_ERR_INIT_UNDONE = 1500008 | The service is not initialized. |
COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED = 1500010 | The number of subscribers exceeds 200. |
COMMONEVENT_ERR_ALLOC_MEMORY_FAILED = 1500011 | The system fails to allocate memory. |
Constant Description
COMMON_EVENT_SHUTDOWN
static const char* const COMMON_EVENT_SHUTDOWN = "usual.event.SHUTDOWN"
Description
Indicates the common event that the device is being shut down and the final shutdown will proceed.
Since: 12
COMMON_EVENT_BATTERY_CHANGED
static const char* const COMMON_EVENT_BATTERY_CHANGED = "usual.event.BATTERY_CHANGED"
Description
Indicates the common event that the charging state, level, and other information about the battery have changed.
Since: 12
COMMON_EVENT_BATTERY_LOW
static const char* const COMMON_EVENT_BATTERY_LOW = "usual.event.BATTERY_LOW"
Description
Indicates the common event that the battery level is low.
Since: 12
COMMON_EVENT_BATTERY_OKAY
static const char* const COMMON_EVENT_BATTERY_OKAY = "usual.event.BATTERY_OKAY"
Description
Indicates the common event that the battery exits the low state.
Since: 12
COMMON_EVENT_POWER_CONNECTED
static const char* const COMMON_EVENT_POWER_CONNECTED = "usual.event.POWER_CONNECTED"
Description
Indicates the common event that the device is connected to an external power supply.
Since: 12
COMMON_EVENT_POWER_DISCONNECTED
static const char* const COMMON_EVENT_POWER_DISCONNECTED = "usual.event.POWER_DISCONNECTED"
Description
Indicates the common event that the device is disconnected from the external power supply.
Since: 12
COMMON_EVENT_SCREEN_OFF
static const char* const COMMON_EVENT_SCREEN_OFF = "usual.event.SCREEN_OFF"
Description
Indicates the common event that the device screen is off and the device is sleeping.
Since: 12
COMMON_EVENT_SCREEN_ON
static const char* const COMMON_EVENT_SCREEN_ON = "usual.event.SCREEN_ON"
Description
Indicates the common event that the device screen is on and the device is in interactive state.
Since: 12
COMMON_EVENT_THERMAL_LEVEL_CHANGED
static const char* const COMMON_EVENT_THERMAL_LEVEL_CHANGED = "usual.event.THERMAL_LEVEL_CHANGED"
Description
Indicates the common event that the device’s thermal level has changed.
Since: 12
COMMON_EVENT_TIME_TICK
static const char* const COMMON_EVENT_TIME_TICK = "usual.event.TIME_TICK"
Description
Indicates the common event that the system time has changed.
Since: 12
COMMON_EVENT_TIME_CHANGED
static const char* const COMMON_EVENT_TIME_CHANGED = "usual.event.TIME_CHANGED"
Description
Indicates the common event that the system time is reset.
Since: 12
COMMON_EVENT_TIMEZONE_CHANGED
static const char* const COMMON_EVENT_TIMEZONE_CHANGED = "usual.event.TIMEZONE_CHANGED"
Description
Indicates the common event that the system time zone has changed.
Since: 12
COMMON_EVENT_PACKAGE_ADDED
static const char* const COMMON_EVENT_PACKAGE_ADDED = "usual.event.PACKAGE_ADDED"
Description
Indicates the common event that a new application package has been installed on the device.
Since: 12
COMMON_EVENT_PACKAGE_REMOVED
static const char* const COMMON_EVENT_PACKAGE_REMOVED = "usual.event.PACKAGE_REMOVED"
Description
Indicates the common event that an installed application has been uninstalled from the device with the application data retained.
Since: 12
COMMON_EVENT_BUNDLE_REMOVED
static const char* const COMMON_EVENT_BUNDLE_REMOVED = "usual.event.BUNDLE_REMOVED"
Description
Indicates the common event that an installed bundle has been uninstalled from the device with the application data retained.
Since: 12
COMMON_EVENT_PACKAGE_FULLY_REMOVED
static const char* const COMMON_EVENT_PACKAGE_FULLY_REMOVED = "usual.event.PACKAGE_FULLY_REMOVED"
Description
Indicates the common event that an installed application, including both the application data and code, has been completely uninstalled from the device.
Since: 12
COMMON_EVENT_PACKAGE_CHANGED
static const char* const COMMON_EVENT_PACKAGE_CHANGED = "usual.event.PACKAGE_CHANGED"
Description
Indicates the common event that an application package has been changed (for example, a component in the package has been enabled or disabled).
Since: 12
COMMON_EVENT_PACKAGE_RESTARTED
static const char* const COMMON_EVENT_PACKAGE_RESTARTED = "usual.event.PACKAGE_RESTARTED"
Description
Indicates the common event that a user restarts an application package and kills all its processes.
Since: 12
COMMON_EVENT_PACKAGE_DATA_CLEARED
static const char* const COMMON_EVENT_PACKAGE_DATA_CLEARED = "usual.event.PACKAGE_DATA_CLEARED"
Description
Indicates the common event that the user has cleared the application package data.
Since: 12
COMMON_EVENT_PACKAGE_CACHE_CLEARED
static const char* const COMMON_EVENT_PACKAGE_CACHE_CLEARED = "usual.event.PACKAGE_CACHE_CLEARED"
Description
Indicates the common event that the user has cleared the application package data cache.
Since: 12
COMMON_EVENT_PACKAGES_SUSPENDED
static const char* const COMMON_EVENT_PACKAGES_SUSPENDED = "usual.event.PACKAGES_SUSPENDED"
Description
Indicates the common event that application packages have been suspended.
Since: 12
COMMON_EVENT_MY_PACKAGE_SUSPENDED
static const char* const COMMON_EVENT_MY_PACKAGE_SUSPENDED = "usual.event.MY_PACKAGE_SUSPENDED"
Description
Indicates the common event that can be sent to a suspended application package.
Since: 12
COMMON_EVENT_MY_PACKAGE_UNSUSPENDED
static const char* const COMMON_EVENT_MY_PACKAGE_UNSUSPENDED = "usual.event.MY_PACKAGE_UNSUSPENDED"
Description
Indicates the common event that application packages have not been suspended.
Since: 12
COMMON_EVENT_LOCALE_CHANGED
static const char* const COMMON_EVENT_LOCALE_CHANGED = "usual.event.LOCALE_CHANGED"
Description
Indicates the common event that the device locale has changed.
Since: 12
COMMON_EVENT_MANAGE_PACKAGE_STORAGE
static const char* const COMMON_EVENT_MANAGE_PACKAGE_STORAGE = "usual.event.MANAGE_PACKAGE_STORAGE"
Description
Indicates the common event that the device storage is insufficient.
Since: 12
COMMON_EVENT_USER_UNLOCKED
static const char* const COMMON_EVENT_USER_UNLOCKED = "usual.event.USER_UNLOCKED"
Description
Indicates the common event that the credential-encrypted storage has become unlocked for the current user when the device is unlocked after being restarted.
Since: 12
COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT
static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT = "common.event.DISTRIBUTED_ACCOUNT_LOGOUT"
Description
Indicates the common event that a distributed account is successfully logged out.
Since: 12
COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID
static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID = "common.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID"
Description
Indicates the common event that the token of a distributed account is invalid.
Since: 12
COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF
static const char* const COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF = "common.event.DISTRIBUTED_ACCOUNT_LOGOFF"
Description
Indicates the common event that a distributed account is deregistered.
Since: 12
COMMON_EVENT_WIFI_POWER_STATE
static const char* const COMMON_EVENT_WIFI_POWER_STATE = "usual.event.wifi.POWER_STATE"
Description
Indicates the common event that the Wi-Fi state has changed, for example, enabled or disabled.
Since: 12
COMMON_EVENT_WIFI_SCAN_FINISHED
static const char* const COMMON_EVENT_WIFI_SCAN_FINISHED = "usual.event.wifi.SCAN_FINISHED"
Description
Indicates the common event that the Wi-Fi access point has been scanned and proven to be available.
Since: 12
COMMON_EVENT_WIFI_RSSI_VALUE
static const char* const COMMON_EVENT_WIFI_RSSI_VALUE = "usual.event.wifi.RSSI_VALUE"
Description
Indicates the common event that the Wi-Fi signal strength (RSSI) has changed.
Since: 12
COMMON_EVENT_WIFI_CONN_STATE
static const char* const COMMON_EVENT_WIFI_CONN_STATE = "usual.event.wifi.CONN_STATE"
Description
Indicates the common event that the Wi-Fi connection state has changed.
Since: 12
COMMON_EVENT_WIFI_HOTSPOT_STATE
static const char* const COMMON_EVENT_WIFI_HOTSPOT_STATE = "usual.event.wifi.HOTSPOT_STATE"
Description
Indicates the common event of the Wi-Fi hotspot state.
Since: 12
COMMON_EVENT_WIFI_AP_STA_JOIN
static const char* const COMMON_EVENT_WIFI_AP_STA_JOIN = "usual.event.wifi.WIFI_HS_STA_JOIN"
Description
Indicates the common event that a client has joined the Wi-Fi hotspot of the current device.
Since: 12
COMMON_EVENT_WIFI_AP_STA_LEAVE
static const char* const COMMON_EVENT_WIFI_AP_STA_LEAVE = "usual.event.wifi.WIFI_HS_STA_LEAVE"
Description
Indicates the common event that a client has disconnected from the Wi-Fi hotspot of the current device.
Since: 12
COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE
static const char* const COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE = "usual.event.wifi.mplink.STATE_CHANGE"
Description
Indicates the common event that the state of MPLINK (an enhanced Wi-Fi feature) has changed.
Since: 12
COMMON_EVENT_WIFI_P2P_CONN_STATE
static const char* const COMMON_EVENT_WIFI_P2P_CONN_STATE = "usual.event.wifi.p2p.CONN_STATE_CHANGE"
Description
Indicates the common event that the Wi-Fi P2P connection state has changed.
Since: 12
COMMON_EVENT_WIFI_P2P_STATE_CHANGED
static const char* const COMMON_EVENT_WIFI_P2P_STATE_CHANGED = "usual.event.wifi.p2p.STATE_CHANGE"
Description
Indicates the common event that the Wi-Fi P2P state has changed, for example, enabled or disabled.
COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED
static const char* const COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED = "usual.event.wifi.p2p.DEVICES_CHANGE"
Description
Indicates the common event that the state of the Wi-Fi P2P peer device has changed.
Since: 12
COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED
static const char* const COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED = "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE"
Description
Indicates the common event that the Wi-Fi P2P discovery state has changed.
Since: 12
COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED
static const char* const COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED = "usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE"
Description
Indicates the common event that the state of the Wi-Fi P2P local device has changed.
Since: 12
COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED
static const char* const COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED = "usual.event.wifi.p2p.GROUP_STATE_CHANGED"
Description
Indicates the common event that the Wi-Fi P2P group information has changed.
Since: 12
COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED
static const char* const COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED = "usual.event.nfc.action.ADAPTER_STATE_CHANGED"
Description
Indicates the common event that the state of the device NFC adapter has changed.
Since: 12
COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED
static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED = "usual.event.nfc.action.RF_FIELD_ON_DETECTED"
Description
Indicates the common event that the NFC RF field is on.
Since: 12
COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED
static const char* const COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED = "usual.event.nfc.action.RF_FIELD_OFF_DETECTED"
Description
Indicates the common event that the NFC RF field is off.
Since: 12
COMMON_EVENT_DISCHARGING
static const char* const COMMON_EVENT_DISCHARGING = "usual.event.DISCHARGING"
Description
Indicates the common event that the system stops charging the battery.
Since: 12
COMMON_EVENT_CHARGING
static const char* const COMMON_EVENT_CHARGING = "usual.event.CHARGING"
Description
Indicates the common event that the system starts charging the battery.
COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED
static const char* const COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED = "usual.event.DEVICE_IDLE_MODE_CHANGED"
Description
Indicates the common event that the system standby mode has changed.
Since: 12
COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED
static const char* const COMMON_EVENT_CHARGE_IDLE_MODE_CHANGED = "usual.event.CHARGE_IDLE_MODE_CHANGED"
Description
Indicates the common event that the device enters the charging idle mode.
Since: 12
COMMON_EVENT_POWER_SAVE_MODE_CHANGED
static const char* const COMMON_EVENT_POWER_SAVE_MODE_CHANGED = "usual.event.POWER_SAVE_MODE_CHANGED"
Description
Indicates the common event that the system power saving mode is changed.
Since: 12
COMMON_EVENT_USB_STATE
static const char* const COMMON_EVENT_USB_STATE = "usual.event.hardware.usb.action.USB_STATE"
Description
Indicates the common event that the USB device state has changed.
Since: 12
COMMON_EVENT_USB_PORT_CHANGED
static const char* const COMMON_EVENT_USB_PORT_CHANGED = "usual.event.hardware.usb.action.USB_PORT_CHANGED"
Description
Indicates the common event that the USB port state of the user device has changed.
Since: 12
COMMON_EVENT_USB_DEVICE_ATTACHED
static const char* const COMMON_EVENT_USB_DEVICE_ATTACHED = "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED"
Description
Indicates the common event that a USB device has been attached when the user device functions as a USB host.
Since: 12
COMMON_EVENT_USB_DEVICE_DETACHED
static const char* const COMMON_EVENT_USB_DEVICE_DETACHED = "usual.event.hardware.usb.action.USB_DEVICE_DETACHED"
Description
Indicates the common event that a USB device has been detached when the user device functions as a USB host.
Since: 12
COMMON_EVENT_AIRPLANE_MODE_CHANGED
static const char* const COMMON_EVENT_AIRPLANE_MODE_CHANGED = "usual.event.AIRPLANE_MODE"
Description
Indicates the common event that the airplane mode of the device has changed.
Since: 12
COMMON_EVENT_SPLIT_SCREEN
static const char* const COMMON_EVENT_SPLIT_SCREEN = "common.event.SPLIT_SCREEN"
Description
Indicates the common event of screen splitting.
Since: 12
COMMON_EVENT_QUICK_FIX_APPLY_RESULT
static const char* const COMMON_EVENT_QUICK_FIX_APPLY_RESULT = "usual.event.QUICK_FIX_APPLY_RESULT"
Description
Indicates the common event that a quick fix is applied to an application.
Since: 12
COMMON_EVENT_QUICK_FIX_REVOKE_RESULT
static const char* const COMMON_EVENT_QUICK_FIX_REVOKE_RESULT = "usual.event.QUICK_FIX_REVOKE_RESULT"
Description
Indicates the common event that a quick fix is canceled.
Since: 12
COMMON_EVENT_USER_INFO_UPDATED
static const char* const COMMON_EVENT_USER_INFO_UPDATED = "usual.event.USER_INFO_UPDATED"
Description
Indicates the common event that the user information has been updated.
Since: 12
COMMON_EVENT_SIM_STATE_CHANGED
static const char* const COMMON_EVENT_SIM_STATE_CHANGED = "usual.event.SIM_STATE_CHANGED"
Description
Indicates the common event that the SIM card state has been updated.
Since: 12
COMMON_EVENT_CALL_STATE_CHANGED
static const char* const COMMON_EVENT_CALL_STATE_CHANGED = "usual.event.CALL_STATE_CHANGED"
Description
Indicates the common event that the call state has been updated.
Since: 12
COMMON_EVENT_NETWORK_STATE_CHANGED
static const char* const COMMON_EVENT_NETWORK_STATE_CHANGED = "usual.event.NETWORK_STATE_CHANGED"
Description
Indicates the common event that the network state has been updated.
Since: 12
COMMON_EVENT_SIGNAL_INFO_CHANGED
static const char* const COMMON_EVENT_SIGNAL_INFO_CHANGED = "usual.event.SIGNAL_INFO_CHANGED"
Description
Indicates the common event that the signal information has been updated.
Since: 12
COMMON_EVENT_SCREEN_UNLOCKED
static const char* const COMMON_EVENT_SCREEN_UNLOCKED = "usual.event.SCREEN_UNLOCKED"
Description
Indicates the common event that the screen has been unlocked.
Since: 12
COMMON_EVENT_SCREEN_LOCKED
static const char* const COMMON_EVENT_SCREEN_LOCKED = "usual.event.SCREEN_LOCKED"
Description
Indicates the common event that the screen has been locked.
Since: 12
COMMON_EVENT_HTTP_PROXY_CHANGE
static const char* const COMMON_EVENT_HTTP_PROXY_CHANGE = "usual.event.HTTP_PROXY_CHANGE"
Description
Indicates the common event that the HTTP proxy configuration has changed.
Since: 12
COMMON_EVENT_CONNECTIVITY_CHANGE
static const char* const COMMON_EVENT_CONNECTIVITY_CHANGE = "usual.event.CONNECTIVITY_CHANGE"
Description
Indicates the common event that the network connection state has changed.
Since: 12
COMMON_EVENT_MINORSMODE_ON
static const char* const COMMON_EVENT_MINORSMODE_ON = "usual.event.MINORSMODE_ON"
Description
Indicates that the minor mode is enabled.
Since: 12
COMMON_EVENT_MINORSMODE_OFF
static const char* const COMMON_EVENT_MINORSMODE_OFF = "usual.event.MINORSMODE_OFF"
Description
Indicates the common event that the minor mode is disabled.
Since: 12
Function Description
OH_CommonEvent_CreateSubscribeInfo
CommonEvent_SubscribeInfo* OH_CommonEvent_CreateSubscribeInfo(const char* events[], int32_t eventsNum)
Description
Creates the subscriber information.
Since: 12
Parameters
Name | Description |
---|---|
events | Events you have subscribed to. |
eventsNum | Number of events |
Returns
Returns the subscriber information.
OH_CommonEvent_SetPublisherPermission
CommonEvent_ErrCode OH_CommonEvent_SetPublisherPermission(CommonEvent_SubscribeInfo* info, const char* permission)
Description
Sets the subscriber permission.
Since: 12
Parameters
Name | Description |
---|---|
info | Subscriber information. |
permission | Name of the permission. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if info is a null pointer.
OH_CommonEvent_SetPublisherBundleName
CommonEvent_ErrCode OH_CommonEvent_SetPublisherBundleName(CommonEvent_SubscribeInfo* info, const char* bundleName)
Description
Sets a bundle name of the subscriber.
Since: 12
Parameters
Name | Description |
---|---|
info | Subscriber information. |
bundleName | Bundle name. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if info is a null pointer.
OH_CommonEvent_DestroySubscribeInfo
void OH_CommonEvent_DestroySubscribeInfo(CommonEvent_SubscribeInfo* info)
Description
Destroys the subscriber information.
Since: 12
Parameters
Name | Description |
---|---|
info | Subscriber information. |
OH_CommonEvent_CreateSubscriber
CommonEvent_Subscriber* OH_CommonEvent_CreateSubscriber(const CommonEvent_SubscribeInfo* info, CommonEvent_ReceiveCallback callback)
Description
Creates a subscriber.
Since: 12
Parameters
Name | Description |
---|---|
info | Subscriber information. |
callback | Event callback. |
Returns
Returns the subscriber.
OH_CommonEvent_DestroySubscriber
void OH_CommonEvent_DestroySubscriber(CommonEvent_Subscriber* subscriber)
Description
Destroys a subscriber.
Since: 12
Parameters
Name | Description |
---|---|
subscriber | Subscriber. |
OH_CommonEvent_Subscribe
CommonEvent_ErrCode OH_CommonEvent_Subscribe(const CommonEvent_Subscriber* subscriber)
Description
Subscribes to a common event.
Since: 12
Parameters
Name | Description |
---|---|
subscriber | Subscriber. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if subscriber is a null parameter.
Returns COMMONEVENT_ERR_SENDING_REQUEST_FAILED if the IPC fails to be sent.
Returns COMMONEVENT_ERR_INIT_UNDONE if the common event service is not initialized.
Returns COMMONEVENT_ERR_SUBSCRIBER_NUM_EXCEEDED if the number of subscribers in the current process exceeds 200.
Returns COMMONEVENT_ERR_ALLOC_MEMORY_FAILED if the system fails to allocate memory.
OH_CommonEvent_UnSubscribe
CommonEvent_ErrCode OH_CommonEvent_UnSubscribe(const CommonEvent_Subscriber* subscriber)
Description
Unsubscribes from a common event.
Since: 12
Parameters
Name | Description |
---|---|
subscriber | Subscriber. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if subscriber is a null parameter.
Returns COMMONEVENT_ERR_SENDING_REQUEST_FAILED if the IPC fails to be sent.
Returns COMMONEVENT_ERR_INIT_UNDONE if the common event service is not initialized.
OH_CommonEvent_GetEventFromRcvData
const char* OH_CommonEvent_GetEventFromRcvData(const CommonEvent_RcvData* rcvData)
Description
Obtains the name of a callback common event.
Since: 12
Parameters
Name | Description |
---|---|
rcvData | Callback data of a common event. |
Returns
Returns the name of a common event.
OH_CommonEvent_GetCodeFromRcvData
int32_t OH_CommonEvent_GetCodeFromRcvData(const CommonEvent_RcvData* rcvData)
Description
Obtains the result code of the callback common event.
Since: 12
Parameters
Name | Description |
---|---|
rcvData | Callback data of a common event. |
Returns
Returns the result code of a common event. The default value is 0.
OH_CommonEvent_GetDataStrFromRcvData
const char* OH_CommonEvent_GetDataStrFromRcvData(const CommonEvent_RcvData* rcvData)
Description
Obtains the custom result data of a common event.
Since: 12
Parameters
Name | Description |
---|---|
rcvData | Callback data of a common event. |
Returns
Returns the custom result data of a common event. The default value is null.
OH_CommonEvent_GetBundleNameFromRcvData
const char* OH_CommonEvent_GetBundleNameFromRcvData(const CommonEvent_RcvData* rcvData)
Description
Obtains the bundle name of a callback common event.
Since: 12
Parameters
Name | Description |
---|---|
rcvData | Callback data of a common event. |
Returns
Returns the bundle name of a common event. The default value is null.
OH_CommonEvent_GetParametersFromRcvData
const CommonEvent_Parameters* OH_CommonEvent_GetParametersFromRcvData(const CommonEvent_RcvData* rcvData)
Description
Obtains the additional information about a callback common event.
Since: 12
Parameters
Name | Description |
---|---|
rcvData | Callback data of a common event. |
Returns
Returns the additional information of a common event. The default value is null.
OH_CommonEvent_HasKeyInParameters
bool OH_CommonEvent_HasKeyInParameters(const CommonEvent_Parameters* para, const char* key)
Description
Checks whether the additional information of a common event contains a key-value pair.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
Returns
Returns true if the key-value pair exists; returns false otherwise.
OH_CommonEvent_GetIntFromParameters
int OH_CommonEvent_GetIntFromParameters(const CommonEvent_Parameters* para, const char* key, const int defaultValue)
Description
Obtains the int data with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
defaultValue | Default value to be returned. |
OH_CommonEvent_GetIntArrayFromParameters
int32_t OH_CommonEvent_GetIntArrayFromParameters(const CommonEvent_Parameters* para, const char* key, int** array)
Description
Obtains the int array with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
array | The int array to receive data. |
Returns
Returns the length of an array.
OH_CommonEvent_GetLongFromParameters
long OH_CommonEvent_GetLongFromParameters(const CommonEvent_Parameters* para, const char* key, const long defaultValue)
Description
Obtains the long data with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
defaultValue | Default value to be returned. |
OH_CommonEvent_GetLongArrayFromParameters
int32_t OH_CommonEvent_GetLongArrayFromParameters(const CommonEvent_Parameters* para, const char* key, long** array)
Description
Obtains the long array with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
array | The long array to receive data. |
Returns
Returns the length of an array.
OH_CommonEvent_GetBoolFromParameters
bool OH_CommonEvent_GetBoolFromParameters(const CommonEvent_Parameters* para, const char* key, const bool defaultValue)
Description
Obtains the Boolean data with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
defaultValue | Default value to be returned. |
OH_CommonEvent_GetBoolArrayFromParameters
int32_t OH_CommonEvent_GetBoolArrayFromParameters(const CommonEvent_Parameters* para, const char* key, bool** array)
Description
Obtains the Boolean array with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
array | The Boolean array to receive data. |
Returns
Returns the length of an array.
OH_CommonEvent_GetCharFromParameters
char OH_CommonEvent_GetCharFromParameters(const CommonEvent_Parameters* para, const char* key, const char defaultValue)
Description
Obtains the character data with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
defaultValue | Default value to be returned. |
OH_CommonEvent_GetCharArrayFromParameters
int32_t OH_CommonEvent_GetCharArrayFromParameters(const CommonEvent_Parameters* para, const char* key, char** array)
Description
Obtains the character array with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
array | The character array to receive data. |
Returns
Returns the length of an array.
OH_CommonEvent_GetDoubleFromParameters
double OH_CommonEvent_GetDoubleFromParameters(const CommonEvent_Parameters* para, const char* key, const double defaultValue)
Description
Obtains the double data with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
defaultValue | Default value to be returned. |
OH_CommonEvent_GetDoubleArrayFromParameters
int32_t OH_CommonEvent_GetDoubleArrayFromParameters(const CommonEvent_Parameters* para, const char* key, double** array)
Description
Obtains the double array with a specific key from the additional information of a common event.
Since: 12
Parameters
Name | Description |
---|---|
para | Additional information about a common event. |
key | Key. |
array | The double array to receive data. |
Returns
Returns the length of an array. The default value is 0.
OH_CommonEvent_CreateParameters
CommonEvent_Parameters* OH_CommonEvent_CreateParameters()
Description
Creates an additional information object of a common event.
Since: 18
Parameters
None.
Returns
Returns additional information of the common event if operation is successful; returns null otherwise.
OH_CommonEvent_DestroyParameters
void OH_CommonEvent_DestroyParameters(CommonEvent_Parameters* param)
Description
Destroys an additional information object of a common event.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
Returns
None.
OH_CommonEvent_SetIntToParameters
CommonEvent_ErrCode OH_CommonEvent_SetIntToParameters(CommonEvent_Parameters* param, const char* key, int value)
Description
Sets the additional information of a common event. The value is the content of the int type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the int type. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetIntArrayToParameters
CommonEvent_ErrCode OH_CommonEvent_SetIntArrayToParameters(CommonEvent_Parameters* param, const char* key, const int* value, size_t num)
Description
Sets the additional information of a common event. The value is the content of the int array type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the int array type. |
num | Number of elements in the content. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
Returns COMMONEVENT_ERR_ALLOC_MEMORY_FAILED if memory allocation fails.
OH_CommonEvent_SetLongToParameters
CommonEvent_ErrCode OH_CommonEvent_SetLongToParameters(CommonEvent_Parameters* param, const char* key, long value)
Description
Sets the additional information of a common event. The value is the content of the long type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the long type. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetLongArrayToParameters
CommonEvent_ErrCode OH_CommonEvent_SetLongArrayToParameters(CommonEvent_Parameters* param, const char* key, const long* value, size_t num)
Description
Sets the additional information of a common event. The value is the content of the long array type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the long array type. |
num | Number of elements in the content. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
Returns COMMONEVENT_ERR_ALLOC_MEMORY_FAILED if memory allocation fails.
OH_CommonEvent_SetDoubleToParameters
CommonEvent_ErrCode OH_CommonEvent_SetDoubleToParameters(CommonEvent_Parameters* param, const char* key, double value)
Description
Sets the additional information of a common event. The value is the content of the double type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the double type. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetDoubleArrayToParameters
CommonEvent_ErrCode OH_CommonEvent_SetDoubleArrayToParameters(CommonEvent_Parameters* param, const char* key, const double* value, size_t num)
Description
Sets the additional information of a common event. The value is the content of the double array type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the double array type. |
num | Number of elements in the content. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
Returns COMMONEVENT_ERR_ALLOC_MEMORY_FAILED if memory allocation fails.
OH_CommonEvent_SetBoolToParameters
CommonEvent_ErrCode OH_CommonEvent_SetBoolToParameters(CommonEvent_Parameters* param, const char* key, bool value)
Description
Sets the additional information of a common event. The value is the content of the Boolean type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the Boolean type. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetBoolArrayToParameters
CommonEvent_ErrCode OH_CommonEvent_SetBoolArrayToParameters(CommonEvent_Parameters* param, const char* key, const bool* value, size_t num)
Description
Sets the additional information of a common event. The value is the content of the Boolean array type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the Boolean array type. |
num | Number of elements in the content. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
Returns COMMONEVENT_ERR_ALLOC_MEMORY_FAILED if memory allocation fails.
OH_CommonEvent_SetCharToParameters
CommonEvent_ErrCode OH_CommonEvent_SetCharToParameters(CommonEvent_Parameters* param, const char* key, char value)
Description
Sets the additional information of a common event. The value is the content of the character type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the character type. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetCharArrayToParameters
CommonEvent_ErrCode OH_CommonEvent_SetCharArrayToParameters(CommonEvent_Parameters* param, const char* key, const char* value, size_t num)
Description
Sets the additional information of a common event. The value is the content of the character array type.
Since: 18
Parameters
Name | Description |
---|---|
param | Additional information about a common event. |
key | Key. |
value | Content of the character array type. |
num | Number of elements in the content. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
Returns COMMONEVENT_ERR_ALLOC_MEMORY_FAILED if memory allocation fails.
OH_CommonEvent_CreatePublishInfo
CommonEvent_PublishInfo* OH_CommonEvent_CreatePublishInfo(bool ordered)
Description
Creates an attribute object of a common event.
Since: 18
Parameters
Name | Description |
---|---|
ordered | Whether the event is an ordered common event. true: ordered common event. false: unordered common event. |
Returns
Returns the attribute object if the operation is successful; returns null otherwise.
OH_CommonEvent_DestroyPublishInfo
void OH_CommonEvent_DestroyPublishInfo(CommonEvent_PublishInfo* info)
Description
Destroys an attribute object of a common event.
Since: 18
Parameters
Name | Description |
---|---|
info | Attribute object of the common event to destroy. |
Returns
None.
OH_CommonEvent_SetPublishInfoBundleName
CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoBundleName(CommonEvent_PublishInfo* info, const char* bundleName)
Description
Sets the bundle name of a common event.
Since: 18
Parameters
Name | Description |
---|---|
info | Attribute object of the common event. |
bundleName | Bundle name to set. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetPublishInfoPermissions
CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoPermissions(CommonEvent_PublishInfo* info, const char* permissions[], int32_t num)
Description
Sets the common event permissions.
Since: 18
Parameters
Name | Description |
---|---|
info | Attribute object of the common event. |
permissions | Permission name array. |
num | Number of permissions. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetPublishInfoCode
CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoCode(CommonEvent_PublishInfo* info, int32_t code)
Description
Sets the result code of a common event.
Since: 18
Parameters
Name | Description |
---|---|
info | Attribute object of the common event. |
code | Result code to set. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetPublishInfoData
CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoData(CommonEvent_PublishInfo* info, const char* data, size_t length)
Description
Sets the result data for the publishing information of a common event.
Since: 18
Parameters
Name | Description |
---|---|
info | Attribute object of the common event. |
data | Result data to set. |
length | Length of the result data. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_SetPublishInfoParameters
CommonEvent_ErrCode OH_CommonEvent_SetPublishInfoParameters(CommonEvent_PublishInfo* info, CommonEvent_Parameters* param)
Description
Sets the additional information of a common event.
Since: 18
Parameters
Name | Description |
---|---|
info | Attribute object of the common event. |
param | Additional information to set. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
OH_CommonEvent_Publish
CommonEvent_ErrCode OH_CommonEvent_Publish(const char* event)
Description
Publishes a custom common event.
Since: 18
Parameters
Name | Description |
---|---|
event | Name of the common event. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
Returns COMMONEVENT_ERR_SENDING_REQUEST_FAILED if the IPC fails to be sent.
Returns COMMONEVENT_ERR_INIT_UNDONE if the common event service is not initialized.
OH_CommonEvent_PublishWithInfo
CommonEvent_ErrCode OH_CommonEvent_PublishWithInfo(const char* event, const CommonEvent_PublishInfo* info)
Description
Publishes a custom common event with specified attributes.
Since: 18
Parameters
Name | Description |
---|---|
event | Name of the common event. |
info | Attribute object of the common event. |
Returns
Returns COMMONEVENT_ERR_OK if the operation is successful.
Returns COMMONEVENT_ERR_INVALID_PARAMETER if the parameters are invalid.
Returns COMMONEVENT_ERR_SENDING_REQUEST_FAILED if the IPC fails to be sent.
Returns COMMONEVENT_ERR_INIT_UNDONE if the common event service is not initialized.
OH_CommonEvent_IsOrderedCommonEvent
bool OH_CommonEvent_IsOrderedCommonEvent(const CommonEvent_Subscriber* subscriber)
Description
Checks whether a common event is an ordered common event.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
Returns
Returns true if the common event is ordered.
Returns false if the common event is unordered.
OH_CommonEvent_FinishCommonEvent
bool OH_CommonEvent_FinishCommonEvent(CommonEvent_Subscriber* subscriber)
Description
Finishes an ordered common event.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
Returns
Returns true if the operation is successful; returns false otherwise.
OH_CommonEvent_GetAbortCommonEvent
bool OH_CommonEvent_GetAbortCommonEvent(const CommonEvent_Subscriber* subscriber)
Description
Checks whether an ordered common event is aborted.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
Returns
Returns true if the ordered common event is aborted; returns false otherwise.
OH_CommonEvent_AbortCommonEvent
bool OH_CommonEvent_AbortCommonEvent(CommonEvent_Subscriber* subscriber)
Description
Aborts an ordered common event when used with OH_CommonEvent_FinishCommonEvent. After the abort, the common event is not sent to the next subscriber.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
Returns
Returns true if the operation is successful; returns false otherwise.
OH_CommonEvent_ClearAbortCommonEvent
bool OH_CommonEvent_ClearAbortCommonEvent(CommonEvent_Subscriber* subscriber)
Description
Clears 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.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
Returns
Returns true if the operation is successful; returns false otherwise.
OH_CommonEvent_GetCodeFromSubscriber
int32_t OH_CommonEvent_GetCodeFromSubscriber(const CommonEvent_Subscriber* subscriber)
Description
Obtains the result code of an ordered common event.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
Returns
Returns the code of the ordered common event. If the code cannot be obtained, 0 is returned.
OH_CommonEvent_GetDataFromSubscriber
const char* OH_CommonEvent_GetDataFromSubscriber(const CommonEvent_Subscriber* subscriber)
Description
Obtains the result data of an ordered common event.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
Returns
Returns the data of the ordered common event. If the data cannot be obtained, null is returned.
OH_CommonEvent_SetCodeToSubscriber
bool OH_CommonEvent_SetCodeToSubscriber(CommonEvent_Subscriber* subscriber, int32_t code)
Description
Sets the result code of an ordered common event.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
code | Common event code. |
Returns
Returns true if the operation is successful; returns false otherwise.
OH_CommonEvent_SetDataToSubscriber
bool OH_CommonEvent_SetDataToSubscriber(CommonEvent_Subscriber* subscriber, const char* data, size_t length)
Description
Sets the result data of an ordered common event.
Since: 18
Parameters
Name | Description |
---|---|
subscriber | Subscriber object of the common event. |
data | Common event data. |
length | Data length. |
Returns
Returns true if the operation is successful; returns false otherwise.
你可能感兴趣的鸿蒙文章
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦