1# Common Events of the USB Subsystem 2This document lists the common system events provided by the USB subsystem to applications. Applications can use [APIs](../js-apis-commonEventManager.md) to subscribe to common system events. 3 4## COMMON_EVENT_USB_STATE 5Indicates that the USB device state has changed. 6 7- Constant value: "usual.event.hardware.usb.action.USB_STATE" 8- Required subscriber permissions: none 9 10When a USB device is connected to or disconnected from the device, the event notification service is triggered to publish this event. 11 12## COMMON_EVENT_USB_PORT_CHANGED 13 14Indicates that the USB port state of the device has changed. 15 16- Constant value: "usual.event.hardware.usb.action.USB_PORT_CHANGED" 17- Required subscriber permissions: none 18 19When the USB port status changes, the event notification service is triggered to publish this event. 20 21APIs related to this event: **dataRole** parameter in [setPortRoles](../js-apis-usbManager.md#usbsetportroles). 22 23## COMMON_EVENT_USB_DEVICE_ATTACHED 24 25Indicates that a USB device has been attached to the device functioning as a USB host. 26 27- Constant value: "usual.event.hardware.usb.action.USB_DEVICE_ATTACHED" 28- Required subscriber permissions: none 29 30When a USB device is attached, the event notification service is triggered to publish this event. 31 32APIs related to this event: [USBDevice](../js-apis-usbManager.md#usbdevice). 33 34## COMMON_EVENT_USB_DEVICE_DETACHED 35 36Indicates that a USB device has been detached from the device functioning as a USB host. 37 38- Constant value: "usual.event.hardware.usb.action.USB_DEVICE_DETACHED" 39- Required subscriber permissions: none 40 41When a USB device is deattached, the event notification service is triggered to publish this event. 42 43APIs related to this event: [USBDevice](../js-apis-usbManager.md#usbdevice). 44 45## COMMON_EVENT_USB_ACCESSORY_ATTACHED 46 47(Reserved, not supported yet) Indicates that a USB accessory was attached. 48 49- Constant value: "usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED" 50- Required subscriber permissions: none 51 52## COMMON_EVENT_USB_ACCESSORY_DETACHED 53 54(Reserved, not supported yet) Indicates that a USB accessory was detached. 55 56- Constant value: "usual.event.data.DISK_MOUNTED" 57- Required subscriber permissions: none 58