Merge change I4f614c9e into eclair

* changes:
  Add a test app that has 100 icons.  None of them do anything when clicked.
diff --git a/api/current.xml b/api/current.xml
index 83f406f..065176b 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -41992,6 +41992,116 @@
  visibility="public"
 >
 </field>
+<field name="FEATURE_CAMERA"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.camera&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_CAMERA_AUTOFOCUS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.camera.autofocus&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_CAMERA_FLASH"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.camera.flash&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_LIVE_WALLPAPER"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.software.live_wallpaper&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_SENSOR_LIGHT"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.sensor.light&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_SENSOR_PROXIMITY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.sensor.proximity&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_TELEPHONY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.telephony&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_TELEPHONY_CDMA"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.telephony.cdma&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_TELEPHONY_GSM"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.telephony.gsm&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_TOUCHSCREEN_MULTITOUCH"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.touchscreen.multitouch&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="GET_ACTIVITIES"
  type="int"
  transient="false"
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index d77d702..3a23b49 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -84,6 +84,8 @@
         EXEC("dmesg");
         PRINT("------ KERNEL WAKELOCKS ------");
         DUMP("/proc/wakelocks");
+        PRINT("------ KERNEL CPUFREQ ------");
+        DUMP("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
         PRINT("");
         PRINT("------ PROCESSES ------");
         EXEC1("ps", "-P");
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index cd48dcb..e2030be 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -514,6 +514,68 @@
     public static final int DONT_DELETE_DATA = 0x00000001;
 
     /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device has a camera facing away
+     * from the screen.
+     */
+    public static final String FEATURE_CAMERA = "android.hardware.camera";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
+     */
+    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device's camera supports flash.
+     */
+    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device includes a light sensor.
+     */
+    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device includes a proximity sensor.
+     */
+    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device has a telephony radio with data
+     * communication support.
+     */
+    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
+     */
+    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
+     */
+    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device's touch screen supports multitouch.
+     */
+    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
+    
+    /**
+     * Feature for {@link #getSystemAvailableFeatures} and
+     * {@link #hasSystemFeature}: The device supports live wallpapers.
+     */
+    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
+    
+    /**
      * Retrieve overall information about an application package that is
      * installed on the system.
      *
diff --git a/include/media/stagefright/MediaPlayerImpl.h b/include/media/stagefright/MediaPlayerImpl.h
index 53a2088..7adf836 100644
--- a/include/media/stagefright/MediaPlayerImpl.h
+++ b/include/media/stagefright/MediaPlayerImpl.h
@@ -112,7 +112,9 @@
 
     MediaSource *makeShoutcastSource(const char *path);
 
-    void displayOrDiscardFrame(MediaBuffer *buffer, int64_t pts_us);
+    void displayOrDiscardFrame(
+            MediaBuffer **lastBuffer, MediaBuffer *buffer, int64_t pts_us);
+
     void populateISurface();
     void depopulateISurface();
     void sendFrameToISurface(MediaBuffer *buffer);
diff --git a/libs/surfaceflinger/LayerBlur.cpp b/libs/surfaceflinger/LayerBlur.cpp
index 5d4a38b..5fd7904 100644
--- a/libs/surfaceflinger/LayerBlur.cpp
+++ b/libs/surfaceflinger/LayerBlur.cpp
@@ -169,7 +169,6 @@
             // This reads the frame-buffer, so a h/w GL would have to
             // finish() its rendering first. we don't want to do that
             // too often. Read data is 4-bytes aligned.
-            glFinish();
             glReadPixels(X, Y, w, h, mReadFormat, mReadType, pixels);
 
             // blur that texture.
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index 28d7c48..88ef7e4 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -118,7 +118,12 @@
     sp<Source> source(getSource());
     if (source != 0)
         source->onTransaction(flags);
-    return LayerBase::doTransaction(flags);    
+    uint32_t res = LayerBase::doTransaction(flags);
+    // we always want filtering for these surfaces
+    if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
+        mUseLinearFiltering = true;
+    }
+    return res;
 }
 
 void LayerBuffer::unlockPageFlip(const Transform& planeTransform,
diff --git a/media/libstagefright/MediaPlayerImpl.cpp b/media/libstagefright/MediaPlayerImpl.cpp
index 622ea7e..8300422 100644
--- a/media/libstagefright/MediaPlayerImpl.cpp
+++ b/media/libstagefright/MediaPlayerImpl.cpp
@@ -40,6 +40,13 @@
 
 namespace android {
 
+static void releaseBufferIfNonNULL(MediaBuffer **buffer) {
+    if (*buffer) {
+        (*buffer)->release();
+        *buffer = NULL;
+    }
+}
+
 MediaPlayerImpl::MediaPlayerImpl(const char *uri)
     : mInitCheck(NO_INIT),
       mTimeSource(NULL),
@@ -51,7 +58,7 @@
       mPlaying(false),
       mPaused(false),
       mSeeking(false) {
-    LOGI("MediaPlayerImpl(%s)", uri);
+    LOGV("MediaPlayerImpl(%s)", uri);
     DataSource::RegisterDefaultSniffers();
 
     status_t err = mClient.connect();
@@ -103,7 +110,7 @@
       mPlaying(false),
       mPaused(false),
       mSeeking(false) {
-    LOGI("MediaPlayerImpl(%d, %lld, %lld)", fd, offset, length);
+    LOGV("MediaPlayerImpl(%d, %lld, %lld)", fd, offset, length);
     DataSource::RegisterDefaultSniffers();
 
     status_t err = mClient.connect();
@@ -140,7 +147,7 @@
 }
 
 void MediaPlayerImpl::play() {
-    LOGI("play");
+    LOGV("play");
 
     if (mPlaying) {
         if (mPaused) {
@@ -229,6 +236,8 @@
     bool firstFrame = true;
     bool eof = false;
 
+    MediaBuffer *lastBuffer = NULL;
+
     status_t err = mVideoDecoder->start();
     CHECK_EQ(err, OK);
 
@@ -241,7 +250,9 @@
         {
             Mutex::Autolock autoLock(mLock);
             if (mSeeking) {
-                LOGI("seek-options to %lld", mSeekTimeUs);
+                releaseBufferIfNonNULL(&lastBuffer);
+
+                LOGV("seek-options to %lld", mSeekTimeUs);
                 options.setSeekTo(mSeekTimeUs);
 
                 mSeeking = false;
@@ -301,19 +312,21 @@
             firstFrame = false;
         }
 
-        displayOrDiscardFrame(buffer, pts_us);
+        displayOrDiscardFrame(&lastBuffer, buffer, pts_us);
     }
 
+    releaseBufferIfNonNULL(&lastBuffer);
+
     mVideoDecoder->stop();
 }
 
 void MediaPlayerImpl::displayOrDiscardFrame(
+        MediaBuffer **lastBuffer,
         MediaBuffer *buffer, int64_t pts_us) {
     for (;;) {
         if (!mPlaying || mPaused) {
-            buffer->release();
-            buffer = NULL;
-
+            releaseBufferIfNonNULL(lastBuffer);
+            *lastBuffer = buffer;
             return;
         }
 
@@ -332,15 +345,13 @@
         if (delay_us < -15000) {
             // We're late.
 
-            LOGI("we're late by %lld ms, dropping a frame\n",
+            LOGV("we're late by %lld ms, dropping a frame\n",
                  -delay_us / 1000);
 
-            buffer->release();
-            buffer = NULL;
+            releaseBufferIfNonNULL(lastBuffer);
+            *lastBuffer = buffer;
             return;
         } else if (delay_us > 100000) {
-            LOGI("we're much too early (by %lld ms)\n",
-                 delay_us / 1000);
             usleep(100000);
             continue;
         } else if (delay_us > 0) {
@@ -352,13 +363,14 @@
 
     {
         Mutex::Autolock autoLock(mLock);
+
         if (mVideoRenderer.get() != NULL) {
             sendFrameToISurface(buffer);
         }
     }
 
-    buffer->release();
-    buffer = NULL;
+    releaseBufferIfNonNULL(lastBuffer);
+    *lastBuffer = buffer;
 }
 
 void MediaPlayerImpl::init() {
@@ -410,7 +422,7 @@
 }
 
 void MediaPlayerImpl::setAudioSource(const sp<MediaSource> &source) {
-    LOGI("setAudioSource");
+    LOGV("setAudioSource");
     mAudioSource = source;
 
     sp<MetaData> meta = source->getFormat();
@@ -420,7 +432,7 @@
 }
 
 void MediaPlayerImpl::setVideoSource(const sp<MediaSource> &source) {
-    LOGI("setVideoSource");
+    LOGV("setVideoSource");
     mVideoSource = source;
 
     sp<MetaData> meta = source->getFormat();
@@ -441,7 +453,7 @@
 }
 
 void MediaPlayerImpl::setSurface(const sp<Surface> &surface) {
-    LOGI("setSurface %p", surface.get());
+    LOGV("setSurface %p", surface.get());
     Mutex::Autolock autoLock(mLock);
 
     depopulateISurface();
@@ -455,7 +467,7 @@
 }
 
 void MediaPlayerImpl::setISurface(const sp<ISurface> &isurface) {
-    LOGI("setISurface %p", isurface.get());
+    LOGV("setISurface %p", isurface.get());
     Mutex::Autolock autoLock(mLock);
 
     depopulateISurface();
@@ -499,7 +511,7 @@
         host = string(host, 0, colon - host.c_str());
     }
 
-    LOGI("Connecting to host '%s', port %d, path '%s'",
+    LOGV("Connecting to host '%s', port %d, path '%s'",
          host.c_str(), port, path.c_str());
 
     HTTPStream *http = new HTTPStream;
@@ -533,7 +545,7 @@
 
             http->disconnect();
 
-            LOGI("Redirecting to %s\n", location.c_str());
+            LOGV("Redirecting to %s\n", location.c_str());
 
             host = string(location, 0, slashPos);
 
@@ -588,7 +600,7 @@
 }
 
 status_t MediaPlayerImpl::seekTo(int64_t time) {
-    LOGI("seekTo %lld", time);
+    LOGV("seekTo %lld", time);
 
     if (mPaused) {
         return UNKNOWN_ERROR;
@@ -651,7 +663,7 @@
 
 void MediaPlayerImpl::setAudioSink(
         const sp<MediaPlayerBase::AudioSink> &audioSink) {
-    LOGI("setAudioSink %p", audioSink.get());
+    LOGV("setAudioSink %p", audioSink.get());
     mAudioSink = audioSink;
 }
 
diff --git a/opengl/libagl/array.cpp b/opengl/libagl/array.cpp
index 4878722..71825c5 100644
--- a/opengl/libagl/array.cpp
+++ b/opengl/libagl/array.cpp
@@ -1548,24 +1548,36 @@
         GLuint name = buffers[i];
         if (name) {
             // unbind bound deleted buffers...
-            if (c->arrays.element_array_buffer->name == name) {
-                c->arrays.element_array_buffer = 0;
+            if (c->arrays.element_array_buffer) {
+                if (c->arrays.element_array_buffer->name == name) {
+                    c->arrays.element_array_buffer = 0;
+                }
             }
-            if (c->arrays.array_buffer->name == name) {
-                c->arrays.array_buffer = 0;
+            if (c->arrays.array_buffer) {
+                if (c->arrays.array_buffer->name == name) {
+                    c->arrays.array_buffer = 0;
+                }
             }
-            if (c->arrays.vertex.bo->name == name) {
-                c->arrays.vertex.bo = 0;
+            if (c->arrays.vertex.bo) {
+                if (c->arrays.vertex.bo->name == name) {
+                    c->arrays.vertex.bo = 0;
+                }
             }
-            if (c->arrays.normal.bo->name == name) {
-                c->arrays.normal.bo = 0;
+            if (c->arrays.normal.bo) {
+                if (c->arrays.normal.bo->name == name) {
+                    c->arrays.normal.bo = 0;
+                }
             }
-            if (c->arrays.color.bo->name == name) {
-                c->arrays.color.bo = 0;
+            if (c->arrays.color.bo) {
+                if (c->arrays.color.bo->name == name) {
+                    c->arrays.color.bo = 0;
+                }
             }
             for (int t=0 ; t<GGL_TEXTURE_UNIT_COUNT ; t++) {
-                if (c->arrays.texture[t].bo->name == name) {
-                    c->arrays.texture[t].bo = 0;
+                if (c->arrays.texture[t].bo) {
+                    if (c->arrays.texture[t].bo->name == name) {
+                        c->arrays.texture[t].bo = 0;
+                    }
                 }
             }
         }