Well, if App can not switch the USB by code, I understand, thank you.
----
I think I've found a bug here, but I think it's on Android 5, because Android 4 works.
I use a motorola lapdock to display the screen by HDMI cable. And your keyboard (and touchpad) over USB.
I tested it for the same device (TV box RK3229) it has 4 USB ports, one of them can work as a device to be connected to the PC (similar to Tablet).
----
With ROM Android 5.1:
For App without "Start At Boot": The Lapdock has blocked the serial cable. (App and its service are not started after initialization).
If I use a USB HUB to lapdock, the serial cable works.If I use a USB HUB for lapdock and the same HUB for the serial cable, the serial cable works as well.
The application service has been activated (after boot), the cable LED indicator blinks, but the activity is not displayed (with USB HUB or not).
For App with "Start at startup" (true): The LED indicator flashes (service activated after startup) and Activity is not yet displayed, and then after a few moments Activity is shown.
If I leave only the serial cable connected to the USB port, without the Lapdock, the cable will work.
----
With Android 4.4:Lapdock did not block the serial cable (Start At Boot: true or false).
After the startup, the App service starts and Activity is displayed normally, the LED indicator flashes normally.
----
Note: For another ROM, with Android 5.1, the service was terminated after returning to Home, but I believe it is an error of this ROM. For other ROMs the service was not terminated.
----
I have a gadget with Android 6, but I still have not been able to activate the USB host, if I can test, I put the result.
----
I have seen that the usb device / host mode configuration option, forces the reboot of this USB port, it's present in the Android 4.4 or Android 5.1 settings (for TV box). Maybe the App of user have some way to access this setting, as it is available for the App Settings.
Thank you.