diff options
author | Siva Velusamy <vsiva@google.com> | 2012-04-20 16:08:50 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-04-20 16:08:51 -0700 |
commit | bcfb71ca12af511996cf5fc90c6bf38e6bb55a20 (patch) | |
tree | 31a621e72b7a427121a4af65ff350956d6266d26 | |
parent | 622512420652f1622a8d0ca9b64845e2a0288aa9 (diff) | |
parent | 047400e2c752b070ca008d1b09db4e8778f8aaff (diff) | |
download | sdk-bcfb71ca12af511996cf5fc90c6bf38e6bb55a20.zip sdk-bcfb71ca12af511996cf5fc90c6bf38e6bb55a20.tar.gz sdk-bcfb71ca12af511996cf5fc90c6bf38e6bb55a20.tar.bz2 |
Merge "Fixes unexpected rows are copied when LogCat paused."
-rw-r--r-- | ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java | 10 | ||||
-rw-r--r-- | ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java | 34 |
2 files changed, 37 insertions, 7 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java index 7651250..0d0e3c2 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java @@ -82,6 +82,16 @@ public final class LogCatMessageList { } /** + * Returns the number of additional elements that this queue can + * ideally (in the absence of memory or resource constraints) + * accept without blocking. + * @return the remaining capacity + */ + public synchronized int remainingCapacity() { + return mQ.remainingCapacity(); + } + + /** * Clear all messages in the list. */ public synchronized void clear() { 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 43dddf1..7aa0328 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java @@ -132,6 +132,9 @@ public final class LogCatPanel extends SelectionDependentPanel private List<LogCatFilter> mLogCatFilters; private int mCurrentSelectedFilterIndex; + private int mRemovedEntriesCount = 0; + private int mPreviousRemainingCapacity = 0; + private ToolItem mNewFilterToolItem; private ToolItem mDeleteFilterToolItem; private ToolItem mEditFilterToolItem; @@ -554,6 +557,8 @@ public final class LogCatPanel extends SelectionDependentPanel mReceiver.clearMessages(); refreshLogCatTable(); + mRemovedEntriesCount = 0; + // the filters view is not cleared unless the filters are re-applied. updateAppliedFilters(); } @@ -685,7 +690,9 @@ public final class LogCatPanel extends SelectionDependentPanel List<LogCatMessage> filteredItems = applyCurrentFilters((LogCatMessageList) input); List<LogCatMessage> selectedMessages = new ArrayList<LogCatMessage>(indices.length); for (int i : indices) { - if (i < filteredItems.size()) { + // consider removed logcat message entries + i -= mRemovedEntriesCount; + if (i >= 0 && i < filteredItems.size()) { LogCatMessage m = filteredItems.get(i); selectedMessages.add(m); } @@ -1030,8 +1037,18 @@ public final class LogCatPanel extends SelectionDependentPanel public void messageReceived(List<LogCatMessage> receivedMessages) { refreshLogCatTable(); - updateUnreadCount(receivedMessages); - refreshFiltersTable(); + if (mShouldScrollToLatestLog) { + updateUnreadCount(receivedMessages); + refreshFiltersTable(); + } else { + LogCatMessageList messageList = mReceiver.getMessages(); + int remainingCapacity = messageList.remainingCapacity(); + if (remainingCapacity == 0) { + mRemovedEntriesCount += + receivedMessages.size() - mPreviousRemainingCapacity; + } + mPreviousRemainingCapacity = remainingCapacity; + } } /** @@ -1098,6 +1115,7 @@ public final class LogCatPanel extends SelectionDependentPanel /** Scroll to the last line. */ private void scrollToLatestLog() { + mRemovedEntriesCount = 0; mViewer.getTable().setTopIndex(mViewer.getTable().getItemCount() - 1); } @@ -1170,10 +1188,12 @@ public final class LogCatPanel extends SelectionDependentPanel sb.append('\n'); } - clipboard.setContents( - new Object[] {sb.toString()}, - new Transfer[] {TextTransfer.getInstance()} - ); + if (sb.length() > 0) { + clipboard.setContents( + new Object[] {sb.toString()}, + new Transfer[] {TextTransfer.getInstance()} + ); + } } /** Select all items in the logcat table. */ |