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

Commit 6b802214 authored by Selim Cinek's avatar Selim Cinek Committed by android-build-merger
Browse files

Not allowing foreground services to be cleared as children am: 1d35979f

am: fd1b667c

Change-Id: Ib363d7a764fc85b0d57422129b4eb8d81200e875
parents c25be09c fd1b667c
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -488,20 +488,6 @@ public class NotificationData {
        return false;
    }

    /**
     * Return whether there are any clearable notifications (that aren't errors).
     */
    public boolean hasActiveClearableNotifications() {
        for (Entry e : mSortedAndFiltered) {
            if (e.getContentView() != null) { // the view successfully inflated
                if (e.notification.isClearable()) {
                    return true;
                }
            }
        }
        return false;
    }

    // Q: What kinds of notifications should show during setup?
    // A: Almost none! Only things coming from the system (package is "android") that also
    // have special "kind" tags marking them as relevant for setup (see below).
+32 −6
Original line number Diff line number Diff line
@@ -1195,6 +1195,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                List<ExpandableNotificationRow> children = row.getNotificationChildren();
                if (row.areChildrenExpanded() && children != null) {
                    for (ExpandableNotificationRow childRow : children) {
                        if (mStackScroller.canChildBeDismissed(childRow)) {
                            if (childRow.getVisibility() == View.VISIBLE) {
                                viewsToHide.add(childRow);
                            }
@@ -1202,6 +1203,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    }
                }
            }
        }
        if (viewsToHide.isEmpty()) {
            animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
            return;
@@ -1544,8 +1546,15 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            }
            List<ExpandableNotificationRow> notificationChildren =
                    entry.row.getNotificationChildren();
            ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>(notificationChildren);
            for (int i = 0; i < toRemove.size(); i++) {
            ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>();
            for (int i = 0; i < notificationChildren.size(); i++) {
                ExpandableNotificationRow row = notificationChildren.get(i);
                if ((row.getStatusBarNotification().getNotification().flags
                        & Notification.FLAG_FOREGROUND_SERVICE) != 0) {
                    // the child is a forground service notification which we can't remove!
                    continue;
                }
                toRemove.add(row);
                toRemove.get(i).setKeepInParent(true);
                // we need to set this state earlier as otherwise we might generate some weird
                // animations
@@ -1817,10 +1826,27 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private void updateClearAll() {
        boolean showDismissView =
                mState != StatusBarState.KEYGUARD &&
                mNotificationData.hasActiveClearableNotifications();
               hasActiveClearableNotifications();
        mStackScroller.updateDismissView(showDismissView);
    }

    /**
     * Return whether there are any clearable notifications
     */
    private boolean hasActiveClearableNotifications() {
        int childCount = mStackScroller.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = mStackScroller.getChildAt(i);
            if (!(child instanceof ExpandableNotificationRow)) {
                continue;
            }
            if (((ExpandableNotificationRow) child).canViewBeDismissed()) {
                    return true;
            }
        }
        return false;
    }

    private void updateEmptyShadeView() {
        boolean showEmptyShade =
                mState != StatusBarState.KEYGUARD &&
@@ -1867,7 +1893,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

        if (SPEW) {
            final boolean clearable = hasActiveNotifications() &&
                    mNotificationData.hasActiveClearableNotifications();
                    hasActiveClearableNotifications();
            Log.d(TAG, "setAreThereNotifications: N=" +
                    mNotificationData.getActiveNotifications().size() + " any=" +
                    hasActiveNotifications() + " clearable=" + clearable);
+2 −1
Original line number Diff line number Diff line
@@ -3995,7 +3995,8 @@ public class NotificationManagerService extends SystemService {
            NotificationRecord childR = mNotificationList.get(i);
            StatusBarNotification childSbn = childR.sbn;
            if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) &&
                    childR.getGroupKey().equals(r.getGroupKey())) {
                    childR.getGroupKey().equals(r.getGroupKey())
                    && (childR.getFlags() & Notification.FLAG_FOREGROUND_SERVICE) == 0) {
                EventLogTags.writeNotificationCancel(callingUid, callingPid, pkg, childSbn.getId(),
                        childSbn.getTag(), userId, 0, 0, reason, listenerName);
                mNotificationList.remove(i);