Reduce notification service historical archive size to 1 for watches.

To remove the memory footprint

Bug: 15536759
Change-Id: I081bd962fef689b5d8ed126208499d56ebf4ae38
This commit is contained in:
Griff Hazen
2014-06-10 11:13:51 -07:00
parent 748856f2d9
commit 9f637d1095
4 changed files with 21 additions and 9 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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" />

View File

@@ -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);
}