Skip to content

Commit

Permalink
select correct android device if only one is active
Browse files Browse the repository at this point in the history
(cherry picked from commit 2d912e3)
  • Loading branch information
ElenaDiachenko committed Sep 20, 2024
1 parent 10be8c7 commit a3dcc8f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/sdk-android/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,22 @@ export const getAndroidDeviceToRunOn = async () => {
}
logDebug('Target not found, asking where to run');
return askWhereToRun();
} else if (activeDevices.length === 1 && device) {
logDebug('Device provided', device);
if (_isString(device)) {
if (foundDevice) {
if (foundDevice.isActive) {
return foundDevice;
}
}
return askWhereToRun();
}
const availableDevice = activeDevices[0];
logInfo(`Found device ${availableDevice.name}:${availableDevice.udid}`);
return availableDevice;
} else if (defaultTarget) {
// neither a target nor an active device is found, revert to default target if available
logDebug('Default target used', defaultTarget);
logDefault('Default target used', defaultTarget);
const foundDevice = devicesAndEmulators.find(
(d) => d.udid.includes(defaultTarget) || d.name.includes(defaultTarget)
);
Expand Down

0 comments on commit a3dcc8f

Please sign in to comment.