1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { paramMock } from "../utils" 17import { CommonEventData } from "./commonEvent/commonEventData" 18import { CommonEventSubscriber } from "./commonEvent/commonEventSubscriber" 19 20export const Support = { 21 COMMON_EVENT_BOOT_COMPLETED: "usual.event.BOOT_COMPLETED", 22 COMMON_EVENT_LOCKED_BOOT_COMPLETED: "usual.event.LOCKED_BOOT_COMPLETED", 23 COMMON_EVENT_SHUTDOWN: "usual.event.SHUTDOWN", 24 COMMON_EVENT_BATTERY_CHANGED: "usual.event.BATTERY_CHANGED", 25 COMMON_EVENT_BATTERY_LOW: "usual.event.BATTERY_LOW", 26 COMMON_EVENT_BATTERY_OKAY: "usual.event.BATTERY_OKAY", 27 COMMON_EVENT_POWER_CONNECTED: "usual.event.POWER_CONNECTED", 28 COMMON_EVENT_POWER_DISCONNECTED: "usual.event.POWER_DISCONNECTED", 29 COMMON_EVENT_SCREEN_OFF: "usual.event.SCREEN_OFF", 30 COMMON_EVENT_SCREEN_ON: "usual.event.SCREEN_ON", 31 COMMON_EVENT_THERMAL_LEVEL_CHANGED: "usual.event.THERMAL_LEVEL_CHANGED", 32 COMMON_EVENT_USER_PRESENT: "usual.event.USER_PRESENT", 33 COMMON_EVENT_TIME_TICK: "usual.event.TIME_TICK", 34 COMMON_EVENT_TIME_CHANGED: "usual.event.TIME_CHANGED", 35 COMMON_EVENT_DATE_CHANGED: "usual.event.DATE_CHANGED", 36 COMMON_EVENT_TIMEZONE_CHANGED: "usual.event.TIMEZONE_CHANGED", 37 COMMON_EVENT_CLOSE_SYSTEM_DIALOGS: "usual.event.CLOSE_SYSTEM_DIALOGS", 38 COMMON_EVENT_PACKAGE_ADDED: "usual.event.PACKAGE_ADDED", 39 COMMON_EVENT_PACKAGE_REPLACED: "usual.event.PACKAGE_REPLACED", 40 COMMON_EVENT_MY_PACKAGE_REPLACED: "usual.event.MY_PACKAGE_REPLACED", 41 COMMON_EVENT_PACKAGE_REMOVED: "usual.event.PACKAGE_REMOVED", 42 COMMON_EVENT_BUNDLE_REMOVED: "usual.event.BUNDLE_REMOVED", 43 COMMON_EVENT_PACKAGE_FULLY_REMOVED: "usual.event.PACKAGE_FULLY_REMOVED", 44 COMMON_EVENT_PACKAGE_CHANGED: "usual.event.PACKAGE_CHANGED", 45 COMMON_EVENT_PACKAGE_RESTARTED: "usual.event.PACKAGE_RESTARTED", 46 COMMON_EVENT_PACKAGE_DATA_CLEARED: "usual.event.PACKAGE_DATA_CLEARED", 47 COMMON_EVENT_PACKAGE_CACHE_CLEARED: "usual.event.PACKAGE_CACHE_CLEARED", 48 COMMON_EVENT_PACKAGES_SUSPENDED: "usual.event.PACKAGES_SUSPENDED", 49 COMMON_EVENT_PACKAGES_UNSUSPENDED: "usual.event.PACKAGES_UNSUSPENDED", 50 COMMON_EVENT_MY_PACKAGE_SUSPENDED: "usual.event.MY_PACKAGE_SUSPENDED", 51 COMMON_EVENT_MY_PACKAGE_UNSUSPENDED: "usual.event.MY_PACKAGE_UNSUSPENDED", 52 COMMON_EVENT_UID_REMOVED: "usual.event.UID_REMOVED", 53 COMMON_EVENT_PACKAGE_FIRST_LAUNCH: "usual.event.PACKAGE_FIRST_LAUNCH", 54 COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION: "usual.event.PACKAGE_NEEDS_VERIFICATION", 55 COMMON_EVENT_PACKAGE_VERIFIED: "usual.event.PACKAGE_VERIFIED", 56 COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE: "usual.event.EXTERNAL_APPLICATIONS_AVAILABLE", 57 COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE: "usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE", 58 COMMON_EVENT_CONFIGURATION_CHANGED: "usual.event.CONFIGURATION_CHANGED", 59 COMMON_EVENT_LOCALE_CHANGED: "usual.event.LOCALE_CHANGED", 60 COMMON_EVENT_MANAGE_PACKAGE_STORAGE: "usual.event.MANAGE_PACKAGE_STORAGE", 61 COMMON_EVENT_DRIVE_MODE: "common.event.DRIVE_MODE", 62 COMMON_EVENT_HOME_MODE: "common.event.HOME_MODE", 63 COMMON_EVENT_OFFICE_MODE: "common.event.OFFICE_MODE", 64 COMMON_EVENT_USER_STARTED: "usual.event.USER_STARTED", 65 COMMON_EVENT_USER_BACKGROUND: "usual.event.USER_BACKGROUND", 66 COMMON_EVENT_USER_FOREGROUND: "usual.event.USER_FOREGROUND", 67 COMMON_EVENT_USER_SWITCHED: "usual.event.USER_SWITCHED", 68 COMMON_EVENT_USER_STARTING: "usual.event.USER_STARTING", 69 COMMON_EVENT_USER_UNLOCKED: "usual.event.USER_UNLOCKED", 70 COMMON_EVENT_USER_STOPPING: "usual.event.USER_STOPPING", 71 COMMON_EVENT_USER_STOPPED: "usual.event.USER_STOPPED", 72 COMMON_EVENT_HWID_LOGIN: "common.event.HWID_LOGIN", 73 COMMON_EVENT_HWID_LOGOUT: "common.event.HWID_LOGOUT", 74 COMMON_EVENT_HWID_TOKEN_INVALID: "common.event.HWID_TOKEN_INVALID", 75 COMMON_EVENT_HWID_LOGOFF: "common.event.HWID_LOGOFF", 76 COMMON_EVENT_WIFI_POWER_STATE: "usual.event.wifi.POWER_STATE", 77 COMMON_EVENT_WIFI_SCAN_FINISHED: "usual.event.wifi.SCAN_FINISHED", 78 COMMON_EVENT_WIFI_RSSI_VALUE: "usual.event.wifi.RSSI_VALUE", 79 COMMON_EVENT_WIFI_CONN_STATE: "usual.event.wifi.CONN_STATE", 80 COMMON_EVENT_WIFI_HOTSPOT_STATE: "usual.event.wifi.HOTSPOT_STATE", 81 COMMON_EVENT_WIFI_AP_STA_JOIN: "usual.event.wifi.WIFI_HS_STA_JOIN", 82 COMMON_EVENT_WIFI_AP_STA_LEAVE: "usual.event.wifi.WIFI_HS_STA_LEAVE", 83 COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE: "usual.event.wifi.mplink.STATE_CHANGE", 84 COMMON_EVENT_WIFI_P2P_CONN_STATE: "usual.event.wifi.p2p.CONN_STATE_CHANGE", 85 COMMON_EVENT_WIFI_P2P_STATE_CHANGED: "usual.event.wifi.p2p.STATE_CHANGE", 86 COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED: "usual.event.wifi.p2p.DEVICES_CHANGE", 87 COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED: "usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE", 88 COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED:"usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE", 89 COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED:"usual.event.wifi.p2p.GROUP_STATE_CHANGED", 90 COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE: 91 "usual.event.bluetooth.handsfree.ag.CONNECT_STATE_UPDATE", 92 COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE: 93 "usual.event.bluetooth.handsfree.ag.CURRENT_DEVICE_UPDATE", 94 COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE: "usual.event.bluetooth.handsfree.ag.AUDIO_STATE_UPDATE", 95 COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE:"usual.event.bluetooth.a2dpsource.CONNECT_STATE_UPDATE", 96 COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE: "usual.event.bluetooth.a2dpsource.CURRENT_DEVICE_UPDATE", 97 COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE: "usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE", 98 COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE: 99 "usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE", 100 COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE: "usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE", 101 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED: "usual.event.bluetooth.remotedevice.DISCOVERED", 102 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE: "usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE", 103 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED: "usual.event.bluetooth.remotedevice.ACL_CONNECTED", 104 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED: "usual.event.bluetooth.remotedevice.ACL_DISCONNECTED", 105 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE: 106 "usual.event.bluetooth.remotedevice.NAME_UPDATE", 107 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE: 108 "usual.event.bluetooth.remotedevice.PAIR_STATE", 109 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE: 110 "usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE", 111 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT: 112 "usual.event.bluetooth.remotedevice.SDP_RESULT", 113 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE: 114 "usual.event.bluetooth.remotedevice.UUID_VALUE", 115 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ: 116 "usual.event.bluetooth.remotedevice.PAIRING_REQ", 117 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL: 118 "usual.event.bluetooth.remotedevice.PAIRING_CANCEL", 119 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ: 120 "usual.event.bluetooth.remotedevice.CONNECT_REQ", 121 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY: 122 "usual.event.bluetooth.remotedevice.CONNECT_REPLY", 123 COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL: 124 "usual.event.bluetooth.remotedevice.CONNECT_CANCEL", 125 COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE: 126 "usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE", 127 COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE: 128 "usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE", 129 COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT: 130 "usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT", 131 COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE: 132 "usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE", 133 COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE: 134 "usual.event.bluetooth.host.STATE_UPDATE", 135 COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE: 136 "usual.event.bluetooth.host.REQ_DISCOVERABLE", 137 COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE: "usual.event.bluetooth.host.REQ_ENABLE", 138 COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE: 139 "usual.event.bluetooth.host.REQ_DISABLE", 140 COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE: 141 "usual.event.bluetooth.host.SCAN_MODE_UPDATE", 142 COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED: 143 "usual.event.bluetooth.host.DISCOVERY_STARTED", 144 COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED: 145 "usual.event.bluetooth.host.DISCOVERY_FINISHED", 146 COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE: 147 "usual.event.bluetooth.host.NAME_UPDATE", 148 COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE: 149 "usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE", 150 COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE: 151 "usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE", 152 COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE: 153 "usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE", 154 COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED: 155 "usual.event.nfc.action.ADAPTER_STATE_CHANGED", 156 COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED: 157 "usual.event.nfc.action.RF_FIELD_ON_DETECTED", 158 COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED: 159 "usual.event.nfc.action.RF_FIELD_OFF_DETECTED", 160 COMMON_EVENT_DISCHARGING: "usual.event.DISCHARGING", 161 COMMON_EVENT_CHARGING: "usual.event.CHARGING", 162 COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED: "usual.event.DEVICE_IDLE_MODE_CHANGED", 163 COMMON_EVENT_POWER_SAVE_MODE_CHANGED: "usual.event.POWER_SAVE_MODE_CHANGED", 164 COMMON_EVENT_USER_ADDED: "usual.event.USER_ADDED", 165 COMMON_EVENT_USER_REMOVED: "usual.event.USER_REMOVED", 166 COMMON_EVENT_ABILITY_ADDED: "common.event.ABILITY_ADDED", 167 COMMON_EVENT_ABILITY_REMOVED: "common.event.ABILITY_REMOVED", 168 COMMON_EVENT_ABILITY_UPDATED: "common.event.ABILITY_UPDATED", 169 COMMON_EVENT_LOCATION_MODE_STATE_CHANGED: 170 "usual.event.location.MODE_STATE_CHANGED", 171 COMMON_EVENT_IVI_SLEEP: "common.event.IVI_SLEEP", 172 COMMON_EVENT_IVI_PAUSE: "common.event.IVI_PAUSE", 173 COMMON_EVENT_IVI_STANDBY: "common.event.IVI_STANDBY", 174 COMMON_EVENT_IVI_LASTMODE_SAVE: "common.event.IVI_LASTMODE_SAVE", 175 COMMON_EVENT_IVI_VOLTAGE_ABNORMAL: "common.event.IVI_VOLTAGE_ABNORMAL", 176 COMMON_EVENT_IVI_HIGH_TEMPERATURE: "common.event.IVI_HIGH_TEMPERATURE", 177 COMMON_EVENT_IVI_EXTREME_TEMPERATURE: "common.event.IVI_EXTREME_TEMPERATURE", 178 COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL: "common.event.IVI_TEMPERATURE_ABNORMAL", 179 COMMON_EVENT_IVI_VOLTAGE_RECOVERY: "common.event.IVI_VOLTAGE_RECOVERY", 180 COMMON_EVENT_IVI_TEMPERATURE_RECOVERY: "common.event.IVI_TEMPERATURE_RECOVERY", 181 COMMON_EVENT_IVI_ACTIVE: "common.event.IVI_ACTIVE", 182 COMMON_EVENT_USB_STATE: "usual.event.hardware.usb.action.USB_STATE", 183 COMMON_EVENT_USB_PORT_CHANGED: "usual.event.hardware.usb.action.USB_PORT_CHANGED", 184 COMMON_EVENT_USB_DEVICE_ATTACHED: 185 "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED", 186 COMMON_EVENT_USB_DEVICE_DETACHED: 187 "usual.event.hardware.usb.action.USB_DEVICE_DETACHED", 188 COMMON_EVENT_USB_ACCESSORY_ATTACHED: 189 "usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED", 190 COMMON_EVENT_USB_ACCESSORY_DETACHED: 191 "usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED", 192 COMMON_EVENT_DISK_REMOVED: "usual.event.data.DISK_REMOVED", 193 COMMON_EVENT_DISK_UNMOUNTED: "usual.event.data.DISK_UNMOUNTED", 194 COMMON_EVENT_DISK_MOUNTED: "usual.event.data.DISK_MOUNTED", 195 COMMON_EVENT_DISK_BAD_REMOVAL: "usual.event.data.DISK_BAD_REMOVAL", 196 COMMON_EVENT_DISK_UNMOUNTABLE: "usual.event.data.DISK_UNMOUNTABLE", 197 COMMON_EVENT_DISK_EJECT: "usual.event.data.DISK_EJECT", 198 COMMON_EVENT_VOLUME_REMOVED: "usual.event.data.VOLUME_REMOVED", 199 COMMON_EVENT_VOLUME_UNMOUNTED: "usual.event.data.VOLUME_UNMOUNTED", 200 COMMON_EVENT_VOLUME_MOUNTED: "usual.event.data.VOLUME_MOUNTED", 201 COMMON_EVENT_VOLUME_BAD_REMOVAL: "usual.event.data.VOLUME_BAD_REMOVAL", 202 COMMON_EVENT_VOLUME_EJECT: "usual.event.data.VOLUME_EJECT", 203 COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED: 204 "usual.event.data.VISIBLE_ACCOUNTS_UPDATED", 205 COMMON_EVENT_ACCOUNT_DELETED: "usual.event.data.ACCOUNT_DELETED", 206 COMMON_EVENT_FOUNDATION_READY: "common.event.FOUNDATION_READY", 207 COMMON_EVENT_AIRPLANE_MODE_CHANGED: "usual.event.AIRPLANE_MODE", 208 COMMON_EVENT_SPLIT_SCREEN: "common.event.SPLIT_SCREEN", 209 COMMON_EVENT_SLOT_CHANGE: "usual.event.SLOT_CHANGE", 210 COMMON_EVENT_SPN_INFO_CHANGED: "usual.event.SPN_INFO_CHANGED" 211} 212export function mockCommonEvent() { 213 const commonEvent = { 214 publish: function (...args) { 215 console.warn('commonEvent.publish interface mocked in the Previewer. How this interface works on the' + 216 ' Previewer may be different from that on a real device.'); 217 const len = args.length; 218 if (typeof args[len - 1] === 'function') { 219 args[len - 1].call(this, paramMock.businessErrorMock); 220 } 221 }, 222 publishAsUser: function (...args) { 223 console.warn('commonEvent.publishAsUser interface mocked in the Previewer. How this interface works on the' + 224 ' Previewer may be different from that on a real device.'); 225 const len = args.length; 226 if (typeof args[len - 1] === 'function') { 227 args[len - 1].call(this, paramMock.businessErrorMock); 228 } 229 }, 230 createSubscriber: function (...args) { 231 console.warn('commonEvent.createSubscriber interface mocked in the Previewer. How this interface works on the' + 232 ' Previewer may be different from that on a real device.'); 233 const len = args.length; 234 if (typeof args[len - 1] === 'function') { 235 args[len - 1].call(this, paramMock.businessErrorMock, CommonEventSubscriber); 236 } else { 237 return new Promise((resolve) => { 238 resolve(CommonEventSubscriber); 239 }); 240 } 241 }, 242 subscribe: function (...args) { 243 console.warn('commonEvent.subscribe interface mocked in the Previewer. How this interface works on the' + 244 ' Previewer may be different from that on a real device.'); 245 const len = args.length; 246 if (typeof args[len - 1] === 'function') { 247 args[len - 1].call(this, paramMock.businessErrorMock, CommonEventData); 248 } 249 }, 250 unsubscribe: function (...args) { 251 console.warn('commonEvent.unsubscribe interface mocked in the Previewer. How this interface works on the' + 252 ' Previewer may be different from that on a real device.'); 253 const len = args.length; 254 if (typeof args[len - 1] === 'function') { 255 args[len - 1].call(this, paramMock.businessErrorMock); 256 } 257 }, 258 Support 259 } 260 return commonEvent 261} 262