Merge change I6c6c166b into eclair

* changes:
  Fix 2268841: Updated portrait tab lockscreen to match latest PPL.
diff --git a/core/java/android/widget/SimpleCursorAdapter.java b/core/java/android/widget/SimpleCursorAdapter.java
index b6a49e5..436b79b 100644
--- a/core/java/android/widget/SimpleCursorAdapter.java
+++ b/core/java/android/widget/SimpleCursorAdapter.java
@@ -74,7 +74,7 @@
      * @param context The context where the ListView associated with this
      *            SimpleListItemFactory is running
      * @param layout resource identifier of a layout file that defines the views
-     *            for this list item. Thelayout file should include at least
+     *            for this list item. The layout file should include at least
      *            those named views defined in "to"
      * @param c The database cursor.  Can be null if the cursor is not available yet.
      * @param from A list of column names representing the data to bind to the UI.  Can be null 
diff --git a/data/sounds/AudioPackage4.mk b/data/sounds/AudioPackage4.mk
index 354002a..6c36bad 100644
--- a/data/sounds/AudioPackage4.mk
+++ b/data/sounds/AudioPackage4.mk
@@ -20,7 +20,11 @@
 	$(LOCAL_PATH)/Alarm_Beep_03.ogg:system/media/audio/alarms/Alarm_Beep_03.ogg \
 	$(LOCAL_PATH)/Alarm_Rooster_02.ogg:system/media/audio/alarms/Alarm_Rooster_02.ogg \
 	$(LOCAL_PATH)/notifications/Beat_Box_Android.ogg:system/media/audio/notifications/Beat_Box_Android.ogg \
+	$(LOCAL_PATH)/notifications/Cricket.ogg:system/media/audio/notifications/Cricket.ogg \
+	$(LOCAL_PATH)/notifications/Doink.ogg:system/media/audio/notifications/Doink.ogg \
+	$(LOCAL_PATH)/notifications/Drip.ogg:system/media/audio/notifications/Drip.ogg \
 	$(LOCAL_PATH)/notifications/Heaven.ogg:system/media/audio/notifications/Heaven.ogg \
+	$(LOCAL_PATH)/notifications/SpaceSeed.ogg:system/media/audio/notifications/SpaceSeed.ogg \
 	$(LOCAL_PATH)/notifications/TaDa.ogg:system/media/audio/notifications/TaDa.ogg \
 	$(LOCAL_PATH)/notifications/Tinkerbell.ogg:system/media/audio/notifications/Tinkerbell.ogg \
 	$(LOCAL_PATH)/newwavelabs/CaffeineSnake.ogg:system/media/audio/notifications/CaffeineSnake.ogg \
diff --git a/data/sounds/notifications/Cricket.ogg b/data/sounds/notifications/Cricket.ogg
new file mode 100644
index 0000000..47b3868
--- /dev/null
+++ b/data/sounds/notifications/Cricket.ogg
Binary files differ
diff --git a/data/sounds/notifications/Cricket.wav b/data/sounds/notifications/Cricket.wav
new file mode 100644
index 0000000..0a1d1db
--- /dev/null
+++ b/data/sounds/notifications/Cricket.wav
Binary files differ
diff --git a/data/sounds/notifications/Doink.ogg b/data/sounds/notifications/Doink.ogg
new file mode 100644
index 0000000..b8b7181
--- /dev/null
+++ b/data/sounds/notifications/Doink.ogg
Binary files differ
diff --git a/data/sounds/notifications/Doink.wav b/data/sounds/notifications/Doink.wav
new file mode 100644
index 0000000..b0d37c4
--- /dev/null
+++ b/data/sounds/notifications/Doink.wav
Binary files differ
diff --git a/data/sounds/notifications/Drip.ogg b/data/sounds/notifications/Drip.ogg
new file mode 100644
index 0000000..2981758
--- /dev/null
+++ b/data/sounds/notifications/Drip.ogg
Binary files differ
diff --git a/data/sounds/notifications/Drip.wav b/data/sounds/notifications/Drip.wav
new file mode 100644
index 0000000..eeb889e
--- /dev/null
+++ b/data/sounds/notifications/Drip.wav
Binary files differ
diff --git a/data/sounds/notifications/SpaceSeed.ogg b/data/sounds/notifications/SpaceSeed.ogg
new file mode 100644
index 0000000..e69024d
--- /dev/null
+++ b/data/sounds/notifications/SpaceSeed.ogg
Binary files differ
diff --git a/data/sounds/notifications/SpaceSeed.wav b/data/sounds/notifications/SpaceSeed.wav
new file mode 100644
index 0000000..d209645
--- /dev/null
+++ b/data/sounds/notifications/SpaceSeed.wav
Binary files differ
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 408d83f..ff8d29f 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -88,7 +88,7 @@
     return false;
 }
 
-void Allocation::uploadToTexture(uint32_t lodOffset)
+void Allocation::uploadToTexture(Context *rsc, uint32_t lodOffset)
 {
     //rsAssert(!mTextureId);
     rsAssert(lodOffset < mType->getLODCount());
@@ -102,6 +102,15 @@
 
     if (!mTextureID) {
         glGenTextures(1, &mTextureID);
+
+        if (!mTextureID) {
+            // This should not happen, however, its likely the cause of the
+            // white sqare bug.
+            // Force a crash to 1: restart the app, 2: make sure we get a bugreport.
+            LOGE("Upload to texture failed to gen mTextureID");
+            rsc->dumpDebug();
+            ((char *)0)[0] = 0;
+        }
     }
     glBindTexture(GL_TEXTURE_2D, mTextureID);
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -203,7 +212,7 @@
     LOGV("%s allocation ptr=%p mCpuWrite=%i, mCpuRead=%i, mGpuWrite=%i, mGpuRead=%i",
           prefix, mPtr, mCpuWrite, mCpuRead, mGpuWrite, mGpuRead);
 
-    LOGV("%s allocation mIsTexture=%i mIsTextureID=%i, mIsVertexBuffer=%i, mBufferID=%i",
+    LOGV("%s allocation mIsTexture=%i mTextureID=%i, mIsVertexBuffer=%i, mBufferID=%i",
           prefix, mIsTexture, mTextureID, mIsVertexBuffer, mBufferID);
 
 
@@ -238,7 +247,7 @@
 void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, uint32_t baseMipLevel)
 {
     Allocation *alloc = static_cast<Allocation *>(va);
-    alloc->uploadToTexture(baseMipLevel);
+    alloc->uploadToTexture(rsc, baseMipLevel);
 }
 
 void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va)
@@ -400,7 +409,6 @@
         LOGE("Memory allocation failure");
         return NULL;
     }
-    texAlloc->incUserRef();
 
     ElementConverter_t cvt = pickConverter(dst, src);
     cvt(texAlloc->getPtr(), data, w * h);
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
index 514b1c2..f54284a 100644
--- a/libs/rs/rsAllocation.h
+++ b/libs/rs/rsAllocation.h
@@ -46,7 +46,7 @@
     void * getPtr() const {return mPtr;}
     const Type * getType() const {return mType.get();}
 
-    void uploadToTexture(uint32_t lodOffset = 0);
+    void uploadToTexture(Context *rsc, uint32_t lodOffset = 0);
     uint32_t getTextureID() const {return mTextureID;}
 
     void uploadToBufferObject();
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 08ed725..52074ca 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -726,6 +726,24 @@
     mIO.mToClient.shutdown();
 }
 
+void Context::dumpDebug() const
+{
+    LOGE("RS Context debug %p", this);
+    LOGE("RS Context debug");
+
+    LOGE(" EGL ver %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion);
+    LOGE(" EGL context %p  surface %p,  w=%i h=%i  Display=%p", mEGL.mContext,
+         mEGL.mSurface, mEGL.mWidth, mEGL.mHeight, mEGL.mDisplay);
+    LOGE(" GL vendor: %s", mGL.mVendor);
+    LOGE(" GL renderer: %s", mGL.mRenderer);
+    LOGE(" GL Version: %s", mGL.mVersion);
+    LOGE(" GL Extensions: %s", mGL.mExtensions);
+    LOGE(" GL int Versions %i %i", mGL.mMajorVersion, mGL.mMinorVersion);
+    LOGE(" RS width %i, height %i", mWidth, mHeight);
+    LOGE(" RS running %i, exit %i, useDepth %i, paused %i", mRunning, mExit, mUseDepth, mPaused);
+    LOGE(" RS pThreadID %li, nativeThreadID %i", mThreadId, mNativeThreadId);
+
+}
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 //
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index fb878eb..4e0f653 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -162,6 +162,8 @@
         bool mLogObjects;
     } props;
 
+    void dumpDebug() const;
+
     mutable const ObjectBase * mObjHead;
 
 protected:
diff --git a/media/libmedia/IMediaMetadataRetriever.cpp b/media/libmedia/IMediaMetadataRetriever.cpp
index 397a55b..e529d25 100644
--- a/media/libmedia/IMediaMetadataRetriever.cpp
+++ b/media/libmedia/IMediaMetadataRetriever.cpp
@@ -21,6 +21,60 @@
 #include <SkBitmap.h>
 #include <media/IMediaMetadataRetriever.h>
 
+// The binder is supposed to propagate the scheduler group across
+// the binder interface so that remote calls are executed with
+// the same priority as local calls. This is currently not working
+// so this change puts in a temporary hack to fix the issue with
+// metadata retrieval which can be a huge CPU hit if done on a
+// foreground thread.
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+
+/* desktop Linux needs a little help with gettid() */
+#if defined(HAVE_GETTID) && !defined(HAVE_ANDROID_OS)
+#define __KERNEL__
+# include <linux/unistd.h>
+#ifdef _syscall0
+_syscall0(pid_t,gettid)
+#else
+pid_t gettid() { return syscall(__NR_gettid);}
+#endif
+#undef __KERNEL__
+#endif
+
+static int myTid() {
+#ifdef HAVE_GETTID
+    return gettid();
+#else
+    return getpid();
+#endif
+}
+
+#undef LOG_TAG
+#define LOG_TAG "IMediaMetadataRetriever"
+#include <utils/Log.h>
+#include <cutils/sched_policy.h>
+
+namespace android {
+
+static void sendSchedPolicy(Parcel& data)
+{
+    SchedPolicy policy;
+    get_sched_policy(myTid(), &policy);
+    data.writeInt32(policy);
+}
+
+static void setSchedPolicy(const Parcel& data)
+{
+    SchedPolicy policy = (SchedPolicy) data.readInt32();
+    set_sched_policy(myTid(), policy);
+}
+static void restoreSchedPolicy()
+{
+    set_sched_policy(myTid(), SP_FOREGROUND);
+}
+}; // end namespace android
+#endif
+
 namespace android {
 
 enum {
@@ -30,7 +84,7 @@
     SET_MODE,
     GET_MODE,
     CAPTURE_FRAME,
-    EXTARCT_ALBUM_ART,
+    EXTRACT_ALBUM_ART,
     EXTRACT_METADATA,
 };
 
@@ -92,6 +146,9 @@
     {
         Parcel data, reply;
         data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+        sendSchedPolicy(data);
+#endif
         remote()->transact(CAPTURE_FRAME, data, &reply);
         status_t ret = reply.readInt32();
         if (ret != NO_ERROR) {
@@ -104,7 +161,10 @@
     {
         Parcel data, reply;
         data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
-        remote()->transact(EXTARCT_ALBUM_ART, data, &reply);
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+        sendSchedPolicy(data);
+#endif
+        remote()->transact(EXTRACT_ALBUM_ART, data, &reply);
         status_t ret = reply.readInt32();
         if (ret != NO_ERROR) {
             return NULL;
@@ -116,6 +176,9 @@
     {
         Parcel data, reply;
         data.writeInterfaceToken(IMediaMetadataRetriever::getInterfaceDescriptor());
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+        sendSchedPolicy(data);
+#endif
         data.writeInt32(keyCode);
         remote()->transact(EXTRACT_METADATA, data, &reply);
         status_t ret = reply.readInt32();
@@ -169,6 +232,9 @@
         } break;
         case CAPTURE_FRAME: {
             CHECK_INTERFACE(IMediaMetadataRetriever, data, reply);
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+            setSchedPolicy(data);
+#endif
             sp<IMemory> bitmap = captureFrame();
             if (bitmap != 0) {  // Don't send NULL across the binder interface
                 reply->writeInt32(NO_ERROR);
@@ -176,10 +242,16 @@
             } else {
                 reply->writeInt32(UNKNOWN_ERROR);
             }
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+            restoreSchedPolicy();
+#endif
             return NO_ERROR;
         } break;
-        case EXTARCT_ALBUM_ART: {
+        case EXTRACT_ALBUM_ART: {
             CHECK_INTERFACE(IMediaMetadataRetriever, data, reply);
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+            setSchedPolicy(data);
+#endif
             sp<IMemory> albumArt = extractAlbumArt();
             if (albumArt != 0) {  // Don't send NULL across the binder interface
                 reply->writeInt32(NO_ERROR);
@@ -187,10 +259,16 @@
             } else {
                 reply->writeInt32(UNKNOWN_ERROR);
             }
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+            restoreSchedPolicy();
+#endif
             return NO_ERROR;
         } break;
         case EXTRACT_METADATA: {
             CHECK_INTERFACE(IMediaMetadataRetriever, data, reply);
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+            setSchedPolicy(data);
+#endif
             int keyCode = data.readInt32();
             const char* value = extractMetadata(keyCode);
             if (value != NULL) {  // Don't send NULL across the binder interface
@@ -199,6 +277,9 @@
             } else {
                 reply->writeInt32(UNKNOWN_ERROR);
             }
+#ifndef DISABLE_GROUP_SCHEDULE_HACK
+            restoreSchedPolicy();
+#endif
             return NO_ERROR;
         } break;
         default:
diff --git a/media/libmediaplayerservice/MetadataRetrieverClient.cpp b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
index 2cdc351..d51ce66 100644
--- a/media/libmediaplayerservice/MetadataRetrieverClient.cpp
+++ b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
@@ -237,7 +237,6 @@
 {
     LOGV("captureFrame");
     Mutex::Autolock lock(mLock);
-    Priority priority(ANDROID_PRIORITY_BACKGROUND);
     mThumbnail.clear();
     mThumbnailDealer.clear();
     if (mRetriever == NULL) {
@@ -279,7 +278,6 @@
 {
     LOGV("extractAlbumArt");
     Mutex::Autolock lock(mLock);
-    Priority priority(ANDROID_PRIORITY_BACKGROUND);
     mAlbumArt.clear();
     mAlbumArtDealer.clear();
     if (mRetriever == NULL) {
@@ -321,19 +319,7 @@
         LOGE("retriever is not initialized");
         return NULL;
     }
-    Priority priority(ANDROID_PRIORITY_BACKGROUND);
     return mRetriever->extractMetadata(keyCode);
 }
 
-MetadataRetrieverClient::Priority::Priority(int newPriority)
-{
-    mOldPriority = getpriority(PRIO_PROCESS, 0);
-    setpriority(PRIO_PROCESS, 0, newPriority);
-}
-
-MetadataRetrieverClient::Priority::~Priority()
-{
-    setpriority(PRIO_PROCESS, 0, mOldPriority);
-}
-
 }; // namespace android
diff --git a/media/libmediaplayerservice/MetadataRetrieverClient.h b/media/libmediaplayerservice/MetadataRetrieverClient.h
index 852d734..8cb8ad1 100644
--- a/media/libmediaplayerservice/MetadataRetrieverClient.h
+++ b/media/libmediaplayerservice/MetadataRetrieverClient.h
@@ -54,16 +54,6 @@
 private:
     friend class MediaPlayerService;
 
-    class Priority
-    {
-    public:
-        Priority(int newPriority);
-        ~Priority();
-    private:
-        Priority();
-        int         mOldPriority;
-    };
-
     explicit MetadataRetrieverClient(pid_t pid);
     virtual ~MetadataRetrieverClient();
 
diff --git a/services/java/com/android/server/InputDevice.java b/services/java/com/android/server/InputDevice.java
index 6eb6242..7c19f24 100644
--- a/services/java/com/android/server/InputDevice.java
+++ b/services/java/com/android/server/InputDevice.java
@@ -288,6 +288,10 @@
                         + " weight: (" + x + "," + y + ")");
                 mAveragedData[ioff + MotionEvent.SAMPLE_X] = x;
                 mAveragedData[ioff + MotionEvent.SAMPLE_Y] = y;
+                mAveragedData[ioff + MotionEvent.SAMPLE_PRESSURE] =
+                        rawData[ioff + MotionEvent.SAMPLE_PRESSURE];
+                mAveragedData[ioff + MotionEvent.SAMPLE_SIZE] =
+                        rawData[ioff + MotionEvent.SAMPLE_SIZE];
             }
             return mAveragedData;
         }
diff --git a/tests/ImfTest/tests/AndroidManifest.xml b/tests/ImfTest/tests/AndroidManifest.xml
index 122d202..c02fa0b 100755
--- a/tests/ImfTest/tests/AndroidManifest.xml
+++ b/tests/ImfTest/tests/AndroidManifest.xml
@@ -18,6 +18,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.imftest.tests">
 
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
diff --git a/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java
index 61dc611..1957640 100755
--- a/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java
+++ b/tests/ImfTest/tests/src/com/android/imftest/samples/ImfBaseTestCase.java
@@ -17,6 +17,8 @@
 package com.android.imftest.samples;
 
 import android.app.Activity;
+import android.app.KeyguardManager;
+import android.content.Context;
 import android.os.SystemClock;
 import android.test.InstrumentationTestCase;
 import android.view.KeyEvent;
@@ -58,6 +60,11 @@
         mTargetActivity = launchActivity(TARGET_PACKAGE_NAME, mTargetActivityClass, null);
         mExpectAutoPop = mTargetActivity.getResources().getBoolean(R.bool.def_expect_ime_autopop);
         mImm = InputMethodManager.getInstance(mTargetActivity);
+
+        KeyguardManager keyguardManager =
+            (KeyguardManager) getInstrumentation().getContext().getSystemService(
+                    Context.KEYGUARD_SERVICE);
+        keyguardManager.newKeyguardLock("imftest").disableKeyguard();
     }
     
     // Utility test methods