@Test public void testMultipleConnectedDevices() { final String[] pSerials = new String[2]; AdbMonitor monitor = new AdbMonitor(new AdbMonitor.AdbDevicesCallback() { private int i; @Override public void onNewDeviceConnected(String serial) { pSerials[i++] = serial; } }); String packet = "0123456789ABCDEF\tdevice\nFEDCBA9876543210\tdevice\n"; monitor.handlePacket(packet); Assert.assertEquals("0123456789ABCDEF", pSerials[0]); Assert.assertEquals("FEDCBA9876543210", pSerials[1]); }
void handlePacket(String packet) { List<String> currentConnectedDevices = parseConnectedDevices(packet); for (String serial : currentConnectedDevices) { if (!connectedDevices.contains(serial)) { callback.onNewDeviceConnected(serial); } } connectedDevices = currentConnectedDevices; }
AdbMonitor { void handlePacket(String packet) { List<String> currentConnectedDevices = parseConnectedDevices(packet); for (String serial : currentConnectedDevices) { if (!connectedDevices.contains(serial)) { callback.onNewDeviceConnected(serial); } } connectedDevices = currentConnectedDevices; } }
AdbMonitor { void handlePacket(String packet) { List<String> currentConnectedDevices = parseConnectedDevices(packet); for (String serial : currentConnectedDevices) { if (!connectedDevices.contains(serial)) { callback.onNewDeviceConnected(serial); } } connectedDevices = currentConnectedDevices; } AdbMonitor(AdbDevicesCallback callback); }
AdbMonitor { void handlePacket(String packet) { List<String> currentConnectedDevices = parseConnectedDevices(packet); for (String serial : currentConnectedDevices) { if (!connectedDevices.contains(serial)) { callback.onNewDeviceConnected(serial); } } connectedDevices = currentConnectedDevices; } AdbMonitor(AdbDevicesCallback callback); void monitor(); }
AdbMonitor { void handlePacket(String packet) { List<String> currentConnectedDevices = parseConnectedDevices(packet); for (String serial : currentConnectedDevices) { if (!connectedDevices.contains(serial)) { callback.onNewDeviceConnected(serial); } } connectedDevices = currentConnectedDevices; } AdbMonitor(AdbDevicesCallback callback); void monitor();  }