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

Commit 29fa89b4 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed a crash on android tv with the new heads-up manager

Bug: 20282768
Change-Id: Ibb3dc879a2529c12f4d8ab6b031711363da93d37
parent 31d9ef7a
Loading
Loading
Loading
Loading
+7 −23
Original line number Diff line number Diff line
@@ -687,13 +687,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        setHeadsUpUser(newUserId);
    }

    private void setHeadsUpUser(int newUserId) {
        mHeadsUpManager.setUser(newUserId);
    }

    public boolean isHeadsUp(String key) {
      return mHeadsUpManager.isHeadsUp(key);
    }
    protected abstract void setHeadsUpUser(int newUserId);

    @Override  // NotificationData.Environment
    public boolean isNotificationForCurrentProfiles(StatusBarNotification n) {
@@ -1578,7 +1572,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                            mCurrentUserId);
            dismissKeyguardThenExecute(new OnDismissAction() {
                public boolean onDismiss() {
                    if (mHeadsUpManager.isHeadsUp(mNotificationKey)) {
                    if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(mNotificationKey)) {
                        // Release the HUN notification to the shade.
                        //
                        // In most cases, when FLAG_AUTO_CANCEL is set, the notification will
@@ -1941,20 +1935,8 @@ public abstract class BaseStatusBar extends SystemUI implements
        setAreThereNotifications();
    }

    private void updateHeadsUp(String key, Entry entry, boolean shouldInterrupt,
            boolean alertAgain) {
        final boolean wasHeadsUp = isHeadsUp(key);
        if (wasHeadsUp) {
            mHeadsUpManager.updateNotification(entry, alertAgain);
            if (!shouldInterrupt) {
                // We don't want this to be interrupting anymore, lets remove it
                mHeadsUpManager.removeNotification(key);
            }
        } else if (shouldInterrupt && alertAgain) {
            // This notification was updated to be a heads-up, show it!
            mHeadsUpManager.showNotification(entry);
        }
    }
    protected abstract void updateHeadsUp(String key, Entry entry, boolean shouldInterrupt,
            boolean alertAgain);

    private void logUpdate(Entry oldEntry, Notification n) {
        StatusBarNotification oldNotification = oldEntry.notification;
@@ -2075,7 +2057,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            return false;
        }

        if (mHeadsUpManager.isSnoozed(sbn.getPackageName())) {
        if (isSnoozedPackage(sbn)) {
            return false;
        }

@@ -2109,6 +2091,8 @@ public abstract class BaseStatusBar extends SystemUI implements
        return interrupt;
    }

    protected abstract boolean isSnoozedPackage(StatusBarNotification sbn);

    public void setInteracting(int barWindow, boolean interacting) {
        // hook for subclasses
    }
+29 −0
Original line number Diff line number Diff line
@@ -1867,6 +1867,35 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

    }

    protected void updateHeadsUp(String key, Entry entry, boolean shouldInterrupt,
            boolean alertAgain) {
        final boolean wasHeadsUp = isHeadsUp(key);
        if (wasHeadsUp) {
            mHeadsUpManager.updateNotification(entry, alertAgain);
            if (!shouldInterrupt) {
                // We don't want this to be interrupting anymore, lets remove it
                mHeadsUpManager.removeNotification(key);
            }
        } else if (shouldInterrupt && alertAgain) {
            // This notification was updated to be a heads-up, show it!
            mHeadsUpManager.showNotification(entry);
        }
    }

    protected void setHeadsUpUser(int newUserId) {
        if (mHeadsUpManager != null) {
            mHeadsUpManager.setUser(newUserId);
        }
    }

    public boolean isHeadsUp(String key) {
        return mHeadsUpManager.isHeadsUp(key);
    }

    protected boolean isSnoozedPackage(StatusBarNotification sbn) {
        return mHeadsUpManager.isSnoozed(sbn.getPackageName());
    }

    /**
     * All changes to the status bar and notifications funnel through here and are batched.
     */
+13 −2
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ import android.os.IBinder;
import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;

import com.android.internal.statusbar.StatusBarIcon;
import com.android.systemui.statusbar.ActivatableNotificationView;
@@ -166,4 +164,17 @@ public class TvStatusBar extends BaseStatusBar {
    @Override
    public void appTransitionStarting(long startTime, long duration) {
    }

    @Override
    protected void updateHeadsUp(String key, NotificationData.Entry entry, boolean shouldInterrupt,
            boolean alertAgain) {
    }

    @Override
    protected void setHeadsUpUser(int newUserId) {
    }

    protected boolean isSnoozedPackage(StatusBarNotification sbn) {
        return false;
    }
}