public String getName() { if (mName != null) { return mName; } if (isOnline()) { // cache name only if device is online mName = constructName(); return mName; } else { return constructName(); } }
@Override public String getName() { if (mName != null) { return mName; } if (isOnline()) { // cache name only if device is online mName = constructName(); return mName; } else { return constructName(); } }
/** * Updates the device list with the new items received from the monitoring service. */ private void updateDevices(@NonNull List<Device> newList) { DeviceListComparisonResult result = DeviceListComparisonResult.compare(mDevices, newList); for (Device device : result.removed) { removeDevice(device); AndroidDebugBridge.deviceDisconnected(device); } List<Device> newlyOnline = new ArrayList<>(mDevices.size()); for (Map.Entry<Device, DeviceState> entry : result.updated.entrySet()) { Device device = entry.getKey(); device.setState(entry.getValue()); if (device.isOnline()) { newlyOnline.add(device); } } for (Device device : result.added) { mDevices.add(device); AndroidDebugBridge.deviceConnected(device); if (device.isOnline()) { newlyOnline.add(device); } } for (Device device : newlyOnline) { // Initiate a property fetch so that future requests can be served out of this cache. // This is necessary for backwards compatibility device.getSystemProperty(Device.PROP_BUILD_API_LEVEL); } }
device.update(Device.CHANGE_STATE); if (device.isOnline()) { newlyOnline.add(device);