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

Commit 196a2956 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "The quietening round 2 part 1"

parents 81d43788 efcdff45
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4668,6 +4668,7 @@ package android.service.notification {
    method public int getUser();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
    field public static final java.lang.String KEY_IMPORTANCE = "key_importance";
    field public static final java.lang.String KEY_PEOPLE = "key_people";
    field public static final java.lang.String KEY_SMART_ACTIONS = "key_smart_actions";
    field public static final java.lang.String KEY_SMART_REPLIES = "key_smart_replies";
+1 −0
Original line number Diff line number Diff line
@@ -1047,6 +1047,7 @@ package android.service.notification {
    method public int getUser();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
    field public static final java.lang.String KEY_IMPORTANCE = "key_importance";
    field public static final java.lang.String KEY_PEOPLE = "key_people";
    field public static final java.lang.String KEY_SMART_ACTIONS = "key_smart_actions";
    field public static final java.lang.String KEY_SMART_REPLIES = "key_smart_replies";
+7 −0
Original line number Diff line number Diff line
@@ -599,6 +599,13 @@ public final class NotificationChannel implements Parcelable {
        return mBlockableSystem;
    }

    /**
     * @hide
     */
    public boolean isImportanceLocked() {
        return (mUserLockedFields & USER_LOCKED_IMPORTANCE) != 0;
    }

    /**
     * @hide
     */
+12 −0
Original line number Diff line number Diff line
@@ -76,6 +76,18 @@ public final class Adjustment implements Parcelable {
     */
    public static final String KEY_SMART_REPLIES = "key_smart_replies";

    /**
     * Data type: int, one of importance values e.g.
     * {@link android.app.NotificationManager#IMPORTANCE_MIN}.
     *
     * If used from
     * {@link NotificationAssistantService#onNotificationEnqueued(StatusBarNotification)}, it can
     * block a notification from appearing or silence it. If used from
     * {@link NotificationAssistantService#adjustNotification(Adjustment)}, it can visually
     * demote a notification.
     */
    public static final String KEY_IMPORTANCE = "key_importance";

    /**
     * Create a notification adjustment.
     *
+12 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.ext.services.notification;

import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.service.notification.NotificationListenerService.Ranking
        .USER_SENTIMENT_NEGATIVE;
@@ -204,17 +205,22 @@ public class Assistant extends NotificationAssistantService {
            @NonNull StatusBarNotification statusBarNotification,
            @NonNull ArrayList<Notification.Action> smartActions,
            @NonNull ArrayList<CharSequence> smartReplies) {
        if (smartActions.isEmpty() && smartReplies.isEmpty()) {
            return null;
        }
        Bundle signals = new Bundle();
        if (!smartActions.isEmpty()) {
            signals.putParcelableArrayList(Adjustment.KEY_SMART_ACTIONS, smartActions);
        }
        if (!smartReplies.isEmpty()) {
            signals.putCharSequenceArrayList(Adjustment.KEY_SMART_REPLIES, smartReplies);
        }

        // TODO: Apply rules to what gets silenced
        signals.putInt(Adjustment.KEY_IMPORTANCE, IMPORTANCE_LOW);

        return new Adjustment(
                statusBarNotification.getPackageName(),
                statusBarNotification.getKey(),
                signals,
                "smart action, reply" /* explanation */,
                "",
                statusBarNotification.getUserId());
    }

Loading