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

Commit 9fd259dd authored by Chris Wren's avatar Chris Wren Committed by Android Git Automerger
Browse files

am bef7d256: Merge "Track Zen Mode status in the NotificationRecord" into lmp-preview-dev

* commit 'bef7d25652c767f9850ec7ad6c51812b1c8db69d':
  Track Zen Mode status in the NotificationRecord
parents 1994f418 4f0e39a9
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -337,8 +337,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mNotificationData.updateRanking(currentRanking);
                    updateNotifications();
                    updateRankingInternal(currentRanking);
                }
            });
        }
@@ -1280,6 +1279,8 @@ public abstract class BaseStatusBar extends SystemUI implements
    public abstract void addNotificationInternal(StatusBarNotification notification,
            Ranking ranking);

    protected abstract void updateRankingInternal(Ranking ranking);

    @Override
    public void removeNotification(String key) {
        if (!USE_NOTIFICATION_LISTENER) {
@@ -1287,7 +1288,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
    }

    protected abstract void removeNotificationInternal(String key, Ranking ranking);
    public abstract void removeNotificationInternal(String key, Ranking ranking);

    public void updateNotification(StatusBarNotification notification) {
        if (!USE_NOTIFICATION_LISTENER) {
+27 −4
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@ import android.app.Notification;
import android.content.Context;
import android.os.Process;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.view.View;

import com.android.systemui.R;
@@ -30,12 +32,13 @@ import com.android.systemui.statusbar.phone.PhoneStatusBar;

public class InterceptedNotifications {
    private static final String TAG = "InterceptedNotifications";
    private static final String EXTRA_INTERCEPT = "android.intercept";
    private static final String SYNTHETIC_KEY = "InterceptedNotifications.SYNTHETIC_KEY";

    private final Context mContext;
    private final PhoneStatusBar mBar;
    private final ArrayMap<String, StatusBarNotification> mIntercepted
            = new ArrayMap<String, StatusBarNotification>();
    private final ArraySet<String> mReleased = new ArraySet<String>();

    private String mSynKey;

@@ -48,25 +51,45 @@ public class InterceptedNotifications {
        final int n = mIntercepted.size();
        for (int i = 0; i < n; i++) {
            final StatusBarNotification sbn = mIntercepted.valueAt(i);
            sbn.getNotification().extras.putBoolean(EXTRA_INTERCEPT, false);
            mReleased.add(sbn.getKey());
            mBar.addNotificationInternal(sbn, null);
        }
        mIntercepted.clear();
        updateSyntheticNotification();
    }

    public boolean tryIntercept(StatusBarNotification notification) {
        if (!notification.getNotification().extras.getBoolean(EXTRA_INTERCEPT)) return false;
    public boolean tryIntercept(StatusBarNotification notification, Ranking ranking) {
        if (ranking == null) return false;
        if (shouldDisplayIntercepted()) return false;
        if (mReleased.contains(notification.getKey())) return false;
        if (!ranking.isInterceptedByDoNotDisturb(notification.getKey())) return false;
        mIntercepted.put(notification.getKey(), notification);
        updateSyntheticNotification();
        return true;
    }

    public void retryIntercepts(Ranking ranking) {
        if (ranking == null) return;

        boolean changed = false;
        final int N = mIntercepted.size();
        for (int i = 0; i < N; i++) {
            final StatusBarNotification sbn = mIntercepted.valueAt(i);
            if (!tryIntercept(sbn, ranking)) {
                changed = true;
                mBar.addNotificationInternal(sbn, ranking);
            }
        }
        if (changed) {
            updateSyntheticNotification();
        }
    }

    public void remove(String key) {
        if (mIntercepted.remove(key) != null) {
            updateSyntheticNotification();
        }
        mReleased.remove(key);
    }

    public boolean isSyntheticEntry(Entry ent) {
+8 −1
Original line number Diff line number Diff line
@@ -1050,7 +1050,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        if (shadeEntry == null) {
            return;
        }
        if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification)) {
        if (mZenMode != Global.ZEN_MODE_OFF && mIntercepted.tryIntercept(notification, ranking)) {
            // Forward the ranking so we can sort the new notification.
            mNotificationData.updateRanking(ranking);
            return;
@@ -1113,6 +1113,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        mIntercepted.update(notification);
    }

    @Override
    protected void updateRankingInternal(Ranking ranking) {
        mNotificationData.updateRanking(ranking);
        mIntercepted.retryIntercepts(ranking);
        updateNotifications();
    }

    @Override
    public void removeNotificationInternal(String key, Ranking ranking) {
        StatusBarNotification old = removeNotificationViews(key, ranking);
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.tv;

import android.os.IBinder;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.StatusBarNotification;
import android.view.View;
@@ -53,12 +54,16 @@ public class TvStatusBar extends BaseStatusBar {
    public void addNotificationInternal(StatusBarNotification notification, Ranking ranking) {
    }

    @Override
    protected void updateRankingInternal(Ranking ranking) {
    }

    @Override
    public void updateNotification(StatusBarNotification notification) {
    }

    @Override
    protected void removeNotificationInternal(String key, Ranking ranking) {
    public void removeNotificationInternal(String key, Ranking ranking) {
    }

    @Override
+2 −3
Original line number Diff line number Diff line
@@ -21,11 +21,10 @@ import java.util.Comparator;
 * Sorts notificaitons into attention-relelvant order.
 */
public class NotificationComparator
        implements Comparator<NotificationManagerService.NotificationRecord> {
        implements Comparator<NotificationRecord> {

    @Override
    public int compare(NotificationManagerService.NotificationRecord lhs,
            NotificationManagerService.NotificationRecord rhs) {
    public int compare(NotificationRecord lhs, NotificationRecord rhs) {
        if (lhs.isRecentlyIntrusive() != rhs.isRecentlyIntrusive()) {
            return lhs.isRecentlyIntrusive() ? -1 : 1;
        }
Loading