Class ShadowUsbManager

    • Constructor Detail

      • ShadowUsbManager

        public ShadowUsbManager()
    • Method Detail

      • hasPermission

        @Implementation
        protected boolean hasPermission​(UsbDevice device)
        Returns true if the caller has permission to access the device.
      • hasPermissionForPackage

        public boolean hasPermissionForPackage​(UsbDevice device,
                                               String packageName)
        Returns true if the given package has permission to access the device.
      • revokePermission

        public void revokePermission​(UsbDevice device,
                                     String packageName)
        Revokes permission to a USB device granted to a package. This method does nothing if the package doesn't have permission to access the device.
      • getDeviceList

        @Implementation
        protected HashMap<String,​UsbDevice> getDeviceList()
        Returns a HashMap containing all USB devices currently attached. USB device name is the key for the returned HashMap. The result will be empty if no devices are attached, or if USB host mode is inactive or unsupported.
      • setAttachedUsbAccessory

        public void setAttachedUsbAccessory​(UsbAccessory usbAccessory)
        Sets the currently attached Usb accessory returned in #getAccessoryList.
      • addOrUpdateUsbDevice

        public void addOrUpdateUsbDevice​(UsbDevice usbDevice,
                                         boolean hasPermission)
        Adds a USB device into available USB devices map with permission value. If the USB device already exists, updates the USB device with new permission value.
      • removeUsbDevice

        public void removeUsbDevice​(UsbDevice usbDevice)
        Removes a USB device from available USB devices map.
      • clearPorts

        public void clearPorts()
        Remove all added ports from UsbManager.
      • addPort

        public void addPort​(String portId)
        Adds a USB port with given ID to UsbManager.
      • addPort

        public void addPort​(String portId,
                            int statusCurrentMode,
                            int statusCurrentPowerRole,
                            int statusCurrentDataRole,
                            int statusSupportedRoleCombinations)
        Adds a USB port with given ID and UsbPortStatus parameters to UsbManager for Q+.