am 4b6d23d7: Merge "Further reduce memory usage of notification archive." into jb-mr2-dev
* commit '4b6d23d7b45f813bee52747b3243ce46ff9edbd0': Further reduce memory usage of notification archive.
This commit is contained in:
@@ -49,6 +49,7 @@ import android.media.IAudioService;
|
|||||||
import android.media.IRingtonePlayer;
|
import android.media.IRingtonePlayer;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@@ -266,18 +267,32 @@ public class NotificationManagerService extends INotificationManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Archive {
|
private static class Archive {
|
||||||
static final int BUFFER_SIZE = 1000;
|
static final int BUFFER_SIZE = 250;
|
||||||
ArrayDeque<StatusBarNotification> mBuffer = new ArrayDeque<StatusBarNotification>(BUFFER_SIZE);
|
ArrayDeque<StatusBarNotification> mBuffer = new ArrayDeque<StatusBarNotification>(BUFFER_SIZE);
|
||||||
|
|
||||||
public Archive() {
|
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) {
|
public void record(StatusBarNotification nr) {
|
||||||
// Nuke heavy parts of notification before storing in archive
|
// Nuke heavy parts of notification before storing in archive
|
||||||
nr.notification.tickerView = null;
|
nr.notification.tickerView = null;
|
||||||
nr.notification.contentView = null;
|
nr.notification.contentView = null;
|
||||||
nr.notification.bigContentView = null;
|
nr.notification.bigContentView = null;
|
||||||
nr.notification.largeIcon = 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) {
|
if (mBuffer.size() == BUFFER_SIZE) {
|
||||||
mBuffer.removeFirst();
|
mBuffer.removeFirst();
|
||||||
@@ -285,6 +300,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
|||||||
mBuffer.addLast(nr);
|
mBuffer.addLast(nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
mBuffer.clear();
|
mBuffer.clear();
|
||||||
}
|
}
|
||||||
@@ -2131,6 +2147,17 @@ public class NotificationManagerService extends INotificationManager.Stub
|
|||||||
pw.println(" mVibrateNotification=" + mVibrateNotification);
|
pw.println(" mVibrateNotification=" + mVibrateNotification);
|
||||||
pw.println(" mDisabledNotifications=0x" + Integer.toHexString(mDisabledNotifications));
|
pw.println(" mDisabledNotifications=0x" + Integer.toHexString(mDisabledNotifications));
|
||||||
pw.println(" mSystemReady=" + mSystemReady);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user