feat: add user configurable device serial for adb based emulators#630
Open
martinmiglio wants to merge 3 commits intomasterfrom
Open
feat: add user configurable device serial for adb based emulators#630martinmiglio wants to merge 3 commits intomasterfrom
martinmiglio wants to merge 3 commits intomasterfrom
Conversation
49e4db7 to
3e00461
Compare
582aa15 to
08d3547
Compare
08d3547 to
42f221c
Compare
f9ebf73 to
144f5f5
Compare
JJamesWWang
approved these changes
Jan 17, 2026
Contributor
JJamesWWang
left a comment
There was a problem hiding this comment.
changes generally lgtm, with some minor comments.
tested with google play and changes work as intended 👍🏼
pyclashbot/__main__.py
Outdated
Comment on lines
146
to
180
| if job_dictionary.get("emulator") == EmulatorType.ADB: | ||
| device_serial = job_dictionary.get(UIField.ADB_SERIAL.value) | ||
| connected_devices = AdbController.list_devices() | ||
| connected_devices = AdbController.discover_system_devices() | ||
| if not device_serial or device_serial not in connected_devices: | ||
| logger.change_status(f"Start cancelled: ADB device '{device_serial}' not connected.") | ||
| return None | ||
|
|
||
| if job_dictionary.get("emulator") == EmulatorType.GOOGLE_PLAY: | ||
| device_serial = job_dictionary.get(UIField.GP_DEVICE_SERIAL.value) | ||
| if device_serial: | ||
| adb_path = GooglePlayEmulatorController.find_adb() or "adb" | ||
| connected_devices = AdbController.discover_system_devices(adb_path) | ||
| if device_serial not in connected_devices: | ||
| logger.change_status(f"Start cancelled: Device '{device_serial}' not connected.") | ||
| return None | ||
|
|
||
| if job_dictionary.get("emulator") == EmulatorType.BLUESTACKS: | ||
| device_serial = job_dictionary.get(UIField.BS_DEVICE_SERIAL.value) | ||
| if device_serial: | ||
| adb_path = BlueStacksEmulatorController.find_adb() or "adb" | ||
| connected_devices = AdbController.discover_system_devices(adb_path) | ||
| if device_serial not in connected_devices: | ||
| logger.change_status(f"Start cancelled: Device '{device_serial}' not connected.") | ||
| return None |
Contributor
There was a problem hiding this comment.
nit: there's room for this to be refactored into something like check_device_exists(emulator_type, key_serial, emulator_controller)
Comment on lines
69
to
72
| c = command.strip() | ||
| if c.startswith("-s "): | ||
| return True # Already device-scoped | ||
| first = c.split()[0] if c else "" |
Contributor
There was a problem hiding this comment.
nit: it may be more correct to regex -s <...>; right now your check is:
if not self._is_server_command(command) and self.device_serial:
parts.append(f"-s {self.device_serial}")and running self._is_server_command(full_command) will still return false because you append -s at the end of the command, while here you're checking that the command starts with -s
144f5f5 to
57c23c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes ADB multi-device conflicts that caused false positives for offline emulator detection and app installation checks. Users with multiple ADB devices (USB phones, other emulators, etc.) can now specify which device to target.
Key changes:
-s device_serialadb()implementations into a single base class methodProblem
When multiple ADB devices are connected, commands like
adb shell pm list packagesfail with:This caused:
Solution
All ADB commands are now scoped to a specific device using the
-sflag. Users can:localhost:6520,127.0.0.1:5567)Architecture
Test plan
localhost:6520)