diff options
Diffstat (limited to 'services/java/com/android/server/NotificationManagerService.java')
-rw-r--r-- | services/java/com/android/server/NotificationManagerService.java | 90 |
1 files changed, 79 insertions, 11 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index cfb892f..fa18e76 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -43,11 +43,13 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.database.ContentObserver; +import android.graphics.Bitmap; import android.media.AudioManager; import android.media.IAudioService; import android.media.IRingtonePlayer; import android.net.Uri; import android.os.Binder; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; @@ -81,6 +83,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; +import java.lang.reflect.Array; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -264,18 +267,32 @@ public class NotificationManagerService extends INotificationManager.Stub } private static class Archive { - static final int BUFFER_SIZE = 1000; + static final int BUFFER_SIZE = 250; ArrayDeque<StatusBarNotification> mBuffer = new ArrayDeque<StatusBarNotification>(BUFFER_SIZE); public Archive() { } + public String toString() { + final StringBuilder sb = new StringBuilder(); + final int N = mBuffer.size(); + sb.append("Archive ("); + sb.append(N); + sb.append(" notification"); + sb.append((N==1)?")":"s)"); + return sb.toString(); + } + public void record(StatusBarNotification nr) { // Nuke heavy parts of notification before storing in archive nr.notification.tickerView = null; nr.notification.contentView = null; nr.notification.bigContentView = null; nr.notification.largeIcon = null; + final Bundle extras = nr.notification.extras; + extras.remove(Notification.EXTRA_LARGE_ICON); + extras.remove(Notification.EXTRA_LARGE_ICON_BIG); + extras.remove(Notification.EXTRA_PICTURE); if (mBuffer.size() == BUFFER_SIZE) { mBuffer.removeFirst(); @@ -283,6 +300,7 @@ public class NotificationManagerService extends INotificationManager.Stub mBuffer.addLast(nr); } + public void clear() { mBuffer.clear(); } @@ -815,22 +833,61 @@ public class NotificationManagerService extends INotificationManager.Stub void dump(PrintWriter pw, String prefix, Context baseContext) { final Notification notification = sbn.notification; pw.println(prefix + this); + pw.println(prefix + " uid=" + sbn.uid + " userId=" + sbn.getUserId()); pw.println(prefix + " icon=0x" + Integer.toHexString(notification.icon) - + " / " + idDebugString(baseContext, this.sbn.pkg, notification.icon)); - pw.println(prefix + " pri=" + notification.priority); - pw.println(prefix + " score=" + this.sbn.score); + + " / " + idDebugString(baseContext, sbn.pkg, notification.icon)); + pw.println(prefix + " pri=" + notification.priority + " score=" + sbn.score); pw.println(prefix + " contentIntent=" + notification.contentIntent); pw.println(prefix + " deleteIntent=" + notification.deleteIntent); pw.println(prefix + " tickerText=" + notification.tickerText); pw.println(prefix + " contentView=" + notification.contentView); - pw.println(prefix + " uid=" + this.sbn.uid + " userId=" + this.sbn.getUserId()); - pw.println(prefix + " defaults=0x" + Integer.toHexString(notification.defaults)); - pw.println(prefix + " flags=0x" + Integer.toHexString(notification.flags)); + pw.println(prefix + String.format(" defaults=0x%08x flags=0x%08x", + notification.defaults, notification.flags)); pw.println(prefix + " sound=" + notification.sound); pw.println(prefix + " vibrate=" + Arrays.toString(notification.vibrate)); - pw.println(prefix + " ledARGB=0x" + Integer.toHexString(notification.ledARGB) - + " ledOnMS=" + notification.ledOnMS - + " ledOffMS=" + notification.ledOffMS); + pw.println(prefix + String.format(" led=0x%08x onMs=%d offMs=%d", + notification.ledARGB, notification.ledOnMS, notification.ledOffMS)); + if (notification.actions != null && notification.actions.length > 0) { + pw.println(prefix + " actions={"); + final int N = notification.actions.length; + for (int i=0; i<N; i++) { + final Notification.Action action = notification.actions[i]; + pw.println(String.format("%s [%d] \"%s\" -> %s", + prefix, + i, + action.title, + action.actionIntent.toString() + )); + } + pw.println(prefix + " }"); + } + if (notification.extras != null && notification.extras.size() > 0) { + pw.println(prefix + " extras={"); + for (String key : notification.extras.keySet()) { + pw.print(prefix + " " + key + "="); + Object val = notification.extras.get(key); + if (val == null) { + pw.println("null"); + } else { + pw.print(val.toString()); + if (val instanceof Bitmap) { + pw.print(String.format(" (%dx%d)", + ((Bitmap) val).getWidth(), + ((Bitmap) val).getHeight())); + } else if (val.getClass().isArray()) { + pw.println(" {"); + final int N = Array.getLength(val); + for (int i=0; i<N; i++) { + if (i > 0) pw.println(","); + pw.print(prefix + " " + Array.get(val, i)); + } + pw.print("\n" + prefix + " }"); + } + pw.println(); + } + } + pw.println(prefix + " }"); + } } @Override @@ -2081,7 +2138,7 @@ public class NotificationManagerService extends INotificationManager.Stub if (N > 0) { pw.println(" Lights List:"); for (int i=0; i<N; i++) { - mLights.get(i).dump(pw, " ", mContext); + pw.println(" " + mLights.get(i)); } pw.println(" "); } @@ -2090,6 +2147,17 @@ public class NotificationManagerService extends INotificationManager.Stub pw.println(" mVibrateNotification=" + mVibrateNotification); pw.println(" mDisabledNotifications=0x" + Integer.toHexString(mDisabledNotifications)); pw.println(" mSystemReady=" + mSystemReady); + pw.println(" mArchive=" + mArchive.toString()); + Iterator<StatusBarNotification> iter = mArchive.descendingIterator(); + int i=0; + while (iter.hasNext()) { + pw.println(" " + iter.next()); + if (++i >= 5) { + if (iter.hasNext()) pw.println(" ..."); + break; + } + } + } } } |