summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author jeffnainap <jeffnainap@google.com> 2023-02-28 19:27:31 +0000
committer Jeff Nainaparampil <jeffnainap@google.com> 2023-03-07 16:38:31 +0000
commit68b75d0ceffd98599aee76c310d9298991d8b521 (patch)
tree14758da38880e8df0cb88131781ad6fe42f2299b
parentae6c0cf5da3f4d3ee1334c466e9911752f5d8f1b (diff)
[People Service] Re-order clean-up to only occur once per shortcuts
update This is a partial roll-forward of the functionality added in ag/21546169. We remove the 500ms debounce as this conflicts with direct boot aware services, and we see an uptick of crashes caused by querying shortcut manager when the user is locked. However, we keep the efficiency of only cleaning up shortcuts once per update -- prior to this change we had performed cleanup multiple times per update which created multiple heaps in a single update operation. Test: unit tests and manually via load test apk Bug: 269420266 Change-Id: I9a445dd88e694c36f0c66491255481df9e4856f3
-rw-r--r--services/people/java/com/android/server/people/data/DataManager.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/services/people/java/com/android/server/people/data/DataManager.java b/services/people/java/com/android/server/people/data/DataManager.java
index eff9e8da9a76..872734f7a01d 100644
--- a/services/people/java/com/android/server/people/data/DataManager.java
+++ b/services/people/java/com/android/server/people/data/DataManager.java
@@ -129,7 +129,6 @@ public class DataManager {
private final List<PeopleService.ConversationsListener> mConversationsListeners =
new ArrayList<>(1);
private final Handler mHandler;
-
private ContentObserver mCallLogContentObserver;
private ContentObserver mMmsSmsContentObserver;
@@ -1106,6 +1105,7 @@ public class DataManager {
@NonNull List<ShortcutInfo> shortcuts, @NonNull UserHandle user) {
mInjector.getBackgroundExecutor().execute(() -> {
PackageData packageData = getPackage(packageName, user.getIdentifier());
+ boolean hasCachedShortcut = false;
for (ShortcutInfo shortcut : shortcuts) {
if (ShortcutHelper.isConversationShortcut(
shortcut, mShortcutServiceInternal, user.getIdentifier())) {
@@ -1114,15 +1114,18 @@ public class DataManager {
? packageData.getConversationInfo(shortcut.getId()) : null;
if (conversationInfo == null
|| !conversationInfo.isShortcutCachedForNotification()) {
- // This is a newly cached shortcut. Clean up the existing cached
- // shortcuts to ensure the cache size is under the limit.
- cleanupCachedShortcuts(user.getIdentifier(),
- MAX_CACHED_RECENT_SHORTCUTS - 1);
+ hasCachedShortcut = true;
}
}
addOrUpdateConversationInfo(shortcut);
}
}
+ // Added at least one new conversation. Uncache older existing cached
+ // shortcuts to ensure the cache size is under the limit.
+ if (hasCachedShortcut) {
+ cleanupCachedShortcuts(user.getIdentifier(),
+ MAX_CACHED_RECENT_SHORTCUTS);
+ }
});
}