The way I have been controlling is using adb shell commands and it works well. I used this as a reference