Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* fixed: device deployment -- fails to pick exact device if multiple is connected #759

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -728,18 +728,16 @@ public static void main(String[] args) throws Exception {
}

if (deviceId == null) {
if (deviceId == null) {
String[] udids = IDevice.listUdids();
if (udids.length == 0) {
System.err.println("No device connected");
return;
}
if (udids.length > 1) {
System.err.println("More than 1 device connected ("
+ Arrays.asList(udids) + "). Using " + udids[0]);
}
deviceId = udids[0];
String[] udids = IDevice.listUdids();
if (udids.length == 0) {
System.err.println("No device connected");
return;
}
if (udids.length > 1) {
System.err.println("More than 1 device connected ("
+ Arrays.asList(udids) + "). Using " + udids[0]);
}
deviceId = udids[0];
}

try (IDevice device = new IDevice(deviceId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package org.robovm.libimobiledevice;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.robovm.libimobiledevice.binding.*;

Expand Down Expand Up @@ -133,11 +135,11 @@ public static String[] listUdids() {
checkResult(LibIMobileDevice.idevice_get_device_list_extended(devicesOut, countOut));
IDeviceInfoArray devices = devicesOut.getValue();
int count = countOut.getValue();
String[] udids = new String[count];
Set<String> udids = new LinkedHashSet<>();
for (int i = 0; i < count; i++) {
udids[i] = devices.get(i).getUdid();
udids.add(devices.get(i).getUdid());
}
return udids;
return udids.toArray(new String[0]);
} catch (LibIMobileDeviceException e) {
if (e.getErrorCode() == IDeviceError.IDEVICE_E_NO_DEVICE.swigValue()) {
// This happens when usbmuxd isn't running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,16 @@ public static void main(String[] args) throws Exception {
}

if (deviceId == null) {
if (deviceId == null) {
String[] udids = IDevice.listUdids();
if (udids.length == 0) {
System.err.println("No device connected");
return;
}
if (udids.length > 1) {
System.err.println("More than 1 device connected ("
+ Arrays.asList(udids) + "). Using " + udids[0]);
}
deviceId = udids[0];
String[] udids = IDevice.listUdids();
if (udids.length == 0) {
System.err.println("No device connected");
return;
}
if (udids.length > 1) {
System.err.println("More than 1 device connected ("
+ Arrays.asList(udids) + "). Using " + udids[0]);
}
deviceId = udids[0];
}

try (IDevice device = new IDevice(deviceId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,16 @@ public static void main(String[] args) throws Exception {
}

if (deviceId == null) {
if (deviceId == null) {
String[] udids = IDevice.listUdids();
if (udids.length == 0) {
System.err.println("No device connected");
return;
}
if (udids.length > 1) {
System.err.println("More than 1 device connected ("
+ Arrays.asList(udids) + "). Using " + udids[0]);
}
deviceId = udids[0];
String[] udids = IDevice.listUdids();
if (udids.length == 0) {
System.err.println("No device connected");
return;
}
if (udids.length > 1) {
System.err.println("More than 1 device connected ("
+ Arrays.asList(udids) + "). Using " + udids[0]);
}
deviceId = udids[0];
}

try (IDevice device = new IDevice(deviceId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ private IDevice waitForDevice(String deviceUdid) throws Exception{
if (udids.length == 1 && (deviceUdid == null || deviceUdid.equals(udids[0]))) {
// single device and it's a match
return new IDevice(udids[0]);
} else if (udids.length > 1 && deviceUdid != null && Arrays.asList(udids).contains(deviceUdid)) {
// multiple devices connected but specified is there
return new IDevice(deviceUdid);
}

String message;
Expand Down
Loading