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

Commit b0c1a462 authored by Gus Prevas's avatar Gus Prevas
Browse files

Includes foreground services in top notification section.

This change modifies the various components which treat high-priority
notifications differently, including the status bar, the lockscreen, and
the notification layout algorithm, such that foreground service
notifications are always included among the high-priority notifications.
This logic is now centralized in NotificationData.

Bug: 116622974
Bug: 118805186
Test: manually
Change-Id: Ia13c1aac0cf91c400594df96ce267e768133f8d1
parent e2d6f040
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5936,8 +5936,9 @@ public class Notification implements Parcelable

    /**
     * @return whether this notification is a foreground service notification
     * @hide
     */
    private boolean isForegroundService() {
    public boolean isForegroundService() {
        return (flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
    }

+1 −4
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.systemui.statusbar;

import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;

import android.app.ActivityManager;
@@ -295,9 +294,7 @@ public class NotificationLockscreenUserManagerImpl implements
        }
        boolean exceedsPriorityThreshold;
        if (NotificationUtils.useNewInterruptionModel(mContext)) {
            exceedsPriorityThreshold =
                    getEntryManager().getNotificationData().getImportance(sbn.getKey())
                            >= IMPORTANCE_DEFAULT;
            exceedsPriorityThreshold = getEntryManager().getNotificationData().isHighPriority(sbn);
        } else {
            exceedsPriorityThreshold =
                    !getEntryManager().getNotificationData().isAmbient(sbn.getKey());
+16 −3
Original line number Diff line number Diff line
@@ -51,13 +51,14 @@ import android.util.ArraySet;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.Dependency;
import com.android.systemui.ForegroundServiceController;
import com.android.systemui.InitController;
import com.android.systemui.statusbar.InflationTask;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -75,8 +76,6 @@ import java.util.Comparator;
import java.util.List;
import java.util.Objects;

import androidx.annotation.Nullable;

/**
 * The list of currently displaying notifications.
 */
@@ -562,6 +561,20 @@ public class NotificationData {
        }
    }

    /**
     * Returns true if this notification should be displayed in the high-priority notifications
     * section (and on the lockscreen and status bar).
     */
    public boolean isHighPriority(StatusBarNotification statusBarNotification) {
        if (mRankingMap != null) {
            getRanking(statusBarNotification.getKey(), mTmpRanking);
            return mTmpRanking.getImportance() >= NotificationManager.IMPORTANCE_DEFAULT
                    || statusBarNotification.getNotification().isForegroundService()
                    || statusBarNotification.getNotification().hasMediaSession();
        }
        return false;
    }

    public boolean isAmbient(String key) {
        if (mRankingMap != null) {
            getRanking(key, mTmpRanking);
+8 −12
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.statusbar.notification.stack;

import static android.app.NotificationManager.IMPORTANCE_DEFAULT;

import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator
        .ExpandAnimationParameters;
import static com.android.systemui.statusbar.phone.NotificationIconAreaController.LOW_PRIORITY;
@@ -28,7 +26,6 @@ import android.animation.TimeAnimator;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.NotificationManager;
import android.app.WallpaperManager;
import android.content.Context;
import android.content.Intent;
@@ -2315,8 +2312,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
            View child = getChildAt(i);
            if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
                if (mEntryManager.getNotificationData().getImportance(
                        row.getStatusBarNotification().getKey()) < IMPORTANCE_DEFAULT) {
                if (mEntryManager.getNotificationData().isHighPriority(
                        row.getStatusBarNotification())) {
                    break;
                } else {
                    lastChildBeforeGap = row;
@@ -2334,8 +2331,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
            View child = getChildAt(i);
            if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
                if (mEntryManager.getNotificationData().getImportance(
                        row.getStatusBarNotification().getKey()) < IMPORTANCE_DEFAULT) {
                if (!mEntryManager.getNotificationData().isHighPriority(
                        row.getStatusBarNotification())) {
                    return row;
                }
            }
@@ -5218,9 +5215,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                beforeSpeedBump = !mEntryManager.getNotificationData().isAmbient(
                        row.getStatusBarNotification().getKey());
            } else {
                beforeSpeedBump = mEntryManager.getNotificationData().getImportance(
                        row.getStatusBarNotification().getKey())
                        >= NotificationManager.IMPORTANCE_DEFAULT;
                beforeSpeedBump = mEntryManager.getNotificationData().isHighPriority(
                        row.getStatusBarNotification());
            }
            if (beforeSpeedBump) {
                speedBumpIndex = currentIndex;
@@ -5244,8 +5240,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                    continue;
                }
                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
                if (mEntryManager.getNotificationData().getImportance(
                        row.getStatusBarNotification().getKey()) < IMPORTANCE_DEFAULT) {
                if (!mEntryManager.getNotificationData().isHighPriority(
                        row.getStatusBarNotification())) {
                    if (currentIndex > 0) {
                        gapIndex = currentIndex;
                    }
+1 −3
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@ package com.android.systemui.statusbar.phone;

import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset;

import android.app.NotificationManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
@@ -190,8 +189,7 @@ public class NotificationIconAreaController implements DarkReceiver {
            return false;
        }
        if (!showLowPriority
                && mEntryManager.getNotificationData().getImportance(entry.key)
                < NotificationManager.IMPORTANCE_DEFAULT) {
                && !mEntryManager.getNotificationData().isHighPriority(entry.notification)) {
            return false;
        }
        if (!StatusBar.isTopLevelChild(entry)) {
Loading