Methods Summary |
---|
private static java.lang.String | buildIsServerRunningShellCommand()
return String.format("service call window %d",
Configuration.SERVICE_CODE_IS_SERVER_RUNNING);
|
private static java.lang.String | buildStartServerShellCommand(int port)
return String.format("service call window %d i32 %d",
Configuration.SERVICE_CODE_START_SERVER, port);
|
private static java.lang.String | buildStopServerShellCommand()
return String.format("service call window %d", Configuration.SERVICE_CODE_STOP_SERVER);
|
public static int | getDeviceLocalPort(com.android.ddmlib.Device device)
synchronized (devicePortMap) {
Integer port = devicePortMap.get(device);
if (port != null) {
return port;
}
Log.e("hierarchy", "Missing forwarded port for " + device.getSerialNumber());
return -1;
}
|
public static com.android.ddmlib.Device[] | getDevices()
return bridge.getDevices();
|
public static void | initDebugBridge()
if (bridge == null) {
AndroidDebugBridge.init(false /* debugger support */);
}
if (bridge == null || !bridge.isConnected()) {
String adbLocation = System.getProperty("hierarchyviewer.adb");
if (adbLocation != null && adbLocation.length() != 0) {
adbLocation += File.separator + "adb";
} else {
adbLocation = "adb";
}
bridge = AndroidDebugBridge.createBridge(adbLocation, true);
}
|
public static boolean | isViewServerRunning(com.android.ddmlib.Device device)
initDebugBridge();
final boolean[] result = new boolean[1];
try {
if (device.isOnline()) {
device.executeShellCommand(buildIsServerRunningShellCommand(),
new BooleanResultReader(result));
}
} catch (IOException e) {
e.printStackTrace();
}
return result[0];
|
public static void | removeDeviceForward(com.android.ddmlib.Device device)
synchronized (devicePortMap) {
final Integer localPort = devicePortMap.get(device);
if (localPort != null) {
device.removeForward(localPort, Configuration.DEFAULT_SERVER_PORT);
devicePortMap.remove(device);
}
}
|
public static void | setupDeviceForward(com.android.ddmlib.Device device)Sets up a just-connected device to work with the view server.
This starts a port forwarding between a local port and a port on the device.
synchronized (devicePortMap) {
if (device.getState() == Device.DeviceState.ONLINE) {
int localPort = nextLocalPort++;
device.createForward(localPort, Configuration.DEFAULT_SERVER_PORT);
devicePortMap.put(device, localPort);
}
}
|
public static void | startListenForDevices(AndroidDebugBridge.IDeviceChangeListener listener)
AndroidDebugBridge.addDeviceChangeListener(listener);
|
public static boolean | startViewServer(com.android.ddmlib.Device device)
return startViewServer(device, Configuration.DEFAULT_SERVER_PORT);
|
public static boolean | startViewServer(com.android.ddmlib.Device device, int port)
initDebugBridge();
final boolean[] result = new boolean[1];
try {
if (device.isOnline()) {
device.executeShellCommand(buildStartServerShellCommand(port),
new BooleanResultReader(result));
}
} catch (IOException e) {
e.printStackTrace();
}
return result[0];
|
public static void | stopListenForDevices(AndroidDebugBridge.IDeviceChangeListener listener)
AndroidDebugBridge.removeDeviceChangeListener(listener);
|
public static boolean | stopViewServer(com.android.ddmlib.Device device)
initDebugBridge();
final boolean[] result = new boolean[1];
try {
if (device.isOnline()) {
device.executeShellCommand(buildStopServerShellCommand(),
new BooleanResultReader(result));
}
} catch (IOException e) {
e.printStackTrace();
}
return result[0];
|
public static void | terminate()
AndroidDebugBridge.terminate();
|