Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0b54515 authored by lyn's avatar lyn Committed by Lyn Han
Browse files

Do not recycle HeadsUpManagerPhone objects

Avoid reset to prevent NPEs from null NotificationEntry

Fixes: 355540042
Test: send HUNs in open and closed shade
Flag: com.android.systemui.notification_avalanche_throttle_hun
Change-Id: I8de2d9bd81248c9a63cc6940025416f69b8bb977
parent e49f5aba
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.notification.shared.NotificationIconContai
import com.android.systemui.statusbar.notification.shared.NotificationMinimalismPrototype
import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor
import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun
import com.android.systemui.statusbar.notification.shared.PriorityPeopleSection
import javax.inject.Inject

@@ -58,6 +59,7 @@ class FlagDependencies @Inject constructor(featureFlags: FeatureFlagsClassic, ha
        NotificationAvalancheSuppression.token dependsOn VisualInterruptionRefactor.token
        PriorityPeopleSection.token dependsOn SortBySectionTimeFlag.token
        NotificationMinimalismPrototype.token dependsOn NotificationsHeadsUpRefactor.token
        NotificationsHeadsUpRefactor.token dependsOn NotificationThrottleHun.token

        // SceneContainer dependencies
        SceneContainerFlag.getFlagDependencies().forEach { (alpha, beta) -> alpha dependsOn beta }
+4 −4
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements

        @Override
        public HeadsUpEntryPhone acquire() {
            NotificationsHeadsUpRefactor.assertInLegacyMode();
            NotificationThrottleHun.assertInLegacyMode();
            if (!mPoolObjects.isEmpty()) {
                return mPoolObjects.pop();
            }
@@ -126,7 +126,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements

        @Override
        public boolean release(@NonNull HeadsUpEntryPhone instance) {
            NotificationsHeadsUpRefactor.assertInLegacyMode();
            NotificationThrottleHun.assertInLegacyMode();
            mPoolObjects.push(instance);
            return true;
        }
@@ -425,7 +425,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
    @NonNull
    @Override
    protected HeadsUpEntry createHeadsUpEntry(NotificationEntry entry) {
        if (NotificationsHeadsUpRefactor.isEnabled()) {
        if (NotificationThrottleHun.isEnabled()) {
            return new HeadsUpEntryPhone(entry);
        } else {
            HeadsUpEntryPhone headsUpEntry = mEntryPool.acquire();
@@ -451,7 +451,7 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
    @Override
    protected void onEntryRemoved(HeadsUpEntry headsUpEntry) {
        super.onEntryRemoved(headsUpEntry);
        if (!NotificationsHeadsUpRefactor.isEnabled()) {
        if (!NotificationThrottleHun.isEnabled()) {
            mEntryPool.release((HeadsUpEntryPhone) headsUpEntry);
        }
        updateTopHeadsUpFlow();
+4 −4
Original line number Diff line number Diff line
@@ -426,7 +426,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
            onEntryRemoved(finalHeadsUpEntry);
            // TODO(b/328390331) move accessibility events to the view layer
            entry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
            if (NotificationsHeadsUpRefactor.isEnabled()) {
            if (NotificationThrottleHun.isEnabled()) {
                finalHeadsUpEntry.cancelAutoRemovalCallbacks("removeEntry");
            } else {
                finalHeadsUpEntry.reset();
@@ -743,7 +743,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
        @Nullable private Runnable mCancelRemoveRunnable;

        public HeadsUpEntry() {
            NotificationsHeadsUpRefactor.assertInLegacyMode();
            NotificationThrottleHun.assertInLegacyMode();
        }

        public HeadsUpEntry(NotificationEntry entry) {
@@ -754,7 +754,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {

        /** Attach a NotificationEntry. */
        public void setEntry(@NonNull final NotificationEntry entry) {
            NotificationsHeadsUpRefactor.assertInLegacyMode();
            NotificationThrottleHun.assertInLegacyMode();
            setEntry(entry, createRemoveRunnable(entry));
        }

@@ -934,7 +934,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
        }

        public void reset() {
            NotificationsHeadsUpRefactor.assertInLegacyMode();
            NotificationThrottleHun.assertInLegacyMode();
            cancelAutoRemovalCallbacks("reset()");
            mEntry = null;
            mRemoveRunnable = null;