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

Commit 1492116a authored by Christoph Studer's avatar Christoph Studer
Browse files

SysUI: Upsort PRIORITY_MAX system notifications

Bug: 17131219
Change-Id: Id29ef5c44a8221d514ea0a8cf5d0fe5dd179744b
parent 09cfeaff
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -99,15 +99,26 @@ public class NotificationData {

        @Override
        public int compare(Entry a, Entry b) {
            String mediaNotification = mEnvironment.getCurrentMediaNotificationKey();

            // Upsort current media notification.
            String mediaNotification = mEnvironment.getCurrentMediaNotificationKey();
            boolean aMedia = a.key.equals(mediaNotification);
            boolean bMedia = b.key.equals(mediaNotification);
            if (aMedia != bMedia) {
                return aMedia ? -1 : 1;
            }

            final StatusBarNotification na = a.notification;
            final StatusBarNotification nb = b.notification;

            // Upsort PRIORITY_MAX system notifications
            boolean aSystemMax = na.getNotification().priority >= Notification.PRIORITY_MAX &&
                    isSystemNotification(na);
            boolean bSystemMax = nb.getNotification().priority >= Notification.PRIORITY_MAX &&
                    isSystemNotification(nb);
            if (aSystemMax != bSystemMax) {
                return aSystemMax ? -1 : 1;
            }

            // RankingMap as received from NoMan.
            if (mRankingMap != null) {
                mRankingMap.getRanking(a.key, mRankingA);
@@ -115,8 +126,6 @@ public class NotificationData {
                return mRankingA.getRank() - mRankingB.getRank();
            }

            final StatusBarNotification na = a.notification;
            final StatusBarNotification nb = b.notification;
            int d = nb.getScore() - na.getScore();
            if (a.interruption != b.interruption) {
                return a.interruption ? -1 : 1;
@@ -296,6 +305,11 @@ public class NotificationData {
        pw.println("      tickerText=\"" + n.getNotification().tickerText + "\"");
    }

    private static boolean isSystemNotification(StatusBarNotification sbn) {
        String sbnPackage = sbn.getPackageName();
        return "android".equals(sbnPackage) || "com.android.systemui".equals(sbnPackage);
    }

    /**
     * Provides access to keyguard state and user settings dependent data.
     */