diff options
author | Siva Velusamy <vsiva@google.com> | 2011-10-10 10:48:34 -0700 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2011-10-10 10:48:34 -0700 |
commit | a6dc10887d24122fa8a9d8b590ac7eff2c36724c (patch) | |
tree | cb4b26b04a5df0d86d9a7537e6bc25b6bcdc1c24 /ddms/libs | |
parent | 9d02c9ee4fa5a92420fa16e0e762d9cd079cee17 (diff) | |
download | sdk-a6dc10887d24122fa8a9d8b590ac7eff2c36724c.zip sdk-a6dc10887d24122fa8a9d8b590ac7eff2c36724c.tar.gz sdk-a6dc10887d24122fa8a9d8b590ac7eff2c36724c.tar.bz2 |
Fix NPE when getCurrentDevice() == null.
Change-Id: I0f9eaf599b5ab22487408ea74d597ea61a22793f
Diffstat (limited to 'ddms/libs')
-rw-r--r-- | ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java index b34b756..35cef96 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java @@ -17,6 +17,8 @@ package com.android.ddmuilib.logcat; import com.android.ddmlib.DdmConstants; +import com.android.ddmlib.IDevice; +import com.android.ddmlib.Log; import com.android.ddmlib.Log.LogLevel; import com.android.ddmuilib.ITableFocusListener; import com.android.ddmuilib.ImageLoader; @@ -122,6 +124,8 @@ public final class LogCatPanel extends SelectionDependentPanel private static final int[] WEIGHTS_SHOW_FILTERS = new int[] {15, 85}; private static final int[] WEIGHTS_LOGCAT_ONLY = new int[] {0, 100}; + private static final String LOG_TAG = "LogCatPanel"; + private LogCatReceiver mReceiver; private IPreferenceStore mPrefStore; @@ -215,6 +219,14 @@ public final class LogCatPanel extends SelectionDependentPanel @Override public void deviceSelected() { + IDevice device = getCurrentDevice(); + if (device == null) { + // If the device is not working properly, getCurrentDevice() could return null. + // In such a case, we don't launch logcat, nor switch the display. + Log.e(LOG_TAG, "Device selected, but getCurrentDevice() == null"); + return; + } + if (mReceiver != null) { // Don't need to listen to new logcat messages from previous device anymore. mReceiver.removeMessageReceivedEventListener(this); @@ -225,7 +237,7 @@ public final class LogCatPanel extends SelectionDependentPanel } } - mReceiver = LogCatReceiverFactory.INSTANCE.newReceiver(getCurrentDevice(), mPrefStore); + mReceiver = LogCatReceiverFactory.INSTANCE.newReceiver(device, mPrefStore); mReceiver.addMessageReceivedEventListener(this); mViewer.setInput(mReceiver.getMessages()); |