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

Commit 4ae17b16 authored by lyn's avatar lyn
Browse files

Null check mEntry in BaseHeadsUpManager

Bug: 355461156
Test: treehugger
Flag: com.android.systemui.notification_avalanche_throttle_hun
Change-Id: I605af2e873873990578e71b206fe290185a6d04a
parent e49f5aba
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
@@ -171,7 +171,6 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
        mLogger.logShowNotificationRequest(entry);

        Runnable runnable = () -> {
            // TODO(b/315362456) log outside runnable too
            mLogger.logShowNotification(entry);

            // Add new entry and begin managing it
@@ -244,8 +243,10 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
            return;
        }
        // TODO(b/328390331) move accessibility events to the view layer
        headsUpEntry.mEntry.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);

        if (headsUpEntry.mEntry != null) {
            headsUpEntry.mEntry.sendAccessibilityEvent(
                    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
        }
        if (shouldHeadsUpAgain) {
            headsUpEntry.updateEntry(true /* updatePostTime */, "updateNotification");
            if (headsUpEntry != null) {
@@ -334,6 +335,9 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
    }

    protected boolean shouldHeadsUpBecomePinned(@NonNull NotificationEntry entry) {
        if (entry == null) {
            return false;
        }
        final HeadsUpEntry headsUpEntry = getHeadsUpEntry(entry.getKey());
        if (headsUpEntry == null) {
            // This should not happen since shouldHeadsUpBecomePinned is always called after adding
@@ -499,6 +503,9 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
        keySet.addAll(mAvalancheController.getWaitingKeys());
        for (String key : keySet) {
            HeadsUpEntry entry = getHeadsUpEntry(key);
            if (entry.mEntry == null) {
                continue;
            }
            String packageName = entry.mEntry.getSbn().getPackageName();
            String snoozeKey = snoozeKey(packageName, mUser);
            mLogger.logPackageSnoozed(snoozeKey);
@@ -566,7 +573,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
        pw.print("  now="); pw.println(mSystemClock.elapsedRealtime());
        pw.print("  mUser="); pw.println(mUser);
        for (HeadsUpEntry entry: mHeadsUpEntryMap.values()) {
            pw.print("  HeadsUpEntry="); pw.println(entry.mEntry);
            pw.println(entry.mEntry == null ? "null" : entry.mEntry);
        }
        int n = mSnoozedPackages.size();
        pw.println("  snoozed packages: " + n);
@@ -586,7 +593,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
    private boolean hasPinnedNotificationInternal() {
        for (String key : mHeadsUpEntryMap.keySet()) {
            HeadsUpEntry entry = getHeadsUpEntry(key);
            if (entry.mEntry.isRowPinned()) {
            if (entry.mEntry != null && entry.mEntry.isRowPinned()) {
                return true;
            }
        }
@@ -611,7 +618,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
                // when the user unpinned all of HUNs by moving one HUN, all of HUNs should not stay
                // on the screen.
                if (userUnPinned && headsUpEntry.mEntry != null) {
                    if (headsUpEntry.mEntry.mustStayOnScreen()) {
                    if (headsUpEntry.mEntry != null && headsUpEntry.mEntry.mustStayOnScreen()) {
                        headsUpEntry.mEntry.setHeadsUpIsVisible();
                    }
                }
@@ -687,7 +694,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
            return true;
        }
        return headsUpEntry == null || headsUpEntry.wasShownLongEnough()
                || headsUpEntry.mEntry.isRowDismissed();
                || (headsUpEntry.mEntry != null && headsUpEntry.mEntry.isRowDismissed());
    }

    /**
@@ -864,6 +871,14 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
        }

        public int compareNonTimeFields(HeadsUpEntry headsUpEntry) {
            if (mEntry == null && headsUpEntry.mEntry == null) {
                return 0;
            } else if (headsUpEntry.mEntry == null) {
                return -1;
            } else if (mEntry == null) {
                return 1;
            }

            boolean selfFullscreen = hasFullScreenIntent(mEntry);
            boolean otherFullscreen = hasFullScreenIntent(headsUpEntry.mEntry);
            if (selfFullscreen && !otherFullscreen) {
@@ -890,6 +905,13 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
        }

        public int compareTo(@NonNull HeadsUpEntry headsUpEntry) {
            if (mEntry == null && headsUpEntry.mEntry == null) {
                return 0;
            } else if (headsUpEntry.mEntry == null) {
                return -1;
            } else if (mEntry == null) {
                return 1;
            }
            boolean isPinned = mEntry.isRowPinned();
            boolean otherPinned = headsUpEntry.mEntry.isRowPinned();
            if (isPinned && !otherPinned) {
@@ -954,7 +976,7 @@ public abstract class BaseHeadsUpManager implements HeadsUpManager {
                    mLogger.logAutoRemoveCanceled(mEntry, reason);
                }
            };
            if (isHeadsUpEntry(this.mEntry.getKey())) {
            if (mEntry != null && isHeadsUpEntry(mEntry.getKey())) {
                mAvalancheController.update(this, runnable, reason + " cancelAutoRemovalCallbacks");
            } else {
                // Just removed