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

Commit 2b45d84e authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Unhide Notification kind, rename to category." into klp-modular-dev

parents eb2c85df cf44a124
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -3920,6 +3920,20 @@ package android.app {
    method public int describeContents();
    method public deprecated void setLatestEventInfo(android.content.Context, java.lang.CharSequence, java.lang.CharSequence, android.app.PendingIntent);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final java.lang.String CATEGORY_ALARM = "alarm";
    field public static final java.lang.String CATEGORY_CALL = "call";
    field public static final java.lang.String CATEGORY_EMAIL = "email";
    field public static final java.lang.String CATEGORY_ERROR = "err";
    field public static final java.lang.String CATEGORY_EVENT = "event";
    field public static final java.lang.String CATEGORY_MESSAGE = "msg";
    field public static final java.lang.String CATEGORY_PROGRESS = "progress";
    field public static final java.lang.String CATEGORY_PROMO = "promo";
    field public static final java.lang.String CATEGORY_RECOMMENDATION = "recommendation";
    field public static final java.lang.String CATEGORY_SERVICE = "service";
    field public static final java.lang.String CATEGORY_SOCIAL = "social";
    field public static final java.lang.String CATEGORY_STATUS = "status";
    field public static final java.lang.String CATEGORY_SYSTEM = "sys";
    field public static final java.lang.String CATEGORY_TRANSPORT = "transport";
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int DEFAULT_ALL = -1; // 0xffffffff
    field public static final int DEFAULT_LIGHTS = 4; // 0x4
@@ -3960,6 +3974,7 @@ package android.app {
    field public android.app.Notification.Action[] actions;
    field public int audioStreamType;
    field public android.widget.RemoteViews bigContentView;
    field public java.lang.String category;
    field public android.app.PendingIntent contentIntent;
    field public android.widget.RemoteViews contentView;
    field public int defaults;
@@ -4018,6 +4033,7 @@ package android.app {
    method public android.os.Bundle getExtras();
    method public deprecated android.app.Notification getNotification();
    method public android.app.Notification.Builder setAutoCancel(boolean);
    method public android.app.Notification.Builder setCategory(java.lang.String);
    method public android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
    method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);
+77 −50
Original line number Diff line number Diff line
@@ -401,41 +401,82 @@ public class Notification implements Parcelable
    public int priority;

    /**
     * @hide
     * Notification type: incoming call (voice or video) or similar synchronous communication request.
     * Notification category: incoming call (voice or video) or similar synchronous communication request.
     */
    public static final String KIND_CALL = "android.call";
    public static final String CATEGORY_CALL = "call";

    /**
     * @hide
     * Notification type: incoming direct message (SMS, instant message, etc.).
     * Notification category: incoming direct message (SMS, instant message, etc.).
     */
    public static final String KIND_MESSAGE = "android.message";
    public static final String CATEGORY_MESSAGE = "msg";

    /**
     * @hide
     * Notification type: asynchronous bulk message (email).
     * Notification category: asynchronous bulk message (email).
     */
    public static final String KIND_EMAIL = "android.email";
    public static final String CATEGORY_EMAIL = "email";

    /**
     * @hide
     * Notification type: calendar event.
     * Notification category: calendar event.
     */
    public static final String KIND_EVENT = "android.event";
    public static final String CATEGORY_EVENT = "event";

    /**
     * @hide
     * Notification type: promotion or advertisement.
     * Notification category: promotion or advertisement.
     */
    public static final String KIND_PROMO = "android.promo";
    public static final String CATEGORY_PROMO = "promo";

    /**
     * @hide
     * If this notification matches of one or more special types (see the <code>KIND_*</code>
     * constants), add them here, best match first.
     * Notification category: alarm or timer.
     */
    public static final String CATEGORY_ALARM = "alarm";

    /**
     * Notification category: progress of a long-running background operation.
     */
    public static final String CATEGORY_PROGRESS = "progress";

    /**
     * Notification category: social network or sharing update.
     */
    public static final String CATEGORY_SOCIAL = "social";

    /**
     * Notification category: error in background operation or authentication status.
     */
    public static final String CATEGORY_ERROR = "err";

    /**
     * Notification category: media transport control for playback.
     */
    public static final String CATEGORY_TRANSPORT = "transport";

    /**
     * Notification category: system or device status update.  Reserved for system use.
     */
    public static final String CATEGORY_SYSTEM = "sys";

    /**
     * Notification category: indication of running background service.
     */
    public String[] kind;
    public static final String CATEGORY_SERVICE = "service";

    /**
     * Notification category: a specific, timely recommendation for a single thing.
     * For example, a news app might want to recommend a news story it believes the user will
     * want to read next.
     */
    public static final String CATEGORY_RECOMMENDATION = "recommendation";

    /**
     * Notification category: ongoing information about device or contextual status.
     */
    public static final String CATEGORY_STATUS = "status";

    /**
     * One of the predefined notification categories (see the <code>CATEGORY_*</code> constants)
     * that best describes this Notification.  May be used by the system for ranking and filtering.
     */
    public String category;

    /**
     * Additional semantic data to be carried around with this Notification.
@@ -567,6 +608,13 @@ public class Notification implements Parcelable
     */
    public static final String EXTRA_AS_HEADS_UP = "headsup";

    /**
     * Allow certain system-generated notifications to appear before the device is provisioned.
     * Only available to notifications coming from the android package.
     * @hide
     */
    public static final String EXTRA_ALLOW_DURING_SETUP = "android.allowDuringSetup";

    /**
     * Value for {@link #EXTRA_AS_HEADS_UP}.
     * @hide
@@ -757,7 +805,7 @@ public class Notification implements Parcelable

        priority = parcel.readInt();

        kind = parcel.createStringArray(); // may set kind to null
        category = parcel.readString();

        extras = parcel.readBundle(); // may be null

@@ -822,12 +870,7 @@ public class Notification implements Parcelable

        that.priority = this.priority;

        final String[] thiskind = this.kind;
        if (thiskind != null) {
            final int N = thiskind.length;
            final String[] thatkind = that.kind = new String[N];
            System.arraycopy(thiskind, 0, thatkind, 0, N);
        }
        that.category = this.category;

        if (this.extras != null) {
            try {
@@ -964,7 +1007,7 @@ public class Notification implements Parcelable

        parcel.writeInt(priority);

        parcel.writeStringArray(kind); // ok for null
        parcel.writeString(category);

        parcel.writeBundle(extras); // null ok

@@ -1084,16 +1127,7 @@ public class Notification implements Parcelable
        sb.append(Integer.toHexString(this.defaults));
        sb.append(" flags=0x");
        sb.append(Integer.toHexString(this.flags));
        sb.append(" kind=[");
        if (this.kind == null) {
            sb.append("null");
        } else {
            for (int i=0; i<this.kind.length; i++) {
                if (i>0) sb.append(",");
                sb.append(this.kind[i]);
            }
        }
        sb.append("]");
        sb.append(" category="); sb.append(this.category);
        if (actions != null) {
            sb.append(" ");
            sb.append(actions.length);
@@ -1172,7 +1206,7 @@ public class Notification implements Parcelable
        private int mProgressMax;
        private int mProgress;
        private boolean mProgressIndeterminate;
        private ArrayList<String> mKindList = new ArrayList<String>(1);
        private String mCategory;
        private Bundle mExtras;
        private int mPriority;
        private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
@@ -1574,14 +1608,12 @@ public class Notification implements Parcelable
        }

        /**
         * @hide
         *
         * Add a kind (category) to this notification. Optional.
         * Set the notification category.
         *
         * @see Notification#kind
         * @see Notification#category
         */
        public Builder addKind(String k) {
            mKindList.add(k);
        public Builder setCategory(String category) {
            mCategory = category;
            return this;
        }

@@ -1873,12 +1905,7 @@ public class Notification implements Parcelable
            if ((mDefaults & DEFAULT_LIGHTS) != 0) {
                n.flags |= FLAG_SHOW_LIGHTS;
            }
            if (mKindList.size() > 0) {
                n.kind = new String[mKindList.size()];
                mKindList.toArray(n.kind);
            } else {
                n.kind = null;
            }
            n.category = mCategory;
            n.priority = mPriority;
            if (mActions.size() > 0) {
                n.actions = new Action[mActions.size()];
+2 −11
Original line number Diff line number Diff line
@@ -1071,17 +1071,8 @@ public abstract class BaseStatusBar extends SystemUI implements
    // 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).
    protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) {
        if ("android".equals(sbn.getPackageName())) {
            if (sbn.getNotification().kind != null) {
                for (String aKind : sbn.getNotification().kind) {
                    // IME switcher, created by InputMethodManagerService
                    if ("android.system.imeswitcher".equals(aKind)) return true;
                    // OTA availability & errors, created by SystemUpdateService
                    if ("android.system.update".equals(aKind)) return true;
                }
            }
        }
        return false;
        return "android".equals(sbn.getPackageName())
                && sbn.getNotification().extras.getBoolean(Notification.EXTRA_ALLOW_DURING_SETUP);
    }

    public boolean inKeyguardRestrictedInputMode() {
+2 −1
Original line number Diff line number Diff line
@@ -632,7 +632,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        mImeSwitcherNotification.vibrate = null;

        // Tag this notification specially so SystemUI knows it's important
        mImeSwitcherNotification.kind = new String[] { "android.system.imeswitcher" };
        mImeSwitcherNotification.extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true);
        mImeSwitcherNotification.category = Notification.CATEGORY_SYSTEM;

        Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
        mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);