diff options
57 files changed, 1194 insertions, 728 deletions
diff --git a/api/current.txt b/api/current.txt index 0a83fe00b0fc..e0dad49a06a1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3631,12 +3631,22 @@ package android.app { field public static final int DEFAULT_VIBRATE = 2; // 0x2 field public static final int FLAG_AUTO_CANCEL = 16; // 0x10 field public static final int FLAG_FOREGROUND_SERVICE = 64; // 0x40 - field public static final int FLAG_HIGH_PRIORITY = 128; // 0x80 + field public static final deprecated int FLAG_HIGH_PRIORITY = 128; // 0x80 field public static final int FLAG_INSISTENT = 4; // 0x4 field public static final int FLAG_NO_CLEAR = 32; // 0x20 field public static final int FLAG_ONGOING_EVENT = 2; // 0x2 field public static final int FLAG_ONLY_ALERT_ONCE = 8; // 0x8 field public static final int FLAG_SHOW_LIGHTS = 1; // 0x1 + field public static final java.lang.String KIND_CALL = "android.call"; + field public static final java.lang.String KIND_EMAIL = "android.email"; + field public static final java.lang.String KIND_EVENT = "android.event"; + field public static final java.lang.String KIND_MESSAGE = "android.message"; + field public static final java.lang.String KIND_PROMO = "android.promo"; + field public static final int PRIORITY_DEFAULT = 0; // 0x0 + field public static final int PRIORITY_HIGH = 1; // 0x1 + field public static final int PRIORITY_LOW = -1; // 0xffffffff + field public static final int PRIORITY_MAX = 2; // 0x2 + field public static final int PRIORITY_MIN = -2; // 0xfffffffe field public static final int STREAM_DEFAULT = -1; // 0xffffffff field public int audioStreamType; field public android.app.PendingIntent contentIntent; @@ -3647,11 +3657,13 @@ package android.app { field public android.app.PendingIntent fullScreenIntent; field public int icon; field public int iconLevel; + field public java.lang.String[] kind; field public android.graphics.Bitmap largeIcon; field public int ledARGB; field public int ledOffMS; field public int ledOnMS; field public int number; + field public int priority; field public android.net.Uri sound; field public java.lang.CharSequence tickerText; field public android.widget.RemoteViews tickerView; @@ -3661,6 +3673,7 @@ package android.app { public static class Notification.Builder { ctor public Notification.Builder(android.content.Context); + method public android.app.Notification.Builder addKind(java.lang.String); method public android.app.Notification getNotification(); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setContent(android.widget.RemoteViews); @@ -3676,6 +3689,7 @@ package android.app { method public android.app.Notification.Builder setNumber(int); method public android.app.Notification.Builder setOngoing(boolean); method public android.app.Notification.Builder setOnlyAlertOnce(boolean); + method public android.app.Notification.Builder setPriority(int); method public android.app.Notification.Builder setProgress(int, int, boolean); method public android.app.Notification.Builder setSmallIcon(int); method public android.app.Notification.Builder setSmallIcon(int, int); @@ -8615,14 +8629,14 @@ package android.graphics { method public static void getPixelFormatInfo(int, android.graphics.PixelFormat); field public static final int A_8 = 8; // 0x8 field public static final deprecated int JPEG = 256; // 0x100 - field public static final int LA_88 = 10; // 0xa + field public static final deprecated int LA_88 = 10; // 0xa field public static final int L_8 = 9; // 0x9 field public static final int OPAQUE = -1; // 0xffffffff - field public static final int RGBA_4444 = 7; // 0x7 - field public static final int RGBA_5551 = 6; // 0x6 + field public static final deprecated int RGBA_4444 = 7; // 0x7 + field public static final deprecated int RGBA_5551 = 6; // 0x6 field public static final int RGBA_8888 = 1; // 0x1 field public static final int RGBX_8888 = 2; // 0x2 - field public static final int RGB_332 = 11; // 0xb + field public static final deprecated int RGB_332 = 11; // 0xb field public static final int RGB_565 = 4; // 0x4 field public static final int RGB_888 = 3; // 0x3 field public static final int TRANSLUCENT = -3; // 0xfffffffd diff --git a/cmds/stagefright/codec.cpp b/cmds/stagefright/codec.cpp index ad246d265e4b..1b01bd61b0a3 100644 --- a/cmds/stagefright/codec.cpp +++ b/cmds/stagefright/codec.cpp @@ -107,9 +107,8 @@ static int decode( CHECK_EQ(err, (status_t)OK); size_t j = 0; - sp<RefBase> obj; - while (format->findObject(StringPrintf("csd-%d", j).c_str(), &obj)) { - sp<ABuffer> buffer = static_cast<ABuffer *>(obj.get()); + sp<ABuffer> buffer; + while (format->findBuffer(StringPrintf("csd-%d", j).c_str(), &buffer)) { state->mCSD.push_back(buffer); ++j; diff --git a/cmds/stagefright/sf2.cpp b/cmds/stagefright/sf2.cpp index 18e2532b463e..6f0fb54c7b14 100644 --- a/cmds/stagefright/sf2.cpp +++ b/cmds/stagefright/sf2.cpp @@ -358,7 +358,7 @@ private: buffer->meta()->setInt32("csd", true); mCSD.push(buffer); - msg->setObject("csd", buffer); + msg->setBuffer("csd", buffer); } else if (meta->findData(kKeyESDS, &type, &data, &size)) { ESDS esds((const char *)data, size); CHECK_EQ(esds.InitCheck(), (status_t)OK); @@ -408,9 +408,8 @@ private: return; } - sp<RefBase> obj; - CHECK(msg->findObject("buffer", &obj)); - sp<ABuffer> outBuffer = static_cast<ABuffer *>(obj.get()); + sp<ABuffer> outBuffer; + CHECK(msg->findBuffer("buffer", &outBuffer)); if (mCSDIndex < mCSD.size()) { outBuffer = mCSD.editItemAt(mCSDIndex++); @@ -509,15 +508,14 @@ private: } } - reply->setObject("buffer", outBuffer); + reply->setBuffer("buffer", outBuffer); reply->post(); } void onDrainThisBuffer(const sp<AMessage> &msg) { - sp<RefBase> obj; - CHECK(msg->findObject("buffer", &obj)); + sp<ABuffer> buffer; + CHECK(msg->findBuffer("buffer", &buffer)); - sp<ABuffer> buffer = static_cast<ABuffer *>(obj.get()); mTotalBytesReceived += buffer->size(); sp<AMessage> reply; diff --git a/core/java/android/accessibilityservice/UiTestAutomationBridge.java b/core/java/android/accessibilityservice/UiTestAutomationBridge.java index 9b3da53a6701..a898c3f6ae55 100644 --- a/core/java/android/accessibilityservice/UiTestAutomationBridge.java +++ b/core/java/android/accessibilityservice/UiTestAutomationBridge.java @@ -74,6 +74,8 @@ public class UiTestAutomationBridge { private volatile boolean mUnprocessedEventAvailable; + private HandlerThread mHandlerThread; + /** * Gets the last received {@link AccessibilityEvent}. * @@ -126,9 +128,10 @@ public class UiTestAutomationBridge { // is needed for making sure the binder calls are interleaved // with check for the expected event and also to make sure the // binder threads are allowed to proceed in the received order. - HandlerThread handlerThread = new HandlerThread("UiTestAutomationBridge"); - handlerThread.start(); - Looper looper = handlerThread.getLooper(); + mHandlerThread = new HandlerThread("UiTestAutomationBridge"); + mHandlerThread.setDaemon(true); + mHandlerThread.start(); + Looper looper = mHandlerThread.getLooper(); mListener = new IEventListenerWrapper(null, looper, new Callbacks() { @Override @@ -217,6 +220,8 @@ public class UiTestAutomationBridge { throw new IllegalStateException("Already disconnected."); } + mHandlerThread.quit(); + IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface( ServiceManager.getService(Context.ACCESSIBILITY_SERVICE)); diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index 2420b846514b..4d5238c582f7 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -33,7 +33,6 @@ interface INotificationManager void enqueueToast(String pkg, ITransientNotification callback, int duration); void cancelToast(String pkg, ITransientNotification callback); void enqueueNotificationWithTag(String pkg, String tag, int id, in Notification notification, inout int[] idReceived); - void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, in Notification notification, inout int[] idReceived); void cancelNotificationWithTag(String pkg, String tag, int id); } diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index d569e2071463..5325af044083 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; +import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; @@ -30,6 +31,7 @@ import android.widget.ProgressBar; import android.widget.RemoteViews; import java.text.NumberFormat; +import java.util.ArrayList; /** * A class that represents how a persistent notification is to be presented to @@ -51,36 +53,58 @@ public class Notification implements Parcelable * Use all default values (where applicable). */ public static final int DEFAULT_ALL = ~0; - + /** * Use the default notification sound. This will ignore any given * {@link #sound}. - * + * + * @see #defaults - */ + */ + public static final int DEFAULT_SOUND = 1; /** * Use the default notification vibrate. This will ignore any given - * {@link #vibrate}. Using phone vibration requires the + * {@link #vibrate}. Using phone vibration requires the * {@link android.Manifest.permission#VIBRATE VIBRATE} permission. - * + * * @see #defaults - */ + */ + public static final int DEFAULT_VIBRATE = 2; - + /** * Use the default notification lights. This will ignore the * {@link #FLAG_SHOW_LIGHTS} bit, and {@link #ledARGB}, {@link #ledOffMS}, or * {@link #ledOnMS}. - * + * * @see #defaults - */ + */ + public static final int DEFAULT_LIGHTS = 4; - + /** - * The timestamp for the notification. The icons and expanded views - * are sorted by this key. + * A timestamp related to this notification, in milliseconds since the epoch. + * + * Default value: {@link System#currentTimeMillis() Now}. + * + * Choose a timestamp that will be most relevant to the user. For most finite events, this + * corresponds to the time the event happened (or will happen, in the case of events that have + * yet to occur but about which the user is being informed). Indefinite events should be + * timestamped according to when the activity began. + * + * Some examples: + * + * <ul> + * <li>Notification of a new chat message should be stamped when the message was received.</li> + * <li>Notification of an ongoing file download (with a progress bar, for example) should be stamped when the download started.</li> + * <li>Notification of a completed file download should be stamped when the download finished.</li> + * <li>Notification of an upcoming meeting should be stamped with the time the meeting will begin (that is, in the future).</li> + * <li>Notification of an ongoing stopwatch (increasing timer) should be stamped with the watch's start time. + * <li>Notification of an ongoing countdown timer should be stamped with the timer's end time. + * </ul> + * */ public long when; @@ -100,10 +124,16 @@ public class Notification implements Parcelable public int iconLevel; /** - * The number of events that this notification represents. For example, in a new mail - * notification, this could be the number of unread messages. This number is superimposed over - * the icon in the status bar. If the number is 0 or negative, it is not shown in the status - * bar. + * The number of events that this notification represents. For example, in a new mail + * notification, this could be the number of unread messages. + * + * The system may or may not use this field to modify the appearance of the notification. For + * example, before {@link android.os.Build.VERSION_CODES#HONEYCOMB}, this number was + * superimposed over the icon in the status bar. Starting with + * {@link android.os.Build.VERSION_CODES#HONEYCOMB}, the template used by + * {@link Notification.Builder} has displayed the number in the expanded notification view. + * + * If the number is 0 or negative, it is never shown. */ public int number; @@ -121,10 +151,11 @@ public class Notification implements Parcelable public PendingIntent contentIntent; /** - * The intent to execute when the status entry is deleted by the user - * with the "Clear All Notifications" button. This probably shouldn't - * be launching an activity since several of those will be sent at the - * same time. + * The intent to execute when the notification is explicitly dismissed by the user, either with + * the "Clear All" button or by swiping it away individually. + * + * This probably shouldn't be launching an activity since several of those will be sent + * at the same time. */ public PendingIntent deleteIntent; @@ -139,11 +170,6 @@ public class Notification implements Parcelable * Text to scroll across the screen when this item is added to * the status bar on large and smaller devices. * - * <p>This field is provided separately from the other ticker fields - * both for compatibility and to allow an application to choose different - * text for when the text scrolls in and when it is displayed all at once - * in conjunction with one or more icons. - * * @see #tickerView */ public CharSequence tickerText; @@ -166,9 +192,9 @@ public class Notification implements Parcelable /** * The sound to play. - * + * * <p> - * To play the default notification sound, see {@link #defaults}. + * To play the default notification sound, see {@link #defaults}. * </p> */ public Uri sound; @@ -187,14 +213,13 @@ public class Notification implements Parcelable */ public int audioStreamType = STREAM_DEFAULT; - /** - * The pattern with which to vibrate. - * + * The pattern with which to vibrate. + * * <p> * To vibrate the default pattern, see {@link #defaults}. * </p> - * + * * @see android.os.Vibrator#vibrate(long[],int) */ public long[] vibrate; @@ -235,7 +260,6 @@ public class Notification implements Parcelable */ public int defaults; - /** * Bit to be bitwise-ored into the {@link #flags} field that should be * set if you want the LED on for this notification. @@ -252,7 +276,7 @@ public class Notification implements Parcelable * because they will be set to values that work on any given hardware. * <p> * The alpha channel must be set for forward compatibility. - * + * */ public static final int FLAG_SHOW_LIGHTS = 0x00000001; @@ -282,7 +306,8 @@ public class Notification implements Parcelable /** * Bit to be bitwise-ored into the {@link #flags} field that should be * set if the notification should be canceled when it is clicked by the - * user. On tablets, the + * user. On tablets, the + */ public static final int FLAG_AUTO_CANCEL = 0x00000010; @@ -301,22 +326,105 @@ public class Notification implements Parcelable public static final int FLAG_FOREGROUND_SERVICE = 0x00000040; /** - * Bit to be bitwise-ored into the {@link #flags} field that should be set if this notification - * represents a high-priority event that may be shown to the user even if notifications are - * otherwise unavailable (that is, when the status bar is hidden). This flag is ideally used - * in conjunction with {@link #fullScreenIntent}. + * Obsolete flag indicating high-priority notifications; use the priority field instead. + * + * @deprecated Use {@link #priority} with a positive value. */ - public static final int FLAG_HIGH_PRIORITY = 0x00000080; + public static final int FLAG_HIGH_PRIORITY = 0x00000080; public int flags; /** - * Constructs a Notification object with everything set to 0. + * Default notification {@link #priority}. If your application does not prioritize its own + * notifications, use this value for all notifications. + */ + public static final int PRIORITY_DEFAULT = 0; + + /** + * Lower {@link #priority}, for items that are less important. The UI may choose to show these + * items smaller, or at a different position in the list, compared with your app's + * {@link #PRIORITY_DEFAULT} items. + */ + public static final int PRIORITY_LOW = -1; + + /** + * Lowest {@link #priority}; these items might not be shown to the user except under special + * circumstances, such as detailed notification logs. + */ + public static final int PRIORITY_MIN = -2; + + /** + * Higher {@link #priority}, for more important notifications or alerts. The UI may choose to + * show these items larger, or at a different position in notification lists, compared with + * your app's {@link #PRIORITY_DEFAULT} items. + */ + public static final int PRIORITY_HIGH = 1; + + /** + * Highest {@link #priority}, for your application's most important items that require the + * user's prompt attention or input. + */ + public static final int PRIORITY_MAX = 2; + + /** + * Relative priority for this notification. + * + * Priority is an indication of how much of the user's valuable attention should be consumed by + * this notification. Low-priority notifications may be hidden from the user in certain + * situations, while the user might be interrupted for a higher-priority notification. The + * system will make a determination about how to interpret notification priority as described in + * MUMBLE MUMBLE. + */ + public int priority; + + /** + * Notification type: incoming call (voice or video) or similar synchronous communication request. + */ + public static final String KIND_CALL = "android.call"; + + /** + * Notification type: incoming direct message (SMS, instant message, etc.). + */ + public static final String KIND_MESSAGE = "android.message"; + + /** + * Notification type: asynchronous bulk message (email). + */ + public static final String KIND_EMAIL = "android.email"; + + /** + * Notification type: calendar event. + */ + public static final String KIND_EVENT = "android.event"; + + /** + * Notification type: promotion or advertisement. + */ + public static final String KIND_PROMO = "android.promo"; + + /** + * 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; + + /** + * Extra key for people values (type TBD). + * + * @hide + */ + public static final String EXTRA_PEOPLE = "android.people"; + + private Bundle extras; + + /** + * Constructs a Notification object with default values. * You might want to consider using {@link Builder} instead. */ public Notification() { this.when = System.currentTimeMillis(); + this.priority = PRIORITY_DEFAULT; } /** @@ -396,6 +504,14 @@ public class Notification implements Parcelable if (parcel.readInt() != 0) { fullScreenIntent = PendingIntent.CREATOR.createFromParcel(parcel); } + + priority = parcel.readInt(); + + kind = parcel.createStringArray(); // may set kind to null + + if (parcel.readInt() != 0) { + extras = parcel.readBundle(); + } } @Override @@ -438,9 +554,23 @@ public class Notification implements Parcelable that.ledOnMS = this.ledOnMS; that.ledOffMS = this.ledOffMS; that.defaults = this.defaults; - + that.flags = this.flags; + 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); + } + + if (this.extras != null) { + that.extras = new Bundle(this.extras); + + } + return that; } @@ -517,6 +647,17 @@ public class Notification implements Parcelable } else { parcel.writeInt(0); } + + parcel.writeInt(priority); + + parcel.writeStringArray(kind); // ok for null + + if (extras != null) { + parcel.writeInt(1); + extras.writeToParcel(parcel, 0); + } else { + parcel.writeInt(0); + } } /** @@ -551,7 +692,7 @@ public class Notification implements Parcelable * that you take care of task management as described in the * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back * Stack</a> document. - * + * * @deprecated Use {@link Builder} instead. */ @Deprecated @@ -579,7 +720,9 @@ public class Notification implements Parcelable @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("Notification(contentView="); + sb.append("Notification(pri="); + sb.append(priority); + sb.append(" contentView="); if (contentView != null) { sb.append(contentView.getPackage()); sb.append("/0x"); @@ -587,6 +730,7 @@ public class Notification implements Parcelable } else { sb.append("null"); } + // TODO(dsandler): defaults take precedence over local values, so reorder the branches below sb.append(" vibrate="); if (this.vibrate != null) { int N = this.vibrate.length-1; @@ -604,7 +748,7 @@ public class Notification implements Parcelable } else { sb.append("null"); } - sb.append(",sound="); + sb.append(" sound="); if (this.sound != null) { sb.append(this.sound.toString()); } else if ((this.defaults & DEFAULT_SOUND) != 0) { @@ -612,20 +756,39 @@ public class Notification implements Parcelable } else { sb.append("null"); } - sb.append(",defaults=0x"); + sb.append(" defaults=0x"); sb.append(Integer.toHexString(this.defaults)); - sb.append(",flags=0x"); + sb.append(" flags=0x"); sb.append(Integer.toHexString(this.flags)); - if ((this.flags & FLAG_HIGH_PRIORITY) != 0) { - sb.append("!!!1!one!"); + 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("])"); return sb.toString(); } /** - * Builder class for {@link Notification} objects. Allows easier control over - * all the flags, as well as help constructing the typical notification layouts. + * Builder class for {@link Notification} objects. + * + * Provides a convenient way to set the various fields of a {@link Notification} and generate + * content views using the platform's notification layout template. + * + * Example: + * + * <pre class="prettyprint"> + * Notification noti = new Notification.Builder() + * .setContentTitle("New mail from " + sender.toString()) + * .setContentText(subject) + * .setSmallIcon(R.drawable.new_mail) + * .setLargeIcon(aBitmap) + * .getNotification(); + * </pre> */ public static class Builder { private Context mContext; @@ -655,16 +818,28 @@ public class Notification implements Parcelable private int mProgressMax; private int mProgress; private boolean mProgressIndeterminate; + private ArrayList<String> mKindList = new ArrayList<String>(1); + private Bundle mExtras; + private int mPriority; /** - * Constructor. + * Constructs a new Builder with the defaults: * - * Automatically sets the when field to {@link System#currentTimeMillis() - * System.currentTimeMllis()} and the audio stream to the {@link #STREAM_DEFAULT}. + + * <table> + * <tr><th align=right>priority</th> + * <td>{@link #PRIORITY_DEFAULT}</td></tr> + * <tr><th align=right>when</th> + * <td>now ({@link System#currentTimeMillis()})</td></tr> + * <tr><th align=right>audio stream</th> + * <td>{@link #STREAM_DEFAULT}</td></tr> + * </table> * - * @param context A {@link Context} that will be used to construct the - * RemoteViews. The Context will not be held past the lifetime of this - * Builder object. + + * @param context + * A {@link Context} that will be used by the Builder to construct the + * RemoteViews. The Context will not be held past the lifetime of this Builder + * object. */ public Builder(Context context) { mContext = context; @@ -672,11 +847,14 @@ public class Notification implements Parcelable // Set defaults to match the defaults of a Notification mWhen = System.currentTimeMillis(); mAudioStreamType = STREAM_DEFAULT; + mPriority = PRIORITY_DEFAULT; } /** - * Set the time that the event occurred. Notifications in the panel are - * sorted by this time. + * Add a timestamp pertaining to the notification (usually the time the event occurred). + * + + * @see Notification#when */ public Builder setWhen(long when) { mWhen = when; @@ -684,11 +862,18 @@ public class Notification implements Parcelable } /** - * Set the small icon to use in the notification layouts. Different classes of devices - * may return different sizes. See the UX guidelines for more information on how to - * design these icons. + * Set the small icon resource, which will be used to represent the notification in the + * status bar. * - * @param icon A resource ID in the application's package of the drawble to use. + + * The platform template for the expanded view will draw this icon in the left, unless a + * {@link #setLargeIcon(Bitmap) large icon} has also been specified, in which case the small + * icon will be moved to the right-hand side. + * + + * @param icon + * A resource ID in the application's package of the drawable to use. + * @see Notification#icon */ public Builder setSmallIcon(int icon) { mSmallIcon = icon; @@ -700,10 +885,11 @@ public class Notification implements Parcelable * level parameter for when the icon is a {@link android.graphics.drawable.LevelListDrawable * LevelListDrawable}. * - * @param icon A resource ID in the application's package of the drawble to use. + * @param icon A resource ID in the application's package of the drawable to use. * @param level The level to use for the icon. * - * @see android.graphics.drawable.LevelListDrawable + * @see Notification#icon + * @see Notification#iconLevel */ public Builder setSmallIcon(int icon, int level) { mSmallIcon = icon; @@ -712,7 +898,7 @@ public class Notification implements Parcelable } /** - * Set the title (first row) of the notification, in a standard notification. + * Set the first line of text in the platform notification template. */ public Builder setContentTitle(CharSequence title) { mContentTitle = title; @@ -720,7 +906,7 @@ public class Notification implements Parcelable } /** - * Set the text (second row) of the notification, in a standard notification. + * Set the second line of text in the platform notification template. */ public Builder setContentText(CharSequence text) { mContentText = text; @@ -738,7 +924,11 @@ public class Notification implements Parcelable } /** - * Set the large text at the right-hand side of the notification. + * A small piece of additional information pertaining to this notification. + * + + * The platform template will draw this on the last line of the notification, at the far + * right (to the right of a smallIcon if it has been placed there). */ public Builder setContentInfo(CharSequence info) { mContentInfo = info; @@ -746,8 +936,10 @@ public class Notification implements Parcelable } /** - * Set the progress this notification represents, which may be - * represented as a {@link ProgressBar}. + * Set the progress this notification represents. + * + + * The platform template will represent this using a {@link ProgressBar}. */ public Builder setProgress(int max, int progress, boolean indeterminate) { mProgressMax = max; @@ -757,7 +949,10 @@ public class Notification implements Parcelable } /** - * Supply a custom RemoteViews to use instead of the standard one. + * Supply a custom RemoteViews to use instead of the platform template. + * + + * @see Notification#contentView */ public Builder setContent(RemoteViews views) { mContentView = views; @@ -765,12 +960,20 @@ public class Notification implements Parcelable } /** - * Supply a {@link PendingIntent} to send when the notification is clicked. - * If you do not supply an intent, you can now add PendingIntents to individual - * views to be launched when clicked by calling {@link RemoteViews#setOnClickPendingIntent - * RemoteViews.setOnClickPendingIntent(int,PendingIntent)}. Be sure to - * read {@link Notification#contentIntent Notification.contentIntent} for - * how to correctly use this. + * Supply a {@link PendingIntent} to be sent when the notification is clicked. + * + + * As of {@link android.os.Build.VERSION_CODES#HONEYCOMB}, if this field is unset and you + * have specified a custom RemoteViews with {@link #setContent(RemoteViews)}, you can use + * {@link RemoteViews#setOnClickPendingIntent RemoteViews.setOnClickPendingIntent(int,PendingIntent)} + + * to assign PendingIntents to individual views in that custom layout (i.e., to create + + * clickable buttons inside the + * notification view). + * + + * @see Notification#contentIntent Notification.contentIntent */ public Builder setContentIntent(PendingIntent intent) { mContentIntent = intent; @@ -778,11 +981,10 @@ public class Notification implements Parcelable } /** - * Supply a {@link PendingIntent} to send when the notification is cleared by the user - * directly from the notification panel. For example, this intent is sent when the user - * clicks the "Clear all" button, or the individual "X" buttons on notifications. This - * intent is not sent when the application calls {@link NotificationManager#cancel - * NotificationManager.cancel(int)}. + * Supply a {@link PendingIntent} to send when the notification is cleared explicitly by the user. + * + + * @see Notification#deleteIntent */ public Builder setDeleteIntent(PendingIntent intent) { mDeleteIntent = intent; @@ -801,6 +1003,8 @@ public class Notification implements Parcelable * @param intent The pending intent to launch. * @param highPriority Passing true will cause this notification to be sent * even if other notifications are suppressed. + * + * @see Notification#fullScreenIntent */ public Builder setFullScreenIntent(PendingIntent intent, boolean highPriority) { mFullScreenIntent = intent; @@ -809,8 +1013,11 @@ public class Notification implements Parcelable } /** - * Set the text that is displayed in the status bar when the notification first + * Set the "ticker" text which is displayed in the status bar when the notification first * arrives. + * + + * @see Notification#tickerText */ public Builder setTicker(CharSequence tickerText) { mTickerText = tickerText; @@ -821,6 +1028,9 @@ public class Notification implements Parcelable * Set the text that is displayed in the status bar when the notification first * arrives, and also a RemoteViews object that may be displayed instead on some * devices. + * + * @see Notification#tickerText + * @see Notification#tickerView */ public Builder setTicker(CharSequence tickerText, RemoteViews views) { mTickerText = tickerText; @@ -829,7 +1039,12 @@ public class Notification implements Parcelable } /** - * Set the large icon that is shown in the ticker and notification. + * Add a large icon to the notification (and the ticker on some devices). + * + * In the platform template, this image will be shown on the left of the notification view + * in place of the {@link #setSmallIcon(int) small icon} (which will move to the right side). + * + * @see Notification#largeIcon */ public Builder setLargeIcon(Bitmap icon) { mLargeIcon = icon; @@ -837,7 +1052,11 @@ public class Notification implements Parcelable } /** - * Set the sound to play. It will play on the default stream. + * Set the sound to play. + * + * It will be played on the {@link #STREAM_DEFAULT default stream} for notifications. + * + * @see Notification#sound */ public Builder setSound(Uri sound) { mSound = sound; @@ -846,10 +1065,11 @@ public class Notification implements Parcelable } /** - * Set the sound to play. It will play on the stream you supply. + * Set the sound to play, along with a specific stream on which to play it. * - * @see #STREAM_DEFAULT - * @see AudioManager for the <code>STREAM_</code> constants. + * See {@link android.media.AudioManager} for the <code>STREAM_</code> constants. + * + * @see Notification#sound */ public Builder setSound(Uri sound, int streamType) { mSound = sound; @@ -860,8 +1080,12 @@ public class Notification implements Parcelable /** * Set the vibration pattern to use. * - * @see android.os.Vibrator for a discussion of the <code>pattern</code> - * parameter. + + * See {@link android.os.Vibrator#vibrate(long[], int)} for a discussion of the + * <code>pattern</code> parameter. + * + + * @see Notification#vibrate */ public Builder setVibrate(long[] pattern) { mVibrate = pattern; @@ -869,9 +1093,16 @@ public class Notification implements Parcelable } /** - * Set the argb value that you would like the LED on the device to blnk, as well as the - * rate. The rate is specified in terms of the number of milliseconds to be on - * and then the number of milliseconds to be off. + * Set the desired color for the indicator LED on the device, as well as the + * blink duty cycle (specified in milliseconds). + * + + * Not all devices will honor all (or even any) of these values. + * + + * @see Notification#ledARGB + * @see Notification#ledOnMS + * @see Notification#ledOffMS */ public Builder setLights(int argb, int onMs, int offMs) { mLedArgb = argb; @@ -881,15 +1112,20 @@ public class Notification implements Parcelable } /** - * Set whether this is an ongoing notification. + * Set whether this is an "ongoing" notification. * - * <p>Ongoing notifications differ from regular notifications in the following ways: - * <ul> - * <li>Ongoing notifications are sorted above the regular notifications in the - * notification panel.</li> - * <li>Ongoing notifications do not have an 'X' close button, and are not affected - * by the "Clear all" button. - * </ul> + + * Ongoing notifications cannot be dismissed by the user, so your application or service + * must take care of canceling them. + * + + * They are typically used to indicate a background task that the user is actively engaged + * with (e.g., playing music) or is pending in some way and therefore occupying the device + * (e.g., a file download, sync operation, active network connection). + * + + * @see Notification#FLAG_ONGOING_EVENT + * @see Service#setForeground(boolean) */ public Builder setOngoing(boolean ongoing) { setFlag(FLAG_ONGOING_EVENT, ongoing); @@ -899,6 +1135,8 @@ public class Notification implements Parcelable /** * Set this flag if you would only like the sound, vibrate * and ticker to be played if the notification is not already showing. + * + * @see Notification#FLAG_ONLY_ALERT_ONCE */ public Builder setOnlyAlertOnce(boolean onlyAlertOnce) { setFlag(FLAG_ONLY_ALERT_ONCE, onlyAlertOnce); @@ -906,10 +1144,10 @@ public class Notification implements Parcelable } /** - * Setting this flag will make it so the notification is automatically - * canceled when the user clicks it in the panel. The PendingIntent - * set with {@link #setDeleteIntent} will be broadcast when the notification - * is canceled. + * Make this notification automatically dismissed when the user touches it. The + * PendingIntent set with {@link #setDeleteIntent} will be sent when this happens. + * + * @see Notification#FLAG_AUTO_CANCEL */ public Builder setAutoCancel(boolean autoCancel) { setFlag(FLAG_AUTO_CANCEL, autoCancel); @@ -917,7 +1155,7 @@ public class Notification implements Parcelable } /** - * Set the default notification options that will be used. + * Set which notification properties will be inherited from system defaults. * <p> * The value should be one or more of the following fields combined with * bitwise-or: @@ -930,6 +1168,41 @@ public class Notification implements Parcelable return this; } + /** + * Set the priority of this notification. + * + * @see Notification#priority + */ + public Builder setPriority(int pri) { + mPriority = pri; + return this; + } + + /** + * Add a kind (category) to this notification. Optional. + * + * @see Notification#kind + */ + public Builder addKind(String k) { + mKindList.add(k); + return this; + } + + /** + * Add metadata to this notification. + * + * A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's + * current contents are copied into the Notification each time {@link #getNotification()} is + * called. + * + * @see Notification#extras + * @hide + */ + public Builder setExtras(Bundle bag) { + mExtras = bag; + return this; + } + private void setFlag(int mask, boolean value) { if (value) { mFlags |= mask; @@ -1042,6 +1315,14 @@ 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.priority = mPriority; + n.extras = mExtras != null ? new Bundle(mExtras) : null; return n; } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 31d874f6a75c..e0d07635c1e8 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -381,6 +381,8 @@ public final class ViewRootImpl implements ViewParent, mAccessibilityManager = AccessibilityManager.getInstance(context); mAccessibilityInteractionConnectionManager = new AccessibilityInteractionConnectionManager(); + mAccessibilityManager.addAccessibilityStateChangeListener( + mAccessibilityInteractionConnectionManager); mAttachInfo = new View.AttachInfo(sWindowSession, mWindow, this, mHandler, this); mViewConfiguration = ViewConfiguration.get(context); mDensity = context.getResources().getDisplayMetrics().densityDpi; diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java b/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java index 4fb0046ffe12..dfbfc7091acf 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java @@ -16,7 +16,6 @@ package android.view.accessibility; -import android.os.Process; import android.util.Log; import android.util.LongSparseArray; @@ -81,14 +80,16 @@ public class AccessibilityNodeInfoCache { public AccessibilityNodeInfo get(long accessibilityNodeId) { if (ENABLED) { synchronized(mLock) { + AccessibilityNodeInfo info = mCacheImpl.get(accessibilityNodeId); + if (info != null) { + // Return a copy since the client calls to AccessibilityNodeInfo#recycle() + // will wipe the data of the cached info. + info = AccessibilityNodeInfo.obtain(info); + } if (DEBUG) { - AccessibilityNodeInfo info = mCacheImpl.get(accessibilityNodeId); - Log.i(LOG_TAG, "Process: " + Process.myPid() + - " get(" + accessibilityNodeId + ") = " + info); - return info; - } else { - return mCacheImpl.get(accessibilityNodeId); + Log.i(LOG_TAG, "get(" + accessibilityNodeId + ") = " + info); } + return info; } } else { return null; @@ -105,10 +106,12 @@ public class AccessibilityNodeInfoCache { if (ENABLED) { synchronized(mLock) { if (DEBUG) { - Log.i(LOG_TAG, "Process: " + Process.myPid() - + " put(" + accessibilityNodeId + ", " + info + ")"); + Log.i(LOG_TAG, "put(" + accessibilityNodeId + ", " + info + ")"); } - mCacheImpl.put(accessibilityNodeId, info); + // Cache a copy since the client calls to AccessibilityNodeInfo#recycle() + // will wipe the data of the cached info. + AccessibilityNodeInfo clone = AccessibilityNodeInfo.obtain(info); + mCacheImpl.put(accessibilityNodeId, clone); } } } @@ -138,8 +141,7 @@ public class AccessibilityNodeInfoCache { if (ENABLED) { synchronized(mLock) { if (DEBUG) { - Log.i(LOG_TAG, "Process: " + Process.myPid() - + " remove(" + accessibilityNodeId + ")"); + Log.i(LOG_TAG, "remove(" + accessibilityNodeId + ")"); } mCacheImpl.remove(accessibilityNodeId); } @@ -153,7 +155,13 @@ public class AccessibilityNodeInfoCache { if (ENABLED) { synchronized(mLock) { if (DEBUG) { - Log.i(LOG_TAG, "Process: " + Process.myPid() + "clear()"); + Log.i(LOG_TAG, "clear()"); + } + // Recycle the nodes before clearing the cache. + final int nodeCount = mCacheImpl.size(); + for (int i = 0; i < nodeCount; i++) { + AccessibilityNodeInfo info = mCacheImpl.valueAt(i); + info.recycle(); } mCacheImpl.clear(); } diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index c51d2440f893..b6b27c126dc5 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -26,7 +26,6 @@ import com.android.internal.view.IInputMethodSession; import com.android.internal.view.InputBindResult; import android.content.Context; -import android.content.pm.PackageManager; import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; @@ -198,7 +197,31 @@ public final class InputMethodManager { static final Object mInstanceSync = new Object(); static InputMethodManager mInstance; - + + /** + * @hide Flag for IInputMethodManager.windowGainedFocus: a view in + * the window has input focus. + */ + public static final int CONTROL_WINDOW_VIEW_HAS_FOCUS = 1<<0; + + /** + * @hide Flag for IInputMethodManager.windowGainedFocus: the focus + * is a text editor. + */ + public static final int CONTROL_WINDOW_IS_TEXT_EDITOR = 1<<1; + + /** + * @hide Flag for IInputMethodManager.windowGainedFocus: this is the first + * time the window has gotten focus. + */ + public static final int CONTROL_WINDOW_FIRST = 1<<2; + + /** + * @hide Flag for IInputMethodManager.startInput: this is the first + * time the window has gotten focus. + */ + public static final int CONTROL_START_INITIAL = 1<<8; + final IInputMethodManager mService; final Looper mMainLooper; @@ -216,7 +239,7 @@ public final class InputMethodManager { /** * Set whenever this client becomes inactive, to know we need to reset - * state with the IME then next time we receive focus. + * state with the IME the next time we receive focus. */ boolean mHasBeenInactive = true; @@ -243,11 +266,6 @@ public final class InputMethodManager { */ View mNextServedView; /** - * True if we should restart input in the next served view, even if the - * view hasn't actually changed from the current serve view. - */ - boolean mNextServedNeedsStart; - /** * This is set when we are in the process of connecting, to determine * when we have actually finished. */ @@ -331,7 +349,7 @@ public final class InputMethodManager { mCurId = res.id; mBindSequence = res.sequence; } - startInputInner(); + startInputInner(null, 0, 0, 0); return; } case MSG_UNBIND: { @@ -362,7 +380,7 @@ public final class InputMethodManager { } } if (startInput) { - startInputInner(); + startInputInner(null, 0, 0, 0); } return; } @@ -957,10 +975,11 @@ public final class InputMethodManager { mServedConnecting = true; } - startInputInner(); + startInputInner(null, 0, 0, 0); } - void startInputInner() { + boolean startInputInner(IBinder windowGainingFocus, int controlFlags, int softInputMode, + int windowFlags) { final View view; synchronized (mH) { view = mServedView; @@ -969,7 +988,7 @@ public final class InputMethodManager { if (DEBUG) Log.v(TAG, "Starting input: view=" + view); if (view == null) { if (DEBUG) Log.v(TAG, "ABORT input: no served view!"); - return; + return false; } } @@ -982,7 +1001,7 @@ public final class InputMethodManager { // If the view doesn't have a handler, something has changed out // from under us, so just bail. if (DEBUG) Log.v(TAG, "ABORT input: no handler for view!"); - return; + return false; } if (vh.getLooper() != Looper.myLooper()) { // The view is running on a different thread than our own, so @@ -990,10 +1009,10 @@ public final class InputMethodManager { if (DEBUG) Log.v(TAG, "Starting input: reschedule to view thread"); vh.post(new Runnable() { public void run() { - startInputInner(); + startInputInner(null, 0, 0, 0); } }); - return; + return false; } // Okay we are now ready to call into the served view and have it @@ -1013,12 +1032,14 @@ public final class InputMethodManager { if (DEBUG) Log.v(TAG, "Starting input: finished by someone else (view=" + mServedView + " conn=" + mServedConnecting + ")"); - return; + return false; } - + // If we already have a text box, then this view is already // connected so we want to restart it. - final boolean initial = mCurrentTextBoxAttribute == null; + if (mCurrentTextBoxAttribute == null) { + controlFlags |= CONTROL_START_INITIAL; + } // Hook 'em up and let 'er rip. mCurrentTextBoxAttribute = tba; @@ -1040,9 +1061,17 @@ public final class InputMethodManager { try { if (DEBUG) Log.v(TAG, "START INPUT: " + view + " ic=" - + ic + " tba=" + tba + " initial=" + initial); - InputBindResult res = mService.startInput(mClient, - servedContext, tba, initial, true); + + ic + " tba=" + tba + " controlFlags=#" + + Integer.toHexString(controlFlags)); + InputBindResult res; + if (windowGainingFocus != null) { + res = mService.windowGainedFocus(mClient, windowGainingFocus, + controlFlags, softInputMode, windowFlags, + tba, servedContext); + } else { + res = mService.startInput(mClient, + servedContext, tba, controlFlags); + } if (DEBUG) Log.v(TAG, "Starting input: Bind result=" + res); if (res != null) { if (res.id != null) { @@ -1051,7 +1080,7 @@ public final class InputMethodManager { } else if (mCurMethod == null) { // This means there is no input method available. if (DEBUG) Log.v(TAG, "ABORT input: no input method!"); - return; + return true; } } if (mCurMethod != null && mCompletions != null) { @@ -1064,6 +1093,8 @@ public final class InputMethodManager { Log.w(TAG, "IME died: " + mCurId, e); } } + + return true; } /** @@ -1139,27 +1170,26 @@ public final class InputMethodManager { * @hide */ public void checkFocus() { - if (checkFocusNoStartInput()) { - startInputInner(); + if (checkFocusNoStartInput(false)) { + startInputInner(null, 0, 0, 0); } } - private boolean checkFocusNoStartInput() { + private boolean checkFocusNoStartInput(boolean forceNewFocus) { // This is called a lot, so short-circuit before locking. - if (mServedView == mNextServedView && !mNextServedNeedsStart) { + if (mServedView == mNextServedView && !forceNewFocus) { return false; } InputConnection ic = null; synchronized (mH) { - if (mServedView == mNextServedView && !mNextServedNeedsStart) { + if (mServedView == mNextServedView && !forceNewFocus) { return false; } if (DEBUG) Log.v(TAG, "checkFocus: view=" + mServedView + " next=" + mNextServedView - + " restart=" + mNextServedNeedsStart); + + " forceNewFocus=" + forceNewFocus); - mNextServedNeedsStart = false; if (mNextServedView == null) { finishInputLocked(); // In this case, we used to have a focused view on the window, @@ -1190,13 +1220,14 @@ public final class InputMethodManager { } catch (RemoteException e) { } } - + /** * Called by ViewAncestor when its window gets input focus. * @hide */ public void onWindowFocus(View rootView, View focusedView, int softInputMode, boolean first, int windowFlags) { + boolean forceNewFocus = false; synchronized (mH) { if (DEBUG) Log.v(TAG, "onWindowFocus: " + focusedView + " softInputMode=" + softInputMode @@ -1205,27 +1236,42 @@ public final class InputMethodManager { if (mHasBeenInactive) { if (DEBUG) Log.v(TAG, "Has been inactive! Starting fresh"); mHasBeenInactive = false; - mNextServedNeedsStart = true; + forceNewFocus = true; } focusInLocked(focusedView != null ? focusedView : rootView); } + + int controlFlags = 0; + if (focusedView != null) { + controlFlags |= CONTROL_WINDOW_VIEW_HAS_FOCUS; + if (focusedView.onCheckIsTextEditor()) { + controlFlags |= CONTROL_WINDOW_IS_TEXT_EDITOR; + } + } + if (first) { + controlFlags |= CONTROL_WINDOW_FIRST; + } - boolean startInput = checkFocusNoStartInput(); + if (checkFocusNoStartInput(forceNewFocus)) { + // We need to restart input on the current focus view. This + // should be done in conjunction with telling the system service + // about the window gaining focus, to help make the transition + // smooth. + if (startInputInner(rootView.getWindowToken(), + controlFlags, softInputMode, windowFlags)) { + return; + } + } + // For some reason we didn't do a startInput + windowFocusGain, so + // we'll just do a window focus gain and call it a day. synchronized (mH) { try { - final boolean isTextEditor = focusedView != null && - focusedView.onCheckIsTextEditor(); mService.windowGainedFocus(mClient, rootView.getWindowToken(), - focusedView != null, isTextEditor, softInputMode, first, - windowFlags); + controlFlags, softInputMode, windowFlags, null, null); } catch (RemoteException e) { } } - - if (startInput) { - startInputInner(); - } } /** @hide */ @@ -1676,8 +1722,7 @@ public final class InputMethodManager { p.println(" mCurMethod=" + mCurMethod); p.println(" mCurRootView=" + mCurRootView); p.println(" mServedView=" + mServedView); - p.println(" mNextServedNeedsStart=" + mNextServedNeedsStart - + " mNextServedView=" + mNextServedView); + p.println(" mNextServedView=" + mNextServedView); p.println(" mServedConnecting=" + mServedConnecting); if (mCurrentTextBoxAttribute != null) { p.println(" mCurrentTextBoxAttribute:"); diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 98d59c43fdec..b9dfb2e99611 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -9238,6 +9238,30 @@ public class WebView extends AbsoluteLayout } } + private void setHitTestTypeFromUrl(String url) { + String substr = null; + if (url.startsWith(SCHEME_GEO)) { + mInitialHitTestResult.mType = HitTestResult.GEO_TYPE; + substr = url.substring(SCHEME_GEO.length()); + } else if (url.startsWith(SCHEME_TEL)) { + mInitialHitTestResult.mType = HitTestResult.PHONE_TYPE; + substr = url.substring(SCHEME_TEL.length()); + } else if (url.startsWith(SCHEME_MAILTO)) { + mInitialHitTestResult.mType = HitTestResult.EMAIL_TYPE; + substr = url.substring(SCHEME_MAILTO.length()); + } else { + mInitialHitTestResult.mType = HitTestResult.SRC_ANCHOR_TYPE; + mInitialHitTestResult.mExtra = url; + return; + } + try { + mInitialHitTestResult.mExtra = URLDecoder.decode(substr, "UTF-8"); + } catch (Throwable e) { + Log.w(LOGTAG, "Failed to decode URL! " + substr, e); + mInitialHitTestResult.mType = HitTestResult.UNKNOWN_TYPE; + } + } + private void setHitTestResult(WebKitHitTest hit) { if (hit == null) { mInitialHitTestResult = null; @@ -9245,9 +9269,9 @@ public class WebView extends AbsoluteLayout } mInitialHitTestResult = new HitTestResult(); if (hit.mLinkUrl != null) { - mInitialHitTestResult.mType = HitTestResult.SRC_ANCHOR_TYPE; - mInitialHitTestResult.mExtra = hit.mLinkUrl; - if (hit.mImageUrl != null) { + setHitTestTypeFromUrl(hit.mLinkUrl); + if (hit.mImageUrl != null + && mInitialHitTestResult.mType == HitTestResult.SRC_ANCHOR_TYPE) { mInitialHitTestResult.mType = HitTestResult.SRC_IMAGE_ANCHOR_TYPE; mInitialHitTestResult.mExtra = hit.mImageUrl; } @@ -9257,25 +9281,7 @@ public class WebView extends AbsoluteLayout } else if (hit.mEditable) { mInitialHitTestResult.mType = HitTestResult.EDIT_TEXT_TYPE; } else if (hit.mIntentUrl != null) { - String substr = null; - if (hit.mIntentUrl.startsWith(SCHEME_GEO)) { - mInitialHitTestResult.mType = HitTestResult.GEO_TYPE; - substr = hit.mIntentUrl.substring(SCHEME_GEO.length()); - } else if (hit.mIntentUrl.startsWith(SCHEME_TEL)) { - mInitialHitTestResult.mType = HitTestResult.PHONE_TYPE; - substr = hit.mIntentUrl.substring(SCHEME_TEL.length()); - } else if (hit.mIntentUrl.startsWith(SCHEME_MAILTO)) { - mInitialHitTestResult.mType = HitTestResult.EMAIL_TYPE; - substr = hit.mIntentUrl.substring(SCHEME_MAILTO.length()); - } else { - return; - } - try { - mInitialHitTestResult.mExtra = URLDecoder.decode(substr, "UTF-8"); - } catch (Throwable e) { - Log.w(LOGTAG, "Failed to decode GEO URL!", e); - mInitialHitTestResult.mType = HitTestResult.UNKNOWN_TYPE; - } + setHitTestTypeFromUrl(hit.mIntentUrl); } } @@ -9522,10 +9528,11 @@ public class WebView extends AbsoluteLayout } } nativeSetTextSelection(mNativeClass, data.mSelectTextPtr); - if (data.mSelectTextPtr != 0) { - mIsCaretSelection = (mFieldPointer == nodePointer) - && (mFieldPointer != 0) - && (data.mStart == data.mEnd); + + if (data.mSelectTextPtr != 0 && + (data.mStart != data.mEnd || + (mFieldPointer == nodePointer && mFieldPointer != 0))) { + mIsCaretSelection = (data.mStart == data.mEnd); if (!mSelectingText) { setupWebkitSelect(); } else if (!mSelectionStarted) { diff --git a/core/java/com/android/internal/statusbar/StatusBarNotification.java b/core/java/com/android/internal/statusbar/StatusBarNotification.java index c03ff1a15f88..d443523a2c12 100644 --- a/core/java/com/android/internal/statusbar/StatusBarNotification.java +++ b/core/java/com/android/internal/statusbar/StatusBarNotification.java @@ -34,25 +34,23 @@ if (truncatedTicker != null && truncatedTicker.length() > maxTickerLen) { } */ +/** + * Class encapsulating a Notification. Sent by the NotificationManagerService to the IStatusBar (in System UI). + */ public class StatusBarNotification implements Parcelable { - public static int PRIORITY_JIFFY_EXPRESS = -100; - public static int PRIORITY_NORMAL = 0; - public static int PRIORITY_ONGOING = 100; - public static int PRIORITY_SYSTEM = 200; - public String pkg; public int id; public String tag; public int uid; public int initialPid; public Notification notification; - public int priority = PRIORITY_NORMAL; - + public int score; + public StatusBarNotification() { } public StatusBarNotification(String pkg, int id, String tag, - int uid, int initialPid, Notification notification) { + int uid, int initialPid, int score, Notification notification) { if (pkg == null) throw new NullPointerException(); if (notification == null) throw new NullPointerException(); @@ -61,9 +59,8 @@ public class StatusBarNotification implements Parcelable { this.tag = tag; this.uid = uid; this.initialPid = initialPid; + this.score = score; this.notification = notification; - - this.priority = PRIORITY_NORMAL; } public StatusBarNotification(Parcel in) { @@ -80,7 +77,7 @@ public class StatusBarNotification implements Parcelable { } this.uid = in.readInt(); this.initialPid = in.readInt(); - this.priority = in.readInt(); + this.score = in.readInt(); this.notification = new Notification(in); } @@ -95,7 +92,7 @@ public class StatusBarNotification implements Parcelable { } out.writeInt(this.uid); out.writeInt(this.initialPid); - out.writeInt(this.priority); + out.writeInt(this.score); this.notification.writeToParcel(out, flags); } @@ -119,12 +116,12 @@ public class StatusBarNotification implements Parcelable { public StatusBarNotification clone() { return new StatusBarNotification(this.pkg, this.id, this.tag, - this.uid, this.initialPid, this.notification.clone()); + this.uid, this.initialPid, this.score, this.notification.clone()); } public String toString() { - return "StatusBarNotification(package=" + pkg + " id=" + id + " tag=" + tag - + " notification=" + notification + " priority=" + priority + ")"; + return "StatusBarNotification(pkg=" + pkg + " id=" + id + " tag=" + tag + + " score=" + score + " notn=" + notification + ")"; } public boolean isOngoing() { diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl index 5d80b799df70..82b2654f1821 100644 --- a/core/java/com/android/internal/view/IInputMethodManager.aidl +++ b/core/java/com/android/internal/view/IInputMethodManager.aidl @@ -43,16 +43,17 @@ interface IInputMethodManager { void removeClient(in IInputMethodClient client); InputBindResult startInput(in IInputMethodClient client, - IInputContext inputContext, in EditorInfo attribute, - boolean initial, boolean needResult); + IInputContext inputContext, in EditorInfo attribute, int controlFlags); void finishInput(in IInputMethodClient client); boolean showSoftInput(in IInputMethodClient client, int flags, in ResultReceiver resultReceiver); boolean hideSoftInput(in IInputMethodClient client, int flags, in ResultReceiver resultReceiver); - void windowGainedFocus(in IInputMethodClient client, in IBinder windowToken, - boolean viewHasFocus, boolean isTextEditor, - int softInputMode, boolean first, int windowFlags); + // Report that a window has gained focus. If 'attribute' is non-null, + // this will also do a startInput. + InputBindResult windowGainedFocus(in IInputMethodClient client, in IBinder windowToken, + int controlFlags, int softInputMode, int windowFlags, + in EditorInfo attribute, IInputContext inputContext); void showInputMethodPickerFromClient(in IInputMethodClient client); void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client, String topId); diff --git a/docs/html/guide/developing/projects/projects-eclipse.jd b/docs/html/guide/developing/projects/projects-eclipse.jd index 40c17ed14d5c..90f7820631ae 100644 --- a/docs/html/guide/developing/projects/projects-eclipse.jd +++ b/docs/html/guide/developing/projects/projects-eclipse.jd @@ -201,7 +201,7 @@ parent.link=index.html priority. The application itself has highest priority and its resources are always used in preference to identical resource IDs defined in libraries.</p> - <h3>Declaring library components in the the manifest file</h3> + <h3>Declaring library components in the manifest file</h3> <p>In the manifest file of the application project, you must add declarations of all components that the application will use that are imported from a library project. For example, you must diff --git a/graphics/java/android/graphics/PixelFormat.java b/graphics/java/android/graphics/PixelFormat.java index 182f14d60e11..f7c202f8dca3 100644 --- a/graphics/java/android/graphics/PixelFormat.java +++ b/graphics/java/android/graphics/PixelFormat.java @@ -39,11 +39,15 @@ public class PixelFormat public static final int RGB_888 = 3; public static final int RGB_565 = 4; + @Deprecated public static final int RGBA_5551 = 6; + @Deprecated public static final int RGBA_4444 = 7; public static final int A_8 = 8; public static final int L_8 = 9; + @Deprecated public static final int LA_88 = 0xA; + @Deprecated public static final int RGB_332 = 0xB; diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h index fc260c4f4b1d..9f3e267139c7 100644 --- a/include/ui/PixelFormat.h +++ b/include/ui/PixelFormat.h @@ -64,9 +64,6 @@ enum { PIXEL_FORMAT_RGBA_5551 = HAL_PIXEL_FORMAT_RGBA_5551, // 16-bit ARGB PIXEL_FORMAT_RGBA_4444 = HAL_PIXEL_FORMAT_RGBA_4444, // 16-bit ARGB PIXEL_FORMAT_A_8 = 8, // 8-bit A - - // New formats can be added if they're also defined in - // pixelflinger/format.h }; typedef int32_t PixelFormat; @@ -80,10 +77,12 @@ struct PixelFormatInfo { }; enum { // components - ALPHA = 1, - RGB = 2, - RGBA = 3, - OTHER = 0xFF + ALPHA = 1, + RGB = 2, + RGBA = 3, + L = 4, + LA = 5, + OTHER = 0xFF }; struct szinfo { diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp index 6993dac6998a..fc1d3c29db11 100644 --- a/libs/ui/PixelFormat.cpp +++ b/libs/ui/PixelFormat.cpp @@ -48,7 +48,10 @@ static Info const sPixelFormatInfos[] = { { 4, 32, {32,24, 24,16, 16, 8, 8, 0 }, PixelFormatInfo::RGBA }, { 2, 16, { 1, 0, 16,11, 11, 6, 6, 1 }, PixelFormatInfo::RGBA }, { 2, 16, { 4, 0, 16,12, 12, 8, 8, 4 }, PixelFormatInfo::RGBA }, - { 1, 8, { 8, 0, 0, 0, 0, 0, 0, 0 }, PixelFormatInfo::ALPHA} + { 1, 8, { 8, 0, 0, 0, 0, 0, 0, 0 }, PixelFormatInfo::ALPHA}, + { 1, 8, { 0, 0, 8, 0, 8, 0, 8, 0 }, PixelFormatInfo::L }, + { 2, 16, {16, 8, 8, 0, 8, 0, 8, 0 }, PixelFormatInfo::LA }, + { 1, 8, { 0, 0, 8, 5, 5, 2, 2, 0 }, PixelFormatInfo::RGB }, }; static const Info* gGetPixelFormatTable(size_t* numEntries) { diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 4acbdbe8b0f4..e14b1c406dc7 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -577,7 +577,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { { /* size_t index = */updateBuffers(kPortIndexInput, msg); - if (mState == FLUSHING) { + if (mState == FLUSHING || mState == STOPPING) { returnBuffersToCodecOnPort(kPortIndexInput); break; } @@ -596,7 +596,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { { /* size_t index = */updateBuffers(kPortIndexOutput, msg); - if (mState == FLUSHING) { + if (mState == FLUSHING || mState == STOPPING) { returnBuffersToCodecOnPort(kPortIndexOutput); break; } @@ -673,9 +673,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) { int32_t nameIsType; int32_t encoder = false; - if (!msg->findInt32("nameIsType", &nameIsType)) { - nameIsType = false; - } else { + CHECK(msg->findInt32("nameIsType", &nameIsType)); + if (nameIsType) { CHECK(msg->findInt32("encoder", &encoder)); } diff --git a/media/libstagefright/codecs/aacenc/basic_op/basic_op.h b/media/libstagefright/codecs/aacenc/basic_op/basic_op.h index ef3c31bad98e..e878bbaccb7c 100644 --- a/media/libstagefright/codecs/aacenc/basic_op/basic_op.h +++ b/media/libstagefright/codecs/aacenc/basic_op/basic_op.h @@ -228,7 +228,7 @@ Word32 L_shr_r (Word32 L_var1, Word16 var2); __inline Word32 ASM_L_shr(Word32 L_var1, Word16 var2) { Word32 result; - asm volatile( + asm ( "MOV %[result], %[L_var1], ASR %[var2] \n" :[result]"=r"(result) :[L_var1]"r"(L_var1), [var2]"r"(var2) @@ -239,15 +239,12 @@ __inline Word32 ASM_L_shr(Word32 L_var1, Word16 var2) __inline Word32 ASM_L_shl(Word32 L_var1, Word16 var2) { Word32 result; - asm volatile( - "MOV r2, %[L_var1] \n" - "MOV r3, #0x7fffffff\n" + asm ( "MOV %[result], %[L_var1], ASL %[var2] \n" - "TEQ r2, %[result], ASR %[var2]\n" - "EORNE %[result],r3,r2,ASR#31\n" - :[result]"+r"(result) - :[L_var1]"r"(L_var1), [var2]"r"(var2) - :"r2", "r3" + "TEQ %[L_var1], %[result], ASR %[var2]\n" + "EORNE %[result], %[mask], %[L_var1], ASR #31\n" + :[result]"=&r"(result) + :[L_var1]"r"(L_var1), [var2]"r"(var2), [mask]"r"(0x7fffffff) ); return result; } @@ -255,10 +252,10 @@ __inline Word32 ASM_L_shl(Word32 L_var1, Word16 var2) __inline Word32 ASM_shr(Word32 L_var1, Word16 var2) { Word32 result; - asm volatile( + asm ( "CMP %[var2], #15\n" - "MOVGE %[var2], #15\n" - "MOV %[result], %[L_var1], ASR %[var2]\n" + "MOVLT %[result], %[L_var1], ASR %[var2]\n" + "MOVGE %[result], %[L_var1], ASR #15\n" :[result]"=r"(result) :[L_var1]"r"(L_var1), [var2]"r"(var2) ); @@ -268,18 +265,16 @@ __inline Word32 ASM_shr(Word32 L_var1, Word16 var2) __inline Word32 ASM_shl(Word32 L_var1, Word16 var2) { Word32 result; - asm volatile( + Word32 tmp; + asm ( "CMP %[var2], #16\n" - "MOVGE %[var2], #16\n" - "MOV %[result], %[L_var1], ASL %[var2]\n" - "MOV r3, #1\n" - "MOV r2, %[result], ASR #15\n" - "RSB r3,r3,r3,LSL #15 \n" - "TEQ r2, %[result], ASR #31 \n" - "EORNE %[result], r3, %[result],ASR #31" - :[result]"+r"(result) - :[L_var1]"r"(L_var1), [var2]"r"(var2) - :"r2", "r3" + "MOVLT %[result], %[L_var1], ASL %[var2]\n" + "MOVGE %[result], %[L_var1], ASL #16\n" + "MOV %[tmp], %[result], ASR #15\n" + "TEQ %[tmp], %[result], ASR #31 \n" + "EORNE %[result], %[mask], %[result],ASR #31" + :[result]"=&r"(result), [tmp]"=&r"(tmp) + :[L_var1]"r"(L_var1), [var2]"r"(var2), [mask]"r"(0x7fff) ); return result; } @@ -295,16 +290,14 @@ __inline Word16 saturate(Word32 L_var1) { #if ARMV5TE_SAT Word16 result; + Word32 tmp; asm volatile ( - "MOV %[result], %[L_var1]\n" - "MOV r3, #1\n" - "MOV r2,%[L_var1],ASR#15\n" - "RSB r3, r3, r3, LSL #15\n" - "TEQ r2,%[L_var1],ASR#31\n" - "EORNE %[result],r3,%[L_var1],ASR#31\n" - :[result]"+r"(result) - :[L_var1]"r"(L_var1) - :"r2", "r3" + "MOV %[tmp], %[L_var1],ASR#15\n" + "TEQ %[tmp], %[L_var1],ASR#31\n" + "EORNE %[result], %[mask],%[L_var1],ASR#31\n" + "MOVEQ %[result], %[L_var1]\n" + :[result]"=&r"(result), [tmp]"=&r"(tmp) + :[L_var1]"r"(L_var1), [mask]"r"(0x7fff) ); return result; @@ -420,10 +413,10 @@ __inline Word32 L_mult(Word16 var1, Word16 var2) { #if ARMV5TE_L_MULT Word32 result; - asm volatile( + asm ( "SMULBB %[result], %[var1], %[var2] \n" "QADD %[result], %[result], %[result] \n" - :[result]"+r"(result) + :[result]"=r"(result) :[var1]"r"(var1), [var2]"r"(var2) ); return result; @@ -450,11 +443,11 @@ __inline Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2) { #if ARMV5TE_L_MSU Word32 result; - asm volatile( + asm ( "SMULBB %[result], %[var1], %[var2] \n" "QADD %[result], %[result], %[result] \n" "QSUB %[result], %[L_var3], %[result]\n" - :[result]"+r"(result) + :[result]"=&r"(result) :[L_var3]"r"(L_var3), [var1]"r"(var1), [var2]"r"(var2) ); return result; @@ -474,9 +467,9 @@ __inline Word32 L_sub(Word32 L_var1, Word32 L_var2) { #if ARMV5TE_L_SUB Word32 result; - asm volatile( + asm ( "QSUB %[result], %[L_var1], %[L_var2]\n" - :[result]"+r"(result) + :[result]"=r"(result) :[L_var1]"r"(L_var1), [L_var2]"r"(L_var2) ); return result; @@ -589,16 +582,14 @@ __inline Word16 add (Word16 var1, Word16 var2) { #if ARMV5TE_ADD Word32 result; - asm volatile( + Word32 tmp; + asm ( "ADD %[result], %[var1], %[var2] \n" - "MOV r3, #0x1\n" - "MOV r2, %[result], ASR #15\n" - "RSB r3, r3, r3, LSL, #15\n" - "TEQ r2, %[result], ASR #31\n" - "EORNE %[result], r3, %[result], ASR #31" - :[result]"+r"(result) - :[var1]"r"(var1), [var2]"r"(var2) - :"r2", "r3" + "MOV %[tmp], %[result], ASR #15 \n" + "TEQ %[tmp], %[result], ASR #31 \n" + "EORNE %[result], %[mask], %[result], ASR #31" + :[result]"=&r"(result), [tmp]"=&r"(tmp) + :[var1]"r"(var1), [var2]"r"(var2), [mask]"r"(0x7fff) ); return result; #else @@ -619,16 +610,14 @@ __inline Word16 sub(Word16 var1, Word16 var2) { #if ARMV5TE_SUB Word32 result; - asm volatile( - "MOV r3, #1\n" + Word32 tmp; + asm ( "SUB %[result], %[var1], %[var2] \n" - "RSB r3,r3,r3,LSL#15\n" - "MOV r2, %[var1], ASR #15 \n" - "TEQ r2, %[var1], ASR #31 \n" - "EORNE %[result], r3, %[result], ASR #31 \n" - :[result]"+r"(result) - :[var1]"r"(var1), [var2]"r"(var2) - :"r2", "r3" + "MOV %[tmp], %[var1], ASR #15 \n" + "TEQ %[tmp], %[var1], ASR #31 \n" + "EORNE %[result], %[mask], %[result], ASR #31 \n" + :[result]"=&r"(result), [tmp]"=&r"(tmp) + :[var1]"r"(var1), [var2]"r"(var2), [mask]"r"(0x7fff) ); return result; #else @@ -683,18 +672,15 @@ __inline Word16 div_s (Word16 var1, Word16 var2) __inline Word16 mult (Word16 var1, Word16 var2) { #if ARMV5TE_MULT - Word32 result; - asm volatile( - "SMULBB r2, %[var1], %[var2] \n" - "MOV r3, #1\n" - "MOV %[result], r2, ASR #15\n" - "RSB r3, r3, r3, LSL #15\n" - "MOV r2, %[result], ASR #15\n" - "TEQ r2, %[result], ASR #31\n" - "EORNE %[result], r3, %[result], ASR #31 \n" - :[result]"+r"(result) - :[var1]"r"(var1), [var2]"r"(var2) - :"r2", "r3" + Word32 result, tmp; + asm ( + "SMULBB %[tmp], %[var1], %[var2] \n" + "MOV %[result], %[tmp], ASR #15\n" + "MOV %[tmp], %[result], ASR #15\n" + "TEQ %[tmp], %[result], ASR #31\n" + "EORNE %[result], %[mask], %[result], ASR #31 \n" + :[result]"=&r"(result), [tmp]"=&r"(tmp) + :[var1]"r"(var1), [var2]"r"(var2), [mask]"r"(0x7fff) ); return result; #else @@ -719,18 +705,17 @@ __inline Word16 norm_s (Word16 var1) { #if ARMV5TE_NORM_S Word16 result; - asm volatile( - "MOV r2,%[var1] \n" - "CMP r2, #0\n" - "RSBLT %[var1], %[var1], #0 \n" - "CLZNE %[result], %[var1]\n" + Word32 tmp; + asm ( + "RSBS %[tmp], %[var1], #0 \n" + "CLZLT %[result], %[var1]\n" + "CLZGT %[result], %[tmp]\n" "SUBNE %[result], %[result], #17\n" "MOVEQ %[result], #0\n" - "CMP r2, #-1\n" + "CMP %[var1], #-1\n" "MOVEQ %[result], #15\n" - :[result]"+r"(result) + :[result]"=&r"(result), [tmp]"=&r"(tmp) :[var1]"r"(var1) - :"r2" ); return result; #else @@ -774,7 +759,7 @@ __inline Word16 norm_l (Word32 L_var1) "CLZNE %[result], %[L_var1]\n" "SUBNE %[result], %[result], #1\n" "MOVEQ %[result], #0\n" - :[result]"+r"(result) + :[result]"=r"(result) :[L_var1]"r"(L_var1) ); return result; @@ -979,13 +964,11 @@ __inline Word16 round16(Word32 L_var1) { #if ARMV5TE_ROUND Word16 result; - asm volatile( - "MOV r1,#0x00008000\n" - "QADD %[result], %[L_var1], r1\n" + asm ( + "QADD %[result], %[L_var1], %[bias]\n" "MOV %[result], %[result], ASR #16 \n" - :[result]"+r"(result) - :[L_var1]"r"(L_var1) - :"r1" + :[result]"=r"(result) + :[L_var1]"r"(L_var1), [bias]"r"(0x8000) ); return result; #else @@ -1005,11 +988,11 @@ __inline Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2) { #if ARMV5TE_L_MAC Word32 result; - asm volatile( + asm ( "SMULBB %[result], %[var1], %[var2]\n" "QADD %[result], %[result], %[result]\n" "QADD %[result], %[result], %[L_var3]\n" - :[result]"+r"(result) + :[result]"=&r"(result) : [L_var3]"r"(L_var3), [var1]"r"(var1), [var2]"r"(var2) ); return result; @@ -1029,9 +1012,9 @@ __inline Word32 L_add (Word32 L_var1, Word32 L_var2) { #if ARMV5TE_L_ADD Word32 result; - asm volatile( + asm ( "QADD %[result], %[L_var1], %[L_var2]\n" - :[result]"+r"(result) + :[result]"=r"(result) :[L_var1]"r"(L_var1), [L_var2]"r"(L_var2) ); return result; diff --git a/media/libstagefright/codecs/aacenc/basic_op/oper_32b.h b/media/libstagefright/codecs/aacenc/basic_op/oper_32b.h index 9ebd1c29d774..6e5844faad34 100644 --- a/media/libstagefright/codecs/aacenc/basic_op/oper_32b.h +++ b/media/libstagefright/codecs/aacenc/basic_op/oper_32b.h @@ -63,7 +63,7 @@ __inline Word32 L_mpy_wx(Word32 L_var2, Word16 var1) Word32 result; asm volatile( "SMULWB %[result], %[L_var2], %[var1] \n" - :[result]"+r"(result) + :[result]"=r"(result) :[L_var2]"r"(L_var2), [var1]"r"(var1) ); return result; diff --git a/media/libstagefright/codecs/aacenc/inc/aacenc_core.h b/media/libstagefright/codecs/aacenc/inc/aacenc_core.h index 1acdbbcb705d..bb75b6dc4796 100644 --- a/media/libstagefright/codecs/aacenc/inc/aacenc_core.h +++ b/media/libstagefright/codecs/aacenc/inc/aacenc_core.h @@ -102,7 +102,7 @@ Word16 AacEncEncode(AAC_ENCODER *hAacEnc, const UWord8 *ancBytes, /*!< pointer to ancillary data bytes */ Word16 *numAncBytes, /*!< number of ancillary Data Bytes, send as fill element */ UWord8 *outBytes, /*!< pointer to output buffer */ - Word32 *numOutBytes /*!< number of bytes in output buffer */ + VO_U32 *numOutBytes /*!< number of bytes in output buffer */ ); /*--------------------------------------------------------------------------- diff --git a/media/libstagefright/codecs/aacenc/inc/bitbuffer.h b/media/libstagefright/codecs/aacenc/inc/bitbuffer.h index e53806491ac6..7c79f07ec50a 100644 --- a/media/libstagefright/codecs/aacenc/inc/bitbuffer.h +++ b/media/libstagefright/codecs/aacenc/inc/bitbuffer.h @@ -76,7 +76,7 @@ Word16 GetBitsAvail(HANDLE_BIT_BUF hBitBuf); Word16 WriteBits(HANDLE_BIT_BUF hBitBuf, - Word32 writeValue, + UWord32 writeValue, Word16 noBitsToWrite); void ResetBitBuf(HANDLE_BIT_BUF hBitBuf, diff --git a/media/libstagefright/codecs/aacenc/inc/psy_configuration.h b/media/libstagefright/codecs/aacenc/inc/psy_configuration.h index 9abfc99fc413..f6981fafff95 100644 --- a/media/libstagefright/codecs/aacenc/inc/psy_configuration.h +++ b/media/libstagefright/codecs/aacenc/inc/psy_configuration.h @@ -31,7 +31,7 @@ typedef struct{ Word16 sfbCnt; Word16 sfbActive; /* number of sf bands containing energy after lowpass */ - Word16 *sfbOffset; + const Word16 *sfbOffset; Word32 sfbThresholdQuiet[MAX_SFB_LONG]; @@ -61,7 +61,7 @@ typedef struct{ Word16 sfbCnt; Word16 sfbActive; /* number of sf bands containing energy after lowpass */ - Word16 *sfbOffset; + const Word16 *sfbOffset; Word32 sfbThresholdQuiet[MAX_SFB_SHORT]; diff --git a/media/libstagefright/codecs/aacenc/src/aacenc_core.c b/media/libstagefright/codecs/aacenc/src/aacenc_core.c index 2b3bd48c9772..cecbc8f10be6 100644 --- a/media/libstagefright/codecs/aacenc/src/aacenc_core.c +++ b/media/libstagefright/codecs/aacenc/src/aacenc_core.c @@ -146,7 +146,7 @@ Word16 AacEncEncode(AAC_ENCODER *aacEnc, /*!< an encoder handle */ const UWord8 *ancBytes, /*!< pointer to ancillary data bytes */ Word16 *numAncBytes, /*!< number of ancillary Data Bytes */ UWord8 *outBytes, /*!< pointer to output buffer (must be large MINBITS_COEF/8*MAX_CHANNELS bytes) */ - Word32 *numOutBytes /*!< number of bytes in output buffer after processing */ + VO_U32 *numOutBytes /*!< number of bytes in output buffer after processing */ ) { ELEMENT_INFO *elInfo = &aacEnc->elInfo; diff --git a/media/libstagefright/codecs/aacenc/src/adj_thr.c b/media/libstagefright/codecs/aacenc/src/adj_thr.c index a8ab809f3f60..373b06303985 100644 --- a/media/libstagefright/codecs/aacenc/src/adj_thr.c +++ b/media/libstagefright/codecs/aacenc/src/adj_thr.c @@ -26,6 +26,7 @@ #include "adj_thr.h" #include "qc_data.h" #include "line_pe.h" +#include <string.h> #define minSnrLimit 0x6666 /* 1 dB */ @@ -1138,6 +1139,7 @@ void AdjustThresholds(ADJ_THR_STATE *adjThrState, Word16 maxBitresBits = elBits->maxBits; Word16 sideInfoBits = (qcOE->staticBitsUsed + qcOE->ancBitsUsed); Word16 ch; + memset(&peData, 0, sizeof(peData)); prepareSfbPe(&peData, psyOutChannel, logSfbEnergy, sfbNRelevantLines, nChannels, AdjThrStateElement->peOffset); diff --git a/media/libstagefright/codecs/aacenc/src/bitbuffer.c b/media/libstagefright/codecs/aacenc/src/bitbuffer.c index 5615ac3cd65c..a706893d54e9 100644 --- a/media/libstagefright/codecs/aacenc/src/bitbuffer.c +++ b/media/libstagefright/codecs/aacenc/src/bitbuffer.c @@ -138,7 +138,7 @@ Word16 GetBitsAvail(HANDLE_BIT_BUF hBitBuf) * *****************************************************************************/ Word16 WriteBits(HANDLE_BIT_BUF hBitBuf, - Word32 writeValue, + UWord32 writeValue, Word16 noBitsToWrite) { Word16 wBitPos; diff --git a/media/libstagefright/codecs/aacenc/src/dyn_bits.c b/media/libstagefright/codecs/aacenc/src/dyn_bits.c index 3d2efdc1ef32..77691884da2a 100644 --- a/media/libstagefright/codecs/aacenc/src/dyn_bits.c +++ b/media/libstagefright/codecs/aacenc/src/dyn_bits.c @@ -281,7 +281,7 @@ noiselessCounter(SECTION_DATA *sectionData, const Word32 blockType) { Word32 grpNdx, i; - Word16 *sideInfoTab = NULL; + const Word16 *sideInfoTab = NULL; SECTION_INFO *sectionInfo; /* diff --git a/media/libstagefright/codecs/aacenc/src/interface.c b/media/libstagefright/codecs/aacenc/src/interface.c index f2472d8c8680..d0ad4335c9c4 100644 --- a/media/libstagefright/codecs/aacenc/src/interface.c +++ b/media/libstagefright/codecs/aacenc/src/interface.c @@ -99,8 +99,8 @@ void BuildInterface(Word32 *groupedMdctSpectrum, Word32 i; Word32 accuSumMS=0; Word32 accuSumLR=0; - Word32 *pSumMS = sfbEnergySumMS.sfbShort; - Word32 *pSumLR = sfbEnergySumLR.sfbShort; + const Word32 *pSumMS = sfbEnergySumMS.sfbShort; + const Word32 *pSumLR = sfbEnergySumLR.sfbShort; for (i=TRANS_FAC; i; i--) { accuSumLR = L_add(accuSumLR, *pSumLR); pSumLR++; diff --git a/media/libstagefright/codecs/aacenc/src/psy_configuration.c b/media/libstagefright/codecs/aacenc/src/psy_configuration.c index 02d92ab1c4b0..dd40f9b24fbb 100644 --- a/media/libstagefright/codecs/aacenc/src/psy_configuration.c +++ b/media/libstagefright/codecs/aacenc/src/psy_configuration.c @@ -139,7 +139,7 @@ static Word16 BarcLineValue(Word16 noOfLines, Word16 fftLine, Word32 samplingFre * *****************************************************************************/ static void initThrQuiet(Word16 numPb, - Word16 *pbOffset, + const Word16 *pbOffset, Word16 *pbBarcVal, Word32 *pbThresholdQuiet) { Word16 i; @@ -250,7 +250,7 @@ static void initSpreading(Word16 numPb, * *****************************************************************************/ static void initBarcValues(Word16 numPb, - Word16 *pbOffset, + const Word16 *pbOffset, Word16 numLines, Word32 samplingFrequency, Word16 *pbBval) diff --git a/media/libstagefright/codecs/aacenc/src/psy_main.c b/media/libstagefright/codecs/aacenc/src/psy_main.c index 085acb8c8692..4e9218c81a39 100644 --- a/media/libstagefright/codecs/aacenc/src/psy_main.c +++ b/media/libstagefright/codecs/aacenc/src/psy_main.c @@ -658,7 +658,8 @@ static Word16 advancePsychShort(PSY_DATA* psyData, Word32 normEnergyShift = (psyData->mdctScale + 1) << 1; /* in reference code, mdct spectrum must be multipied with 2, so +1 */ Word32 clipEnergy = hPsyConfShort->clipEnergy >> normEnergyShift; Word32 wOffset = 0; - Word32 *data0, *data1; + Word32 *data0; + const Word32 *data1; for(w = 0; w < TRANS_FAC; w++) { Word32 i, tdata; diff --git a/media/libstagefright/codecs/aacenc/src/quantize.c b/media/libstagefright/codecs/aacenc/src/quantize.c index 54add2f73f47..0d0f550402e6 100644 --- a/media/libstagefright/codecs/aacenc/src/quantize.c +++ b/media/libstagefright/codecs/aacenc/src/quantize.c @@ -110,7 +110,7 @@ static void quantizeLines(const Word16 gain, Word32 m = gain&3; Word32 g = (gain >> 2) + 4; Word32 mdctSpeL; - Word16 *pquat; + const Word16 *pquat; /* gain&3 */ pquat = quantBorders[m]; @@ -333,7 +333,7 @@ Word32 calcSfbDist(const Word32 *spec, Word32 m = gain&3; Word32 g = (gain >> 2) + 4; Word32 g2 = (g << 1) + 1; - Word16 *pquat, *repquat; + const Word16 *pquat, *repquat; /* gain&3 */ pquat = quantBorders[m]; diff --git a/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp b/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp index bd99b30969af..4135f30ea73f 100644 --- a/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp +++ b/media/libstagefright/codecs/amrnb/common/src/az_lsp.cpp @@ -299,7 +299,7 @@ static Word16 Chebps(Word16 x, t0 += (Word32) * (p_f) << 13; - if ((UWord32)(t0 - 0xfe000000L) < 0x01ffffffL - 0xfe000000L) + if ((UWord32)(t0 - 0xfe000000L) < (UWord32)0x03ffffffL) { cheb = (Word16)(t0 >> 10); } diff --git a/media/libstagefright/codecs/amrnb/enc/src/set_sign.cpp b/media/libstagefright/codecs/amrnb/enc/src/set_sign.cpp index dedf91acd7e7..d626de37e5a4 100644 --- a/media/libstagefright/codecs/amrnb/enc/src/set_sign.cpp +++ b/media/libstagefright/codecs/amrnb/enc/src/set_sign.cpp @@ -552,10 +552,10 @@ void set_sign12k2( else { *(p_sign--) = -32767; /* sign = -1 */ - cor = - (cor); + cor = negate(cor); /* modify dn[] according to the fixed sign */ - dn[i] = - val; + dn[i] = negate(val); } *(p_en--) = cor; diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index cd8bd4ecd3be..14ce266c63db 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -236,10 +236,6 @@ public class SwipeHelper { public void onAnimationEnd(Animator animation) { mCallback.onChildDismissed(view); animView.setLayerType(View.LAYER_TYPE_NONE, null); - // Restore the alpha/translation parameters to what they were before swiping - // (for when these items are recycled) - animView.setAlpha(1f); - setTranslation(animView, 0f); } }); anim.addUpdateListener(new AnimatorUpdateListener() { diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java index 4718a1719dcb..4dc3e33b3087 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java @@ -181,6 +181,11 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView mLinearLayout.removeView(v); mCallback.handleSwipe(v); v.setActivated(false); + // Restore the alpha/translation parameters to what they were before swiping + // (for when these items are recycled) + View contentView = getChildContentView(v); + contentView.setAlpha(1f); + contentView.setTranslationY(0); } public void onBeginDrag(View v) { diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java index 0605c4c039a2..19fce37cf48d 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java @@ -187,6 +187,11 @@ public class RecentsVerticalScrollView extends ScrollView implements SwipeHelper mLinearLayout.removeView(v); mCallback.handleSwipe(v); v.setActivated(false); + // Restore the alpha/translation parameters to what they were before swiping + // (for when these items are recycled) + View contentView = getChildContentView(v); + contentView.setAlpha(1f); + contentView.setTranslationX(0); } public void onBeginDrag(View v) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java index 3d904ee52bda..6fbcd64786c7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java @@ -47,12 +47,13 @@ public class NotificationData { } private final ArrayList<Entry> mEntries = new ArrayList<Entry>(); private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() { + // sort first by score, then by when public int compare(Entry a, Entry b) { final StatusBarNotification na = a.notification; final StatusBarNotification nb = b.notification; - int priDiff = na.priority - nb.priority; - return (priDiff != 0) - ? priDiff + int d = na.score - nb.score; + return (d != 0) + ? d : (int)(na.notification.when - nb.notification.when); } }; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index b3cef9063e39..401553fa21cd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -232,6 +232,11 @@ public class PhoneStatusBar extends StatusBar { private int mNavigationIconHints = 0; + // TODO(dsandler): codify this stuff in NotificationManager's header somewhere + private int mDisplayMinScore = Notification.PRIORITY_LOW * 10; + private int mIntruderMinScore = Notification.PRIORITY_HIGH * 10; + private int mIntruderInImmersiveMinScore = Notification.PRIORITY_HIGH * 10 + 5; + private class ExpandedDialog extends Dialog { ExpandedDialog(Context context) { super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar); @@ -540,6 +545,7 @@ public class PhoneStatusBar extends StatusBar { } public void addNotification(IBinder key, StatusBarNotification notification) { + /* if (DEBUG) */ Slog.d(TAG, "addNotification score=" + notification.score); StatusBarIconView iconView = addNotificationViews(key, notification); if (iconView == null) return; @@ -551,31 +557,30 @@ public class PhoneStatusBar extends StatusBar { } } catch (RemoteException ex) { } - if (immersive) { - if ((notification.notification.flags & Notification.FLAG_HIGH_PRIORITY) != 0) { - Slog.d(TAG, "Presenting high-priority notification in immersive activity"); - // special new transient ticker mode - // 1. Populate mIntruderAlertView - - ImageView alertIcon = (ImageView) mIntruderAlertView.findViewById(R.id.alertIcon); - TextView alertText = (TextView) mIntruderAlertView.findViewById(R.id.alertText); - alertIcon.setImageDrawable(StatusBarIconView.getIcon( - alertIcon.getContext(), - iconView.getStatusBarIcon())); - alertText.setText(notification.notification.tickerText); - - View button = mIntruderAlertView.findViewById(R.id.intruder_alert_content); - button.setOnClickListener( - new NotificationClicker(notification.notification.contentIntent, - notification.pkg, notification.tag, notification.id)); - - // 2. Animate mIntruderAlertView in - mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); - - // 3. Set alarm to age the notification off (TODO) - mHandler.removeMessages(MSG_HIDE_INTRUDER); - mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); - } + if ((notification.score >= mIntruderInImmersiveMinScore) + || (!immersive && (notification.score > mIntruderMinScore))) { + Slog.d(TAG, "Presenting high-priority notification"); + // special new transient ticker mode + // 1. Populate mIntruderAlertView + + ImageView alertIcon = (ImageView) mIntruderAlertView.findViewById(R.id.alertIcon); + TextView alertText = (TextView) mIntruderAlertView.findViewById(R.id.alertText); + alertIcon.setImageDrawable(StatusBarIconView.getIcon( + alertIcon.getContext(), + iconView.getStatusBarIcon())); + alertText.setText(notification.notification.tickerText); + + View button = mIntruderAlertView.findViewById(R.id.intruder_alert_content); + button.setOnClickListener( + new NotificationClicker(notification.notification.contentIntent, + notification.pkg, notification.tag, notification.id)); + + // 2. Animate mIntruderAlertView in + mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); + + // 3. Set alarm to age the notification off (TODO) + mHandler.removeMessages(MSG_HIDE_INTRUDER); + mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); } else if (notification.notification.fullScreenIntent != null) { // not immersive & a full-screen alert should be shown Slog.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); @@ -632,8 +637,8 @@ public class PhoneStatusBar extends StatusBar { && oldContentView.getLayoutId() == contentView.getLayoutId(); ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); boolean orderUnchanged = notification.notification.when==oldNotification.notification.when - && notification.priority == oldNotification.priority; - // priority now encompasses isOngoing() + && notification.score == oldNotification.score; + // score now encompasses/supersedes isOngoing() boolean updateTicker = notification.notification.tickerText != null && !TextUtils.equals(notification.notification.tickerText, @@ -725,69 +730,6 @@ public class PhoneStatusBar extends StatusBar { } - View[] makeNotificationView(StatusBarNotification notification, ViewGroup parent) { - Notification n = notification.notification; - RemoteViews remoteViews = n.contentView; - if (remoteViews == null) { - return null; - } - - // create the row view - LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); - - // wire up the veto button - View vetoButton = updateNotificationVetoButton(row, notification); - vetoButton.setContentDescription(mContext.getString( - R.string.accessibility_remove_notification)); - - // the large icon - ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); - if (notification.notification.largeIcon != null) { - largeIcon.setImageBitmap(notification.notification.largeIcon); - } else { - largeIcon.getLayoutParams().width = 0; - largeIcon.setVisibility(View.INVISIBLE); - } - - // bind the click event to the content area - ViewGroup content = (ViewGroup)row.findViewById(R.id.content); - content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); - content.setOnFocusChangeListener(mFocusChangeListener); - PendingIntent contentIntent = n.contentIntent; - if (contentIntent != null) { - final View.OnClickListener listener = new NotificationClicker(contentIntent, - notification.pkg, notification.tag, notification.id); - largeIcon.setOnClickListener(listener); - content.setOnClickListener(listener); - } else { - largeIcon.setOnClickListener(null); - content.setOnClickListener(null); - } - - View expanded = null; - Exception exception = null; - try { - expanded = remoteViews.apply(mContext, content); - } - catch (RuntimeException e) { - exception = e; - } - if (expanded == null) { - String ident = notification.pkg + "/0x" + Integer.toHexString(notification.id); - Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); - return null; - } else { - content.addView(expanded); - row.setDrawingCacheEnabled(true); - } - - applyLegacyRowBackground(notification, content); - - return new View[] { row, content, expanded }; - } - StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { if (DEBUG) { Slog.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification); @@ -850,7 +792,7 @@ public class PhoneStatusBar extends StatusBar { for (int i=0; i<toShow.size(); i++) { View v = toShow.get(i); if (v.getParent() == null) { - mPile.addView(v, 0); // the notification shade has newest at the top + mPile.addView(v, i); } } } @@ -1807,7 +1749,7 @@ public class PhoneStatusBar extends StatusBar { NotificationData.Entry e = mNotificationData.get(i); pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon); StatusBarNotification n = e.notification; - pw.println(" pkg=" + n.pkg + " id=" + n.id + " priority=" + n.priority); + pw.println(" pkg=" + n.pkg + " id=" + n.id + " score=" + n.score); pw.println(" notification=" + n.notification); pw.println(" tickerText=\"" + n.notification.tickerText + "\""); } @@ -2317,6 +2259,30 @@ public class PhoneStatusBar extends StatusBar { vib.vibrate(250); } + public int getScoreThreshold() { + return mDisplayMinScore; + } + + public void setScoreThreshold(int score) { + // XXX HAX + if (mDisplayMinScore != score) { + this.mDisplayMinScore = score; + applyScoreThreshold(); + } + } + + private void applyScoreThreshold() { + int N = mNotificationData.size(); + for (int i=0; i<N; i++) { + NotificationData.Entry entry = mNotificationData.get(i); + int vis = (entry.notification.score < mDisplayMinScore) + ? View.GONE + : View.VISIBLE; + entry.row.setVisibility(vis); + entry.icon.setVisibility(vis); + } + } + Runnable mStartTracing = new Runnable() { public void run() { vibrate(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java index bb326fef461f..a60bba7ce106 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationController.java @@ -99,13 +99,14 @@ public class LocationController extends BroadcastReceiver { // Notification.Builder will helpfully fill these out for you no matter what you do n.tickerView = null; n.tickerText = null; + + n.priority = Notification.PRIORITY_HIGH; int[] idOut = new int[1]; - mNotificationService.enqueueNotificationWithTagPriority( + mNotificationService.enqueueNotificationWithTag( mContext.getPackageName(), null, GPS_NOTIFICATION_ID, - StatusBarNotification.PRIORITY_SYSTEM, // !!!1!one!!! n, idOut); } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index 5151cade488d..6e56cd4089b9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -859,8 +859,8 @@ public class TabletStatusBar extends StatusBar implements && oldContentView.getLayoutId() == contentView.getLayoutId(); ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); boolean orderUnchanged = notification.notification.when==oldNotification.notification.when - && notification.priority == oldNotification.priority; - // priority now encompasses isOngoing() + && notification.score == oldNotification.score; + // score now encompasses/supersedes isOngoing() boolean updateTicker = notification.notification.tickerText != null && !TextUtils.equals(notification.notification.tickerText, oldEntry.notification.notification.tickerText); @@ -1688,7 +1688,7 @@ public class TabletStatusBar extends StatusBar implements mNotificationDNDDummyEntry = new NotificationData.Entry( null, - new StatusBarNotification("", 0, "", 0, 0, dndNotification), + new StatusBarNotification("", 0, "", 0, 0, Notification.PRIORITY_MAX, dndNotification), iconView); mIconLayout.addView(iconView, params); diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 62569512566c..d5220912b198 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -432,6 +432,7 @@ sp<IAudioTrack> AudioFlinger::createTrack( audio_format_t format, uint32_t channelMask, int frameCount, + // FIXME dead, remove from IAudioFlinger uint32_t flags, const sp<IMemory>& sharedBuffer, audio_io_handle_t output, @@ -1932,6 +1933,63 @@ AudioFlinger::MixerThread::~MixerThread() delete mAudioMixer; } +class CpuStats { +public: + void sample(); +#ifdef DEBUG_CPU_USAGE +private: + ThreadCpuUsage mCpu; +#endif +}; + +void CpuStats::sample() { +#ifdef DEBUG_CPU_USAGE + const CentralTendencyStatistics& stats = mCpu.statistics(); + mCpu.sampleAndEnable(); + unsigned n = stats.n(); + // mCpu.elapsed() is expensive, so don't call it every loop + if ((n & 127) == 1) { + long long elapsed = mCpu.elapsed(); + if (elapsed >= DEBUG_CPU_USAGE * 1000000000LL) { + double perLoop = elapsed / (double) n; + double perLoop100 = perLoop * 0.01; + double mean = stats.mean(); + double stddev = stats.stddev(); + double minimum = stats.minimum(); + double maximum = stats.maximum(); + mCpu.resetStatistics(); + ALOGI("CPU usage over past %.1f secs (%u mixer loops at %.1f mean ms per loop):\n us per mix loop: mean=%.0f stddev=%.0f min=%.0f max=%.0f\n %% of wall: mean=%.1f stddev=%.1f min=%.1f max=%.1f", + elapsed * .000000001, n, perLoop * .000001, + mean * .001, + stddev * .001, + minimum * .001, + maximum * .001, + mean / perLoop100, + stddev / perLoop100, + minimum / perLoop100, + maximum / perLoop100); + } + } +#endif +}; + +void AudioFlinger::PlaybackThread::checkSilentMode_l() +{ + if (!mMasterMute) { + char value[PROPERTY_VALUE_MAX]; + if (property_get("ro.audio.silent", value, "0") > 0) { + char *endptr; + unsigned long ul = strtoul(value, &endptr, 0); + if (*endptr == '\0' && ul != 0) { + ALOGD("Silence is golden"); + // The setprop command will not allow a property to be changed after + // the first time it is set, so we don't have to worry about un-muting. + setMasterMute_l(true); + } + } + } +} + bool AudioFlinger::MixerThread::threadLoop() { Vector< sp<Track> > tracksToRemove; @@ -1950,42 +2008,13 @@ bool AudioFlinger::MixerThread::threadLoop() uint32_t sleepTime = idleSleepTime; uint32_t sleepTimeShift = 0; Vector< sp<EffectChain> > effectChains; -#ifdef DEBUG_CPU_USAGE - ThreadCpuUsage cpu; - const CentralTendencyStatistics& stats = cpu.statistics(); -#endif + CpuStats cpuStats; acquireWakeLock(); while (!exitPending()) { -#ifdef DEBUG_CPU_USAGE - cpu.sampleAndEnable(); - unsigned n = stats.n(); - // cpu.elapsed() is expensive, so don't call it every loop - if ((n & 127) == 1) { - long long elapsed = cpu.elapsed(); - if (elapsed >= DEBUG_CPU_USAGE * 1000000000LL) { - double perLoop = elapsed / (double) n; - double perLoop100 = perLoop * 0.01; - double mean = stats.mean(); - double stddev = stats.stddev(); - double minimum = stats.minimum(); - double maximum = stats.maximum(); - cpu.resetStatistics(); - ALOGI("CPU usage over past %.1f secs (%u mixer loops at %.1f mean ms per loop):\n us per mix loop: mean=%.0f stddev=%.0f min=%.0f max=%.0f\n %% of wall: mean=%.1f stddev=%.1f min=%.1f max=%.1f", - elapsed * .000000001, n, perLoop * .000001, - mean * .001, - stddev * .001, - minimum * .001, - maximum * .001, - mean / perLoop100, - stddev / perLoop100, - minimum / perLoop100, - maximum / perLoop100); - } - } -#endif + cpuStats.sample(); processConfigEvents(); mixerStatus = MIXER_IDLE; @@ -2030,14 +2059,7 @@ bool AudioFlinger::MixerThread::threadLoop() acquireWakeLock_l(); mPrevMixerStatus = MIXER_IDLE; - if (!mMasterMute) { - char value[PROPERTY_VALUE_MAX]; - property_get("ro.audio.silent", value, "0"); - if (atoi(value)) { - ALOGD("Silence is golden"); - setMasterMute_l(true); - } - } + checkSilentMode_l(); standbyTime = systemTime() + mStandbyTimeInNsecs; sleepTime = idleSleepTime; @@ -2739,14 +2761,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop() ALOGV("DirectOutputThread %p TID %d waking up in active mode", this, gettid()); acquireWakeLock_l(); - if (!mMasterMute) { - char value[PROPERTY_VALUE_MAX]; - property_get("ro.audio.silent", value, "0"); - if (atoi(value)) { - ALOGD("Silence is golden"); - setMasterMute_l(true); - } - } + checkSilentMode_l(); standbyTime = systemTime() + standbyDelay; sleepTime = idleSleepTime; @@ -3135,15 +3150,7 @@ bool AudioFlinger::DuplicatingThread::threadLoop() ALOGV("DuplicatingThread %p TID %d waking up", this, gettid()); acquireWakeLock_l(); - mPrevMixerStatus = MIXER_IDLE; - if (!mMasterMute) { - char value[PROPERTY_VALUE_MAX]; - property_get("ro.audio.silent", value, "0"); - if (atoi(value)) { - ALOGD("Silence is golden"); - setMasterMute_l(true); - } - } + checkSilentMode_l(); standbyTime = systemTime() + mStandbyTimeInNsecs; sleepTime = idleSleepTime; @@ -3306,7 +3313,6 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase( audio_format_t format, uint32_t channelMask, int frameCount, - uint32_t flags, const sp<IMemory>& sharedBuffer, int sessionId) : RefBase(), @@ -3318,7 +3324,7 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase( mFrameCount(0), mState(IDLE), mFormat(format), - mFlags(flags & ~SYSTEM_FLAGS_MASK), + mStepServerFailed(false), mSessionId(sessionId) // mChannelCount // mChannelMask @@ -3413,7 +3419,7 @@ bool AudioFlinger::ThreadBase::TrackBase::step() { result = cblk->stepServer(mFrameCount); if (!result) { ALOGV("stepServer failed acquiring cblk mutex"); - mFlags |= STEPSERVER_FAILED; + mStepServerFailed = true; } return result; } @@ -3425,7 +3431,7 @@ void AudioFlinger::ThreadBase::TrackBase::reset() { cblk->server = 0; cblk->userBase = 0; cblk->serverBase = 0; - mFlags &= (uint32_t)(~SYSTEM_FLAGS_MASK); + mStepServerFailed = false; ALOGV("TrackBase::reset"); } @@ -3465,7 +3471,7 @@ AudioFlinger::PlaybackThread::Track::Track( int frameCount, const sp<IMemory>& sharedBuffer, int sessionId) - : TrackBase(thread, client, sampleRate, format, channelMask, frameCount, 0, sharedBuffer, sessionId), + : TrackBase(thread, client, sampleRate, format, channelMask, frameCount, sharedBuffer, sessionId), mMute(false), mSharedBuffer(sharedBuffer), mName(-1), mMainBuffer(NULL), mAuxBuffer(NULL), mAuxEffectId(0), mHasVolumeController(false) { @@ -3556,10 +3562,10 @@ status_t AudioFlinger::PlaybackThread::Track::getNextBuffer( uint32_t framesReq = buffer->frameCount; // Check if last stepServer failed, try to step now - if (mFlags & TrackBase::STEPSERVER_FAILED) { + if (mStepServerFailed) { if (!step()) goto getNextBuffer_exit; ALOGV("stepServer recovered"); - mFlags &= ~TrackBase::STEPSERVER_FAILED; + mStepServerFailed = false; } framesReady = cblk->framesReady(); @@ -4155,10 +4161,9 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack( audio_format_t format, uint32_t channelMask, int frameCount, - uint32_t flags, int sessionId) : TrackBase(thread, client, sampleRate, format, - channelMask, frameCount, flags, 0, sessionId), + channelMask, frameCount, 0 /*sharedBuffer*/, sessionId), mOverflow(false) { if (mCblk != NULL) { @@ -4188,10 +4193,10 @@ status_t AudioFlinger::RecordThread::RecordTrack::getNextBuffer(AudioBufferProvi uint32_t framesReq = buffer->frameCount; // Check if last stepServer failed, try to step now - if (mFlags & TrackBase::STEPSERVER_FAILED) { + if (mStepServerFailed) { if (!step()) goto getNextBuffer_exit; ALOGV("stepServer recovered"); - mFlags &= ~TrackBase::STEPSERVER_FAILED; + mStepServerFailed = false; } framesAvail = cblk->framesAvailable_l(); @@ -4654,6 +4659,7 @@ sp<IAudioRecord> AudioFlinger::openRecord( audio_format_t format, uint32_t channelMask, int frameCount, + // FIXME dead, remove from IAudioFlinger uint32_t flags, int *sessionId, status_t *status) @@ -4698,7 +4704,6 @@ sp<IAudioRecord> AudioFlinger::openRecord( format, channelMask, frameCount, - flags, lSessionId, &lStatus); } @@ -4992,7 +4997,6 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR audio_format_t format, int channelMask, int frameCount, - uint32_t flags, int sessionId, status_t *status) { @@ -5009,7 +5013,7 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR Mutex::Autolock _l(mLock); track = new RecordTrack(this, client, sampleRate, - format, channelMask, frameCount, flags, sessionId); + format, channelMask, frameCount, sessionId); if (track->getCblk() == 0) { lStatus = NO_MEMORY; diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 1a52de5b67d7..2a5d805d1df0 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -312,19 +312,12 @@ private: PAUSED }; - enum track_flags { - STEPSERVER_FAILED = 0x01, // StepServer could not acquire cblk->lock mutex - SYSTEM_FLAGS_MASK = 0x0000ffffUL, - // The upper 16 bits are used for track-specific flags. - }; - TrackBase(ThreadBase *thread, const sp<Client>& client, uint32_t sampleRate, audio_format_t format, uint32_t channelMask, int frameCount, - uint32_t flags, const sp<IMemory>& sharedBuffer, int sessionId); virtual ~TrackBase(); @@ -384,7 +377,7 @@ private: // we don't really need a lock for these track_state mState; const audio_format_t mFormat; - uint32_t mFlags; + bool mStepServerFailed; const int mSessionId; uint8_t mChannelCount; uint32_t mChannelMask; @@ -866,6 +859,9 @@ private: virtual uint32_t idleSleepTimeUs() = 0; virtual uint32_t suspendSleepTimeUs() = 0; + // Code snippets that are temporarily lifted up out of threadLoop() until the merge + void checkSilentMode_l(); + private: friend class AudioFlinger; @@ -1048,7 +1044,6 @@ private: audio_format_t format, uint32_t channelMask, int frameCount, - uint32_t flags, int sessionId); virtual ~RecordTrack(); @@ -1094,7 +1089,6 @@ private: audio_format_t format, int channelMask, int frameCount, - uint32_t flags, int sessionId, status_t *status); diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index 86669f8df6e0..c70564658576 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -786,7 +786,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub return flags; } - InputBindResult attachNewInputLocked(boolean initial, boolean needResult) { + InputBindResult attachNewInputLocked(boolean initial) { if (!mBoundToMethod) { executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO( MSG_BIND_INPUT, mCurMethod, mCurClient.binding)); @@ -804,14 +804,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (DEBUG) Slog.v(TAG, "Attach new input asks to show input"); showCurrentInputLocked(getAppShowFlags(), null); } - return needResult - ? new InputBindResult(session.session, mCurId, mCurSeq) - : null; + return new InputBindResult(session.session, mCurId, mCurSeq); } InputBindResult startInputLocked(IInputMethodClient client, - IInputContext inputContext, EditorInfo attribute, - boolean initial, boolean needResult) { + IInputContext inputContext, EditorInfo attribute, int controlFlags) { // If no method is currently selected, do nothing. if (mCurMethodId == null) { return mNoBinding; @@ -837,6 +834,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } catch (RemoteException e) { } + return startInputUncheckedLocked(cs, inputContext, attribute, controlFlags); + } + + InputBindResult startInputUncheckedLocked(ClientState cs, + IInputContext inputContext, EditorInfo attribute, int controlFlags) { + // If no method is currently selected, do nothing. + if (mCurMethodId == null) { + return mNoBinding; + } + if (mCurClient != cs) { // If the client is changing, we need to switch over to the new // one. @@ -867,7 +874,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (cs.curSession != null) { // Fast case: if we are already connected to the input method, // then just return it. - return attachNewInputLocked(initial, needResult); + return attachNewInputLocked( + (controlFlags&InputMethodManager.CONTROL_START_INITIAL) != 0); } if (mHaveConnection) { if (mCurMethod != null) { @@ -948,13 +956,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public InputBindResult startInput(IInputMethodClient client, - IInputContext inputContext, EditorInfo attribute, - boolean initial, boolean needResult) { + IInputContext inputContext, EditorInfo attribute, int controlFlags) { synchronized (mMethodMap) { final long ident = Binder.clearCallingIdentity(); try { - return startInputLocked(client, inputContext, attribute, - initial, needResult); + return startInputLocked(client, inputContext, attribute, controlFlags); } finally { Binder.restoreCallingIdentity(ident); } @@ -997,7 +1003,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mCurClient.curSession = new SessionState(mCurClient, method, session); mCurClient.sessionRequested = false; - InputBindResult res = attachNewInputLocked(true, true); + InputBindResult res = attachNewInputLocked(true); if (res.method != null) { executeOrSendMessage(mCurClient.client, mCaller.obtainMessageOO( MSG_BIND_METHOD, mCurClient.client, res)); @@ -1482,36 +1488,45 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } @Override - public void windowGainedFocus(IInputMethodClient client, IBinder windowToken, - boolean viewHasFocus, boolean isTextEditor, int softInputMode, - boolean first, int windowFlags) { + public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder windowToken, + int controlFlags, int softInputMode, int windowFlags, + EditorInfo attribute, IInputContext inputContext) { + InputBindResult res = null; long ident = Binder.clearCallingIdentity(); try { synchronized (mMethodMap) { if (DEBUG) Slog.v(TAG, "windowGainedFocus: " + client.asBinder() - + " viewHasFocus=" + viewHasFocus - + " isTextEditor=" + isTextEditor + + " controlFlags=#" + Integer.toHexString(controlFlags) + " softInputMode=#" + Integer.toHexString(softInputMode) - + " first=" + first + " flags=#" - + Integer.toHexString(windowFlags)); + + " windowFlags=#" + Integer.toHexString(windowFlags)); - if (mCurClient == null || client == null - || mCurClient.client.asBinder() != client.asBinder()) { - try { - // We need to check if this is the current client with - // focus in the window manager, to allow this call to - // be made before input is started in it. - if (!mIWindowManager.inputMethodClientHasFocus(client)) { - Slog.w(TAG, "Client not active, ignoring focus gain of: " + client); - return; - } - } catch (RemoteException e) { + ClientState cs = mClients.get(client.asBinder()); + if (cs == null) { + throw new IllegalArgumentException("unknown client " + + client.asBinder()); + } + + try { + if (!mIWindowManager.inputMethodClientHasFocus(cs.client)) { + // Check with the window manager to make sure this client actually + // has a window with focus. If not, reject. This is thread safe + // because if the focus changes some time before or after, the + // next client receiving focus that has any interest in input will + // be calling through here after that change happens. + Slog.w(TAG, "Focus gain on non-focused client " + cs.client + + " (uid=" + cs.uid + " pid=" + cs.pid + ")"); + return null; } + } catch (RemoteException e) { } if (mCurFocusedWindow == windowToken) { Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client); - return; + if (attribute != null) { + return startInputUncheckedLocked(cs, inputContext, attribute, + controlFlags); + } + return null; } mCurFocusedWindow = windowToken; @@ -1527,6 +1542,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE || mRes.getConfiguration().isLayoutSizeAtLeast( Configuration.SCREENLAYOUT_SIZE_LARGE); + final boolean isTextEditor = + (controlFlags&InputMethodManager.CONTROL_WINDOW_IS_TEXT_EDITOR) != 0; + + // We want to start input before showing the IME, but after closing + // it. We want to do this after closing it to help the IME disappear + // more quickly (not get stuck behind it initializing itself for the + // new focused input, even if its window wants to hide the IME). + boolean didStart = false; switch (softInputMode&WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE) { case WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED: @@ -1542,12 +1565,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) { // There is a focus view, and we are navigating forward // into the window, so show the input window for the user. - // We only do this automatically if the window an resize - // to accomodate the IME (so what the user sees will give + // We only do this automatically if the window can resize + // to accommodate the IME (so what the user sees will give // them good context without input information being obscured // by the IME) or if running on a large screen where there // is more room for the target window + IME. if (DEBUG) Slog.v(TAG, "Unspecified window will show input"); + if (attribute != null) { + res = startInputUncheckedLocked(cs, inputContext, attribute, + controlFlags); + didStart = true; + } showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null); } break; @@ -1569,18 +1597,35 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if ((softInputMode & WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) { if (DEBUG) Slog.v(TAG, "Window asks to show input going forward"); + if (attribute != null) { + res = startInputUncheckedLocked(cs, inputContext, attribute, + controlFlags); + didStart = true; + } showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null); } break; case WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE: if (DEBUG) Slog.v(TAG, "Window asks to always show input"); + if (attribute != null) { + res = startInputUncheckedLocked(cs, inputContext, attribute, + controlFlags); + didStart = true; + } showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null); break; } + + if (!didStart && attribute != null) { + res = startInputUncheckedLocked(cs, inputContext, attribute, + controlFlags); + } } } finally { Binder.restoreCallingIdentity(ident); } + + return res; } @Override diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index b3eceb10864c..624ee98a9c8c 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -146,19 +146,18 @@ public class NotificationManagerService extends INotificationManager.Stub final int id; final int uid; final int initialPid; - final int priority; final Notification notification; + final int score; IBinder statusBarKey; - NotificationRecord(String pkg, String tag, int id, int uid, int initialPid, int priority, - Notification notification) + NotificationRecord(String pkg, String tag, int id, int uid, int initialPid, int score, Notification notification) { this.pkg = pkg; this.tag = tag; this.id = id; this.uid = uid; this.initialPid = initialPid; - this.priority = priority; + this.score = score; this.notification = notification; } @@ -166,6 +165,8 @@ public class NotificationManagerService extends INotificationManager.Stub pw.println(prefix + this); pw.println(prefix + " icon=0x" + Integer.toHexString(notification.icon) + " / " + idDebugString(baseContext, this.pkg, notification.icon)); + pw.println(prefix + " pri=" + notification.priority); + pw.println(prefix + " score=" + this.score); pw.println(prefix + " contentIntent=" + notification.contentIntent); pw.println(prefix + " deleteIntent=" + notification.deleteIntent); pw.println(prefix + " tickerText=" + notification.tickerText); @@ -187,7 +188,7 @@ public class NotificationManagerService extends INotificationManager.Stub + " pkg=" + pkg + " id=" + Integer.toHexString(id) + " tag=" + tag - + " pri=" + priority + + " score=" + score + "}"; } } @@ -660,28 +661,17 @@ public class NotificationManagerService extends INotificationManager.Stub enqueueNotificationInternal(pkg, Binder.getCallingUid(), Binder.getCallingPid(), tag, id, notification, idOut); } - - public void enqueueNotificationWithTagPriority(String pkg, String tag, int id, int priority, - Notification notification, int[] idOut) - { - enqueueNotificationInternal(pkg, Binder.getCallingUid(), Binder.getCallingPid(), - tag, id, priority, notification, idOut); + + private final static int clamp(int x, int low, int high) { + return (x < low) ? low : ((x > high) ? high : x); } + // Not exposed via Binder; for system use only (otherwise malicious apps could spoof the // uid/pid of another application) public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid, String tag, int id, Notification notification, int[] idOut) { - enqueueNotificationInternal(pkg, callingUid, callingPid, tag, id, - ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0) - ? StatusBarNotification.PRIORITY_ONGOING - : StatusBarNotification.PRIORITY_NORMAL, - notification, idOut); - } - public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid, - String tag, int id, int priority, Notification notification, int[] idOut) - { checkIncomingCall(pkg); // Limit the number of notifications that any given package except the android @@ -723,10 +713,35 @@ public class NotificationManagerService extends INotificationManager.Stub } } + // === Scoring === + + // 0. Sanitize inputs + notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN, Notification.PRIORITY_MAX); + // Migrate notification flags to scores + if (0 != (notification.flags & Notification.FLAG_HIGH_PRIORITY)) { + if (notification.priority < Notification.PRIORITY_MAX) notification.priority = Notification.PRIORITY_MAX; + } else if (0 != (notification.flags & Notification.FLAG_ONGOING_EVENT)) { + if (notification.priority < Notification.PRIORITY_HIGH) notification.priority = Notification.PRIORITY_HIGH; + } + + // 1. initial score: buckets of 10, around the app + int score = notification.priority * 10; //[-20..20] + + // 2. Consult oracles (external heuristics) + // TODO(dsandler): oracles + + // 3. Apply local heuristics & overrides + + // blocked apps + // TODO(dsandler): add block db + if (pkg.startsWith("com.test.spammer.")) { + score = -1000; + } + synchronized (mNotificationList) { NotificationRecord r = new NotificationRecord(pkg, tag, id, callingUid, callingPid, - priority, + score, notification); NotificationRecord old = null; @@ -752,9 +767,7 @@ public class NotificationManagerService extends INotificationManager.Stub if (notification.icon != 0) { StatusBarNotification n = new StatusBarNotification(pkg, id, tag, - r.uid, r.initialPid, notification); - n.priority = r.priority; - + r.uid, r.initialPid, score, notification); if (old != null && old.statusBarKey != null) { r.statusBarKey = old.statusBarKey; long identity = Binder.clearCallingIdentity(); diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 4ee695398f62..efcdd8764275 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -160,7 +160,10 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, // this surfaces pixel format PixelFormatInfo info; status_t err = getPixelFormatInfo(format, &info); - if (err) return err; + if (err) { + ALOGE("unsupported pixelformat %d", format); + return err; + } // the display's pixel format const DisplayHardware& hw(graphicPlane(0).displayHardware()); @@ -170,6 +173,7 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, // never allow a surface larger than what our underlying GL implementation // can handle. if ((uint32_t(w)>maxSurfaceDims) || (uint32_t(h)>maxSurfaceDims)) { + ALOGE("dimensions too large %u x %u", uint32_t(w), uint32_t(h)); return BAD_VALUE; } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 9d821dc47203..05b5bf5d5403 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1285,7 +1285,7 @@ sp<ISurface> SurfaceFlinger::createSurface( return surfaceHandle; } - //ALOGD("createSurface for pid %d (%d x %d)", pid, w, h); + //ALOGD("createSurface for (%d x %d), name=%s", w, h, name.string()); sp<Layer> normalLayer; switch (flags & eFXSurfaceMask) { case eFXSurfaceNormal: diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 32a6975ed1cb..9d88a1844f42 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -64,44 +64,47 @@ public class ServiceState implements Parcelable { /** * Available radio technologies for GSM, UMTS and CDMA. + * Duplicates the constants from hardware/radio/include/ril.h + * This should only be used by agents working with the ril. Others + * should use the equivalent TelephonyManager.NETWORK_TYPE_* */ /** @hide */ - public static final int RADIO_TECHNOLOGY_UNKNOWN = 0; + public static final int RIL_RADIO_TECHNOLOGY_UNKNOWN = 0; /** @hide */ - public static final int RADIO_TECHNOLOGY_GPRS = 1; + public static final int RIL_RADIO_TECHNOLOGY_GPRS = 1; /** @hide */ - public static final int RADIO_TECHNOLOGY_EDGE = 2; + public static final int RIL_RADIO_TECHNOLOGY_EDGE = 2; /** @hide */ - public static final int RADIO_TECHNOLOGY_UMTS = 3; + public static final int RIL_RADIO_TECHNOLOGY_UMTS = 3; /** @hide */ - public static final int RADIO_TECHNOLOGY_IS95A = 4; + public static final int RIL_RADIO_TECHNOLOGY_IS95A = 4; /** @hide */ - public static final int RADIO_TECHNOLOGY_IS95B = 5; + public static final int RIL_RADIO_TECHNOLOGY_IS95B = 5; /** @hide */ - public static final int RADIO_TECHNOLOGY_1xRTT = 6; + public static final int RIL_RADIO_TECHNOLOGY_1xRTT = 6; /** @hide */ - public static final int RADIO_TECHNOLOGY_EVDO_0 = 7; + public static final int RIL_RADIO_TECHNOLOGY_EVDO_0 = 7; /** @hide */ - public static final int RADIO_TECHNOLOGY_EVDO_A = 8; + public static final int RIL_RADIO_TECHNOLOGY_EVDO_A = 8; /** @hide */ - public static final int RADIO_TECHNOLOGY_HSDPA = 9; + public static final int RIL_RADIO_TECHNOLOGY_HSDPA = 9; /** @hide */ - public static final int RADIO_TECHNOLOGY_HSUPA = 10; + public static final int RIL_RADIO_TECHNOLOGY_HSUPA = 10; /** @hide */ - public static final int RADIO_TECHNOLOGY_HSPA = 11; + public static final int RIL_RADIO_TECHNOLOGY_HSPA = 11; /** @hide */ - public static final int RADIO_TECHNOLOGY_EVDO_B = 12; + public static final int RIL_RADIO_TECHNOLOGY_EVDO_B = 12; /** @hide */ - public static final int RADIO_TECHNOLOGY_EHRPD = 13; + public static final int RIL_RADIO_TECHNOLOGY_EHRPD = 13; /** @hide */ - public static final int RADIO_TECHNOLOGY_LTE = 14; + public static final int RIL_RADIO_TECHNOLOGY_LTE = 14; /** @hide */ - public static final int RADIO_TECHNOLOGY_HSPAP = 15; + public static final int RIL_RADIO_TECHNOLOGY_HSPAP = 15; /** * GSM radio technology only supports voice. It does not support data. * @hide */ - public static final int RADIO_TECHNOLOGY_GSM = 16; + public static final int RIL_RADIO_TECHNOLOGY_GSM = 16; /** * Available registration states for GSM, UMTS and CDMA. @@ -400,59 +403,59 @@ public class ServiceState implements Parcelable { * * @hide */ - public static String radioTechnologyToString(int rt) { + public static String rilRadioTechnologyToString(int rt) { String rtString; switch(rt) { - case 0: + case RIL_RADIO_TECHNOLOGY_UNKNOWN: rtString = "Unknown"; break; - case 1: + case RIL_RADIO_TECHNOLOGY_GPRS: rtString = "GPRS"; break; - case 2: + case RIL_RADIO_TECHNOLOGY_EDGE: rtString = "EDGE"; break; - case 3: + case RIL_RADIO_TECHNOLOGY_UMTS: rtString = "UMTS"; break; - case 4: + case RIL_RADIO_TECHNOLOGY_IS95A: rtString = "CDMA-IS95A"; break; - case 5: + case RIL_RADIO_TECHNOLOGY_IS95B: rtString = "CDMA-IS95B"; break; - case 6: + case RIL_RADIO_TECHNOLOGY_1xRTT: rtString = "1xRTT"; break; - case 7: + case RIL_RADIO_TECHNOLOGY_EVDO_0: rtString = "EvDo-rev.0"; break; - case 8: + case RIL_RADIO_TECHNOLOGY_EVDO_A: rtString = "EvDo-rev.A"; break; - case 9: + case RIL_RADIO_TECHNOLOGY_HSDPA: rtString = "HSDPA"; break; - case 10: + case RIL_RADIO_TECHNOLOGY_HSUPA: rtString = "HSUPA"; break; - case 11: + case RIL_RADIO_TECHNOLOGY_HSPA: rtString = "HSPA"; break; - case 12: + case RIL_RADIO_TECHNOLOGY_EVDO_B: rtString = "EvDo-rev.B"; break; - case 13: + case RIL_RADIO_TECHNOLOGY_EHRPD: rtString = "eHRPD"; break; - case 14: + case RIL_RADIO_TECHNOLOGY_LTE: rtString = "LTE"; break; - case 15: + case RIL_RADIO_TECHNOLOGY_HSPAP: rtString = "HSPAP"; break; - case 16: + case RIL_RADIO_TECHNOLOGY_GSM: rtString = "GSM"; break; default: @@ -460,12 +463,12 @@ public class ServiceState implements Parcelable { Log.w(LOG_TAG, "Unexpected radioTechnology=" + rt); break; } - return rtString + ":" + rt; + return rtString; } @Override public String toString() { - String radioTechnology = radioTechnologyToString(mRadioTechnology); + String radioTechnology = rilRadioTechnologyToString(mRadioTechnology); return (mState + " " + (mRoaming ? "roaming" : "home") + " " + mOperatorAlphaLong @@ -644,11 +647,48 @@ public class ServiceState implements Parcelable { } /** @hide */ - public int getRadioTechnology() { + public int getRilRadioTechnology() { return this.mRadioTechnology; } /** @hide */ + public int getNetworkType() { + switch(mRadioTechnology) { + case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS: + return TelephonyManager.NETWORK_TYPE_GPRS; + case ServiceState.RIL_RADIO_TECHNOLOGY_EDGE: + return TelephonyManager.NETWORK_TYPE_EDGE; + case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS: + return TelephonyManager.NETWORK_TYPE_UMTS; + case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA: + return TelephonyManager.NETWORK_TYPE_HSDPA; + case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA: + return TelephonyManager.NETWORK_TYPE_HSUPA; + case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA: + return TelephonyManager.NETWORK_TYPE_HSPA; + case ServiceState.RIL_RADIO_TECHNOLOGY_IS95A: + case ServiceState.RIL_RADIO_TECHNOLOGY_IS95B: + return TelephonyManager.NETWORK_TYPE_CDMA; + case ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT: + return TelephonyManager.NETWORK_TYPE_1xRTT; + case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0: + return TelephonyManager.NETWORK_TYPE_EVDO_0; + case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A: + return TelephonyManager.NETWORK_TYPE_EVDO_A; + case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B: + return TelephonyManager.NETWORK_TYPE_EVDO_B; + case ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD: + return TelephonyManager.NETWORK_TYPE_EHRPD; + case ServiceState.RIL_RADIO_TECHNOLOGY_LTE: + return TelephonyManager.NETWORK_TYPE_LTE; + case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP: + return TelephonyManager.NETWORK_TYPE_HSPAP; + default: + return TelephonyManager.NETWORK_TYPE_UNKNOWN; + } + } + + /** @hide */ public int getCssIndicator() { return this.mCssIndicator ? 1 : 0; } @@ -665,25 +705,25 @@ public class ServiceState implements Parcelable { /** @hide */ public static boolean isGsm(int radioTechnology) { - return radioTechnology == RADIO_TECHNOLOGY_GPRS - || radioTechnology == RADIO_TECHNOLOGY_EDGE - || radioTechnology == RADIO_TECHNOLOGY_UMTS - || radioTechnology == RADIO_TECHNOLOGY_HSDPA - || radioTechnology == RADIO_TECHNOLOGY_HSUPA - || radioTechnology == RADIO_TECHNOLOGY_HSPA - || radioTechnology == RADIO_TECHNOLOGY_LTE - || radioTechnology == RADIO_TECHNOLOGY_HSPAP - || radioTechnology == RADIO_TECHNOLOGY_GSM; + return radioTechnology == RIL_RADIO_TECHNOLOGY_GPRS + || radioTechnology == RIL_RADIO_TECHNOLOGY_EDGE + || radioTechnology == RIL_RADIO_TECHNOLOGY_UMTS + || radioTechnology == RIL_RADIO_TECHNOLOGY_HSDPA + || radioTechnology == RIL_RADIO_TECHNOLOGY_HSUPA + || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPA + || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE + || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPAP + || radioTechnology == RIL_RADIO_TECHNOLOGY_GSM; } /** @hide */ public static boolean isCdma(int radioTechnology) { - return radioTechnology == RADIO_TECHNOLOGY_IS95A - || radioTechnology == RADIO_TECHNOLOGY_IS95B - || radioTechnology == RADIO_TECHNOLOGY_1xRTT - || radioTechnology == RADIO_TECHNOLOGY_EVDO_0 - || radioTechnology == RADIO_TECHNOLOGY_EVDO_A - || radioTechnology == RADIO_TECHNOLOGY_EVDO_B - || radioTechnology == RADIO_TECHNOLOGY_EHRPD; + return radioTechnology == RIL_RADIO_TECHNOLOGY_IS95A + || radioTechnology == RIL_RADIO_TECHNOLOGY_IS95B + || radioTechnology == RIL_RADIO_TECHNOLOGY_1xRTT + || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_0 + || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_A + || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_B + || radioTechnology == RIL_RADIO_TECHNOLOGY_EHRPD; } } diff --git a/telephony/java/com/android/internal/telephony/DataConnection.java b/telephony/java/com/android/internal/telephony/DataConnection.java index d0e304fc1a79..238afbed320f 100644 --- a/telephony/java/com/android/internal/telephony/DataConnection.java +++ b/telephony/java/com/android/internal/telephony/DataConnection.java @@ -355,14 +355,14 @@ public abstract class DataConnection extends StateMachine { if (DBG) log("NotifyDisconnectCompleted DisconnectParams=" + dp); } - protected int getRadioTechnology(int defaultRadioTechnology) { - int radioTechnology; + protected int getRilRadioTechnology(int defaultRilRadioTechnology) { + int rilRadioTechnology; if (mRilVersion < 6) { - radioTechnology = defaultRadioTechnology; + rilRadioTechnology = defaultRilRadioTechnology; } else { - radioTechnology = phone.getServiceState().getRadioTechnology() + 2; + rilRadioTechnology = phone.getServiceState().getRilRadioTechnology() + 2; } - return radioTechnology; + return rilRadioTechnology; } /* diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java index 2b9fb913241c..fa90f1c3a4c8 100644 --- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java @@ -40,6 +40,7 @@ import android.preference.PreferenceManager; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.telephony.ServiceState; +import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; @@ -1167,15 +1168,14 @@ public abstract class DataConnectionTracker extends Handler { } protected String getReryConfig(boolean forDefault) { - int rt = mPhone.getServiceState().getRadioTechnology(); - - if ((rt == ServiceState.RADIO_TECHNOLOGY_IS95A) || - (rt == ServiceState.RADIO_TECHNOLOGY_IS95B) || - (rt == ServiceState.RADIO_TECHNOLOGY_1xRTT) || - (rt == ServiceState.RADIO_TECHNOLOGY_EVDO_0) || - (rt == ServiceState.RADIO_TECHNOLOGY_EVDO_A) || - (rt == ServiceState.RADIO_TECHNOLOGY_EVDO_B) || - (rt == ServiceState.RADIO_TECHNOLOGY_EHRPD)) { + int nt = mPhone.getServiceState().getNetworkType(); + + if ((nt == TelephonyManager.NETWORK_TYPE_CDMA) || + (nt == TelephonyManager.NETWORK_TYPE_1xRTT) || + (nt == TelephonyManager.NETWORK_TYPE_EVDO_0) || + (nt == TelephonyManager.NETWORK_TYPE_EVDO_A) || + (nt == TelephonyManager.NETWORK_TYPE_EVDO_B) || + (nt == TelephonyManager.NETWORK_TYPE_EHRPD)) { // CDMA variant return SystemProperties.get("ro.cdma.data_retry_config"); } else { diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java index 2931a0297657..1a8b3ca01ca2 100644 --- a/telephony/java/com/android/internal/telephony/PhoneProxy.java +++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java @@ -149,7 +149,7 @@ public class PhoneProxy extends Handler implements Phone { logd("LTE ON CDMA property is set. Switch to CDMALTEPhone" + " newVoiceRadioTech = " + newVoiceRadioTech + " Active Phone = " + mActivePhone.getPhoneName()); - newVoiceRadioTech = ServiceState.RADIO_TECHNOLOGY_1xRTT; + newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT; } } else { if ((ServiceState.isCdma(newVoiceRadioTech) && @@ -165,7 +165,7 @@ public class PhoneProxy extends Handler implements Phone { } } - if (newVoiceRadioTech == ServiceState.RADIO_TECHNOLOGY_UNKNOWN) { + if (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) { // We need some voice phone object to be active always, so never // delete the phone without anything to replace it with! logd("Ignoring voice radio technology changed message. newVoiceRadioTech = Unknown." diff --git a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java index 9c80de7553b3..fd39e04ff34a 100644 --- a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java @@ -54,10 +54,10 @@ public abstract class ServiceStateTracker extends Handler { protected boolean mDesiredPowerState; /** - * Values correspond to ServiceState.RADIO_TECHNOLOGY_ definitions. + * Values correspond to ServiceState.RIL_RADIO_TECHNOLOGY_ definitions. */ - protected int mRadioTechnology = 0; - protected int mNewRadioTechnology = 0; + protected int mRilRadioTechnology = 0; + protected int mNewRilRadioTechnology = 0; /** * By default, strength polling is enabled. However, if we're diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java index a93d94fbc284..64d018e2edba 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnection.java @@ -86,7 +86,7 @@ public class CdmaDataConnection extends DataConnection { Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp); msg.obj = cp; phone.mCM.setupDataCall( - Integer.toString(getRadioTechnology(RILConstants.SETUP_DATA_TECH_CDMA)), + Integer.toString(getRilRadioTechnology(RILConstants.SETUP_DATA_TECH_CDMA)), Integer.toString(dataProfile), null, null, null, Integer.toString(RILConstants.SETUP_DATA_AUTH_PAP_CHAP), diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java index 7da23d05e3d9..cad2e2258c3e 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java @@ -185,19 +185,21 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { @Override protected void pollStateDone() { - // determine data NetworkType from both LET and CDMA SS + // determine data RadioTechnology from both LET and CDMA SS if (mLteSS.getState() == ServiceState.STATE_IN_SERVICE) { //in LTE service - newNetworkType = mLteSS.getRadioTechnology(); + mNewRilRadioTechnology = mLteSS.getRilRadioTechnology(); mNewDataConnectionState = mLteSS.getState(); - newSS.setRadioTechnology(newNetworkType); - log("pollStateDone LTE/eHRPD STATE_IN_SERVICE newNetworkType = " + newNetworkType); + newSS.setRadioTechnology(mNewRilRadioTechnology); + log("pollStateDone LTE/eHRPD STATE_IN_SERVICE mNewRilRadioTechnology = " + + mNewRilRadioTechnology); } else { // LTE out of service, get CDMA Service State - newNetworkType = newSS.getRadioTechnology(); - mNewDataConnectionState = radioTechnologyToDataServiceState(newNetworkType); - log("pollStateDone CDMA STATE_IN_SERVICE newNetworkType = " + newNetworkType + - " mNewDataConnectionState = " + mNewDataConnectionState); + mNewRilRadioTechnology = newSS.getRilRadioTechnology(); + mNewDataConnectionState = radioTechnologyToDataServiceState(mNewRilRadioTechnology); + log("pollStateDone CDMA STATE_IN_SERVICE mNewRilRadioTechnology = " + + mNewRilRadioTechnology + " mNewDataConnectionState = " + + mNewDataConnectionState); } // TODO: Add proper support for LTE Only, we should be looking at @@ -239,7 +241,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { boolean hasCdmaDataConnectionChanged = mDataConnectionState != mNewDataConnectionState; - boolean hasNetworkTypeChanged = networkType != newNetworkType; + boolean hasRadioTechnologyChanged = mRilRadioTechnology != mNewRilRadioTechnology; boolean hasChanged = !newSS.equals(ss); @@ -251,20 +253,20 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { boolean has4gHandoff = mNewDataConnectionState == ServiceState.STATE_IN_SERVICE && - (((networkType == ServiceState.RADIO_TECHNOLOGY_LTE) && - (newNetworkType == ServiceState.RADIO_TECHNOLOGY_EHRPD)) || - ((networkType == ServiceState.RADIO_TECHNOLOGY_EHRPD) && - (newNetworkType == ServiceState.RADIO_TECHNOLOGY_LTE))); + (((mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) && + (mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) || + ((mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD) && + (mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE))); boolean hasMultiApnSupport = - (((newNetworkType == ServiceState.RADIO_TECHNOLOGY_LTE) || - (newNetworkType == ServiceState.RADIO_TECHNOLOGY_EHRPD)) && - ((networkType != ServiceState.RADIO_TECHNOLOGY_LTE) && - (networkType != ServiceState.RADIO_TECHNOLOGY_EHRPD))); + (((mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) || + (mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) && + ((mRilRadioTechnology != ServiceState.RIL_RADIO_TECHNOLOGY_LTE) && + (mRilRadioTechnology != ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD))); boolean hasLostMultiApnSupport = - ((newNetworkType >= ServiceState.RADIO_TECHNOLOGY_IS95A) && - (newNetworkType <= ServiceState.RADIO_TECHNOLOGY_EVDO_A)); + ((mNewRilRadioTechnology >= ServiceState.RIL_RADIO_TECHNOLOGY_IS95A) && + (mNewRilRadioTechnology <= ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A)); if (DBG) { log("pollStateDone:" @@ -273,7 +275,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { + " hasCdmaDataConnectionAttached=" + hasCdmaDataConnectionAttached + " hasCdmaDataConnectionDetached=" + hasCdmaDataConnectionDetached + " hasCdmaDataConnectionChanged=" + hasCdmaDataConnectionChanged - + " hasNetworkTypeChanged = " + hasNetworkTypeChanged + + " hasRadioTechnologyChanged = " + hasRadioTechnologyChanged + " hasChanged=" + hasChanged + " hasRoamingOn=" + hasRoamingOn + " hasRoamingOff=" + hasRoamingOff @@ -316,13 +318,14 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { newCellLoc = tcl; mDataConnectionState = mNewDataConnectionState; - networkType = newNetworkType; + mRilRadioTechnology = mNewRilRadioTechnology; + mNewRilRadioTechnology = 0; newSS.setStateOutOfService(); // clean slate for next time - if (hasNetworkTypeChanged) { + if (hasRadioTechnologyChanged) { phone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, - ServiceState.radioTechnologyToString(networkType)); + ServiceState.rilRadioTechnologyToString(mRilRadioTechnology)); } if (hasRegistered) { @@ -404,7 +407,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { mDetachedRegistrants.notifyRegistrants(); } - if ((hasCdmaDataConnectionChanged || hasNetworkTypeChanged)) { + if ((hasCdmaDataConnectionChanged || hasRadioTechnologyChanged)) { phone.notifyDataConnection(null); } @@ -446,7 +449,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { int evdoSnr = ((ints[offset + 4] > 0) && (ints[offset + 4] <= 8)) ? ints[offset + 4] : -1; - if (networkType == ServiceState.RADIO_TECHNOLOGY_LTE) { + if (mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) { lteRssi = ints[offset+5]; lteRsrp = ints[offset+6]; lteRsrq = ints[offset+7]; @@ -454,7 +457,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { lteCqi = ints[offset+9]; } - if (networkType != ServiceState.RADIO_TECHNOLOGY_LTE) { + if (mRilRadioTechnology != ServiceState.RIL_RADIO_TECHNOLOGY_LTE) { mSignalStrength = new SignalStrength(99, -1, cdmaDbm, cdmaEcio, evdoRssi, evdoEcio, evdoSnr, false); } else { @@ -476,7 +479,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker { // Note: it needs to be confirmed which CDMA network types // can support voice and data calls concurrently. // For the time-being, the return value will be false. - return (networkType == ServiceState.RADIO_TECHNOLOGY_LTE); + return (mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE); } /** diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index 5115d76462a5..75f5d478e3af 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -86,12 +86,6 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { private int mNitzUpdateDiff = SystemProperties.getInt("ro.nitz_update_diff", NITZ_UPDATE_DIFF_DEFAULT); - /** - * Values correspond to ServiceState.RADIO_TECHNOLOGY_ definitions. - */ - protected int networkType = 0; - protected int newNetworkType = 0; - private boolean mCdmaRoaming = false; private int mRoamingIndicator; private boolean mIsInPrl; @@ -556,10 +550,10 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { /** * Determine data network type based on radio technology. */ - protected void setCdmaTechnology(int radioTechnology){ - mNewDataConnectionState = radioTechnologyToDataServiceState(radioTechnology); - newSS.setRadioTechnology(radioTechnology); - newNetworkType = radioTechnology; + protected void setCdmaTechnology(int radioTech){ + mNewDataConnectionState = radioTechnologyToDataServiceState(radioTech); + newSS.setRadioTechnology(radioTech); + mNewRilRadioTechnology = radioTech; } /** @@ -925,7 +919,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { boolean hasCdmaDataConnectionChanged = mDataConnectionState != mNewDataConnectionState; - boolean hasNetworkTypeChanged = networkType != newNetworkType; + boolean hasRadioTechnologyChanged = mRilRadioTechnology != mNewRilRadioTechnology; boolean hasChanged = !newSS.equals(ss); @@ -955,15 +949,15 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { newCellLoc = tcl; mDataConnectionState = mNewDataConnectionState; - networkType = newNetworkType; + mRilRadioTechnology = mNewRilRadioTechnology; // this new state has been applied - forget it until we get a new new state - newNetworkType = 0; + mNewRilRadioTechnology = 0; newSS.setStateOutOfService(); // clean slate for next time - if (hasNetworkTypeChanged) { + if (hasRadioTechnologyChanged) { phone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, - ServiceState.radioTechnologyToString(networkType)); + ServiceState.rilRadioTechnologyToString(mRilRadioTechnology)); } if (hasRegistered) { @@ -1030,7 +1024,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { mDetachedRegistrants.notifyRegistrants(); } - if (hasCdmaDataConnectionChanged || hasNetworkTypeChanged) { + if (hasCdmaDataConnectionChanged || hasRadioTechnologyChanged) { phone.notifyDataConnection(null); } diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java index 1f28280685c6..4956ef41ff8f 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java @@ -100,7 +100,7 @@ public class GsmDataConnection extends DataConnection { } phone.mCM.setupDataCall( - Integer.toString(getRadioTechnology(RILConstants.SETUP_DATA_TECH_GSM)), + Integer.toString(getRilRadioTechnology(RILConstants.SETUP_DATA_TECH_GSM)), Integer.toString(mProfileId), mApn.apn, mApn.user, mApn.password, Integer.toString(authType), diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index 66e948793a8c..d1873ebbf2c9 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -2318,7 +2318,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } String operator = mPhone.mIccRecords.getOperatorNumeric(); - int radioTech = mPhone.getServiceState().getRadioTechnology(); + int networkType = mPhone.getServiceState().getNetworkType(); if (requestedApnType.equals(Phone.APN_TYPE_DEFAULT)) { if (canSetPreferApn && mPreferredApn != null) { @@ -2327,7 +2327,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { + mPreferredApn.numeric + ":" + mPreferredApn); } if (mPreferredApn.numeric.equals(operator)) { - if (mPreferredApn.bearer == 0 || mPreferredApn.bearer == radioTech) { + if (mPreferredApn.bearer == 0 || mPreferredApn.bearer == networkType) { apnList.add(mPreferredApn); if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList); return apnList; @@ -2346,7 +2346,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { if (mAllApns != null) { for (ApnSetting apn : mAllApns) { if (apn.canHandleType(requestedApnType)) { - if (apn.bearer == 0 || apn.bearer == radioTech) { + if (apn.bearer == 0 || apn.bearer == networkType) { if (DBG) log("apn info : " +apn.toString()); apnList.add(apn); } diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index 0ebeabedacfc..a4fb1d89e63c 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -629,7 +629,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } newGPRSState = regCodeToServiceState(regState); mDataRoaming = regCodeIsRoaming(regState); - mNewRadioTechnology = type; + mNewRilRadioTechnology = type; newSS.setRadioTechnology(type); break; @@ -746,8 +746,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker { " mNewMaxDataCalls=" + mNewMaxDataCalls + " oldReasonDataDenied=" + mReasonDataDenied + " mNewReasonDataDenied=" + mNewReasonDataDenied + - " oldType=" + ServiceState.radioTechnologyToString(mRadioTechnology) + - " newType=" + ServiceState.radioTechnologyToString(mNewRadioTechnology)); + " oldType=" + ServiceState.rilRadioTechnologyToString(mRilRadioTechnology) + + " newType=" + ServiceState.rilRadioTechnologyToString(mNewRilRadioTechnology)); } boolean hasRegistered = @@ -766,7 +766,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { gprsState == ServiceState.STATE_IN_SERVICE && newGPRSState != ServiceState.STATE_IN_SERVICE; - boolean hasRadioTechnologyChanged = mRadioTechnology != mNewRadioTechnology; + boolean hasRadioTechnologyChanged = mRilRadioTechnology != mNewRilRadioTechnology; boolean hasChanged = !newSS.equals(ss); @@ -800,11 +800,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker { int cid = -1; GsmCellLocation loc = ((GsmCellLocation)phone.getCellLocation()); if (loc != null) cid = loc.getCid(); - EventLog.writeEvent(EventLogTags.GSM_RAT_SWITCHED, cid, mRadioTechnology, - mNewRadioTechnology); + EventLog.writeEvent(EventLogTags.GSM_RAT_SWITCHED, cid, mRilRadioTechnology, + mNewRilRadioTechnology); if (DBG) { - log("RAT switched " + ServiceState.radioTechnologyToString(mRadioTechnology) + - " -> " + ServiceState.radioTechnologyToString(mNewRadioTechnology) + + log("RAT switched " + ServiceState.rilRadioTechnologyToString(mRilRadioTechnology) + + " -> " + ServiceState.rilRadioTechnologyToString(mNewRilRadioTechnology) + " at cell " + cid); } } @@ -812,16 +812,16 @@ final class GsmServiceStateTracker extends ServiceStateTracker { gprsState = newGPRSState; mReasonDataDenied = mNewReasonDataDenied; mMaxDataCalls = mNewMaxDataCalls; - mRadioTechnology = mNewRadioTechnology; + mRilRadioTechnology = mNewRilRadioTechnology; // this new state has been applied - forget it until we get a new new state - mNewRadioTechnology = 0; + mNewRilRadioTechnology = 0; newSS.setStateOutOfService(); // clean slate for next time if (hasRadioTechnologyChanged) { phone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, - ServiceState.radioTechnologyToString(mRadioTechnology)); + ServiceState.rilRadioTechnologyToString(mRilRadioTechnology)); } if (hasRegistered) { @@ -1246,7 +1246,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker { * that could support voice and data simultaneously. */ public boolean isConcurrentVoiceAndDataAllowed() { - return (mRadioTechnology >= ServiceState.RADIO_TECHNOLOGY_UMTS); + return (mRilRadioTechnology >= ServiceState.RIL_RADIO_TECHNOLOGY_UMTS); } /** diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java index f463a194070e..ae01c750847f 100644 --- a/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java +++ b/tests/StatusBar/src/com/android/statusbartest/NotificationTestList.java @@ -765,22 +765,70 @@ public class NotificationTestList extends TestActivity } }, - new Test("System priority notification") { + new Test("PRIORITY_HIGH") { public void run() { Notification n = new Notification.Builder(NotificationTestList.this) - .setSmallIcon(R.drawable.notification1) - .setContentTitle("System priority") + .setSmallIcon(R.drawable.notification5) + .setContentTitle("High priority") .setContentText("This should appear before all others") + .setPriority(Notification.PRIORITY_HIGH) .getNotification(); int[] idOut = new int[1]; try { INotificationManager directLine = mNM.getService(); - directLine.enqueueNotificationWithTagPriority( + directLine.enqueueNotificationWithTag( + getPackageName(), + null, + 100, + n, + idOut); + } catch (android.os.RemoteException ex) { + // oh well + } + } + }, + + new Test("PRIORITY_MAX") { + public void run() { + Notification n = new Notification.Builder(NotificationTestList.this) + .setSmallIcon(R.drawable.notification9) + .setContentTitle("MAX priority") + .setContentText("This might appear as an intruder alert") + .setPriority(Notification.PRIORITY_MAX) + .getNotification(); + + int[] idOut = new int[1]; + try { + INotificationManager directLine = mNM.getService(); + directLine.enqueueNotificationWithTag( + getPackageName(), + null, + 200, + n, + idOut); + } catch (android.os.RemoteException ex) { + // oh well + } + } + }, + + new Test("PRIORITY_MIN") { + public void run() { + Notification n = new Notification.Builder(NotificationTestList.this) + .setSmallIcon(R.drawable.notification0) + .setContentTitle("MIN priority") + .setContentText("You should not see this") + .setPriority(Notification.PRIORITY_MIN) + .getNotification(); + + int[] idOut = new int[1]; + try { + INotificationManager directLine = mNM.getService(); + directLine.enqueueNotificationWithTag( getPackageName(), null, 1, - StatusBarNotification.PRIORITY_SYSTEM, n, idOut); } catch (android.os.RemoteException ex) { |