Android 12 has added the ability for IT admins to disable data signaling over USB on corporate-owned devices (except for the charging function). In order to support this functionality, OEMs must update their USB HAL and utilize the added support for Device Policy Manager APIs.
Device Policy Manager
To support disabling signaling over USB, the following three public APIs are included in
DevicePolicyManager
:
setUsbDataSignalingEnabled(boolean enabled)
is an API that enables or disables USB data signaling by calling theenableUsbDataSignal
API inUsbManager
.canUsbDataSignalingBeDisabled()
is an API that checks whether enabling or disabling USB data signaling is supported on the device.isUsbDataSignalingEnabled()
is an API that checks whether USB data signaling has been enabled.- This is required to check whether or not a policy transparency dialog window is shown. System users can call a hidden variant for this particular API that can be called by the system user to check if USB data signaling has been enabled for a particular user.
Device Policy Manager implementation example
The following is an example of how to implement the Device Policy Manager.class android.app.admin.DevicePolicyManager { /** * Called by device owner or profile owner of an organization-owned managed profile to * enable or disable USB data signaling for the device. When disabled, USB data connections * (except from charging functions) are prohibited. * * <p> This API is not supported on all devices, the caller should call * {@link #canUsbDataSignalingBeDisabled()} to check whether enabling or disabling USB data * signaling is supported on the device. * * @param enabled whether USB data signaling should be enabled or not. * @throws SecurityException if the caller is not a device owner or a profile owner on * an organization-owned managed profile. * @throws IllegalStateException if disabling USB data signaling is not supported or * if USB data signaling fails to be enabled/disabled. */ public void setUsbDataSignalingEnabled(boolean enabled);
/** * Called by device owner or profile owner of an organization-owned managed profile to return * whether USB data signaling is currently enabled by the admin. * * @return {@code true} if USB data signaling is enabled, {@code false} otherwise. */ public boolean isUsbDataSignalingEnabled();
/** * Called by the system to check whether USB data signaling is currently enabled for this user. * * @param userId which user to check for. * @return {@code true} if USB data signaling is enabled, {@code false} otherwise. * @hide */ public boolean isUsbDataSignalingEnabledForUser(@UserIdInt int userId);
/** * Returns whether enabling or disabling USB data signaling is supported on the device. * * @return {@code true} if the device supports enabling and disabling USB data signaling. */ public boolean canUsbDataSignalingBeDisabled();
Settings
Users can modify USB preference and tethering settings as soon as USB is connected. To access the USB preferences screen, do the following:
- Tap Settings.
- Tap Connected devices.
- Tap USB.
Note: If USB is not connected, USB preferences can't be modified and will not appear in the Connected devices window.
If an IT admin disables USB data signaling on a corporate-owned device, the user can't modify their USB preferences. Instead, all USB preferences in Settings are totally disabled, which will create a policy transparency dialog window.
Note: If USB data signaling is disabled, USB debugging, default USB configurations, and USB audio routing preferences will all be disabled in developer options.