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

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

Merge "Add APIs for summarizing a notification" into main

parents 53d05392 a52ed746
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -42267,6 +42267,7 @@ package android.service.notification {
    method public int getRank();
    method @NonNull public java.util.List<android.app.Notification.Action> getSmartActions();
    method @NonNull public java.util.List<java.lang.CharSequence> getSmartReplies();
    method @FlaggedApi("android.app.nm_summarization") @Nullable public String getSummarization();
    method public int getSuppressedVisualEffects();
    method public int getUserSentiment();
    method public boolean isAmbient();
+1 −0
Original line number Diff line number Diff line
@@ -13446,6 +13446,7 @@ package android.service.notification {
    field public static final String KEY_RANKING_SCORE = "key_ranking_score";
    field public static final String KEY_SENSITIVE_CONTENT = "key_sensitive_content";
    field public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
    field @FlaggedApi("android.app.nm_summarization") public static final String KEY_SUMMARIZATION = "key_summarization";
    field public static final String KEY_TEXT_REPLIES = "key_text_replies";
    field @FlaggedApi("android.service.notification.notification_classification") public static final String KEY_TYPE = "key_type";
    field public static final String KEY_USER_SENTIMENT = "key_user_sentiment";
+14 −0
Original line number Diff line number Diff line
@@ -310,3 +310,17 @@ flag {
  description: "removes sbnholder from NLS"
  bug: "362981561"
}

flag {
  name: "nm_summarization"
  namespace: "systemui"
  description: "Allows the NAS to summarize notifications"
  bug: "390417189"
}

flag {
  name: "nm_summarization_ui"
  namespace: "systemui"
  description: "Shows summarized notifications in the UI"
  bug: "390217880"
}
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.Notification;
import android.os.Build;
import android.os.Bundle;
@@ -222,6 +223,14 @@ public final class Adjustment implements Parcelable {
    @FlaggedApi(Flags.FLAG_NOTIFICATION_CLASSIFICATION)
    public static final int TYPE_CONTENT_RECOMMENDATION = 4;

    /**
     * Data type: String, the classification type of this notification. The OS may display
     * notifications differently depending on the type, and may change the alerting level of the
     * notification.
     */
    @FlaggedApi(android.app.Flags.FLAG_NM_SUMMARIZATION)
    public static final String KEY_SUMMARIZATION = "key_summarization";

    /**
     * Create a notification adjustment.
     *
+21 −3
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UiThread;
import android.app.ActivityManager;
import android.app.INotificationManager;
@@ -56,6 +57,7 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.widget.RemoteViews;
@@ -1824,6 +1826,7 @@ public abstract class NotificationListenerService extends Service {
        private int mProposedImportance;
        // Sensitive info detected by the notification assistant
        private boolean mSensitiveContent;
        private String mSummarization;

        private static final int PARCEL_VERSION = 2;

@@ -1864,6 +1867,7 @@ public abstract class NotificationListenerService extends Service {
            out.writeBoolean(mIsBubble);
            out.writeInt(mProposedImportance);
            out.writeBoolean(mSensitiveContent);
            out.writeString(mSummarization);
        }

        /** @hide */
@@ -1904,6 +1908,7 @@ public abstract class NotificationListenerService extends Service {
            mIsBubble = in.readBoolean();
            mProposedImportance = in.readInt();
            mSensitiveContent = in.readBoolean();
            mSummarization = in.readString();
        }


@@ -2179,6 +2184,16 @@ public abstract class NotificationListenerService extends Service {
            return mShortcutInfo;
        }

        /**
         * Returns a summary of the content in the notification, or potentially of the current
         * notification and related notifications (for example, if this is provided for a group
         * summary notification it may be summarizing all the child notifications).
         */
        @FlaggedApi(android.app.Flags.FLAG_NM_SUMMARIZATION)
        public @Nullable String getSummarization() {
            return mSummarization;
        }

        /**
         * Returns the intended transition to ranking passed by {@link NotificationAssistantService}
         * @hide
@@ -2201,7 +2216,7 @@ public abstract class NotificationListenerService extends Service {
                ArrayList<CharSequence> smartReplies, boolean canBubble,
                boolean isTextChanged, boolean isConversation, ShortcutInfo shortcutInfo,
                int rankingAdjustment, boolean isBubble, int proposedImportance,
                boolean sensitiveContent) {
                boolean sensitiveContent, String summarization) {
            mKey = key;
            mRank = rank;
            mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW;
@@ -2229,6 +2244,7 @@ public abstract class NotificationListenerService extends Service {
            mIsBubble = isBubble;
            mProposedImportance = proposedImportance;
            mSensitiveContent = sensitiveContent;
            mSummarization = TextUtils.nullIfEmpty(summarization);
        }

        /**
@@ -2271,7 +2287,8 @@ public abstract class NotificationListenerService extends Service {
                    other.mRankingAdjustment,
                    other.mIsBubble,
                    other.mProposedImportance,
                    other.mSensitiveContent);
                    other.mSensitiveContent,
                    other.mSummarization);
        }

        /**
@@ -2332,7 +2349,8 @@ public abstract class NotificationListenerService extends Service {
                    && Objects.equals(mRankingAdjustment, other.mRankingAdjustment)
                    && Objects.equals(mIsBubble, other.mIsBubble)
                    && Objects.equals(mProposedImportance, other.mProposedImportance)
                    && Objects.equals(mSensitiveContent, other.mSensitiveContent);
                    && Objects.equals(mSensitiveContent, other.mSensitiveContent)
                    && Objects.equals(mSummarization, other.mSummarization);
        }
    }

Loading