bundletool icon indicating copy to clipboard operation
bundletool copied to clipboard

Should support ADB_SERVER_SOCKET

Open sleekweasel opened this issue 6 years ago • 3 comments

We use adb servers on remote machines, and our tests on our CI, so we need this to support ADB_SERVER_SOCKET just like adb, without killing the remote server in case someone else is using one of the remote devices.

Version 0.10.1

Steps

  1. remote.machine> adb -a -P 9125 nodaemon server
  2. local> ADB_SERVER_SOCKET=tcp:remote.machine:9125 adb devices 2a. emulator-5554 device
  3. local> ADB_SERVER_SOCKET=tcp:remote.machine:9125 java -jar bundletool.jar get-device-spec --output x.json 3a. No connected devices found.

Expected behavior

It would honour ADB_SERVER_SOCKET just like adb does - without killing the remote server.

4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

sleekweasel avatar Jul 17 '19 15:07 sleekweasel

Although ddmlib support DdmPreferences get/set AdbHostValue and UseAdbHost, it doesn't seem that it finished implementing it.

I have a proof of concept working by setting DdmPreferences to ${ADBHOST} in BundleToolMain and copying ddmlib/AndroidDebugBridge.java and replacing the two places where it uses DEFAULT_ADB_HOST with references to

      String adbHost = DdmPreferences.getUseAdbHost() ? DdmPreferences.getAdbHostValue() : DEFAULT_ADB_HOST;

but I can't find the label to configure in my Android source checkout to propose the fix - would you be able to tell me that?

sleekweasel avatar Jul 18 '19 16:07 sleekweasel

I don't see a link to my pull request (which requires a ddm lib file to be patched too) so I'll put it here. I think you need ddmlib changed to get this working.

https://github.com/google/bundletool/pull/93

sleekweasel avatar Aug 24 '22 14:08 sleekweasel

Also, I found some kind of workaround - if the remote emulators' adb is running in promiscuous mode, you can use 'socat' to publish the remote port locally. It's not very nice and if there are connection issues then good luck trying to diagnose them, but:

socat -d tcp-listen:$EMULATOR_ADB_PORT,reuseaddr,fork,bind=$CONTAINER_IP tcp:127.0.0.1:$LOCAL_EMULATOR_ADB_PORT &

sleekweasel avatar Aug 24 '22 14:08 sleekweasel