Skip to content

Commit c418c63

Browse files
committed
Show device info in device selector window
1 parent 33912b4 commit c418c63

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

src/processing/mode/android/Device.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
package processing.mode.android;
22

3-
import java.io.IOException;
4-
import java.util.ArrayList;
5-
import java.util.Collections;
6-
import java.util.HashSet;
7-
import java.util.List;
8-
import java.util.Set;
9-
import java.util.regex.Matcher;
10-
import java.util.regex.Pattern;
11-
123
import processing.app.Base;
134
import processing.app.RunnerListener;
145
import processing.app.exec.LineProcessor;
@@ -18,6 +9,11 @@
189
import processing.core.PApplet;
1910
import processing.mode.android.LogEntry.Severity;
2011

12+
import java.io.IOException;
13+
import java.util.*;
14+
import java.util.regex.Matcher;
15+
import java.util.regex.Pattern;
16+
2117

2218
class Device {
2319
private final Devices env;
@@ -47,6 +43,28 @@ public void bringLauncherToFront() {
4743
}
4844
}
4945

46+
public String getName() {
47+
String name = "";
48+
49+
try {
50+
ProcessResult result = AndroidSDK.runADB("-s", id, "shell", "getprop", "ro.product.brand");
51+
if(result.succeeded()) {
52+
name += result.getStdout() + " ";
53+
}
54+
55+
result = AndroidSDK.runADB("-s", id, "shell", "getprop", "ro.product.model");
56+
if(result.succeeded()) {
57+
name += result.getStdout();
58+
}
59+
} catch (InterruptedException e) {
60+
e.printStackTrace();
61+
} catch (IOException e) {
62+
e.printStackTrace();
63+
}
64+
65+
return name + " [" + id + "]";
66+
}
67+
5068
// adb -s emulator-5556 install helloWorld.apk
5169

5270
// : adb -s HT91MLC00031 install bin/Brightness-debug.apk

src/processing/mode/android/DeviceSelector.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ public DeviceSelector() {
2020
}
2121

2222
private void refreshList() {
23-
Devices devices = Devices.getInstance();
24-
java.util.List<Device> deviceList = devices.findMultiple(false);
23+
new Thread() {
24+
public void run() {
25+
Devices devices = Devices.getInstance();
26+
java.util.List<Device> deviceList = devices.findMultiple(false);
2527

26-
String[] data = new String[deviceList.size()];
27-
for(int i = 0; i < deviceList.size(); i++) {
28-
data[i] = deviceList.get(0).toString();
29-
}
28+
String[] data = new String[deviceList.size()];
29+
for(int i = 0; i < deviceList.size(); i++) {
30+
data[i] = deviceList.get(0).getName();
31+
}
3032

31-
list.setListData(data);
33+
list.setListData(data);
34+
}
35+
}.start();
3236
}
3337

3438
private void createLayout() {

0 commit comments

Comments
 (0)