@Test public void testHandlePacketOffline() { final String[] pSerial = new String[1]; AdbMonitor monitor = new AdbMonitor((serial) -> pSerial[0] = serial); String packet = "0123456789ABCDEF\toffline\n"; monitor.handlePacket(packet); Assert.assertNull(pSerial[0]); }
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();  }