Fix duplicate bubbles in overflow

If multiple calls to applyUpdate happen, we could load & add the bubbles
from disk multiple times resulting in dupes. This adds a flag to only do
it once.

Test: manual
Fixes: 158353722
Change-Id: I5a14574a78ce0b1c55b3b32d2348aa3c4241a341
This commit is contained in:
Mady Mellor
2020-06-10 14:50:59 -07:00
parent 266bf584c7
commit f4afd8db2f

View File

@@ -55,7 +55,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Handler;
import android.os.RemoteException;
@@ -180,6 +179,9 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
// Callback that updates BubbleOverflowActivity on data change.
@Nullable private Runnable mOverflowCallback = null;
// Only load overflow data from disk once
private boolean mOverflowDataLoaded = false;
private final NotificationInterruptStateProvider mNotificationInterruptStateProvider;
private IStatusBarService mBarService;
private WindowManager mWindowManager;
@@ -193,9 +195,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
/** Whether or not the BubbleStackView has been added to the WindowManager. */
private boolean mAddedToWindowManager = false;
// Used for determining view rect for touch interaction
private Rect mTempRect = new Rect();
// Listens to user switch so bubbles can be saved and restored.
private final NotificationLockscreenUserManager mNotifUserManager;
@@ -962,13 +961,14 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
* Fills the overflow bubbles by loading them from disk.
*/
void loadOverflowBubblesFromDisk() {
if (!mBubbleData.getOverflowBubbles().isEmpty()) {
if (!mBubbleData.getOverflowBubbles().isEmpty() || mOverflowDataLoaded) {
// we don't need to load overflow bubbles from disk if it is already in memory
return;
}
mOverflowDataLoaded = true;
mDataRepository.loadBubbles((bubbles) -> {
bubbles.forEach(bubble -> {
if (mBubbleData.getBubbles().contains(bubble)) {
if (mBubbleData.hasAnyBubbleWithKey(bubble.getKey())) {
// if the bubble is already active, there's no need to push it to overflow
return;
}