> My old no-name Android phone (not USB C) has such an option, and searching around it seems to be a reasonably common feature, although not present on all devices.
I use one of these. The nice thing about the newer versions is that you can verify the impossibility of a data connection through easy physical inspection.
https://www.amazon.com/PortaPow-3rd-Data-Blocker-Pack/dp/B00...
If my Moto G5+ is locked then it seems that plugging in a keyboard behaves pretty much like plugging a keyboard into a desktop or laptop computer except that it doesn't respond to c-a-del.
I can unlock from the external keyboard by pressing the windows key and then typing my pin number but the multimedia keys and print screen on the keyboard work even with the screen locked.
I would rather that it didn't do any of that until I give permission on the mobile itself.
My old no-name Android phone (not USB C) has such an option, and searching around it seems to be a reasonably common feature, although not present on all devices. It looks similar to this (mine has the same typo, "USB fuctions"):
https://farm8.staticflickr.com/7485/16035739946_51d110ea40.j...
In charge-only mode it doesn't even enumerate as a USB device when plugged into a computer with an active USB controller, so I suspect no attacks (besides physical ones like overvolting as others here have mentioned) are possible in this mode --- the USB controller on the device is completely disabled.