diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2013-01-22 17:37:44 -0800 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2013-01-22 18:18:17 -0800 |
commit | 2cd8cae457b25efbd83c87f8ee8fa582281d8829 (patch) | |
tree | c5f23ee7c80ee89d3e05a262e74f6438676f1eb1 /hierarchyviewer2/libs | |
parent | 9f1289904984b750300dc07cf52322f05d5d987c (diff) | |
download | sdk-2cd8cae457b25efbd83c87f8ee8fa582281d8829.zip sdk-2cd8cae457b25efbd83c87f8ee8fa582281d8829.tar.gz sdk-2cd8cae457b25efbd83c87f8ee8fa582281d8829.tar.bz2 |
Fix bug #8054449 hierarchyviewer crashes on connection/disconnections
- fix various NPEs
Change-Id: I9157b9072c822146874d1c693a81c024fa5fe5f2
Diffstat (limited to 'hierarchyviewer2/libs')
3 files changed, 8 insertions, 3 deletions
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java index 4bd5d6b..0febcef 100644 --- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java +++ b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java @@ -135,14 +135,14 @@ public class ViewServerDevice extends AbstractHvDevice { @Override public void addWindowChangeListener(IWindowChangeListener l) { - if (mViewServerInfo.protocolVersion >= 3) { + if (mViewServerInfo != null && mViewServerInfo.protocolVersion >= 3) { WindowUpdater.startListenForWindowChanges(l, mDevice); } } @Override public void removeWindowChangeListener(IWindowChangeListener l) { - if (mViewServerInfo.protocolVersion >= 3) { + if (mViewServerInfo != null && mViewServerInfo.protocolVersion >= 3) { WindowUpdater.stopListenForWindowChanges(l, mDevice); } } diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java index 9dbb989..a67d400 100644 --- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java +++ b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java @@ -72,6 +72,9 @@ public class WindowUpdater { public static void stopListenForWindowChanges(IWindowChangeListener listener, IDevice device) { synchronized (sWindowChangeListeners) { ArrayList<IWindowChangeListener> listeners = sWindowChangeListeners.get(device); + if (listeners == null) { + return; + } listeners.remove(listener); // There are more listeners, so don't stop the listening thread. if (listeners.size() != 0) { diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java index c3154c8..ae8ad26 100644 --- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java +++ b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java @@ -330,7 +330,9 @@ public class DeviceSelector extends Composite implements IWindowChangeListener, @Override public void widgetSelected(SelectionEvent e) { - Object selection = ((TreeItem) e.item).getData(); + TreeItem item = (TreeItem) e.item; + if (item == null) return; + Object selection = item.getData(); if (selection instanceof IHvDevice) { mModel.setSelection((IHvDevice) selection, null); } else if (selection instanceof Window) { |