diff options
author | John Spurlock <jspurlock@google.com> | 2014-03-24 17:38:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-03-24 17:38:44 +0000 |
commit | 2b45d84e24946d0cbbcc577ca3e195c0db687c9a (patch) | |
tree | 5f5b6b10c13e34c446343b9f94cca439d7e50144 | |
parent | eb2c85df4b2d8ea5dd3cd08cb0367d5ff666afe6 (diff) | |
parent | cf44a124ab4eca431b3c57776183cd3857113e6f (diff) | |
download | frameworks_base-2b45d84e24946d0cbbcc577ca3e195c0db687c9a.zip frameworks_base-2b45d84e24946d0cbbcc577ca3e195c0db687c9a.tar.gz frameworks_base-2b45d84e24946d0cbbcc577ca3e195c0db687c9a.tar.bz2 |
Merge "Unhide Notification kind, rename to category." into klp-modular-dev
-rw-r--r-- | api/current.txt | 16 | ||||
-rw-r--r-- | core/java/android/app/Notification.java | 127 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java | 13 | ||||
-rw-r--r-- | services/core/java/com/android/server/InputMethodManagerService.java | 3 |
4 files changed, 97 insertions, 62 deletions
diff --git a/api/current.txt b/api/current.txt index f981523..f6b0c33 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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); diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 6be2b7b..e6b5de1 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -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 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[] kind; + public String category; /** * Additional semantic data to be carried around with this Notification. @@ -568,6 +609,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()]; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index ed00398..9a0749d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -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() { diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 26424a5..bbec329 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -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); |