Skip to content

Commit

Permalink
check how many non-emulator devices are available
Browse files Browse the repository at this point in the history
  • Loading branch information
codeanticode committed Aug 6, 2017
1 parent d697d75 commit 2b0f03a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/processing/mode/android/AndroidEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void run() {
if (androidMode == null || androidMode.getSDK() == null) return;

if (appComponent == AndroidBuild.WATCHFACE) {
Devices.enableBlueToothDebugging();
Devices.enableBluetoothDebugging();
}

final Devices devices = Devices.getInstance();
Expand Down
17 changes: 14 additions & 3 deletions src/processing/mode/android/Devices.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,22 @@ public static void killAdbServer() {
}
}

public static void enableBlueToothDebugging() {
public static void enableBluetoothDebugging() {
final Devices devices = Devices.getInstance();
java.util.List<Device> deviceList = devices.findMultiple(false);

if (deviceList.size() != 1) {
// There is more than one non-emulator device connected to the computer,
// but don't know which one the watch could be paired to... or the watch
// is already paired to the phone, in which case we don't need to keep
// trying to connect.
return;
}
Device device = deviceList.get(0);
try {
// Enable debugging over bluetooth
// Try Enable debugging over bluetooth
// http://developer.android.com/training/wearables/apps/bt-debugging.html
AndroidSDK.runADB("forward", "tcp:" + BT_DEBUG_PORT, "localabstract:/adb-hub");
AndroidSDK.runADB("-s", device.getId(), "forward", "tcp:" + BT_DEBUG_PORT, "localabstract:/adb-hub");
AndroidSDK.runADB("connect", "127.0.0.1:" + BT_DEBUG_PORT);
} catch (final Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 2b0f03a

Please sign in to comment.