robotnix icon indicating copy to clipboard operation
robotnix copied to clipboard

Auto-start adb with trusted keys

Open Atemu opened this issue 3 years ago • 6 comments

So this is a fairly specific problem I'm having but might have general usefulness.

I've got a friend's cheeseburger where the screen is almost entirely broken. Glass shattered, no image and only a portion of the screen registers touch.

Bootloader is unlocked though and I can control the device via adb, fastboot and/or twrp.

I plan to use this device as a guinea pig to test without risking breaking my daily driver.

However, I cannot trivially control android itself. I need adb to be enabled in order to use use scrcpy to do anything, including enabling adb.
This can be solved by enabling adb from the recovery: https://gist.github.com/niikoo/3f6bd13a69f2d68f3dd51cc667e79bdc (property step is unnecessary)

You basically need to set some system build.props and push your public key; akin to enabling ssh and pushing a trusted key.

Is it possible to bake these into the system image for simplicity?

Atemu avatar Mar 22 '22 12:03 Atemu

I think using an eng build instead of userdebug might do this:

  • https://source.android.com/setup/build/building#choose-a-target

But I also believe LineageOS has slightly different semantics for userdebug than AOSP does. [citation needed].

samueldr avatar Mar 22 '22 16:03 samueldr

Oh, we even have a variant option for that! I'll try that tomorrow.

I'd still kind of like to have a regular userdebug build but with adb running.

Atemu avatar Mar 22 '22 20:03 Atemu

I do this to embed my adb vendor keys:

  product.extraConfig = ''
    # Uncomment as needed
    #PRODUCT_SYSTEM_PROPERTIES += persist.service.adb.enable=1
    #PRODUCT_SYSTEM_PROPERTIES += persist.service.debuggable=1
    #PRODUCT_SYSTEM_PROPERTIES += persist.sys.usb.config=mtp,adb
    PRODUCT_ADB_KEYS := ${./adbkey.pub}
  '';

zhaofengli avatar Mar 22 '22 22:03 zhaofengli

Thanks a bunch @zhaofengli but unfortunately, that doesn't seem to work. My system's build.prop doesn't contain those proerties and adb isn't started.

Atemu avatar Mar 23 '22 15:03 Atemu

Wait, shouldn't that go to system.extraConfig?

Atemu avatar Mar 23 '22 15:03 Atemu

That doesn't work either. Any idea?

I'm using LineageOS, maybe that's why.

Atemu avatar Mar 24 '22 14:03 Atemu