diff options
-rw-r--r-- | core/res/res/values-watch/config.xml | 4 | ||||
-rw-r--r-- | core/res/res/values/config.xml | 3 | ||||
-rw-r--r-- | core/res/res/values/symbols.xml | 1 | ||||
-rw-r--r-- | services/core/java/com/android/server/notification/NotificationManagerService.java | 22 |
4 files changed, 21 insertions, 9 deletions
diff --git a/core/res/res/values-watch/config.xml b/core/res/res/values-watch/config.xml index 8d82a17..6052fb0 100644 --- a/core/res/res/values-watch/config.xml +++ b/core/res/res/values-watch/config.xml @@ -36,4 +36,8 @@ <!-- Maximum velocity to initiate a fling, as measured in dips per second. --> <dimen name="config_viewMaxFlingVelocity">8000dp</dimen> + <!-- Number of notifications to keep in the notification service historical archive. + Reduced intentionally for watches to retain minimal memory footprint --> + <integer name="config_notificationServiceArchiveSize">1</integer> + </resources> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index bbc58f5..f239cc5 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -605,6 +605,9 @@ <!-- Default value for LED off time when the battery is low on charge in miliseconds --> <integer name="config_notificationsBatteryLedOff">2875</integer> + <!-- Number of notifications to keep in the notification service historical archive --> + <integer name="config_notificationServiceArchiveSize">250</integer> + <!-- Allow the menu hard key to be disabled in LockScreen on some devices --> <bool name="config_disableMenuKeyInLockScreen">false</bool> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 412ae9d..c5b8a5a 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1511,6 +1511,7 @@ <java-symbol type="integer" name="config_notificationsBatteryLedOn" /> <java-symbol type="integer" name="config_notificationsBatteryLowARGB" /> <java-symbol type="integer" name="config_notificationsBatteryMediumARGB" /> + <java-symbol type="integer" name="config_notificationServiceArchiveSize" /> <java-symbol type="integer" name="config_radioScanningTimeout" /> <java-symbol type="integer" name="config_screenBrightnessSettingMinimum" /> <java-symbol type="integer" name="config_screenBrightnessSettingMaximum" /> diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index d163a617..f8ff038 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -177,6 +177,8 @@ public class NotificationManagerService extends SystemService { private AppOpsManager mAppOps; + private Archive mArchive; + // contains connections to all connected listeners, including app services // and system listeners private ArrayList<NotificationListenerInfo> mListeners @@ -277,10 +279,12 @@ public class NotificationManagerService extends SystemService { } private static class Archive { - static final int BUFFER_SIZE = 250; - ArrayDeque<StatusBarNotification> mBuffer = new ArrayDeque<StatusBarNotification>(BUFFER_SIZE); + final int mBufferSize; + final ArrayDeque<StatusBarNotification> mBuffer; - public Archive() { + public Archive(int size) { + mBufferSize = size; + mBuffer = new ArrayDeque<StatusBarNotification>(mBufferSize); } public String toString() { @@ -294,7 +298,7 @@ public class NotificationManagerService extends SystemService { } public void record(StatusBarNotification nr) { - if (mBuffer.size() == BUFFER_SIZE) { + if (mBuffer.size() == mBufferSize) { mBuffer.removeFirst(); } @@ -304,7 +308,6 @@ public class NotificationManagerService extends SystemService { mBuffer.addLast(nr.cloneLight()); } - public void clear() { mBuffer.clear(); } @@ -354,7 +357,7 @@ public class NotificationManagerService extends SystemService { } public StatusBarNotification[] getArray(int count) { - if (count == 0) count = Archive.BUFFER_SIZE; + if (count == 0) count = mBufferSize; final StatusBarNotification[] a = new StatusBarNotification[Math.min(count, mBuffer.size())]; Iterator<StatusBarNotification> iter = descendingIterator(); @@ -366,7 +369,7 @@ public class NotificationManagerService extends SystemService { } public StatusBarNotification[] getArray(int count, String pkg, int userId) { - if (count == 0) count = Archive.BUFFER_SIZE; + if (count == 0) count = mBufferSize; final StatusBarNotification[] a = new StatusBarNotification[Math.min(count, mBuffer.size())]; Iterator<StatusBarNotification> iter = filter(descendingIterator(), pkg, userId); @@ -379,8 +382,6 @@ public class NotificationManagerService extends SystemService { } - Archive mArchive = new Archive(); - private void loadBlockDb() { synchronized(mBlockedPackages) { if (mPolicyFile == null) { @@ -1231,6 +1232,9 @@ public class NotificationManagerService extends SystemService { } } + mArchive = new Archive(resources.getInteger( + R.integer.config_notificationServiceArchiveSize)); + publishBinderService(Context.NOTIFICATION_SERVICE, mService); publishLocalService(NotificationManagerInternal.class, mInternalService); } |