/** Returns whether this device supports the given hardware feature. */ public boolean supportsFeature(@NonNull HardwareFeature feature) { if (mHardwareCharacteristics == null) { try { String characteristics = getSystemProperty(PROP_BUILD_CHARACTERISTICS).get(); mHardwareCharacteristics = new HashSet<>(); Collections.addAll(mHardwareCharacteristics, characteristics.split(",")); } catch (Exception e) { mHardwareCharacteristics = Collections.emptySet(); } } return mHardwareCharacteristics.contains(feature.getCharacteristic()); }
private String constructName() { String manufacturer = null; String model = null; try { manufacturer = cleanupStringForDisplay( getSystemProperty(PROP_DEVICE_MANUFACTURER).get()); model = cleanupStringForDisplay( getSystemProperty(PROP_DEVICE_MODEL).get()); } catch (Exception e) { // If there are exceptions thrown while attempting to get these properties, // we can just use the serial number, so ignore these exceptions. } StringBuilder sb = new StringBuilder(20); if (manufacturer != null) { sb.append(manufacturer); sb.append(SEPARATOR); } if (model != null) { sb.append(model); sb.append(SEPARATOR); } sb.append(getSerialNumber()); return sb.toString(); }
/** * 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.getSystemProperty(IDevice.PROP_BUILD_API_LEVEL);