@VisibleForTesting static Map<String, DeviceState> parseDeviceListResponse(@Nullable String result) { Map<String, DeviceState> deviceStateMap = Maps.newHashMap(); String[] devices = result == null ? new String[0] : result.split("\n"); //$NON-NLS-1$ for (String d : devices) { String[] param = d.split("\t"); //$NON-NLS-1$ if (param.length == 2) { // new adb uses only serial numbers to identify devices deviceStateMap.put(param[0], DeviceState.getState(param[1])); } } return deviceStateMap; }
/** * Processes an incoming device message from the socket * @param socket * @param length * @throws IOException */ private void processIncomingDeviceData(int length) throws IOException { ArrayList<Device> list = new ArrayList<Device>(); if (length > 0) { byte[] buffer = new byte[length]; String result = read(mMainAdbConnection, buffer); String[] devices = result.split("\n"); //$NON-NLS-1$ for (String d : devices) { String[] param = d.split("\t"); //$NON-NLS-1$ if (param.length == 2) { // new adb uses only serial numbers to identify devices Device device = new Device(this, param[0] /*serialnumber*/, DeviceState.getState(param[1])); //add the device to the list list.add(device); } } } // now merge the new devices with the old ones. updateDevices(list); }