I can open "Use USB to" system dialog by:
val p = Runtime.getRuntime().exec(arrayOf("su", "-c", "system/bin/sh"))
val stdout = DataOutputStream(p.outputStream)
stdout.writeBytes("am start com.android.settings/.UsbSettings")
stdout.flush()
stdout.close()
I also would like to select any of choice programmatically (for example "Transfer files")?
Is this possible with rooted Android?
Update
Seems I can play with input keyevent https://stackoverflow.com/a/28969112/9766649 (e.g. 61 --> "KEYCODE_TAB" and 62 -->  "KEYCODE_SPACE" are useful)
