diff options
author | Siva Velusamy <vsiva@google.com> | 2011-12-20 16:15:11 -0800 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2011-12-20 16:24:27 -0800 |
commit | 615441726b9a35b63a8db16af14729bc9fa72f14 (patch) | |
tree | c0091415ee5038a4fd0c4e26c38cb933a4ae1a15 /ddms | |
parent | 3d73211da767ae07698d12db1f6d6f8a0b0ed7bd (diff) | |
download | sdk-615441726b9a35b63a8db16af14729bc9fa72f14.zip sdk-615441726b9a35b63a8db16af14729bc9fa72f14.tar.gz sdk-615441726b9a35b63a8db16af14729bc9fa72f14.tar.bz2 |
ddms: display manufacturer & model for devices.
DDMS displays only the serial number for connected devices.
This patch appends the manufacturer & model name to the serial
number.
Change-Id: I90400365fe984b0b0a198e3c21aaf25eb05aa930
Diffstat (limited to 'ddms')
-rw-r--r-- | ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java index db1ebc6..dc391a6 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java @@ -152,6 +152,8 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen * labels and images for {@link IDevice} and {@link Client} objects. */ private class LabelProvider implements ITableLabelProvider { + private static final String DEVICE_MODEL_PROPERTY = "ro.product.model"; //$NON-NLS-1$ + private static final String DEVICE_MANUFACTURER_PROPERTY = "ro.product.manufacturer"; //$NON-NLS-1$ public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == DEVICE_COL_SERIAL && element instanceof IDevice) { @@ -198,7 +200,7 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen IDevice device = (IDevice)element; switch (columnIndex) { case DEVICE_COL_SERIAL: - return device.getSerialNumber(); + return getDeviceName(device); case DEVICE_COL_STATE: return getStateString(device); case DEVICE_COL_BUILD: { @@ -261,6 +263,54 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen return null; } + private String getDeviceName(IDevice device) { + StringBuilder sb = new StringBuilder(20); + sb.append(device.getSerialNumber()); + + if (device.isEmulator()) { + sb.append(String.format(" [%s]", device.getAvdName())); + } else { + String manufacturer = device.getProperty(DEVICE_MANUFACTURER_PROPERTY); + manufacturer = cleanupStringForDisplay(manufacturer); + + String model = device.getProperty(DEVICE_MODEL_PROPERTY); + model = cleanupStringForDisplay(model); + + boolean hasManufacturer = manufacturer.length() > 0; + boolean hasModel = model.length() > 0; + if (hasManufacturer || hasModel) { + sb.append(" ["); //$NON-NLS-1$ + sb.append(manufacturer); + + if (hasManufacturer && hasModel) { + sb.append(':'); + } + + sb.append(model); + sb.append(']'); + } + } + + return sb.toString(); + } + + private String cleanupStringForDisplay(String s) { + if (s == null) { + return ""; + } + + StringBuilder sb = new StringBuilder(s.length()); + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + + if (Character.isLetterOrDigit(c)) { + sb.append(c); + } + } + + return sb.toString(); + } + public void addListener(ILabelProviderListener listener) { // pass } |