Programmatically set device USB to camera vs media

When I execute my automation on a real device it doesn’t work when the USB is Media vs Camera. Once I set it to camera it occasionally switches back to media which screws up my test because it cannot find the android device.

Does anyone know a way to programmatically set the USB before connecting to there android device?

I’ll keep digging.