Merge "[People Service] Re-order clean-up to only occur once per shortcuts update" into tm-qpr-dev am: 038e86d89a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21649889

Change-Id: I6a3e007f6d19d86226668f22e174d28086356660
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jeff Nainaparampil
2023-03-07 19:11:05 +00:00
committed by Automerger Merge Worker

View File

@@ -129,7 +129,6 @@ public class DataManager {
private final List<PeopleService.ConversationsListener> mConversationsListeners = private final List<PeopleService.ConversationsListener> mConversationsListeners =
new ArrayList<>(1); new ArrayList<>(1);
private final Handler mHandler; private final Handler mHandler;
private ContentObserver mCallLogContentObserver; private ContentObserver mCallLogContentObserver;
private ContentObserver mMmsSmsContentObserver; private ContentObserver mMmsSmsContentObserver;
@@ -1106,6 +1105,7 @@ public class DataManager {
@NonNull List<ShortcutInfo> shortcuts, @NonNull UserHandle user) { @NonNull List<ShortcutInfo> shortcuts, @NonNull UserHandle user) {
mInjector.getBackgroundExecutor().execute(() -> { mInjector.getBackgroundExecutor().execute(() -> {
PackageData packageData = getPackage(packageName, user.getIdentifier()); PackageData packageData = getPackage(packageName, user.getIdentifier());
boolean hasCachedShortcut = false;
for (ShortcutInfo shortcut : shortcuts) { for (ShortcutInfo shortcut : shortcuts) {
if (ShortcutHelper.isConversationShortcut( if (ShortcutHelper.isConversationShortcut(
shortcut, mShortcutServiceInternal, user.getIdentifier())) { shortcut, mShortcutServiceInternal, user.getIdentifier())) {
@@ -1114,15 +1114,18 @@ public class DataManager {
? packageData.getConversationInfo(shortcut.getId()) : null; ? packageData.getConversationInfo(shortcut.getId()) : null;
if (conversationInfo == null if (conversationInfo == null
|| !conversationInfo.isShortcutCachedForNotification()) { || !conversationInfo.isShortcutCachedForNotification()) {
// This is a newly cached shortcut. Clean up the existing cached hasCachedShortcut = true;
// shortcuts to ensure the cache size is under the limit.
cleanupCachedShortcuts(user.getIdentifier(),
MAX_CACHED_RECENT_SHORTCUTS - 1);
} }
} }
addOrUpdateConversationInfo(shortcut); 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);
}
}); });
} }