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

Commit eecc15fa authored by Danesh Mondegarian's avatar Danesh Mondegarian Committed by Gerrit Code Review
Browse files

SystemUI : Improve heads up display logic

- Add ticker as a condition for high priority (based on upstream L patch http://goo.gl/Kofy4V)
- Make sure non high priority don't get shown if screen is off or dreaming

Change-Id: I527ac55c641ac45848715a1baae5c44df1381644
parent 9a649624
Loading
Loading
Loading
Loading
+11 −18
Original line number Diff line number Diff line
@@ -1251,6 +1251,7 @@ public abstract class BaseStatusBar extends SystemUI implements
                || notification.vibrate != null;
        boolean isHighPriority = sbn.getScore() >= INTERRUPTION_THRESHOLD;
        boolean isFullscreen = notification.fullScreenIntent != null;
        boolean hasTicker = !TextUtils.isEmpty(notification.tickerText);
        boolean isAllowed = notification.extras.getInt(Notification.EXTRA_AS_HEADS_UP,
                Notification.HEADS_UP_ALLOWED) != Notification.HEADS_UP_NEVER;
        boolean isOngoing = sbn.isOngoing();
@@ -1263,29 +1264,21 @@ public abstract class BaseStatusBar extends SystemUI implements
                mContext.getSystemService(Context.INPUT_METHOD_SERVICE);

        boolean isIMEShowing = inputMethodManager.isImeShowing();

        boolean interrupt = (isFullscreen || (isHighPriority && isNoisy))
                && isAllowed
                && keyguardNotVisible
                && !isOngoing
                && !isIMEShowing
                && mPowerManager.isScreenOn();

        boolean isDreamShowing = false;
        try {
            interrupt = interrupt && !mDreamManager.isDreaming();
            isDreamShowing = mDreamManager.isDreaming();
        } catch (RemoteException e) {
            Log.d(TAG, "failed to query dream manager", e);
        }

        // its below our threshold priority, we might want to always display
        // notifications from certain apps
        if (!isHighPriority && keyguardNotVisible && !isOngoing && !isIMEShowing) {
            // However, we don't want to interrupt if we're in an application that is
            // in Do Not Disturb
            if (!isPackageInDnd(getTopLevelPackage())) {
                return true;
            }
        }
        boolean interrupt = (isFullscreen || !isHighPriority || isNoisy || hasTicker)
                && isAllowed
                && keyguardNotVisible
                && !isOngoing
                && !isIMEShowing
                && mPowerManager.isScreenOn()
                && !isDreamShowing
                && !isPackageInDnd(getTopLevelPackage());

        if (DEBUG) Log.d(TAG, "interrupt: " + interrupt);
        return interrupt;