Merge "Unhide notification category."

This commit is contained in:
John Spurlock
2014-03-21 14:26:55 +00:00
committed by Android (Google) Code Review
4 changed files with 89 additions and 62 deletions

View File

@ -4202,6 +4202,19 @@ package android.app {
method public int describeContents(); method public int describeContents();
method public deprecated void setLatestEventInfo(android.content.Context, java.lang.CharSequence, java.lang.CharSequence, android.app.PendingIntent); 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); 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_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 android.os.Parcelable.Creator CREATOR;
field public static final int DEFAULT_ALL = -1; // 0xffffffff field public static final int DEFAULT_ALL = -1; // 0xffffffff
field public static final int DEFAULT_LIGHTS = 4; // 0x4 field public static final int DEFAULT_LIGHTS = 4; // 0x4
@ -4246,6 +4259,7 @@ package android.app {
field public android.app.Notification.Action[] actions; field public android.app.Notification.Action[] actions;
field public int audioStreamType; field public int audioStreamType;
field public android.widget.RemoteViews bigContentView; field public android.widget.RemoteViews bigContentView;
field public java.lang.String category;
field public android.app.PendingIntent contentIntent; field public android.app.PendingIntent contentIntent;
field public android.widget.RemoteViews contentView; field public android.widget.RemoteViews contentView;
field public int defaults; field public int defaults;
@ -4306,6 +4320,7 @@ package android.app {
method public android.os.Bundle getExtras(); method public android.os.Bundle getExtras();
method public deprecated android.app.Notification getNotification(); method public deprecated android.app.Notification getNotification();
method public android.app.Notification.Builder setAutoCancel(boolean); 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 setContent(android.widget.RemoteViews);
method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence); method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent); method public android.app.Notification.Builder setContentIntent(android.app.PendingIntent);

View File

@ -444,41 +444,75 @@ public class Notification implements Parcelable
public static final int VISIBILITY_SECRET = -1; public static final int VISIBILITY_SECRET = -1;
/** /**
* @hide * Notification category: incoming call (voice or video) or similar synchronous communication request.
* Notification type: 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 category: incoming direct message (SMS, instant message, etc.).
* Notification type: incoming direct message (SMS, instant message, etc.).
*/ */
public static final String KIND_MESSAGE = "android.message"; public static final String CATEGORY_MESSAGE = "msg";
/** /**
* @hide * Notification category: asynchronous bulk message (email).
* Notification type: asynchronous bulk message (email).
*/ */
public static final String KIND_EMAIL = "android.email"; public static final String CATEGORY_EMAIL = "email";
/** /**
* @hide * Notification category: calendar event.
* Notification type: calendar event.
*/ */
public static final String KIND_EVENT = "android.event"; public static final String CATEGORY_EVENT = "event";
/** /**
* @hide * Notification category: promotion or advertisement.
* Notification type: promotion or advertisement.
*/ */
public static final String KIND_PROMO = "android.promo"; public static final String CATEGORY_PROMO = "promo";
/** /**
* @hide * Notification category: alarm or timer.
* If this notification matches of one or more special types (see the <code>KIND_*</code>
* constants), add them here, best match first.
*/ */
public String[] kind; 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: 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. * Additional semantic data to be carried around with this Notification.
@ -618,6 +652,13 @@ public class Notification implements Parcelable
*/ */
public static final String EXTRA_BUILDER_REMOTE_VIEWS = "android.builderRemoteViews"; public static final String EXTRA_BUILDER_REMOTE_VIEWS = "android.builderRemoteViews";
/**
* 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}. * Value for {@link #EXTRA_AS_HEADS_UP}.
* @hide * @hide
@ -815,7 +856,7 @@ public class Notification implements Parcelable
priority = parcel.readInt(); priority = parcel.readInt();
kind = parcel.createStringArray(); // may set kind to null category = parcel.readString();
extras = parcel.readBundle(); // may be null extras = parcel.readBundle(); // may be null
@ -890,12 +931,7 @@ public class Notification implements Parcelable
that.priority = this.priority; that.priority = this.priority;
final String[] thiskind = this.kind; that.category = this.category;
if (thiskind != null) {
final int N = thiskind.length;
final String[] thatkind = that.kind = new String[N];
System.arraycopy(thiskind, 0, thatkind, 0, N);
}
if (this.extras != null) { if (this.extras != null) {
try { try {
@ -1044,7 +1080,7 @@ public class Notification implements Parcelable
parcel.writeInt(priority); parcel.writeInt(priority);
parcel.writeStringArray(kind); // ok for null parcel.writeString(category);
parcel.writeBundle(extras); // null ok parcel.writeBundle(extras); // null ok
@ -1180,16 +1216,7 @@ public class Notification implements Parcelable
sb.append(Integer.toHexString(this.defaults)); sb.append(Integer.toHexString(this.defaults));
sb.append(" flags=0x"); sb.append(" flags=0x");
sb.append(Integer.toHexString(this.flags)); sb.append(Integer.toHexString(this.flags));
sb.append(" kind=["); sb.append(" category="); sb.append(this.category);
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("]");
if (actions != null) { if (actions != null) {
sb.append(" "); sb.append(" ");
sb.append(actions.length); sb.append(actions.length);
@ -1271,7 +1298,7 @@ public class Notification implements Parcelable
private int mProgressMax; private int mProgressMax;
private int mProgress; private int mProgress;
private boolean mProgressIndeterminate; private boolean mProgressIndeterminate;
private ArrayList<String> mKindList = new ArrayList<String>(1); private String mCategory;
private Bundle mExtras; private Bundle mExtras;
private int mPriority; private int mPriority;
private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS); private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
@ -1679,14 +1706,12 @@ public class Notification implements Parcelable
} }
/** /**
* @hide * Set the notification category.
* *
* Add a kind (category) to this notification. Optional. * @see Notification#category
*
* @see Notification#kind
*/ */
public Builder addKind(String k) { public Builder setCategory(String category) {
mKindList.add(k); mCategory = category;
return this; return this;
} }
@ -2010,12 +2035,7 @@ public class Notification implements Parcelable
if ((mDefaults & DEFAULT_LIGHTS) != 0) { if ((mDefaults & DEFAULT_LIGHTS) != 0) {
n.flags |= FLAG_SHOW_LIGHTS; n.flags |= FLAG_SHOW_LIGHTS;
} }
if (mKindList.size() > 0) { n.category = mCategory;
n.kind = new String[mKindList.size()];
mKindList.toArray(n.kind);
} else {
n.kind = null;
}
n.priority = mPriority; n.priority = mPriority;
if (mActions.size() > 0) { if (mActions.size() > 0) {
n.actions = new Action[mActions.size()]; n.actions = new Action[mActions.size()];

View File

@ -1521,17 +1521,8 @@ public abstract class BaseStatusBar extends SystemUI implements
// A: Almost none! Only things coming from the system (package is "android") that also // 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). // have special "kind" tags marking them as relevant for setup (see below).
protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) { protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) {
if ("android".equals(sbn.getPackageName())) { return "android".equals(sbn.getPackageName())
if (sbn.getNotification().kind != null) { && sbn.getNotification().extras.getBoolean(Notification.EXTRA_ALLOW_DURING_SETUP);
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;
} }
public boolean inKeyguardRestrictedInputMode() { public boolean inKeyguardRestrictedInputMode() {

View File

@ -637,7 +637,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
mImeSwitcherNotification.vibrate = null; mImeSwitcherNotification.vibrate = null;
// Tag this notification specially so SystemUI knows it's important // 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); Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); mImeSwitchPendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);