NotificationMemoryLogger: Drop usages of runBlocking
- Previously, notificationPipeline.allNotifs.toList() had to be accessed on the main thread. While this is a completely synchronous call, runBlocking was used to switch threads and access allNotifs. - Given this is synchronous, we can instead use thread-safe alternatives for the underlying Collection. - allNotifs is a getter in NotifCollection, which returns mReadOnlyNotificationSet - which derives values from mNotificationSet. - NotifCollection.mNotificationSet is now a ConcurrentHashMap for thread-safe access, and the main thread assertion is removed, allowing access via a background thread. - Lastly, getAllNotificationsOnMainThread() is appropriately renamed to getAllNotifications() Bug: 423462317 Flag: com.android.systemui.do_not_use_run_blocking Test: atest NotificationMemoryLoggerTest Change-Id: I3400ec5276fbe37d5799e97dbcf6c90e468c40c2
Loading
Please register or sign in to comment