androiddebuggingusbrsamonkeyrunner

Android automate usb debugging (rsa fingerprint)


I'm trying to fully automate the CTS tests (including the Google registration part), but I'm running into a bit of a problem with the USB debugging/RSA fingerprint dialog that comes up when you first connect your device to the computer. Without manually pressing the OK button, the ADB cannot detect the device, so my Monkeyrunner script will not start. How would you go about automatically confirming this dialog? Better yet, is there a way to auto-accept the RSA fingerprint from the computer so at the very least ADB communication can be established so that the Monkeyrunner script can click on the dialog?

I've tried:

  1. Pre-installing an APK in the system/app partition that makes calls to Settings.Global.putInt(...) to enable USB debugging by default, but you still get the confirmation dialog.
  2. Modifying the default.prop file found in the ramdisk part of the boot.img image, but you still get the same problem as 1)
  3. Extracting the relevant bits of code from UsbDebuggingManager.java to extract the RSA fingerprint and putting it in an APK, but I get a "Connection Failed" error.

Is there something I overlooked? Or is this impossible without swapping the Kernel with another one?


Solution

  • Actually, I realized I made a mistake when flashing the boot.img file back onto the device. Now that I've got it flashed correctly, I am no longer prompted with the USB Debugging dialog in the beginning.

    Make sure you have the following flags set in your default.prop:

    ro.debuggable=1
    persist.sys.usb.config=mtp,adb
    ro.adb.secure=0
    

    and you should be good to go. With these set, it's not necessary to pre-install an APK into the system/app folder to change the ADB_ENABLED settings using Settings.Global.putint(...)