ashishb / adb-enhanced

🔪Swiss-army knife for Android testing and development 🔪 ⛺
https://ashishb.net/tech/introducing-adb-enhanced-a-swiss-army-knife-for-android-development/
Apache License 2.0
1.23k stars 80 forks source link

Multiple devices support #210

Closed lwasyl closed 1 year ago

lwasyl commented 1 year ago

Reopening https://github.com/ashishb/adb-enhanced/issues/128 as new issue, per Github's suggestion: image


I think having some sort of multiple devices support might be a nice addition, or at least some sort of enhanced wrapping around existing multi-device capabilities of adb. Couple of ideas/suggestions that I feel would make my workflow easier:

I realize all of those are tricky and require a bit more thought than simply adding a new command (e.g. what if currently used device is disconnected?) but choosing the device with regular adb is clunky and seems like something that adbe could improve upon

ashishb commented 1 year ago

Thanks for the suggestion.

I did consider ANDROID_SERIAL but it seems like one can always create a temporary shell alias to do that instead.

show a device picker when multiple devices are connected, so instead of the command failing, I'd be able to choose which device to run the command on

This is nice. Right now, there is a warning but you are right, it can definitely improve.

opt-in to running a command on all devices, accepting that the output might be not helpful.

I like this idea, may by -m mode for certain commands like uninstall or rotate where there isn't a desire to care about the output?

lwasyl commented 1 year ago

I did consider ANDROID_SERIAL but it seems like one can always create a temporary shell alias to do that instead.

The hurdle I aimed to improve is extracting the proper value of ANDROID_SERIAL. For example if I start two different emulators, they might have different serial values (5554 or 5556), so I'd need to create more aliases with all the possible values beforehand. This, coupled with different serial values when wifi debugging is used means you'd need several aliases with just a handful of devices. That's why I suggested to have adbe set proper ANDROID_SERIAL for me

mode for certain commands like uninstall or rotate where there isn't a desire to care about the output?

Exactly, I think there's a number of commands that either realistically never fail (like show-taps) or the failure would mean the desired result is achieved (like uninstall). If it's possible to only allow such multi-device mode for particular commands, I think it makes perfect sense :+1:

ashishb commented 1 year ago

Exactly, I think there's a number of commands that either realistically never fail (like show-taps) or the failure would mean the desired result is achieved (like uninstall). If it's possible to only allow such multi-device mode for particular commands, I think it makes perfect sense

Indeed.

Do you know sufficient Python and would you like to add a new -m parameter? You can start by adding it to exactly one command say show-taps and then add it to more commands later on.

Most of the glue code to run against particular ANDROID_SERIAL is already there. What you are looking for is a function to just get a list of serials and that's present as well (see adbe devices command) and run against all the serials one by one while printing the result.

stavfx commented 1 year ago

A device picker would be great, I've been using a similar script for a few years and it makes a huge difference. I wound add that a "run on all devices" sound be added of anyone is taking the time to add a device picker. (I might do it, but I've written about 50 lines of python my whole life)

ashishb commented 1 year ago

@stavfx Thanks I will consider adding it. As of now, --serial is supported. This allows you to run against a particular device.