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

Commit dcd70d6e authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Allow conversations to be demoted out of the conversation space

Also default the flag to allow more notifications into that
space to on.

Test: atest
Bug: 137397357
Change-Id: I225f462879bdb28411cc631a3e259b4c71ba7394
parent 25e6dd3e
Loading
Loading
Loading
Loading
+29 −5
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ public final class NotificationChannel implements Parcelable {
    private static final String ATT_ORIG_IMP = "orig_imp";
    private static final String ATT_PARENT_CHANNEL = "parent";
    private static final String ATT_CONVERSATION_ID = "conv_id";
    private static final String ATT_DEMOTE = "dem";
    private static final String DELIMITER = ",";

    /**
@@ -194,6 +195,7 @@ public final class NotificationChannel implements Parcelable {
    private boolean mImportanceLockedDefaultApp;
    private String mParentId = null;
    private String mConversationId = null;
    private boolean mDemoted = false;

    /**
     * Creates a notification channel.
@@ -260,6 +262,7 @@ public final class NotificationChannel implements Parcelable {
        mOriginalImportance = in.readInt();
        mParentId = in.readString();
        mConversationId = in.readString();
        mDemoted = in.readBoolean();
    }

    @Override
@@ -317,6 +320,7 @@ public final class NotificationChannel implements Parcelable {
        dest.writeInt(mOriginalImportance);
        dest.writeString(mParentId);
        dest.writeString(mConversationId);
        dest.writeBoolean(mDemoted);
    }

    /**
@@ -386,8 +390,6 @@ public final class NotificationChannel implements Parcelable {
        return input;
    }

    // Modifiable by apps on channel creation.

    /**
     * @hide
     */
@@ -395,6 +397,8 @@ public final class NotificationChannel implements Parcelable {
        mId = id;
    }

    // Modifiable by apps on channel creation.

    /**
     * Sets what group this channel belongs to.
     *
@@ -766,6 +770,20 @@ public final class NotificationChannel implements Parcelable {
        mOriginalImportance = importance;
    }

    /**
     * @hide
     */
    public void setDemoted(boolean demoted) {
        mDemoted = demoted;
    }

    /**
     * @hide
     */
    public boolean isDemoted() {
        return mDemoted;
    }

    /**
     * Returns whether the user has chosen the importance of this channel, either to affirm the
     * initial selection from the app, or changed it to be higher or lower.
@@ -829,6 +847,7 @@ public final class NotificationChannel implements Parcelable {
        setOriginalImportance(safeInt(parser, ATT_ORIG_IMP, DEFAULT_IMPORTANCE));
        setConversationId(parser.getAttributeValue(null, ATT_PARENT_CHANNEL),
                parser.getAttributeValue(null, ATT_CONVERSATION_ID));
        setDemoted(safeBool(parser, ATT_DEMOTE, false));
    }

    @Nullable
@@ -959,6 +978,9 @@ public final class NotificationChannel implements Parcelable {
        if (getConversationId() != null) {
            out.attribute(null, ATT_CONVERSATION_ID, getConversationId());
        }
        if (isDemoted()) {
            out.attribute(null, ATT_DEMOTE, Boolean.toString(isDemoted()));
        }

        // mImportanceLockedDefaultApp and mImportanceLockedByOEM have a different source of
        // truth and so aren't written to this xml file
@@ -1118,7 +1140,8 @@ public final class NotificationChannel implements Parcelable {
                && mImportanceLockedDefaultApp == that.mImportanceLockedDefaultApp
                && mOriginalImportance == that.mOriginalImportance
                && Objects.equals(getParentChannelId(), that.getParentChannelId())
                && Objects.equals(getConversationId(), that.getConversationId());
                && Objects.equals(getConversationId(), that.getConversationId())
                && isDemoted() == that.isDemoted();
    }

    @Override
@@ -1129,7 +1152,7 @@ public final class NotificationChannel implements Parcelable {
                isFgServiceShown(), mVibrationEnabled, mShowBadge, isDeleted(), getGroup(),
                getAudioAttributes(), isBlockableSystem(), mAllowBubbles,
                mImportanceLockedByOEM, mImportanceLockedDefaultApp, mOriginalImportance,
                mParentId, mConversationId);
                mParentId, mConversationId, mDemoted);
        result = 31 * result + Arrays.hashCode(mVibration);
        return result;
    }
@@ -1176,7 +1199,8 @@ public final class NotificationChannel implements Parcelable {
                + ", mImportanceLockedDefaultApp=" + mImportanceLockedDefaultApp
                + ", mOriginalImp=" + mOriginalImportance
                + ", mParent=" + mParentId
                + ", mConversationId=" + mConversationId;
                + ", mConversationId=" + mConversationId
                + ", mDemoted=" + mDemoted;
    }

    /** @hide */
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS.put(SETTINGS_WIFITRACKER2, "false");
        DEFAULT_FLAGS.put("settings_controller_loading_enhancement", "false");
        DEFAULT_FLAGS.put("settings_conditionals", "false");
        DEFAULT_FLAGS.put(NOTIF_CONVO_BYPASS_SHORTCUT_REQ, "false");
        DEFAULT_FLAGS.put(NOTIF_CONVO_BYPASS_SHORTCUT_REQ, "true");
    }

    /**
+4 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.collection

import android.app.NotificationChannel
import android.app.NotificationManager.IMPORTANCE_HIGH
import android.app.NotificationManager.IMPORTANCE_MIN
import android.service.notification.NotificationListenerService.Ranking
@@ -191,9 +192,9 @@ open class NotificationRankingManager @Inject constructor(
    }

    private fun NotificationEntry.isPeopleNotification() =
            sbn.isPeopleNotification()
    private fun StatusBarNotification.isPeopleNotification() =
            peopleNotificationIdentifier.isPeopleNotification(this)
            sbn.isPeopleNotification(channel)
    private fun StatusBarNotification.isPeopleNotification(channel: NotificationChannel) =
            peopleNotificationIdentifier.isPeopleNotification(this, channel)

    private fun NotificationEntry.isHighPriority() =
            highPriorityProvider.isHighPriority(this)
+2 −1
Original line number Diff line number Diff line
@@ -99,7 +99,8 @@ public class HighPriorityProvider {
    }

    private boolean isPeopleNotification(NotificationEntry entry) {
        return mPeopleNotificationIdentifier.isPeopleNotification(entry.getSbn());
        return mPeopleNotificationIdentifier.isPeopleNotification(
                entry.getSbn(), entry.getChannel());
    }

    private boolean hasUserSetImportance(NotificationEntry entry) {
+6 −4
Original line number Diff line number Diff line
@@ -18,13 +18,14 @@ package com.android.systemui.statusbar.notification.people

import android.app.Notification
import android.content.Context
import android.app.NotificationChannel
import android.service.notification.StatusBarNotification
import android.util.FeatureFlagUtils
import javax.inject.Inject
import javax.inject.Singleton

interface PeopleNotificationIdentifier {
    fun isPeopleNotification(sbn: StatusBarNotification): Boolean
    fun isPeopleNotification(sbn: StatusBarNotification, channel: NotificationChannel): Boolean
}

@Singleton
@@ -33,12 +34,13 @@ class PeopleNotificationIdentifierImpl @Inject constructor(
    private val context: Context
) : PeopleNotificationIdentifier {

    override fun isPeopleNotification(sbn: StatusBarNotification) =
            (sbn.notification.notificationStyle == Notification.MessagingStyle::class.java &&
    override fun isPeopleNotification(sbn: StatusBarNotification, channel: NotificationChannel) =
            ((sbn.notification.notificationStyle == Notification.MessagingStyle::class.java &&
                    (sbn.notification.shortcutId != null ||
                            FeatureFlagUtils.isEnabled(
                                    context,
                                    FeatureFlagUtils.NOTIF_CONVO_BYPASS_SHORTCUT_REQ
                            ))) ||
                    personExtractor.isPersonNotification(sbn)
                    personExtractor.isPersonNotification(sbn)) &&
                    !channel.isDemoted
}
 No newline at end of file
Loading