On LineageOS (and most Android-based systems), you can use ADB (Android Debug Bridge) to enable or disable the "Restrict USB" setting, which is part of Android's USB Guard or USB restrictions feature. This setting is often used to prevent data transfer or unauthorized access via USB when the device is locked.
(Ensure your device is listed and authorized.)bashadb devices
Use the following ADB command to enable or disable USB restrictions:
bashadb shell settings put global usb_restricted_mode [0|1]
0 = Disable USB restrictions (allow data transfer when locked).1 = Enable USB restrictions (block data transfer when locked).To check the current status:
bashadb shell settings get global usb_restricted_mode
1 if enabled, 0 if disabled.bashadb shell settings list global | grep usb