summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-07-27 18:39:21 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-07-27 18:39:21 -0700
commit8b67752c82a26e21fe0977cb5e201acf2e22824d (patch)
treec2d81850e571530c5a7a9fe13568fe264f4b4690 /services
parent42d8f6f2fbf2d73f01dd485e043bc33b575f9881 (diff)
parent931ee98cc05aedaf0a7cdf0b7ec503a8586359f5 (diff)
downloadframeworks_base-8b67752c82a26e21fe0977cb5e201acf2e22824d.zip
frameworks_base-8b67752c82a26e21fe0977cb5e201acf2e22824d.tar.gz
frameworks_base-8b67752c82a26e21fe0977cb5e201acf2e22824d.tar.bz2
am 931ee98c: am b7304593: Merge "Cap the size of StrictMode buffering we do before calling DropBox." into gingerbread
Merge commit '931ee98cc05aedaf0a7cdf0b7ec503a8586359f5' * commit '931ee98cc05aedaf0a7cdf0b7ec503a8586359f5': Cap the size of StrictMode buffering we do before calling DropBox.
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index fa2ec1f..440ebbd 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6173,7 +6173,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return;
boolean bufferWasEmpty;
-
+ boolean needsFlush;
final StringBuilder sb = isSystemApp ? mStrictModeBuffer : new StringBuilder(1024);
synchronized (sb) {
bufferWasEmpty = sb.length() == 0;
@@ -6188,18 +6188,32 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
sb.append(crashInfo.stackTrace);
}
sb.append("\n");
+
+ // Only buffer up to ~64k. Various logging bits truncate
+ // things at 128k.
+ needsFlush = (sb.length() > 64 * 1024);
}
- // Non-system apps are isolated with a different tag & policy.
- // They're also not batched. Batching is useful during system
- // boot with strict system-wide logging policies and lots of
- // things firing, but not common with regular apps, which
- // won't ship with StrictMode dropboxing enabled.
- if (!isSystemApp) {
+ // Flush immediately if the buffer's grown too large, or this
+ // is a non-system app. Non-system apps are isolated with a
+ // different tag & policy and not batched.
+ //
+ // Batching is useful during internal testing with
+ // StrictMode settings turned up high. Without batching,
+ // thousands of separate files could be created on boot.
+ if (!isSystemApp || needsFlush) {
new Thread("Error dump: " + dropboxTag) {
@Override
public void run() {
- dbox.addText(dropboxTag, sb.toString());
+ String report;
+ synchronized (sb) {
+ report = sb.toString();
+ sb.delete(0, sb.length());
+ sb.trimToSize();
+ }
+ if (report.length() != 0) {
+ dbox.addText(dropboxTag, report);
+ }
}
}.start();
return;
@@ -6207,8 +6221,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
// System app batching:
if (!bufferWasEmpty) {
- // An existing dropbox-writing thread is outstanding and
- // will handle it.
+ // An existing dropbox-writing thread is outstanding, so
+ // we don't need to start it up. The existing thread will
+ // catch the buffer appends we just did.
return;
}