How do I specify how a device USB can be used?

Use the following APIs:

  • RestrictionPolicy.allowUsbHostStorage(): to enable or disable USB host storage. If enabled, a user can connect any portable USB storage, external HD, or Secure Digital (SD) card reader, which is mounted as a storage drive on the device. If disabled, the user cannot mount an external storage device.
  • RestrictionPolicy.setUsbExceptionList(): to set the USB class exception list. If set, all USB device classes are blocked except the classes in the exception list.


  • Enable only keyboard and mice: allowUsbHostStorage(true), setUsbExceptionList(HID).
  • Enable only Ethernet ports: allowUsbHostStorage(true), setUsbExceptionList(VEN:CDC:COM).
  • Block all USB devices: allowUsbHostStorage(true), setUsbExceptionList(OFF).

Here is some sample source code to disable all USB interfaces except HID devices like mice and keyboards:

EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
// enable only mice and keyboards
RestrictionPolicy restrictionPolicy = edm.getRestrictionPolicy();

For information about enabling and disabling DeX, see How do I enable and disable DeX?