Merge "Use LinkProperties for IP and proxy configuration"
diff --git a/api/current.xml b/api/current.xml
index 953c9f3..1336472 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -2352,6 +2352,17 @@
  visibility="public"
 >
 </field>
+<field name="alertDialogTheme"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843598"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="allContactsName"
  type="int"
  transient="false"
@@ -3617,6 +3628,17 @@
  visibility="public"
 >
 </field>
+<field name="dialogTheme"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843597"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="dialogTitle"
  type="int"
  transient="false"
@@ -20328,7 +20350,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="value" type="android.view.animation.Interpolator">
+<parameter name="value" type="android.animation.TimeInterpolator">
 </parameter>
 </method>
 <method name="setStartDelay"
@@ -20678,7 +20700,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="interpolator" type="android.view.animation.Interpolator">
+<parameter name="interpolator" type="android.animation.TimeInterpolator">
 </parameter>
 </method>
 <method name="setStartDelay"
@@ -20981,7 +21003,7 @@
 >
 </method>
 <method name="getInterpolator"
- return="android.view.animation.Interpolator"
+ return="android.animation.TimeInterpolator"
  abstract="false"
  native="false"
  synchronized="false"
@@ -21036,7 +21058,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="interpolator" type="android.view.animation.Interpolator">
+<parameter name="interpolator" type="android.animation.TimeInterpolator">
 </parameter>
 </method>
 <method name="setValue"
@@ -21124,7 +21146,7 @@
 </parameter>
 </method>
 <method name="getInterpolator"
- return="android.view.animation.Interpolator"
+ return="android.animation.TimeInterpolator"
  abstract="false"
  native="false"
  synchronized="false"
@@ -21271,7 +21293,7 @@
 >
 <parameter name="transitionType" type="int">
 </parameter>
-<parameter name="interpolator" type="android.view.animation.Interpolator">
+<parameter name="interpolator" type="android.animation.TimeInterpolator">
 </parameter>
 </method>
 <method name="setStagger"
@@ -21670,6 +21692,27 @@
 </parameter>
 </method>
 </class>
+<interface name="TimeInterpolator"
+ abstract="true"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="getInterpolation"
+ return="float"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="input" type="float">
+</parameter>
+</method>
+</interface>
 <interface name="TypeEvaluator"
  abstract="true"
  static="false"
@@ -21794,7 +21837,7 @@
 >
 </method>
 <method name="getInterpolator"
- return="android.view.animation.Interpolator"
+ return="android.animation.TimeInterpolator"
  abstract="false"
  native="false"
  synchronized="false"
@@ -21956,7 +21999,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="value" type="android.view.animation.Interpolator">
+<parameter name="value" type="android.animation.TimeInterpolator">
 </parameter>
 </method>
 <method name="setRepeatCount"
@@ -43986,6 +44029,17 @@
  synchronized="false"
  static="true"
  final="false"
+ deprecated="deprecated"
+ visibility="public"
+>
+</method>
+<method name="getCurrentSyncs"
+ return="java.util.List&lt;android.content.SyncInfo&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
  deprecated="not deprecated"
  visibility="public"
 >
@@ -54129,6 +54183,34 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.os.Parcelable">
+</implements>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="parcel" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 <field name="account"
  type="android.accounts.Account"
  transient="false"
@@ -112283,6 +112365,348 @@
 </method>
 </class>
 </package>
+<package name="android.nfc"
+>
+<class name="NdefMessage"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<constructor name="NdefMessage"
+ type="android.nfc.NdefMessage"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="records" type="android.nfc.NdefRecord[]">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getRecords"
+ return="android.nfc.NdefRecord[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.Creator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="NdefRecord"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<constructor name="NdefRecord"
+ type="android.nfc.NdefRecord"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="tnf" type="short">
+</parameter>
+<parameter name="type" type="byte[]">
+</parameter>
+<parameter name="id" type="byte[]">
+</parameter>
+<parameter name="payload" type="byte[]">
+</parameter>
+</constructor>
+<constructor name="NdefRecord"
+ type="android.nfc.NdefRecord"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="data" type="byte[]">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getId"
+ return="byte[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getPayload"
+ return="byte[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getTnf"
+ return="short"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getType"
+ return="byte[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.Creator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RTD_ALTERNATIVE_CARRIER"
+ type="byte[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RTD_HANDOVER_CARRIER"
+ type="byte[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RTD_HANDOVER_REQUEST"
+ type="byte[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RTD_HANDOVER_SELECT"
+ type="byte[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RTD_SMART_POSTER"
+ type="byte[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RTD_TEXT"
+ type="byte[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RTD_URI"
+ type="byte[]"
+ transient="false"
+ volatile="false"
+ value="null"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TNF_ABSOLUTE_URI"
+ type="short"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TNF_EMPTY"
+ type="short"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TNF_EXTERNAL_TYPE"
+ type="short"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TNF_MIME_MEDIA"
+ type="short"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TNF_UNCHANGED"
+ type="short"
+ transient="false"
+ volatile="false"
+ value="6"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TNF_UNKNOWN"
+ type="short"
+ transient="false"
+ volatile="false"
+ value="5"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TNF_WELL_KNOWN"
+ type="short"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+</package>
 <package name="android.opengl"
 >
 <class name="ETC1"
@@ -201101,7 +201525,7 @@
  static="false"
  final="false"
  deprecated="not deprecated"
- visibility="protected"
+ visibility="public"
 >
 <parameter name="event" type="android.view.DragEvent">
 </parameter>
@@ -202843,6 +203267,23 @@
 <parameter name="animation" type="android.view.animation.Animation">
 </parameter>
 </method>
+<method name="startDrag"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="data" type="android.content.ClipData">
+</parameter>
+<parameter name="thumbBuilder" type="android.view.View.DragThumbnailBuilder">
+</parameter>
+<parameter name="myWindowOnly" type="boolean">
+</parameter>
+</method>
 <method name="unscheduleDrawable"
  return="void"
  abstract="false"
@@ -212058,19 +212499,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<method name="getInterpolation"
- return="float"
- abstract="true"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="input" type="float">
-</parameter>
-</method>
+<implements name="android.animation.TimeInterpolator">
+</implements>
 </interface>
 <class name="LayoutAnimationController"
  extends="java.lang.Object"
@@ -215354,6 +215784,19 @@
 <parameter name="id" type="java.lang.String">
 </parameter>
 </method>
+<method name="showInputMethodAndSubtypeEnabler"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="topId" type="java.lang.String">
+</parameter>
+</method>
 <method name="showInputMethodPicker"
  return="void"
  abstract="false"
@@ -242375,7 +242818,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="t" type="T">
+<parameter name="arg0" type="T">
 </parameter>
 </method>
 </interface>
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 7decf9a..0159edd 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -171,9 +171,9 @@
             runtime.start();
         }
     } else {
-        LOG_ALWAYS_FATAL("app_process: no class name or --zygote supplied.");
         fprintf(stderr, "Error: no class name or --zygote supplied.\n");
         app_usage();
+        LOG_ALWAYS_FATAL("app_process: no class name or --zygote supplied.");
         return 10;
     }
 
diff --git a/cmds/stagefright/recordvideo.cpp b/cmds/stagefright/recordvideo.cpp
index 330fbc2..f8eb514 100644
--- a/cmds/stagefright/recordvideo.cpp
+++ b/cmds/stagefright/recordvideo.cpp
@@ -18,12 +18,10 @@
 
 #include <binder/ProcessState.h>
 #include <media/stagefright/AudioPlayer.h>
-#include <media/stagefright/FileSource.h>
 #include <media/stagefright/MediaBufferGroup.h>
 #include <media/stagefright/MediaDebug.h>
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MetaData.h>
-#include <media/stagefright/MediaExtractor.h>
 #include <media/stagefright/MPEG4Writer.h>
 #include <media/stagefright/OMXClient.h>
 #include <media/stagefright/OMXCodec.h>
@@ -31,18 +29,21 @@
 
 using namespace android;
 
-// print usage showing how to use this utility to record videos
+// Print usage showing how to use this utility to record videos
 static void usage(const char *me) {
     fprintf(stderr, "usage: %s\n", me);
     fprintf(stderr, "       -h(elp)\n");
-    fprintf(stderr, "       -b bit rate in bits per second (default 300000)\n");
-    fprintf(stderr, "       -c YUV420 color format: [0] semi planar or [1] planar (default 1)\n");
-    fprintf(stderr, "       -f frame rate in frames per second (default 30)\n");
-    fprintf(stderr, "       -i I frame interval in seconds (default 1)\n");
-    fprintf(stderr, "       -n number of frames to be recorded (default 300)\n");
-    fprintf(stderr, "       -w width in pixels (default 176)\n");
-    fprintf(stderr, "       -t height in pixels (default 144)\n");
-    fprintf(stderr, "       -v video codec: [0] AVC [1] M4V [2] H263 (default 0)\n");
+    fprintf(stderr, "       -b bit rate in bits per second (default: 300000)\n");
+    fprintf(stderr, "       -c YUV420 color format: [0] semi planar or [1] planar (default: 1)\n");
+    fprintf(stderr, "       -f frame rate in frames per second (default: 30)\n");
+    fprintf(stderr, "       -i I frame interval in seconds (default: 1)\n");
+    fprintf(stderr, "       -n number of frames to be recorded (default: 300)\n");
+    fprintf(stderr, "       -w width in pixels (default: 176)\n");
+    fprintf(stderr, "       -t height in pixels (default: 144)\n");
+    fprintf(stderr, "       -l encoder level. see omx il header (default: encoder specific)\n");
+    fprintf(stderr, "       -p encoder profile. see omx il header (default: encoder specific)\n");
+    fprintf(stderr, "       -v video codec: [0] AVC [1] M4V [2] H263 (default: 0)\n");
+    fprintf(stderr, "The output file is /sdcard/output.mp4\n");
     exit(1);
 }
 
@@ -56,6 +57,7 @@
           mFrameRate(fps),
           mColorFormat(colorFormat),
           mSize((width * height * 3) / 2) {
+
         mGroup.add_buffer(new MediaBuffer(mSize));
 
         // Check the color format to make sure
@@ -98,8 +100,11 @@
             return err;
         }
 
-        char x = (char)((double)rand() / RAND_MAX * 255);
-        memset((*buffer)->data(), x, mSize);
+        // We don't care about the contents. we just test video encoder
+        // Also, by skipping the content generation, we can return from
+        // read() much faster.
+        //char x = (char)((double)rand() / RAND_MAX * 255);
+        //memset((*buffer)->data(), x, mSize);
         (*buffer)->set_range(0, mSize);
         (*buffer)->meta_data()->clear();
         (*buffer)->meta_data()->setInt64(
@@ -125,38 +130,6 @@
     DummySource &operator=(const DummySource &);
 };
 
-sp<MediaSource> createSource(const char *filename) {
-    sp<MediaSource> source;
-
-    sp<MediaExtractor> extractor =
-        MediaExtractor::Create(new FileSource(filename));
-    if (extractor == NULL) {
-        return NULL;
-    }
-
-    size_t num_tracks = extractor->countTracks();
-
-    sp<MetaData> meta;
-    for (size_t i = 0; i < num_tracks; ++i) {
-        meta = extractor->getTrackMetaData(i);
-        CHECK(meta.get() != NULL);
-
-        const char *mime;
-        if (!meta->findCString(kKeyMIMEType, &mime)) {
-            continue;
-        }
-
-        if (strncasecmp(mime, "video/", 6)) {
-            continue;
-        }
-
-        source = extractor->getTrack(i);
-        break;
-    }
-
-    return source;
-}
-
 enum {
     kYUV420SP = 0,
     kYUV420P  = 1,
@@ -186,12 +159,14 @@
     int iFramesIntervalSeconds = 1;
     int colorFormat = OMX_COLOR_FormatYUV420Planar;
     int nFrames = 300;
+    int level = -1;        // Encoder specific default
+    int profile = -1;      // Encoder specific default
     int codec = 0;
     const char *fileName = "/sdcard/output.mp4";
 
     android::ProcessState::self()->startThreadPool();
     int res;
-    while ((res = getopt(argc, argv, "b:c:f:i:n:w:t:v:o:h")) >= 0) {
+    while ((res = getopt(argc, argv, "b:c:f:i:n:w:t:l:p:v:h")) >= 0) {
         switch (res) {
             case 'b':
             {
@@ -238,6 +213,18 @@
                 break;
             }
 
+            case 'l':
+            {
+                level = atoi(optarg);
+                break;
+            }
+
+            case 'p':
+            {
+                profile = atoi(optarg);
+                break;
+            }
+
             case 'v':
             {
                 codec = atoi(optarg);
@@ -260,7 +247,8 @@
     CHECK_EQ(client.connect(), OK);
 
     status_t err = OK;
-    sp<MediaSource> decoder = new DummySource(width, height, nFrames, frameRateFps, colorFormat);
+    sp<MediaSource> source =
+        new DummySource(width, height, nFrames, frameRateFps, colorFormat);
 
     sp<MetaData> enc_meta = new MetaData;
     switch (codec) {
@@ -282,10 +270,16 @@
     enc_meta->setInt32(kKeySliceHeight, height);
     enc_meta->setInt32(kKeyIFramesInterval, iFramesIntervalSeconds);
     enc_meta->setInt32(kKeyColorFormat, colorFormat);
+    if (level != -1) {
+        enc_meta->setInt32(kKeyVideoLevel, level);
+    }
+    if (profile != -1) {
+        enc_meta->setInt32(kKeyVideoProfile, profile);
+    }
 
     sp<MediaSource> encoder =
         OMXCodec::Create(
-                client.interface(), enc_meta, true /* createEncoder */, decoder);
+                client.interface(), enc_meta, true /* createEncoder */, source);
 
     sp<MPEG4Writer> writer = new MPEG4Writer(fileName);
     writer->addSource(encoder);
@@ -296,7 +290,7 @@
     err = writer->stop();
     int64_t end = systemTime();
 
-    printf("$\n");
+    fprintf(stderr, "$\n");
     client.disconnect();
 
     if (err != OK && err != ERROR_END_OF_STREAM) {
diff --git a/core/java/android/animation/Animator.java b/core/java/android/animation/Animator.java
index 2ada6d6..d3e0797 100644
--- a/core/java/android/animation/Animator.java
+++ b/core/java/android/animation/Animator.java
@@ -16,8 +16,6 @@
 
 package android.animation;
 
-import android.view.animation.Interpolator;
-
 import java.util.ArrayList;
 
 /**
@@ -97,7 +95,7 @@
      *
      * @param value the interpolator to be used by this animation
      */
-    public abstract void setInterpolator(Interpolator value);
+    public abstract void setInterpolator(TimeInterpolator value);
 
     /**
      * Returns whether this Animator is currently running (having been started and not yet ended).
diff --git a/core/java/android/animation/AnimatorSet.java b/core/java/android/animation/AnimatorSet.java
index a8385e4..5de0293 100644
--- a/core/java/android/animation/AnimatorSet.java
+++ b/core/java/android/animation/AnimatorSet.java
@@ -16,8 +16,6 @@
 
 package android.animation;
 
-import android.view.animation.Interpolator;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 
@@ -173,13 +171,13 @@
     }
 
     /**
-     * Sets the Interpolator for all current {@link #getChildAnimations() child animations}
+     * Sets the TimeInterpolator for all current {@link #getChildAnimations() child animations}
      * of this AnimatorSet.
      *
      * @param interpolator the interpolator to be used by each child animation of this AnimatorSet
      */
     @Override
-    public void setInterpolator(Interpolator interpolator) {
+    public void setInterpolator(TimeInterpolator interpolator) {
         for (Node node : mNodes) {
             node.animation.setInterpolator(interpolator);
         }
diff --git a/core/java/android/animation/Keyframe.java b/core/java/android/animation/Keyframe.java
index 192ba5c..f9a4f3c 100644
--- a/core/java/android/animation/Keyframe.java
+++ b/core/java/android/animation/Keyframe.java
@@ -16,14 +16,12 @@
 
 package android.animation;
 
-import android.view.animation.Interpolator;
-
 /**
  * This class holds a time/value pair for an animation. The Keyframe class is used
  * by {@link ValueAnimator} to define the values that the animation target will have over the course
  * of the animation. As the time proceeds from one keyframe to the other, the value of the
  * target object will animate between the value at the previous keyframe and the value at the
- * next keyframe. Each keyframe also holds an option {@link android.view.animation.Interpolator}
+ * next keyframe. Each keyframe also holds an optional {@link TimeInterpolator}
  * object, which defines the time interpolation over the intervalue preceding the keyframe.
  */
 public class Keyframe implements Cloneable {
@@ -47,7 +45,7 @@
      * The optional time interpolator for the interval preceding this keyframe. A null interpolator
      * (the default) results in linear interpolation over the interval.
      */
-    private Interpolator mInterpolator = null;
+    private TimeInterpolator mInterpolator = null;
 
     /**
      * Private constructor, called from the public constructors with the additional
@@ -224,7 +222,7 @@
      *
      * @return The optional interpolator for this Keyframe.
      */
-    public Interpolator getInterpolator() {
+    public TimeInterpolator getInterpolator() {
         return mInterpolator;
     }
 
@@ -234,7 +232,7 @@
      *
      * @return The optional interpolator for this Keyframe.
      */
-    public void setInterpolator(Interpolator interpolator) {
+    public void setInterpolator(TimeInterpolator interpolator) {
         mInterpolator = interpolator;
     }
 
diff --git a/core/java/android/animation/KeyframeSet.java b/core/java/android/animation/KeyframeSet.java
index af47a15..a24b1fb 100644
--- a/core/java/android/animation/KeyframeSet.java
+++ b/core/java/android/animation/KeyframeSet.java
@@ -18,8 +18,6 @@
 
 import java.util.ArrayList;
 
-import android.view.animation.Interpolator;
-
 /**
  * This class holds a collection of Keyframe objects and is called by ValueAnimator to calculate
  * values between those keyframes for a given animation. The class internal to the animation
@@ -58,7 +56,7 @@
         if (fraction <= 0f) {
             final Keyframe prevKeyframe = mKeyframes.get(0);
             final Keyframe nextKeyframe = mKeyframes.get(1);
-            final Interpolator interpolator = nextKeyframe.getInterpolator();
+            final TimeInterpolator interpolator = nextKeyframe.getInterpolator();
             if (interpolator != null) {
                 fraction = interpolator.getInterpolation(fraction);
             }
@@ -69,7 +67,7 @@
         } else if (fraction >= 1f) {
             final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2);
             final Keyframe nextKeyframe = mKeyframes.get(mNumKeyframes - 1);
-            final Interpolator interpolator = nextKeyframe.getInterpolator();
+            final TimeInterpolator interpolator = nextKeyframe.getInterpolator();
             if (interpolator != null) {
                 fraction = interpolator.getInterpolation(fraction);
             }
@@ -82,7 +80,7 @@
         for (int i = 1; i < mNumKeyframes; ++i) {
             Keyframe nextKeyframe = mKeyframes.get(i);
             if (fraction < nextKeyframe.getFraction()) {
-                final Interpolator interpolator = nextKeyframe.getInterpolator();
+                final TimeInterpolator interpolator = nextKeyframe.getInterpolator();
                 if (interpolator != null) {
                     fraction = interpolator.getInterpolation(fraction);
                 }
diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java
index 52f0f16..56ad857 100644
--- a/core/java/android/animation/LayoutTransition.java
+++ b/core/java/android/animation/LayoutTransition.java
@@ -21,7 +21,6 @@
 import android.view.ViewTreeObserver;
 import android.view.animation.AccelerateDecelerateInterpolator;
 import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -142,10 +141,10 @@
     /**
      * The default interpolators used for the animations
      */
-    private Interpolator mAppearingInterpolator = new AccelerateDecelerateInterpolator();
-    private Interpolator mDisappearingInterpolator = new AccelerateDecelerateInterpolator();
-    private Interpolator mChangingAppearingInterpolator = new DecelerateInterpolator();
-    private Interpolator mChangingDisappearingInterpolator = new DecelerateInterpolator();
+    private TimeInterpolator mAppearingInterpolator = new AccelerateDecelerateInterpolator();
+    private TimeInterpolator mDisappearingInterpolator = new AccelerateDecelerateInterpolator();
+    private TimeInterpolator mChangingAppearingInterpolator = new DecelerateInterpolator();
+    private TimeInterpolator mChangingDisappearingInterpolator = new DecelerateInterpolator();
 
     /**
      * This hashmap is used to store the animations that are currently running as part of
@@ -387,9 +386,9 @@
      * {@link #APPEARING}, or {@link #DISAPPEARING}, which determines the animation whose
      * duration is being set.
      * @param interpolator The interpolator that the specified animation should use.
-     * @see Animator#setInterpolator(android.view.animation.Interpolator)
+     * @see Animator#setInterpolator(TimeInterpolator)
      */
-    public void setInterpolator(int transitionType, Interpolator interpolator) {
+    public void setInterpolator(int transitionType, TimeInterpolator interpolator) {
         switch (transitionType) {
             case CHANGE_APPEARING:
                 mChangingAppearingInterpolator = interpolator;
@@ -414,10 +413,10 @@
      * @param transitionType one of {@link #CHANGE_APPEARING}, {@link #CHANGE_DISAPPEARING},
      * {@link #APPEARING}, or {@link #DISAPPEARING}, which determines the animation whose
      * duration is being set.
-     * @return Interpolator The interpolator that the specified animation uses.
-     * @see Animator#setInterpolator(android.view.animation.Interpolator)
+     * @return TimeInterpolator The interpolator that the specified animation uses.
+     * @see Animator#setInterpolator(TimeInterpolator)
      */
-    public Interpolator getInterpolator(int transitionType) {
+    public TimeInterpolator getInterpolator(int transitionType) {
         switch (transitionType) {
             case CHANGE_APPEARING:
                 return mChangingAppearingInterpolator;
diff --git a/core/java/android/animation/TimeInterpolator.java b/core/java/android/animation/TimeInterpolator.java
new file mode 100644
index 0000000..8d795a8
--- /dev/null
+++ b/core/java/android/animation/TimeInterpolator.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.animation;
+
+/**
+ * A time interpolator defines the rate of change of an animation. This allows animations
+ * to have non-linear motion, such as acceleration and deceleration.
+ */
+public interface TimeInterpolator {
+
+    /**
+     * Maps a value representing the elapsed fraciton of an animation to a value that represents
+     * the interpolated fraction. This interpolated value is then multiplied by the change in
+     * value of an animation to derive the animated value at the current elapsed animation time.
+     *
+     * @param input A value between 0 and 1.0 indicating our current point
+     *        in the animation where 0 represents the start and 1.0 represents
+     *        the end
+     * @return The interpolation value. This value can be more than 1.0 for
+     *         interpolators which overshoot their targets, or less than 0 for
+     *         interpolators that undershoot their targets.
+     */
+    float getInterpolation(float input);
+}
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index f81b1ea..d2b17f0 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -21,7 +21,6 @@
 import android.os.Message;
 import android.view.animation.AccelerateDecelerateInterpolator;
 import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -36,7 +35,7 @@
  * <p>By default, ValueAnimator uses non-linear time interpolation, via the
  * {@link AccelerateDecelerateInterpolator} class, which accelerates into and decelerates
  * out of an animation. This behavior can be changed by calling
- * {@link ValueAnimator#setInterpolator(Interpolator)}.</p>
+ * {@link ValueAnimator#setInterpolator(TimeInterpolator)}.</p>
  */
 public class ValueAnimator<T> extends Animator {
 
@@ -95,7 +94,8 @@
     private static final ArrayList<ValueAnimator> sPendingAnimations = new ArrayList<ValueAnimator>();
 
     // The time interpolator to be used if none is set on the animation
-    private static final Interpolator sDefaultInterpolator = new AccelerateDecelerateInterpolator();
+    private static final TimeInterpolator sDefaultInterpolator =
+            new AccelerateDecelerateInterpolator();
 
     // type evaluators for the three primitive types handled by this implementation
     private static final TypeEvaluator sIntEvaluator = new IntEvaluator();
@@ -178,7 +178,7 @@
      * through this interpolator to calculate the interpolated fraction, which is then used to
      * calculate the animated values.
      */
-    private Interpolator mInterpolator = sDefaultInterpolator;
+    private TimeInterpolator mInterpolator = sDefaultInterpolator;
 
     /**
      * The set of listeners to be sent events through the life of an animation.
@@ -654,7 +654,7 @@
      * @param value the interpolator to be used by this animation
      */
     @Override
-    public void setInterpolator(Interpolator value) {
+    public void setInterpolator(TimeInterpolator value) {
         if (value != null) {
             mInterpolator = value;
         }
@@ -665,7 +665,7 @@
      *
      * @return The timing interpolator for this ValueAnimator.
      */
-    public Interpolator getInterpolator() {
+    public TimeInterpolator getInterpolator() {
         return mInterpolator;
     }
 
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index ee49d97..7c87b79 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1745,35 +1745,11 @@
     }
 
     /**
-     * @deprecated This functionality will be removed in the future; please do
-     * not use.
-     *
-     * Control whether this activity is required to be persistent.  By default
-     * activities are not persistent; setting this to true will prevent the
-     * system from stopping this activity or its process when running low on
-     * resources.
-     * 
-     * <p><em>You should avoid using this method</em>, it has severe negative
-     * consequences on how well the system can manage its resources.  A better
-     * approach is to implement an application service that you control with
-     * {@link Context#startService} and {@link Context#stopService}.
-     * 
-     * @param isPersistent Control whether the current activity must be
-     *                     persistent, true if so, false for the normal
-     *                     behavior.
+     * @deprecated As of {@link android.os.Build.VERSION_CODES#GINGERBREAD}
+     * this is a no-op.
      */
     @Deprecated
     public void setPersistent(boolean isPersistent) {
-        if (mParent == null) {
-            try {
-                ActivityManagerNative.getDefault()
-                    .setPersistent(mToken, isPersistent);
-            } catch (RemoteException e) {
-                // Empty
-            }
-        } else {
-            throw new RuntimeException("setPersistent() not yet supported for embedded activities");
-        }
     }
 
     /**
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index b34c243..8cc6428 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -345,17 +345,6 @@
             return true;
         }
 
-        case SET_PERSISTENT_TRANSACTION: {
-            data.enforceInterface(IActivityManager.descriptor);
-            IBinder token = data.readStrongBinder();
-            boolean isPersistent = data.readInt() != 0;
-            if (token != null) {
-                setPersistent(token, isPersistent);
-            }
-            reply.writeNoException();
-            return true;
-        }
-
         case ATTACH_APPLICATION_TRANSACTION: {
             data.enforceInterface(IActivityManager.descriptor);
             IApplicationThread app = ApplicationThreadNative.asInterface(
@@ -1640,18 +1629,6 @@
         data.recycle();
         reply.recycle();
     }
-    public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
-    {
-        Parcel data = Parcel.obtain();
-        Parcel reply = Parcel.obtain();
-        data.writeInterfaceToken(IActivityManager.descriptor);
-        data.writeStrongBinder(token);
-        data.writeInt(isPersistent ? 1 : 0);
-        mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
-        reply.readException();
-        data.recycle();
-        reply.recycle();
-    }
     public void attachApplication(IApplicationThread app) throws RemoteException
     {
         Parcel data = Parcel.obtain();
diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java
index f0477e5..0a40a98 100644
--- a/core/java/android/app/AlertDialog.java
+++ b/core/java/android/app/AlertDialog.java
@@ -22,9 +22,10 @@
 import android.content.DialogInterface;
 import android.database.Cursor;
 import android.graphics.drawable.Drawable;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.Message;
+import android.util.Log;
+import android.util.TypedValue;
 import android.view.ContextThemeWrapper;
 import android.view.KeyEvent;
 import android.view.View;
@@ -58,27 +59,29 @@
     private AlertController mAlert;
 
     protected AlertDialog(Context context) {
-        this(context,
-                context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
-                        ? com.android.internal.R.style.Theme_Holo_Dialog_Alert
-                        : com.android.internal.R.style.Theme_Dialog_Alert);
+        this(context, getDefaultDialogTheme(context));
     }
 
     protected AlertDialog(Context context, int theme) {
-        super(context, theme);
+        super(context, theme == 0 ? getDefaultDialogTheme(context) : theme);
         mAlert = new AlertController(context, this, getWindow());
     }
 
     protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
-        super(context,
-                context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
-                ? com.android.internal.R.style.Theme_Holo_Dialog_Alert
-                : com.android.internal.R.style.Theme_Dialog_Alert);
+        super(context, getDefaultDialogTheme(context));
         setCancelable(cancelable);
         setOnCancelListener(cancelListener);
         mAlert = new AlertController(context, this, getWindow());
     }
 
+    private static int getDefaultDialogTheme(Context context) {
+        TypedValue outValue = new TypedValue();
+        context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
+                outValue, true);
+        Log.d("AlertDialog", "getDefaultDialogTheme data " + outValue.data + " id " + outValue.resourceId);
+        return outValue.resourceId;
+    }
+
     /**
      * Gets one of the buttons used in the dialog.
      * <p>
@@ -280,10 +283,7 @@
          * Constructor using a context for this builder and the {@link AlertDialog} it creates.
          */
         public Builder(Context context) {
-            this(context,
-                    context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
-                    ? com.android.internal.R.style.Theme_Holo_Dialog_Alert
-                    : com.android.internal.R.style.Theme_Dialog_Alert);
+            this(context, getDefaultDialogTheme(context));
         }
 
         /**
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index a178c04..526129a 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -29,6 +29,7 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.util.TypedValue;
 import android.view.ActionMode;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
@@ -140,11 +141,14 @@
      * <var>context</var>.  If 0, the default dialog theme will be used.
      */
     public Dialog(Context context, int theme) {
-        mContext = new ContextThemeWrapper(
-            context, theme == 0 ? 
-                    (context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
-                            ? com.android.internal.R.style.Theme_Holo_Dialog
-                                    : com.android.internal.R.style.Theme_Dialog) : theme);
+        if (theme == 0) {
+            TypedValue outValue = new TypedValue();
+            context.getTheme().resolveAttribute(com.android.internal.R.attr.dialogTheme,
+                    outValue, true);
+            theme = outValue.resourceId;
+        }
+
+        mContext = new ContextThemeWrapper(context, theme);
         mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
         Window w = PolicyManager.makeNewWindow(mContext);
         mWindow = w;
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index cd229e3..c9d5448 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -116,7 +116,6 @@
     public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException;
     /* oneway */
     public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException;
-    public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException;
     public void attachApplication(IApplicationThread app) throws RemoteException;
     /* oneway */
     public void activityIdle(IBinder token, Configuration config) throws RemoteException;
@@ -455,7 +454,7 @@
     int REPORT_THUMBNAIL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+27;
     int GET_CONTENT_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+28;
     int PUBLISH_CONTENT_PROVIDERS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+29;
-    int SET_PERSISTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+30;
+    
     int FINISH_SUB_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+31;
     int GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+32;
     int START_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+33;
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index 3289120..da1aac4 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -1319,12 +1319,36 @@
     }
 
     /**
-     * If a sync is active returns the information about it, otherwise returns false.
+     * If a sync is active returns the information about it, otherwise returns null.
+     * <p>
      * @return the SyncInfo for the currently active sync or null if one is not active.
+     * @deprecated
+     * Since multiple concurrent syncs are now supported you should use
+     * {@link #getCurrentSyncs()} to get the accurate list of current syncs.
+     * This method returns the first item from the list of current syncs
+     * or null if there are none.
      */
+    @Deprecated
     public static SyncInfo getCurrentSync() {
         try {
-            return getContentService().getCurrentSync();
+            final List<SyncInfo> syncs = getContentService().getCurrentSyncs();
+            if (syncs.isEmpty()) {
+                return null;
+            }
+            return syncs.get(0);
+        } catch (RemoteException e) {
+            throw new RuntimeException("the ContentService should always be reachable", e);
+        }
+    }
+
+    /**
+     * Returns a list with information about all the active syncs. This list will be empty
+     * if there are no active syncs.
+     * @return a List of SyncInfo objects for the currently active syncs.
+     */
+    public static List<SyncInfo> getCurrentSyncs() {
+        try {
+            return getContentService().getCurrentSyncs();
         } catch (RemoteException e) {
             throw new RuntimeException("the ContentService should always be reachable", e);
         }
diff --git a/core/java/android/content/ContentService.java b/core/java/android/content/ContentService.java
index fc2dfc0..afe8483 100644
--- a/core/java/android/content/ContentService.java
+++ b/core/java/android/content/ContentService.java
@@ -386,19 +386,15 @@
         return false;
     }
 
-    public SyncInfo getCurrentSync() {
+    public List<SyncInfo> getCurrentSyncs() {
         mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
                 "no permission to read the sync stats");
         long identityToken = clearCallingIdentity();
         try {
-            SyncManager syncManager = getSyncManager();
-            if (syncManager != null) {
-                return syncManager.getSyncStorageEngine().getCurrentSync();
-            }
+            return getSyncManager().getSyncStorageEngine().getCurrentSyncs();
         } finally {
             restoreCallingIdentity(identityToken);
         }
-        return null;
     }
 
     public SyncStatusInfo getSyncStatus(Account account, String authority) {
diff --git a/core/java/android/content/IContentService.aidl b/core/java/android/content/IContentService.aidl
index a6368d5..86a9392 100644
--- a/core/java/android/content/IContentService.aidl
+++ b/core/java/android/content/IContentService.aidl
@@ -104,7 +104,7 @@
      */
     boolean isSyncActive(in Account account, String authority);
 
-    SyncInfo getCurrentSync();
+    List<SyncInfo> getCurrentSyncs();
 
     /**
      * Returns the types of the SyncAdapters that are registered with the system.
diff --git a/core/java/android/content/SyncInfo.java b/core/java/android/content/SyncInfo.java
index 616b05f..abfe964 100644
--- a/core/java/android/content/SyncInfo.java
+++ b/core/java/android/content/SyncInfo.java
@@ -18,12 +18,13 @@
 
 import android.accounts.Account;
 import android.os.Parcel;
+import android.os.Parcelable;
 import android.os.Parcelable.Creator;
 
 /**
  * Information about the sync operation that is currently underway.
  */
-public class SyncInfo {
+public class SyncInfo implements Parcelable {
     /** @hide */
     public final int authorityId;
 
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java
index 487f6ce..17d85fa 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -1088,23 +1088,6 @@
     }
 
     /**
-     * Return the currently active sync information, or null if there is no
-     * active sync.  Note that the returned object is the real, live active
-     * sync object, so be careful what you do with it.
-     * <p>
-     * Since multiple concurrent syncs are now supported you should use
-     * {@link #getCurrentSyncs()} to get the accurate list of current syncs.
-     * This method returns the first item from the list of current syncs
-     * or null if there are none.
-     * @deprecated use {@link #getCurrentSyncs()}
-     */
-    public SyncInfo getCurrentSync() {
-        synchronized (mAuthorities) {
-            return !mCurrentSyncs.isEmpty() ? mCurrentSyncs.get(0) : null;
-        }
-    }
-
-    /**
      * Return a list of the currently active syncs. Note that the returned items are the
      * real, live active sync objects, so be careful what you do with it.
      */
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 38d897e..643e747 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -296,12 +296,12 @@
      * the normal application lifecycle.
      *
      * <p>Comes from the
-     * {@link android.R.styleable#AndroidManifestApplication_heavyWeight android:heavyWeight}
+     * {@link android.R.styleable#AndroidManifestApplication_cantSaveState android:cantSaveState}
      * attribute of the &lt;application&gt; tag.
      *
      * {@hide}
      */
-    public static final int CANT_SAVE_STATE = 1<<27;
+    public static final int FLAG_CANT_SAVE_STATE = 1<<27;
 
     /**
      * Flags associated with the application.  Any combination of
@@ -380,6 +380,12 @@
      */
     public boolean enabled = true;
 
+    /**
+     * For convenient access to package's install location.
+     * @hide
+     */
+    public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
+    
     public void dump(Printer pw, String prefix) {
         super.dumpFront(pw, prefix);
         if (className != null) {
@@ -393,7 +399,11 @@
         pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
                 + " theme=0x" + Integer.toHexString(theme));
         pw.println(prefix + "sourceDir=" + sourceDir);
-        if (!sourceDir.equals(publicSourceDir)) {
+        if (sourceDir == null) {
+            if (publicSourceDir != null) {
+                pw.println(prefix + "publicSourceDir=" + publicSourceDir);
+            }
+        } else if (!sourceDir.equals(publicSourceDir)) {
             pw.println(prefix + "publicSourceDir=" + publicSourceDir);
         }
         if (resourceDirs != null) {
@@ -456,6 +466,7 @@
         uid = orig.uid;
         targetSdkVersion = orig.targetSdkVersion;
         enabled = orig.enabled;
+        installLocation = orig.installLocation;
         manageSpaceActivityName = orig.manageSpaceActivityName;
         descriptionRes = orig.descriptionRes;
     }
@@ -488,6 +499,7 @@
         dest.writeInt(uid);
         dest.writeInt(targetSdkVersion);
         dest.writeInt(enabled ? 1 : 0);
+        dest.writeInt(installLocation);
         dest.writeString(manageSpaceActivityName);
         dest.writeString(backupAgentName);
         dest.writeInt(descriptionRes);
@@ -520,6 +532,7 @@
         uid = source.readInt();
         targetSdkVersion = source.readInt();
         enabled = source.readInt() != 0;
+        installLocation = source.readInt();
         manageSpaceActivityName = source.readString();
         backupAgentName = source.readString();
         descriptionRes = source.readInt();
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index eaf1e33..6cbc9b5 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -783,7 +783,8 @@
         pkg.installLocation = sa.getInteger(
                 com.android.internal.R.styleable.AndroidManifest_installLocation,
                 PARSE_DEFAULT_INSTALL_LOCATION);
-
+        pkg.applicationInfo.installLocation = pkg.installLocation;
+        
         // Resource boolean are -1, so 1 means we don't know the value.
         int supportsSmallScreens = 1;
         int supportsNormalScreens = 1;
@@ -1612,7 +1613,7 @@
                 if (sa.getBoolean(
                         com.android.internal.R.styleable.AndroidManifestApplication_cantSaveState,
                         false)) {
-                    ai.flags |= ApplicationInfo.CANT_SAVE_STATE;
+                    ai.flags |= ApplicationInfo.FLAG_CANT_SAVE_STATE;
 
                     // A heavy-weight application can not be in a custom process.
                     // We can do direct compare because we intern all strings.
@@ -1929,7 +1930,7 @@
 
         sa.recycle();
 
-        if (receiver && (owner.applicationInfo.flags&ApplicationInfo.CANT_SAVE_STATE) != 0) {
+        if (receiver && (owner.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
             // A heavy-weight application can not have receives in its main process
             // We can do direct compare because we intern all strings.
             if (a.info.processName == owner.packageName) {
@@ -2219,7 +2220,7 @@
 
         sa.recycle();
 
-        if ((owner.applicationInfo.flags&ApplicationInfo.CANT_SAVE_STATE) != 0) {
+        if ((owner.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
             // A heavy-weight application can not have providers in its main process
             // We can do direct compare because we intern all strings.
             if (p.info.processName == owner.packageName) {
@@ -2460,7 +2461,7 @@
 
         sa.recycle();
 
-        if ((owner.applicationInfo.flags&ApplicationInfo.CANT_SAVE_STATE) != 0) {
+        if ((owner.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
             // A heavy-weight application can not have services in its main process
             // We can do direct compare because we intern all strings.
             if (s.info.processName == owner.packageName) {
diff --git a/core/java/android/nfc/NdefMessage.java b/core/java/android/nfc/NdefMessage.java
new file mode 100644
index 0000000..557f651
--- /dev/null
+++ b/core/java/android/nfc/NdefMessage.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nfc;
+
+import android.nfc.NdefRecord;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.UnsupportedOperationException;
+
+/**
+ * NDEF Message data.
+ * <p>
+ * Immutable data class. An NDEF message always contains zero or more NDEF
+ * records.
+ */
+public class NdefMessage implements Parcelable {
+    /**
+     * Create an NDEF message from raw bytes.
+     * <p>
+     * Validation is performed to make sure the Record format headers are valid,
+     * and the ID + TYPE + PAYLOAD fields are of the correct size.
+     *
+     * @hide
+     */
+    public NdefMessage(byte[] data) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Create an NDEF message from NDEF records.
+     */
+    public NdefMessage(NdefRecord[] records) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Get the NDEF records inside this NDEF message.
+     *
+     * @return array of zero or more NDEF records.
+     */
+    public NdefRecord[] getRecords() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Get a byte array representation of this NDEF message.
+     *
+     * @return byte array
+     * @hide
+     */
+    public byte[] toByteArray() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        throw new UnsupportedOperationException();
+    }
+
+    public static final Parcelable.Creator<NdefMessage> CREATOR =
+            new Parcelable.Creator<NdefMessage>() {
+        public NdefMessage createFromParcel(Parcel in) {
+            throw new UnsupportedOperationException();
+        }
+        public NdefMessage[] newArray(int size) {
+            throw new UnsupportedOperationException();
+        }
+    };
+}
\ No newline at end of file
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
new file mode 100644
index 0000000..54cbbeb
--- /dev/null
+++ b/core/java/android/nfc/NdefRecord.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nfc;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.UnsupportedOperationException;
+
+/**
+ * NDEF Record data.
+ * <p>
+ * Immutable data class. An NDEF record always contains
+ * <ul>
+ * <li>3-bit TNF field
+ * <li>Variable length type
+ * <li>Variable length ID
+ * <li>Variable length payload
+ * </ul>
+ * The TNF (Type Name Format) field indicates how to interpret the type field.
+ * <p>
+ * This class represents a logical (unchunked) NDEF record. The underlying
+ * representation may be chunked across several NDEF records when the payload is
+ * large.
+ */
+public class NdefRecord implements Parcelable {
+    /**
+     * Indicates no type, id, or payload is associated with this NDEF Record.
+     * <p>
+     * Type, id and payload fields must all be empty to be a valid TNF_EMPTY
+     * record.
+     */
+    public static final short TNF_EMPTY = 0x00;
+
+    /**
+     * Indicates the type field uses the RTD type name format.
+     * <p>
+     * Use this TNF with RTD types such as RTD_TEXT, RTD_URI.
+     */
+    public static final short TNF_WELL_KNOWN = 0x01;
+
+    /**
+     * Indicates the type field contains a value that follows the media-type BNF
+     * construct defined by RFC 2046.
+     */
+    public static final short TNF_MIME_MEDIA = 0x02;
+
+    /**
+     * Indicates the type field contains a value that follows the absolute-URI
+     * BNF construct defined by RFC 3986.
+     */
+    public static final short TNF_ABSOLUTE_URI = 0x03;
+
+    /**
+     * Indicates the type field contains a value that follows the RTD external
+     * name specification.
+     * <p>
+     * Note this TNF should not be used with RTD_TEXT or RTD_URI constants.
+     * Those are well known RTD constants, not external RTD constants.
+     */
+    public static final short TNF_EXTERNAL_TYPE = 0x04;
+
+    /**
+     * Indicates the payload type is unknown.
+     * <p>
+     * This is similar to the "application/octet-stream" MIME type. The payload
+     * type is not explicitly encoded within the NDEF Message.
+     * <p>
+     * The type field must be empty to be a valid TNF_UNKNOWN record.
+     */
+    public static final short TNF_UNKNOWN = 0x05;
+
+    /**
+     * Indicates the payload is an intermediate or final chunk of a chunked
+     * NDEF Record.
+     * <p>
+     * The payload type is specified in the first chunk, and subsequent chunks
+     * must use TNF_UNCHANGED with an empty type field. TNF_UNCHANGED must not
+     * be used in any other situation.
+     */
+    public static final short TNF_UNCHANGED = 0x06;
+
+    /**
+     * Reserved TNF type.
+     * <p>
+     * The NFC Forum NDEF Specification v1.0 suggests for NDEF parsers to treat this
+     * value like TNF_UNKNOWN.
+     * @hide
+     */
+    public static final short TNF_RESERVED = 0x07;
+
+    /**
+     * RTD Text type. For use with TNF_WELL_KNOWN.
+     */
+    public static final byte[] RTD_TEXT = {0x54};  // "T"
+
+    /**
+     * RTD URI type. For use with TNF_WELL_KNOWN.
+     */
+    public static final byte[] RTD_URI = {0x55};   // "U"
+
+    /**
+     * RTD Smart Poster type. For use with TNF_WELL_KNOWN.
+     */
+    public static final byte[] RTD_SMART_POSTER = {0x53, 0x70};  // "Sp"
+
+    /**
+     * RTD Alternative Carrier type. For use with TNF_WELL_KNOWN.
+     */
+    public static final byte[] RTD_ALTERNATIVE_CARRIER = {0x61, 0x63};  // "ac"
+
+    /**
+     * RTD Handover Carrier type. For use with TNF_WELL_KNOWN.
+     */
+    public static final byte[] RTD_HANDOVER_CARRIER = {0x48, 0x63};  // "Hc"
+
+    /**
+     * RTD Handover Request type. For use with TNF_WELL_KNOWN.
+     */
+    public static final byte[] RTD_HANDOVER_REQUEST = {0x48, 0x72};  // "Hr"
+
+    /**
+     * RTD Handover Select type. For use with TNF_WELL_KNOWN.
+     */
+    public static final byte[] RTD_HANDOVER_SELECT = {0x48, 0x73}; // "Hs"
+
+    /**
+     * Construct an NDEF Record.
+     * <p>
+     * Applications should not attempt to manually chunk NDEF Records - the
+     * implementation of android.nfc will automatically chunk an NDEF Record
+     * when necessary (and only present a single logical NDEF Record to the
+     * application). So applications should not use TNF_UNCHANGED.
+     *
+     * @param tnf  a 3-bit TNF constant
+     * @param type byte array, containing zero to 255 bytes, must not be null
+     * @param id   byte array, containing zero to 255 bytes, must not be null
+     * @param payload byte array, containing zero to (2 ** 32 - 1) bytes,
+     *                must not be null
+     */
+    public NdefRecord(short tnf, byte[] type, byte[] id, byte[] payload) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Construct an NDEF Record from raw bytes.
+     * <p>
+     * Validation is performed to make sure the header is valid, and that
+     * the id, type and payload sizes appear to be valid.
+     *
+     * @throws FormatException if the data is not a valid NDEF record
+     */
+    public NdefRecord(byte[] data) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns the 3-bit TNF.
+     * <p>
+     * TNF is the top-level type.
+     */
+    public short getTnf() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns the variable length Type field.
+     * <p>
+     * This should be used in conjunction with the TNF field to determine the
+     * payload format.
+     */
+    public byte[] getType() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns the variable length ID.
+     */
+    public byte[] getId() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns the variable length payload.
+     */
+    public byte[] getPayload() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Return this NDEF Record as a byte array.
+     * @hide
+     */
+    public byte[] toByteArray() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        throw new UnsupportedOperationException();
+    }
+
+    public static final Parcelable.Creator<NdefRecord> CREATOR =
+            new Parcelable.Creator<NdefRecord>() {
+        public NdefRecord createFromParcel(Parcel in) {
+            throw new UnsupportedOperationException();
+        }
+        public NdefRecord[] newArray(int size) {
+            throw new UnsupportedOperationException();
+        }
+    };
+}
\ No newline at end of file
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java
index 44b73c5..5fd2246 100644
--- a/core/java/android/os/BatteryManager.java
+++ b/core/java/android/os/BatteryManager.java
@@ -84,7 +84,15 @@
      * String describing the technology of the current battery.
      */
     public static final String EXTRA_TECHNOLOGY = "technology";
-    
+
+    /**
+     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+     * Boolean value set to true if an unsupported charger is attached
+     * to the device.
+     * {@hide}
+     */
+    public static final String EXTRA_INVALID_CHARGER = "invalid_charger";
+
     // values for "status" field in the ACTION_BATTERY_CHANGED Intent
     public static final int BATTERY_STATUS_UNKNOWN = 1;
     public static final int BATTERY_STATUS_CHARGING = 2;
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index f0b00dd..2fadb82 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -135,10 +135,10 @@
 
     @Override
     void onPreDraw() {
-        nPrepare(mRenderer);
+        nPrepare(mRenderer, mOpaque);
     }
 
-    private native void nPrepare(int renderer);
+    private native void nPrepare(int renderer, boolean opaque);
 
     @Override
     void onPostDraw() {
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 2cc4052..b87dbc5 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -585,7 +585,7 @@
 
         @Override
         GLES20Canvas createCanvas() {
-            return mGlCanvas = new GLES20Canvas(true);
+            return mGlCanvas = new GLES20Canvas(mTranslucent);
         }
 
         @Override
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 54cb4ca..b45aa99 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -287,10 +287,12 @@
         setMeasuredDimension(width, height);
     }
     
+    /** @hide */
     @Override
-    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
-        super.onSizeChanged(w, h, oldw, oldh);
+    protected boolean setFrame(int left, int top, int right, int bottom) {
+        boolean result = super.setFrame(left, top, right, bottom);
         updateWindow(false, false);
+        return result;
     }
 
     @Override
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 35b806a..472f7b4 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -9898,11 +9898,10 @@
     }
 
     /**
-     * Drag and drop.  App calls startDrag(), then callbacks to onMeasureDragThumbnail()
-     * and onDrawDragThumbnail() happen, then the drag operation is handed over to the
-     * OS.
+     * Drag and drop.  App calls startDrag(), then callbacks to the thumbnail builder's
+     * onProvideThumbnailMetrics() and onDrawThumbnail() methods happen, then the drag
+     * operation is handed over to the OS.
      * !!! TODO: real docs
-     * @hide
      */
     public final boolean startDrag(ClipData data, DragThumbnailBuilder thumbBuilder,
             boolean myWindowOnly) {
@@ -10027,7 +10026,7 @@
      * For DRAG_ENDED_EVENT, the 'event' argument may be null.  The view should return
      * to its normal visual state.
      */
-    protected boolean onDragEvent(DragEvent event) {
+    public boolean onDragEvent(DragEvent event) {
         return false;
     }
 
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 5ebc981..5b3a091 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -938,11 +938,16 @@
             if (ViewDebug.DEBUG_DRAG) Log.d(View.VIEW_LOG_TAG, "Drop event: " + event);
             View target = findFrontmostDroppableChildAt(event.mX, event.mY, mLocalPoint);
             if (target != null) {
+                if (ViewDebug.DEBUG_DRAG) Log.d(View.VIEW_LOG_TAG, "   dispatch drop to " + target);
                 event.mX = mLocalPoint.x;
                 event.mY = mLocalPoint.y;
                 retval = target.dispatchDragEvent(event);
                 event.mX = tx;
                 event.mY = ty;
+            } else {
+                if (ViewDebug.DEBUG_DRAG) {
+                    Log.d(View.VIEW_LOG_TAG, "   not dropped on an accepting view");
+                }
             }
         } break;
         }
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 155122f..79f1f5b 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -16,25 +16,41 @@
 
 package android.view;
 
-import com.android.internal.view.BaseSurfaceHolder;
-import com.android.internal.view.IInputMethodCallback;
-import com.android.internal.view.IInputMethodSession;
-import com.android.internal.view.RootViewSurfaceTaker;
-
+import android.Manifest;
+import android.app.ActivityManagerNative;
+import android.content.ClipDescription;
+import android.content.ComponentCallbacks;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.CompatibilityInfo;
+import android.content.res.Configuration;
+import android.content.res.Resources;
 import android.graphics.Canvas;
 import android.graphics.PixelFormat;
-import android.graphics.PorterDuff;
 import android.graphics.Point;
 import android.graphics.PointF;
+import android.graphics.PorterDuff;
 import android.graphics.Rect;
 import android.graphics.Region;
-import android.os.*;
+import android.media.AudioManager;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.Debug;
+import android.os.Handler;
+import android.os.LatencyTimer;
+import android.os.Looper;
+import android.os.Message;
+import android.os.ParcelFileDescriptor;
 import android.os.Process;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemClock;
+import android.os.SystemProperties;
 import android.util.AndroidRuntimeException;
 import android.util.Config;
 import android.util.DisplayMetrics;
-import android.util.Log;
 import android.util.EventLog;
+import android.util.Log;
 import android.util.Slog;
 import android.util.SparseArray;
 import android.view.View.MeasureSpec;
@@ -43,21 +59,14 @@
 import android.view.inputmethod.InputConnection;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.Scroller;
-import android.content.pm.PackageManager;
-import android.content.res.CompatibilityInfo;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.content.ClipData;
-import android.content.ClipDescription;
-import android.content.ComponentCallbacks;
-import android.content.Context;
-import android.app.ActivityManagerNative;
-import android.Manifest;
-import android.media.AudioManager;
+import com.android.internal.view.BaseSurfaceHolder;
+import com.android.internal.view.IInputMethodCallback;
+import com.android.internal.view.IInputMethodSession;
+import com.android.internal.view.RootViewSurfaceTaker;
 
-import java.lang.ref.WeakReference;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 
 /**
diff --git a/core/java/android/view/WindowOrientationListener.java b/core/java/android/view/WindowOrientationListener.java
index 3e2e92b..2a76e33 100755
--- a/core/java/android/view/WindowOrientationListener.java
+++ b/core/java/android/view/WindowOrientationListener.java
@@ -109,7 +109,9 @@
     }
 
     public void setAllow180Rotation(boolean allowed) {
-        mSensorEventListener.setAllow180Rotation(allowed);
+        if (mSensorEventListener != null) {
+            mSensorEventListener.setAllow180Rotation(allowed);
+        }
     }
 
     public int getCurrentRotation(int lastRotation) {
diff --git a/core/java/android/view/animation/Interpolator.java b/core/java/android/view/animation/Interpolator.java
index d14c3e33..5d0fe7e 100644
--- a/core/java/android/view/animation/Interpolator.java
+++ b/core/java/android/view/animation/Interpolator.java
@@ -16,24 +16,16 @@
 
 package android.view.animation;
 
+import android.animation.TimeInterpolator;
+
 /**
  * An interpolator defines the rate of change of an animation. This allows
  * the basic animation effects (alpha, scale, translate, rotate) to be 
  * accelerated, decelerated, repeated, etc.
  */
-public interface Interpolator {
-    
-    /**
-     * Maps a point on the timeline to a multiplier to be applied to the
-     * transformations of an animation.
-     * 
-     * @param input A value between 0 and 1.0 indicating our current point
-     *        in the animation where 0 represents the start and 1.0 represents
-     *        the end
-     * @return The interpolation value. This value can be more than 1.0 for
-     *         Interpolators which overshoot their targets, or less than 0 for
-     *         Interpolators that undershoot their targets.
-     */
-    float getInterpolation(float input);
-    
+public interface Interpolator extends TimeInterpolator {
+    // A new interface, TimeInterpolator, was introduced for the new android.animation
+    // package. This older Interpolator interface extends TimeInterpolator so that users of
+    // the new Animator-based animations can use either the old Interpolator implementations or
+    // new classes that implement TimeInterpolator directly.
 }
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 8bd3298..8e355d6 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -1401,6 +1401,16 @@
         }
     }
 
+    public void showInputMethodAndSubtypeEnabler(String topId) {
+        synchronized (mH) {
+            try {
+                mService.showInputMethodAndSubtypeEnablerFromClient(mClient, topId);
+            } catch (RemoteException e) {
+                Log.w(TAG, "IME died: " + mCurId, e);
+            }
+        }
+    }
+
     void doDump(FileDescriptor fd, PrintWriter fout, String[] args) {
         final Printer p = new PrintWriterPrinter(fout);
         p.println("Input method client state for " + this + ":");
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java
index b00f88c..8c9f266 100644
--- a/core/java/android/webkit/CallbackProxy.java
+++ b/core/java/android/webkit/CallbackProxy.java
@@ -710,6 +710,9 @@
                 break;
 
             case ADD_MESSAGE_TO_CONSOLE:
+                if (mWebChromeClient == null) {
+                    break;
+                }
                 String message = msg.getData().getString("message");
                 String sourceID = msg.getData().getString("sourceID");
                 int lineNumber = msg.getData().getInt("lineNumber");
@@ -786,7 +789,9 @@
                         host, realm, username, password);
                 break;
             case SET_INSTALLABLE_WEBAPP:
-                mWebChromeClient.setInstallableWebApp();
+                if (mWebChromeClient != null) {
+                    mWebChromeClient.setInstallableWebApp();
+                }
                 break;
         }
     }
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 70c6378..1c954fc 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -97,6 +97,7 @@
 import android.view.View;
 import android.view.ViewDebug;
 import android.view.ViewGroup.LayoutParams;
+import android.view.ViewParent;
 import android.view.ViewRoot;
 import android.view.ViewTreeObserver;
 import android.view.accessibility.AccessibilityEvent;
@@ -198,7 +199,8 @@
 
     private int mCurrentAlpha = 255;    
 
-    private final int[] mTempCoords = new int[2];
+    final int[] mTempCoords = new int[2];
+    Rect mTempRect;
 
     private ColorStateList mTextColor;
     private int mCurTextColor;
@@ -4362,6 +4364,7 @@
 
         switch (keyCode) {
             case KeyEvent.KEYCODE_ENTER:
+                mEnterKeyIsDown = true;
                 // If ALT modifier is held, then we always insert a
                 // newline character.
                 if ((event.getMetaState()&KeyEvent.META_ALT_ON) == 0) {
@@ -4394,6 +4397,7 @@
                 break;
                 
             case KeyEvent.KEYCODE_DPAD_CENTER:
+                mDPadCenterIsDown = true;
                 if (shouldAdvanceFocusOnEnter()) {
                     return 0;
                 }
@@ -4488,6 +4492,7 @@
 
         switch (keyCode) {
             case KeyEvent.KEYCODE_DPAD_CENTER:
+                mDPadCenterIsDown = false;
                 /*
                  * If there is a click listener, just call through to
                  * super, which will invoke it.
@@ -4508,6 +4513,7 @@
                 return super.onKeyUp(keyCode, event);
                 
             case KeyEvent.KEYCODE_ENTER:
+                mEnterKeyIsDown = false;
                 if (mInputContentType != null
                         && mInputContentType.onEditorActionListener != null
                         && mInputContentType.enterDown) {
@@ -7286,9 +7292,21 @@
         }
 
         // Two ints packed in a long
+        return packRangeInLong(start, end);
+    }
+
+    private static long packRangeInLong(int start, int end) {
         return (((long) start) << 32) | end;
     }
 
+    private static int extractRangeStartFromLong(long range) {
+        return (int) (range >>> 32);
+    }
+
+    private static int extractRangeEndFromLong(long range) {
+        return (int) (range & 0x00000000FFFFFFFFL);
+    }
+    
     private void selectCurrentWord() {
         // In case selection mode is started after an orientation change or after a select all,
         // use the current selection instead of creating one
@@ -7296,67 +7314,31 @@
             return;
         }
 
-        int selectionStart, selectionEnd;
+        int minOffset, maxOffset;
 
-        // selectionModifierCursorController is not null at that point
-        SelectionModifierCursorController selectionModifierCursorController =
-            ((SelectionModifierCursorController) mSelectionModifierCursorController);
-        int minOffset = selectionModifierCursorController.getMinTouchOffset();
-        int maxOffset = selectionModifierCursorController.getMaxTouchOffset();
-
-        if (minOffset == maxOffset) {
-            int offset = Math.max(0, Math.min(minOffset, mTransformed.length()));
-
-            // Tolerance, number of charaters around tapped position
-            final int range = 1;
-            final int max = mTransformed.length() - 1;
-
-            // 'Smart' word selection: detect position between words
-            for (int i = -range; i <= range; i++) {
-                int index = offset + i;
-                if (index >= 0 && index <= max) {
-                    if (Character.isSpaceChar(mTransformed.charAt(index))) {
-                        // Select current space
-                        selectionStart = index;
-                        selectionEnd = selectionStart + 1;
-
-                        // Extend selection to maximum space range
-                        while (selectionStart > 0 &&
-                                Character.isSpaceChar(mTransformed.charAt(selectionStart - 1))) {
-                            selectionStart--;
-                        }
-                        while (selectionEnd < max &&
-                                Character.isSpaceChar(mTransformed.charAt(selectionEnd))) {
-                            selectionEnd++;
-                        }
-
-                        Selection.setSelection((Spannable) mText, selectionStart, selectionEnd);
-                        return;
-                    }
-                }
-            }
-
-            // 'Smart' word selection: detect position at beginning or end of text.
-            if (offset <= range) {
-                Selection.setSelection((Spannable) mText, 0, 0);
-                return;
-            }
-            if (offset >= (max - range)) {
-                Selection.setSelection((Spannable) mText, max + 1, max + 1);
-                return;
-            }
+        if (mDPadCenterIsDown || mEnterKeyIsDown) {
+            minOffset = getSelectionStart();
+            maxOffset = getSelectionEnd();
+        } else {
+            // selectionModifierCursorController is not null at that point
+            SelectionModifierCursorController selectionModifierCursorController =
+                ((SelectionModifierCursorController) mSelectionModifierCursorController);
+            minOffset = selectionModifierCursorController.getMinTouchOffset();
+            maxOffset = selectionModifierCursorController.getMaxTouchOffset();
         }
 
+        int selectionStart, selectionEnd;
+
         long wordLimits = getWordLimitsAt(minOffset);
         if (wordLimits >= 0) {
-            selectionStart = (int) (wordLimits >>> 32);
+            selectionStart = extractRangeStartFromLong(wordLimits);
         } else {
             selectionStart = Math.max(minOffset - 5, 0);
         }
 
         wordLimits = getWordLimitsAt(maxOffset);
         if (wordLimits >= 0) {
-            selectionEnd = (int) (wordLimits & 0x00000000FFFFFFFFL);
+            selectionEnd = extractRangeEndFromLong(wordLimits);
         } else {
             selectionEnd = Math.min(maxOffset + 5, mText.length());
         }
@@ -7485,7 +7467,6 @@
 
         switch (id) {
             case ID_COPY_URL:
-
                 URLSpan[] urls = ((Spanned) mText).getSpans(min, max, URLSpan.class);
                 if (urls.length >= 1) {
                     ClipData clip = null;
@@ -7511,6 +7492,49 @@
         return false;
     }
 
+    /**
+     * Prepare text so that there are not zero or two spaces at beginning and end of region defined
+     * by [min, max] when replacing this region by paste.
+     */
+    private long prepareSpacesAroundPaste(int min, int max, CharSequence paste) {
+        // Paste adds/removes spaces before or after insertion as needed.
+        if (Character.isSpaceChar(paste.charAt(0))) {
+            if (min > 0 && Character.isSpaceChar(mTransformed.charAt(min - 1))) {
+                // Two spaces at beginning of paste: remove one
+                final int originalLength = mText.length();
+                ((Editable) mText).replace(min - 1, min, "");
+                // Due to filters, there is no garantee that exactly one character was
+                // removed. Count instead.
+                final int delta = mText.length() - originalLength;
+                min += delta;
+                max += delta;
+            }
+        } else {
+            if (min > 0 && !Character.isSpaceChar(mTransformed.charAt(min - 1))) {
+                // No space at beginning of paste: add one
+                final int originalLength = mText.length();
+                ((Editable) mText).replace(min, min, " ");
+                // Taking possible filters into account as above.
+                final int delta = mText.length() - originalLength;
+                min += delta;
+                max += delta;
+            }
+        }
+
+        if (Character.isSpaceChar(paste.charAt(paste.length() - 1))) {
+            if (max < mText.length() && Character.isSpaceChar(mTransformed.charAt(max))) {
+                // Two spaces at end of paste: remove one
+                ((Editable) mText).replace(max, max + 1, "");
+            }
+        } else {
+            if (max < mText.length() && !Character.isSpaceChar(mTransformed.charAt(max))) {
+                // No space at end of paste: add one
+                ((Editable) mText).replace(max, max, " ");
+            }
+        }
+        return packRangeInLong(min, max);
+    }
+
     @Override
     public boolean performLongClick() {
         if (super.performLongClick()) {
@@ -7702,6 +7726,9 @@
                             CharSequence paste = clip.getItem(i).coerceToText(getContext());
                             if (paste != null) {
                                 if (!didfirst) {
+                                    long minMax = prepareSpacesAroundPaste(min, max, paste);
+                                    min = extractRangeStartFromLong(minMax);
+                                    max = extractRangeEndFromLong(minMax);
                                     Selection.setSelection((Spannable) mText, max);
                                     ((Editable) mText).replace(min, max, paste);
                                 } else {
@@ -7712,7 +7739,6 @@
                         }
                         stopSelectionActionMode();
                     }
-
                     return true;
 
                 case ID_CUT:
@@ -7792,6 +7818,8 @@
         private float mOffsetY;
         private float mHotspotX;
         private float mHotspotY;
+        private int mLastParentX;
+        private int mLastParentY;
 
         public HandleView(CursorController controller, Drawable handle) {
             super(TextView.this.mContext);
@@ -7801,8 +7829,11 @@
                     com.android.internal.R.attr.textSelectHandleWindowStyle);
             mContainer.setSplitTouchEnabled(true);
             mContainer.setClippingEnabled(false);
-            mHotspotX = mDrawable.getIntrinsicWidth() * 0.5f;
-            mHotspotY = -mDrawable.getIntrinsicHeight() * 0.2f;
+
+            final int handleWidth = mDrawable.getIntrinsicWidth();
+            final int handleHeight = mDrawable.getIntrinsicHeight();
+            mHotspotX = handleWidth * 0.5f;
+            mHotspotY = -handleHeight * 0.2f;
         }
 
         @Override
@@ -7812,7 +7843,7 @@
         }
 
         public void show() {
-            if (!isPositionInBounds()) {
+            if (!isPositionVisible()) {
                 hide();
                 return;
             }
@@ -7833,7 +7864,12 @@
             return mContainer.isShowing();
         }
 
-        private boolean isPositionInBounds() {
+        private boolean isPositionVisible() {
+            // Always show a dragging handle.
+            if (mIsDragging) {
+                return true;
+            }
+
             final int extendedPaddingTop = getExtendedPaddingTop();
             final int extendedPaddingBottom = getExtendedPaddingBottom();
             final int compoundPaddingLeft = getCompoundPaddingLeft();
@@ -7845,28 +7881,55 @@
             final int top = 0;
             final int bottom = hostView.getHeight();
 
-            final int clipLeft = left + compoundPaddingLeft;
-            final int clipTop = top + extendedPaddingTop;
-            final int clipRight = right - compoundPaddingRight;
-            final int clipBottom = bottom - extendedPaddingBottom;
+            if (mTempRect == null) {
+                mTempRect = new Rect();
+            }
+            final Rect clip = mTempRect;
+            clip.left = left + compoundPaddingLeft;
+            clip.top = top + extendedPaddingTop;
+            clip.right = right - compoundPaddingRight;
+            clip.bottom = bottom - extendedPaddingBottom;
 
-            return mPositionX + mHotspotX >= clipLeft && mPositionX + mHotspotX <= clipRight &&
-                    mPositionY + mHotspotY >= clipTop && mPositionY + mHotspotY <= clipBottom;
+            final ViewParent parent = hostView.getParent();
+            if (parent == null || !parent.getChildVisibleRect(hostView, clip, null)) {
+                return false;
+            }
+
+            final int[] coords = mTempCoords;
+            hostView.getLocationInWindow(coords);
+            final int posX = coords[0] + mPositionX + (int) mHotspotX;
+            final int posY = coords[1] + mPositionY;
+
+            return posX >= clip.left && posX <= clip.right &&
+                    posY >= clip.top && posY + mHotspotY <= clip.bottom;
         }
 
         private void moveTo(int x, int y) {
             mPositionX = x - TextView.this.mScrollX;
             mPositionY = y - TextView.this.mScrollY;
-            if (isPositionInBounds()) {
+            if (isPositionVisible()) {
+                int[] coords = null;
                 if (mContainer.isShowing()){
-                    final int[] coords = mTempCoords;
+                    coords = mTempCoords;
                     TextView.this.getLocationInWindow(coords);
-                    coords[0] += mPositionX;
-                    coords[1] += mPositionY;
-                    mContainer.update(coords[0], coords[1], mRight - mLeft, mBottom - mTop);
+                    mContainer.update(coords[0] + mPositionX, coords[1] + mPositionY,
+                            mRight - mLeft, mBottom - mTop);
                 } else {
                     show();
                 }
+
+                if (mIsDragging) {
+                    if (coords == null) {
+                        coords = mTempCoords;
+                        TextView.this.getLocationInWindow(coords);
+                    }
+                    if (coords[0] != mLastParentX || coords[1] != mLastParentY) {
+                        mOffsetX += coords[0] - mLastParentX;
+                        mOffsetY += coords[1] - mLastParentY;
+                        mLastParentX = coords[0];
+                        mLastParentY = coords[1];
+                    }
+                }
             } else {
                 hide();
             }
@@ -7893,6 +7956,10 @@
                 final float rawY = ev.getRawY();
                 mOffsetX = rawX - mPositionX;
                 mOffsetY = rawY - mPositionY;
+                final int[] coords = mTempCoords;
+                TextView.this.getLocationInWindow(coords);
+                mLastParentX = coords[0];
+                mLastParentY = coords[1];
                 mIsDragging = true;
                 break;
             }
@@ -8286,6 +8353,10 @@
     private CursorController        mSelectionModifierCursorController;
     private ActionMode              mSelectionActionMode;
     private int                     mLastTouchOffset = -1;
+    // These are needed to desambiguate a long click. If the long click comes from ones of these, we
+    // select from the current cursor position. Otherwise, select from long pressed position.
+    private boolean                 mDPadCenterIsDown = false;
+    private boolean                 mEnterKeyIsDown = false;
     // Created once and shared by different CursorController helper methods.
     // Only one cursor controller is active at any time which prevent race conditions.
     private static Rect             sCursorControllerTempRect = new Rect();
diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java
index e07c54f..8104ece 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -18,15 +18,17 @@
 package com.android.internal.app;
 
 import android.app.ActivityManagerNative;
+import android.app.AlertDialog;
+import android.app.Dialog;
 import android.app.IActivityManager;
 import android.app.ProgressDialog;
-import android.app.AlertDialog;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.IBluetooth;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.os.Handler;
 import android.os.Power;
 import android.os.PowerManager;
@@ -91,13 +93,20 @@
             }
         }
 
-        Log.d(TAG, "Notifying thread to start radio shutdown");
+        final int longPressBehavior = context.getResources().getInteger(
+                        com.android.internal.R.integer.config_longPressOnPowerBehavior);
+        final int resourceId = longPressBehavior == 2
+                ? com.android.internal.R.string.shutdown_confirm_question
+                : com.android.internal.R.string.shutdown_confirm;
+
+        Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);
 
         if (confirm) {
+            final CloseDialogReceiver closer = new CloseDialogReceiver(context);
             final AlertDialog dialog = new AlertDialog.Builder(context)
                     .setIcon(android.R.drawable.ic_dialog_alert)
                     .setTitle(com.android.internal.R.string.power_off)
-                    .setMessage(com.android.internal.R.string.shutdown_confirm)
+                    .setMessage(resourceId)
                     .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int which) {
                             beginShutdownSequence(context);
@@ -105,6 +114,8 @@
                     })
                     .setNegativeButton(com.android.internal.R.string.no, null)
                     .create();
+            closer.dialog = dialog;
+            dialog.setOnDismissListener(closer);
             dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
             if (!context.getResources().getBoolean(
                     com.android.internal.R.bool.config_sf_slowBlur)) {
@@ -116,6 +127,27 @@
         }
     }
 
+    private static class CloseDialogReceiver extends BroadcastReceiver
+            implements DialogInterface.OnDismissListener {
+        private Context mContext;
+        public Dialog dialog;
+
+        CloseDialogReceiver(Context context) {
+            mContext = context;
+            IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+            context.registerReceiver(this, filter);
+        }
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            dialog.cancel();
+        }
+
+        public void onDismiss(DialogInterface unused) {
+            mContext.unregisterReceiver(this);
+        }
+    }
+
     /**
      * Request a clean shutdown, waiting for subsystems to clean up their
      * state etc.  Must be called from a Looper thread in which its UI
diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java
index 2a8cd94..00c4dbe 100644
--- a/core/java/com/android/internal/content/NativeLibraryHelper.java
+++ b/core/java/com/android/internal/content/NativeLibraryHelper.java
@@ -294,33 +294,44 @@
         }
     }
 
+    // Convenience method to call removeNativeBinariesFromDirLI(File)
+    public static boolean removeNativeBinariesLI(String nativeLibraryPath) {
+        return removeNativeBinariesFromDirLI(new File(nativeLibraryPath));
+    }
+
     // Remove the native binaries of a given package. This simply
     // gets rid of the files in the 'lib' sub-directory.
-    public static void removeNativeBinariesLI(String nativeLibraryPath) {
+    public static boolean removeNativeBinariesFromDirLI(File nativeLibraryDir) {
         if (DEBUG_NATIVE) {
-            Slog.w(TAG, "Deleting native binaries from: " + nativeLibraryPath);
+            Slog.w(TAG, "Deleting native binaries from: " + nativeLibraryDir.getPath());
         }
 
+        boolean deletedFiles = false;
+
         /*
          * Just remove any file in the directory. Since the directory is owned
          * by the 'system' UID, the application is not supposed to have written
          * anything there.
          */
-        File binaryDir = new File(nativeLibraryPath);
-        if (binaryDir.exists()) {
-            File[] binaries = binaryDir.listFiles();
+        if (nativeLibraryDir.exists()) {
+            final File[] binaries = nativeLibraryDir.listFiles();
             if (binaries != null) {
                 for (int nn = 0; nn < binaries.length; nn++) {
                     if (DEBUG_NATIVE) {
                         Slog.d(TAG, "    Deleting " + binaries[nn].getName());
                     }
+
                     if (!binaries[nn].delete()) {
                         Slog.w(TAG, "Could not delete native binary: " + binaries[nn].getPath());
+                    } else {
+                        deletedFiles = true;
                     }
                 }
             }
             // Do not delete 'lib' directory itself, or this will prevent
             // installation of future updates.
         }
+
+        return deletedFiles;
     }
 }
diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl
index d012b0f..bffec1d 100644
--- a/core/java/com/android/internal/view/IInputMethodManager.aidl
+++ b/core/java/com/android/internal/view/IInputMethodManager.aidl
@@ -49,6 +49,7 @@
             
     void showInputMethodPickerFromClient(in IInputMethodClient client);
     void showInputMethodSubtypePickerFromClient(in IInputMethodClient client);
+    void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client, String topId);
     void setInputMethod(in IBinder token, String id);
     void hideMySoftInput(in IBinder token, int flags);
     void showMySoftInput(in IBinder token, int flags);
diff --git a/core/java/com/android/internal/view/InputMethodAndSubtypeEnabler.java b/core/java/com/android/internal/view/InputMethodAndSubtypeEnabler.java
new file mode 100644
index 0000000..200d49f
--- /dev/null
+++ b/core/java/com/android/internal/view/InputMethodAndSubtypeEnabler.java
@@ -0,0 +1,319 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.view;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceCategory;
+import android.preference.PreferenceScreen;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+public class InputMethodAndSubtypeEnabler extends PreferenceActivity {
+
+    private boolean mHaveHardKeyboard;
+
+    private List<InputMethodInfo> mInputMethodProperties;
+
+    private final TextUtils.SimpleStringSplitter mStringColonSplitter
+            = new TextUtils.SimpleStringSplitter(':');
+
+    private String mLastInputMethodId;
+    private String mLastTickedInputMethodId;
+
+    private AlertDialog mDialog = null;
+
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        Configuration config = getResources().getConfiguration();
+        mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY);
+        onCreateIMM();
+        setPreferenceScreen(createPreferenceHierarchy());
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        loadInputMethodSubtypeList();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        saveInputMethodSubtypeList();
+    }
+
+    @Override
+    public boolean onPreferenceTreeClick(
+            PreferenceScreen preferenceScreen, Preference preference) {
+
+        if (preference instanceof CheckBoxPreference) {
+            final CheckBoxPreference chkPref = (CheckBoxPreference) preference;
+            final String id = chkPref.getKey();
+            // TODO: Check subtype or not here
+            if (chkPref.isChecked()) {
+                InputMethodInfo selImi = null;
+                final int N = mInputMethodProperties.size();
+                for (int i = 0; i < N; i++) {
+                    InputMethodInfo imi = mInputMethodProperties.get(i);
+                    if (id.equals(imi.getId())) {
+                        selImi = imi;
+                        if (isSystemIme(imi)) {
+                            setSubtypesPreferenceEnabled(id, true);
+                            // This is a built-in IME, so no need to warn.
+                            mLastTickedInputMethodId = id;
+                            return super.onPreferenceTreeClick(preferenceScreen, preference);
+                        }
+                        break;
+                    }
+                }
+                if (selImi == null) {
+                    return super.onPreferenceTreeClick(preferenceScreen, preference);
+                }
+                chkPref.setChecked(false);
+                if (mDialog == null) {
+                    mDialog = (new AlertDialog.Builder(this))
+                            .setTitle(android.R.string.dialog_alert_title)
+                            .setIcon(android.R.drawable.ic_dialog_alert)
+                            .setCancelable(true)
+                            .setPositiveButton(android.R.string.ok,
+                                    new DialogInterface.OnClickListener() {
+                                        public void onClick(DialogInterface dialog, int which) {
+                                            chkPref.setChecked(true);
+                                            setSubtypesPreferenceEnabled(id, true);
+                                            mLastTickedInputMethodId = id;
+                                        }
+
+                            })
+                            .setNegativeButton(android.R.string.cancel,
+                                    new DialogInterface.OnClickListener() {
+                                        public void onClick(DialogInterface dialog, int which) {
+                                        }
+
+                            })
+                            .create();
+                } else {
+                    if (mDialog.isShowing()) {
+                        mDialog.dismiss();
+                    }
+                }
+                mDialog.setMessage(getResources().getString(
+                        com.android.internal.R.string.ime_enabler_security_warning,
+                        selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
+                mDialog.show();
+            } else {
+                if (id.equals(mLastTickedInputMethodId)) {
+                    mLastTickedInputMethodId = null;
+                }
+                setSubtypesPreferenceEnabled(id, false);
+            }
+        }
+        return super.onPreferenceTreeClick(preferenceScreen, preference);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        if (mDialog != null) {
+            mDialog.dismiss();
+            mDialog = null;
+        }
+    }
+
+    private void onCreateIMM() {
+        InputMethodManager imm = (InputMethodManager) getSystemService(
+                Context.INPUT_METHOD_SERVICE);
+
+        // TODO: Change mInputMethodProperties to Map
+        mInputMethodProperties = imm.getInputMethodList();
+
+        mLastInputMethodId = Settings.Secure.getString(getContentResolver(),
+                Settings.Secure.DEFAULT_INPUT_METHOD);
+    }
+
+    private PreferenceScreen createPreferenceHierarchy() {
+        // Root
+        PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
+
+        int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
+        // TODO: Use iterator.
+        for (int i = 0; i < N; ++i) {
+            PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(this);
+            root.addPreference(keyboardSettingsCategory);
+            InputMethodInfo property = mInputMethodProperties.get(i);
+            String prefKey = property.getId();
+
+            PackageManager pm = getPackageManager();
+            CharSequence label = property.loadLabel(pm);
+            boolean systemIME = isSystemIme(property);
+
+            keyboardSettingsCategory.setTitle(label);
+
+            // Add a check box.
+            // Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
+            if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
+                CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
+                chkbxPref.setKey(prefKey);
+                chkbxPref.setTitle(label);
+                keyboardSettingsCategory.addPreference(chkbxPref);
+            }
+
+            ArrayList<InputMethodSubtype> subtypes = property.getSubtypes();
+            if (subtypes.size() > 0) {
+                PreferenceCategory subtypesCategory = new PreferenceCategory(this);
+                subtypesCategory.setTitle(getResources().getString(
+                        com.android.internal.R.string.ime_enabler_subtype_title, label));
+                root.addPreference(subtypesCategory);
+                for (InputMethodSubtype subtype: subtypes) {
+                    CharSequence subtypeLabel;
+                    int nameResId = subtype.getNameResId();
+                    if (nameResId != 0) {
+                        subtypeLabel = pm.getText(property.getPackageName(), nameResId,
+                                property.getServiceInfo().applicationInfo);
+                    } else {
+                        int modeResId = subtype.getModeResId();
+                        CharSequence language = subtype.getLocale();
+                        CharSequence mode = modeResId == 0 ? null
+                                : pm.getText(property.getPackageName(), modeResId,
+                                        property.getServiceInfo().applicationInfo);
+                        // TODO: Use more friendly Title and UI
+                        subtypeLabel = (mode == null ? "" : mode) + ","
+                                + (language == null ? "" : language);
+                    }
+                    CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
+                    chkbxPref.setKey(prefKey + subtype.hashCode());
+                    chkbxPref.setTitle(subtypeLabel);
+                    chkbxPref.setSummary(label);
+                    subtypesCategory.addPreference(chkbxPref);
+                }
+            }
+        }
+        return root;
+    }
+
+    private void loadInputMethodSubtypeList() {
+        final HashSet<String> enabled = new HashSet<String>();
+        String enabledStr = Settings.Secure.getString(getContentResolver(),
+                Settings.Secure.ENABLED_INPUT_METHODS);
+        if (enabledStr != null) {
+            final TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
+            splitter.setString(enabledStr);
+            while (splitter.hasNext()) {
+                enabled.add(splitter.next());
+            }
+        }
+
+        // Update the statuses of the Check Boxes.
+        int N = mInputMethodProperties.size();
+        // TODO: Use iterator.
+        for (int i = 0; i < N; ++i) {
+            final String id = mInputMethodProperties.get(i).getId();
+            CheckBoxPreference pref = (CheckBoxPreference) findPreference(
+                    mInputMethodProperties.get(i).getId());
+            if (pref != null) {
+                boolean isEnabled = enabled.contains(id);
+                pref.setChecked(isEnabled);
+                setSubtypesPreferenceEnabled(id, isEnabled);
+            }
+        }
+        mLastTickedInputMethodId = null;
+    }
+
+    private void saveInputMethodSubtypeList() {
+        StringBuilder builder = new StringBuilder();
+        StringBuilder disabledSysImes = new StringBuilder();
+
+        int firstEnabled = -1;
+        int N = mInputMethodProperties.size();
+        for (int i = 0; i < N; ++i) {
+            final InputMethodInfo property = mInputMethodProperties.get(i);
+            final String id = property.getId();
+            CheckBoxPreference pref = (CheckBoxPreference) findPreference(id);
+            boolean currentInputMethod = id.equals(mLastInputMethodId);
+            boolean systemIme = isSystemIme(property);
+            // TODO: Append subtypes by using the separator ";"
+            if (((N == 1 || systemIme) && !mHaveHardKeyboard)
+                    || (pref != null && pref.isChecked())) {
+                if (builder.length() > 0) builder.append(':');
+                builder.append(id);
+                if (firstEnabled < 0) {
+                    firstEnabled = i;
+                }
+            } else if (currentInputMethod) {
+                mLastInputMethodId = mLastTickedInputMethodId;
+            }
+            // If it's a disabled system ime, add it to the disabled list so that it
+            // doesn't get enabled automatically on any changes to the package list
+            if (pref != null && !pref.isChecked() && systemIme && mHaveHardKeyboard) {
+                if (disabledSysImes.length() > 0) disabledSysImes.append(":");
+                disabledSysImes.append(id);
+            }
+        }
+
+        // If the last input method is unset, set it as the first enabled one.
+        if (TextUtils.isEmpty(mLastInputMethodId)) {
+            if (firstEnabled >= 0) {
+                mLastInputMethodId = mInputMethodProperties.get(firstEnabled).getId();
+            } else {
+                mLastInputMethodId = null;
+            }
+        }
+
+        Settings.Secure.putString(getContentResolver(),
+                Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
+        Settings.Secure.putString(getContentResolver(),
+                Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
+        Settings.Secure.putString(getContentResolver(),
+                Settings.Secure.DEFAULT_INPUT_METHOD,
+                mLastInputMethodId != null ? mLastInputMethodId : "");
+    }
+
+    private void setSubtypesPreferenceEnabled(String id, boolean enabled) {
+        PreferenceScreen preferenceScreen = getPreferenceScreen();
+        final int N = mInputMethodProperties.size();
+        // TODO: Use iterator.
+        for (int i = 0; i < N; i++) {
+            InputMethodInfo imi = mInputMethodProperties.get(i);
+            if (id.equals(imi.getId())) {
+                for (InputMethodSubtype subtype: imi.getSubtypes()) {
+                    preferenceScreen.findPreference(id + subtype.hashCode()).setEnabled(enabled);
+                }
+            }
+        }
+    }
+
+    private boolean isSystemIme(InputMethodInfo property) {
+        return (property.getServiceInfo().applicationInfo.flags
+                & ApplicationInfo.FLAG_SYSTEM) != 0;
+    }
+}
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index d517d4c..eaeb67f 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -29,6 +29,7 @@
 import android.os.Parcelable;
 import android.util.Log;
 import android.util.SparseArray;
+import android.util.TypedValue;
 import android.view.ContextThemeWrapper;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
@@ -77,16 +78,17 @@
 
     private static final String VIEWS_TAG = "android:views";
 
+    private static final int THEME_SYSTEM_DEFAULT = 0;
+    private static final int THEME_APPLICATION = -1;
+    private static final int THEME_ALERT_DIALOG = -2;
+
     // Order must be the same order as the TYPE_*
-    // Special values:
-    // 0: Use the system default theme
-    // -1: Use the app's own theme
     static final int THEME_RES_FOR_TYPE[] = new int[] {
         com.android.internal.R.style.Theme_IconMenu,
         com.android.internal.R.style.Theme_ExpandedMenu,
-        com.android.internal.R.style.Theme_Light,
-        -1,
-        -1,
+        THEME_ALERT_DIALOG,
+        THEME_APPLICATION,
+        THEME_APPLICATION,
     };
     
     // Order must be the same order as the TYPE_*
@@ -205,7 +207,14 @@
     private boolean mPreventDispatchingItemsChanged = false;
     
     private boolean mOptionalIconsVisible = false;
-    
+
+    private static int getAlertDialogTheme(Context context) {
+        TypedValue outValue = new TypedValue();
+        context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
+                outValue, true);
+        return outValue.resourceId;
+    }
+
     private MenuType[] mMenuTypes;
     class MenuType {
         private int mMenuType;
@@ -223,9 +232,20 @@
         LayoutInflater getInflater() {
             // Create an inflater that uses the given theme for the Views it inflates
             if (mInflater == null) {
+                Context wrappedContext;
                 int themeResForType = THEME_RES_FOR_TYPE[mMenuType];
-                Context wrappedContext = themeResForType < 0 ? mContext :
-                        new ContextThemeWrapper(mContext, themeResForType);
+                switch (themeResForType) {
+                    case THEME_APPLICATION:
+                        wrappedContext = new ContextThemeWrapper(mContext, themeResForType);
+                        break;
+                    case THEME_ALERT_DIALOG:
+                        wrappedContext = new ContextThemeWrapper(mContext,
+                                getAlertDialogTheme(mContext));
+                        break;
+                    default:
+                        wrappedContext = mContext;
+                        break;
+                }
                 mInflater = (LayoutInflater) wrappedContext
                         .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
             }
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 7521af4..2001919 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -103,8 +103,8 @@
 }
 
 static void android_view_GLES20Canvas_prepare(JNIEnv* env, jobject canvas,
-        OpenGLRenderer* renderer) {
-    renderer->prepare();
+        OpenGLRenderer* renderer, jboolean opaque) {
+    renderer->prepare(opaque);
 }
 
 static void android_view_GLES20Canvas_finish(JNIEnv* env, jobject canvas,
@@ -445,7 +445,7 @@
     { "nCreateRenderer",    "()I",             (void*) android_view_GLES20Canvas_createRenderer },
     { "nDestroyRenderer",   "(I)V",            (void*) android_view_GLES20Canvas_destroyRenderer },
     { "nSetViewport",       "(III)V",          (void*) android_view_GLES20Canvas_setViewport },
-    { "nPrepare",           "(I)V",            (void*) android_view_GLES20Canvas_prepare },
+    { "nPrepare",           "(IZ)V",           (void*) android_view_GLES20Canvas_prepare },
     { "nFinish",            "(I)V",            (void*) android_view_GLES20Canvas_finish },
     { "nAcquireContext",    "(I)V",            (void*) android_view_GLES20Canvas_acquireContext },
     { "nReleaseContext",    "(I)V",            (void*) android_view_GLES20Canvas_releaseContext },
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 3a1d76f..f15d0a4 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1373,6 +1373,11 @@
                 android:permission="android.permission.BIND_WALLPAPER">
         </service>
 
+        <activity android:name="com.android.internal.view.InputMethodAndSubtypeEnabler"
+                android:excludeFromRecents="true"
+                android:exported="true">
+        </activity>
+
         <receiver android:name="com.android.server.BootReceiver" >
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
diff --git a/core/res/res/drawable-hdpi/btn_check_off_disabled_focused_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_off_disabled_focused_holo_dark.png
new file mode 100644
index 0000000..c0f0d167
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_disabled_focused_holo_light.png b/core/res/res/drawable-hdpi/btn_check_off_disabled_focused_holo_light.png
new file mode 100644
index 0000000..ba03d28
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_disabled_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_off_disabled_holo_dark.png
new file mode 100644
index 0000000..a320240
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_disabled_holo_light.png b/core/res/res/drawable-hdpi/btn_check_off_disabled_holo_light.png
new file mode 100644
index 0000000..7f48c54
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_focused_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_off_focused_holo_dark.png
new file mode 100644
index 0000000..82b7ba7
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_focused_holo_light.png b/core/res/res/drawable-hdpi/btn_check_off_focused_holo_light.png
new file mode 100644
index 0000000..69ecf05
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_normal_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_off_normal_holo_dark.png
new file mode 100644
index 0000000..b81d4f9
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_normal_holo_light.png b/core/res/res/drawable-hdpi/btn_check_off_normal_holo_light.png
new file mode 100644
index 0000000..b74055e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_off_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_dark.png
index 9f9cb01..c18e18b 100644
--- a/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_light.png b/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_light.png
index 56425d2..258c3d3 100644
--- a/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_check_off_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_disabled_focused_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_on_disabled_focused_holo_dark.png
new file mode 100644
index 0000000..e63e5a5
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_disabled_focused_holo_light.png b/core/res/res/drawable-hdpi/btn_check_on_disabled_focused_holo_light.png
new file mode 100644
index 0000000..37415e0
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_disabled_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_on_disabled_holo_dark.png
new file mode 100644
index 0000000..77a3115
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_disabled_holo_light.png b/core/res/res/drawable-hdpi/btn_check_on_disabled_holo_light.png
new file mode 100644
index 0000000..51993e3
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_focused_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_on_focused_holo_dark.png
new file mode 100644
index 0000000..817adf7
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_focused_holo_light.png b/core/res/res/drawable-hdpi/btn_check_on_focused_holo_light.png
new file mode 100644
index 0000000..6459240
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_normal_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_on_normal_holo_dark.png
new file mode 100644
index 0000000..bf4f3bb
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_normal_holo_light.png b/core/res/res/drawable-hdpi/btn_check_on_normal_holo_light.png
new file mode 100644
index 0000000..5a2a3c1
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_check_on_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_dark.png b/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_dark.png
index 91e5f14..1333cb1 100644
--- a/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_light.png b/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_light.png
index 0cf7ed2..4413328 100644
--- a/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_check_on_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png
index 3deb385..05d1668 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png
index de378a5..6f7eb42 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png
index 35f8b3d..2c814f0 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png
index 3f45375..a88bdf6 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png
index ea58bf7..9a61d82 100644
--- a/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png
index b225aaff..56ca528 100644
--- a/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png
index b5b1533..6600035 100644
--- a/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png
index 81b8a75..11d31bb 100644
--- a/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png
index eb8d85a..8c58c37 100644
--- a/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png
index 6777ebf..d543c66 100644
--- a/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_dark.png
index 2a7505b..4fdf5ce 100644
--- a/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_light.png
index bbb01f0..e70f8c3 100644
--- a/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_disabled_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_dark.png
index b617a2a..c28d6cd 100644
--- a/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_light.png
index fd59f4a..ebf4da6 100644
--- a/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_disabled_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_dark.png
index 5d17cde..9a5455c 100644
--- a/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_light.png
index b6b4bf1..9648df2 100644
--- a/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_focused_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_dark.png
index eab5039..cd59fab 100644
--- a/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_light.png
index b6b4bf1..4da6192 100644
--- a/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_focused_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_dark.png
index edf2296..f18c6da 100644
--- a/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_light.png
index 68afa4c..70afefc 100644
--- a/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_normal_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_dark.png
index c7df168..fdf1586 100644
--- a/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_light.png
index 5a9087b..457038a6 100644
--- a/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_normal_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_dark.png
index 500490d..aa10966 100644
--- a/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_light.png
index f6690c6..8eaf738 100644
--- a/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_pressed_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_dark.png b/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_dark.png
index 933d2fe..674cc55 100644
--- a/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_dark.png
+++ b/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_light.png b/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_light.png
index c07445a..b4f8800 100644
--- a/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_light.png
+++ b/core/res/res/drawable-hdpi/btn_radio_pressed_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_off_focused_holo_dark.png b/core/res/res/drawable-hdpi/btn_star_off_focused_holo_dark.png
new file mode 100644
index 0000000..15feef1
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_off_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_off_focused_holo_light.png b/core/res/res/drawable-hdpi/btn_star_off_focused_holo_light.png
new file mode 100644
index 0000000..0cff364
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_off_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_off_normal_holo_dark.png b/core/res/res/drawable-hdpi/btn_star_off_normal_holo_dark.png
new file mode 100644
index 0000000..f480729
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_off_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_off_normal_holo_light.png b/core/res/res/drawable-hdpi/btn_star_off_normal_holo_light.png
new file mode 100644
index 0000000..1c632e8
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_off_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_on_focused_holo_dark.png b/core/res/res/drawable-hdpi/btn_star_on_focused_holo_dark.png
new file mode 100644
index 0000000..2dd3d77
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_on_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_on_focused_holo_light.png b/core/res/res/drawable-hdpi/btn_star_on_focused_holo_light.png
new file mode 100644
index 0000000..7b10118
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_on_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_on_normal_holo_dark.png b/core/res/res/drawable-hdpi/btn_star_on_normal_holo_dark.png
new file mode 100644
index 0000000..2f863bb
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_on_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_star_on_normal_holo_light.png b/core/res/res/drawable-hdpi/btn_star_on_normal_holo_light.png
new file mode 100644
index 0000000..1220c20
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_star_on_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
index 128a8dd..5a8c8e5 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png
index da05c23..2263153 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png
index da66a98..dbfa16a 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png
index 3ac8417..47a43e9 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png
index fc9d493..2787a4b 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png
index 315ae3b..c8bf8b1 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png
index ee9590c6..eb4f17a 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png
index cbc9da2c..42b434c 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png
index 1792063..e362aa1 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png
index 097025b..cc61414 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
index 5b92d7c6..8b813b9 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png
index a244f45..54686cd 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png
index 9218f91..056f451 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png
index 81802f8..2c4a6dd 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png
index 9dea983..127a9be 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png
index fc2374b..4853ef4 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png
index 18bb6bd..d767185 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png
index de78a9f..00e6105 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png
index 2269326..293cad3 100755
--- a/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_pressed_holo_light.9.png
new file mode 100644
index 0000000..6963a0e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_toggle_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_divider_holo_dark.png b/core/res/res/drawable-hdpi/cab_divider_holo_dark.png
index e6f61fc..e2c2119 100755
--- a/core/res/res/drawable-hdpi/cab_divider_holo_dark.png
+++ b/core/res/res/drawable-hdpi/cab_divider_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_divider_holo_light.png b/core/res/res/drawable-hdpi/cab_divider_holo_light.png
index 2f97a29..51e2295 100755
--- a/core/res/res/drawable-hdpi/cab_divider_holo_light.png
+++ b/core/res/res/drawable-hdpi/cab_divider_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_holo_dark.9.png b/core/res/res/drawable-hdpi/cab_holo_dark.9.png
index 662d63c..64e2052 100755
--- a/core/res/res/drawable-hdpi/cab_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/cab_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_holo_light.9.png b/core/res/res/drawable-hdpi/cab_holo_light.9.png
index e8cbde1..4f2afcf 100755
--- a/core/res/res/drawable-hdpi/cab_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/cab_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_ic_close_focused_holo.png b/core/res/res/drawable-hdpi/cab_ic_close_focused_holo.png
index 861e0a1..9d7f932 100755
--- a/core/res/res/drawable-hdpi/cab_ic_close_focused_holo.png
+++ b/core/res/res/drawable-hdpi/cab_ic_close_focused_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_ic_close_normal_holo.png b/core/res/res/drawable-hdpi/cab_ic_close_normal_holo.png
index 036f362..641507d 100755
--- a/core/res/res/drawable-hdpi/cab_ic_close_normal_holo.png
+++ b/core/res/res/drawable-hdpi/cab_ic_close_normal_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/cab_ic_close_pressed_holo.png b/core/res/res/drawable-hdpi/cab_ic_close_pressed_holo.png
index be8c2ff..ebb0fc8 100755
--- a/core/res/res/drawable-hdpi/cab_ic_close_pressed_holo.png
+++ b/core/res/res/drawable-hdpi/cab_ic_close_pressed_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
new file mode 100644
index 0000000..83c0852
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
new file mode 100644
index 0000000..c495216
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
new file mode 100644
index 0000000..620adaa
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
new file mode 100644
index 0000000..b03d6cd
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_ic_close_focused_holo_dark.png b/core/res/res/drawable-hdpi/dialog_ic_close_focused_holo_dark.png
new file mode 100644
index 0000000..785ae6e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_ic_close_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_ic_close_focused_holo_light.png b/core/res/res/drawable-hdpi/dialog_ic_close_focused_holo_light.png
new file mode 100644
index 0000000..d96787b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_ic_close_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_ic_close_normal_holo_dark.png b/core/res/res/drawable-hdpi/dialog_ic_close_normal_holo_dark.png
new file mode 100644
index 0000000..d042a81
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_ic_close_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_ic_close_normal_holo_light.png b/core/res/res/drawable-hdpi/dialog_ic_close_normal_holo_light.png
new file mode 100644
index 0000000..677cf3d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_ic_close_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_ic_close_pressed_holo_dark.png b/core/res/res/drawable-hdpi/dialog_ic_close_pressed_holo_dark.png
new file mode 100644
index 0000000..9b13c5b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_ic_close_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_ic_close_pressed_holo_light.png b/core/res/res/drawable-hdpi/dialog_ic_close_pressed_holo_light.png
new file mode 100644
index 0000000..8e245fc
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_ic_close_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
new file mode 100644
index 0000000..cffae3e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
new file mode 100644
index 0000000..0394885
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
new file mode 100644
index 0000000..6746ce8
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
new file mode 100644
index 0000000..bdcdc71
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/dropdown_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..519f522
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/dropdown_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..9c181d0
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/dropdown_disabled_holo_dark.9.png
new file mode 100644
index 0000000..6ca975f
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/dropdown_disabled_holo_light.9.png
new file mode 100644
index 0000000..7a20af7
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/dropdown_focused_holo_dark.9.png
new file mode 100644
index 0000000..a3dfb98
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_focused_holo_light.9.png b/core/res/res/drawable-hdpi/dropdown_focused_holo_light.9.png
new file mode 100644
index 0000000..766543c
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_focused_holo_dark.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_focused_holo_dark.png
new file mode 100644
index 0000000..53f02576
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_focused_holo_light.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_focused_holo_light.png
new file mode 100644
index 0000000..0daee9b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_holo_dark.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_holo_dark.png
new file mode 100644
index 0000000..b659926
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_holo_light.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_holo_light.png
new file mode 100644
index 0000000..e22dbfd
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_focused_holo_dark.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_focused_holo_dark.png
new file mode 100644
index 0000000..0f65227
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_focused_holo_light.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_focused_holo_light.png
new file mode 100644
index 0000000..9c47d7e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_normal_holo_dark.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_normal_holo_dark.png
new file mode 100644
index 0000000..06e5b47
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_normal_holo_light.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_normal_holo_light.png
new file mode 100644
index 0000000..d362ec1
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_pressed_holo_dark.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_pressed_holo_dark.png
new file mode 100644
index 0000000..d010995
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_ic_arrow_pressed_holo_light.png b/core/res/res/drawable-hdpi/dropdown_ic_arrow_pressed_holo_light.png
new file mode 100644
index 0000000..b95f94b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_ic_arrow_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_normal_holo_dark.9.png b/core/res/res/drawable-hdpi/dropdown_normal_holo_dark.9.png
new file mode 100644
index 0000000..a4ac317
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_normal_holo_light.9.png b/core/res/res/drawable-hdpi/dropdown_normal_holo_light.9.png
new file mode 100644
index 0000000..b4ab9ad
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/dropdown_pressed_holo_dark.9.png
new file mode 100644
index 0000000..f6382c8
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dropdown_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/dropdown_pressed_holo_light.9.png
new file mode 100644
index 0000000..c849e2f
--- /dev/null
+++ b/core/res/res/drawable-hdpi/dropdown_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_menu_moreoverflow_focused_holo_dark.png b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_focused_holo_dark.png
new file mode 100644
index 0000000..061f80a
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_menu_moreoverflow_focused_holo_light.png b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_focused_holo_light.png
new file mode 100644
index 0000000..d818806
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png
new file mode 100644
index 0000000..8563c1a8d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_light.png b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_light.png
new file mode 100644
index 0000000..1cd2384
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_menu_moreoverflow_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_divider_horizontal_holo_dark.9.png b/core/res/res/drawable-hdpi/list_divider_horizontal_holo_dark.9.png
new file mode 100644
index 0000000..0a4347f
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_divider_horizontal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_section_header_holo_dark.9.png b/core/res/res/drawable-hdpi/list_section_header_holo_dark.9.png
new file mode 100644
index 0000000..2030d3b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_section_header_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_section_header_holo_light.9.png b/core/res/res/drawable-hdpi/list_section_header_holo_light.9.png
new file mode 100644
index 0000000..4ca2773
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_section_header_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_activated_holo_dark.9.png b/core/res/res/drawable-hdpi/list_selector_activated_holo_dark.9.png
new file mode 100644
index 0000000..1a516c1
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_activated_holo_light.9.png b/core/res/res/drawable-hdpi/list_selector_activated_holo_light.9.png
new file mode 100644
index 0000000..f22217b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/list_selector_disabled_holo_dark.9.png
new file mode 100644
index 0000000..f6fd30d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/list_selector_disabled_holo_light.9.png
new file mode 100644
index 0000000..ca8e9a2
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/list_selector_focused_holo_dark.9.png
new file mode 100644
index 0000000..c1f3d7d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_focused_holo_light.9.png b/core/res/res/drawable-hdpi/list_selector_focused_holo_light.9.png
new file mode 100644
index 0000000..99bb246
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_multiselect_holo_dark.9.png b/core/res/res/drawable-hdpi/list_selector_multiselect_holo_dark.9.png
new file mode 100644
index 0000000..f702fc8
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_multiselect_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_multiselect_holo_light.9.png b/core/res/res/drawable-hdpi/list_selector_multiselect_holo_light.9.png
new file mode 100644
index 0000000..e8f277d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_multiselect_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/list_selector_pressed_holo_dark.9.png
new file mode 100644
index 0000000..0ed5ba3
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/list_selector_pressed_holo_light.9.png
new file mode 100644
index 0000000..1471c17
--- /dev/null
+++ b/core/res/res/drawable-hdpi/list_selector_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png
new file mode 100644
index 0000000..7ec3a33f
--- /dev/null
+++ b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_light.9.png b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_light.9.png
new file mode 100644
index 0000000..da1fe94
--- /dev/null
+++ b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowdown_left_holo_dark.9.png b/core/res/res/drawable-hdpi/quickactions_arrowdown_left_holo_dark.9.png
new file mode 100644
index 0000000..93a8417
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowdown_left_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowdown_left_holo_light.9.png b/core/res/res/drawable-hdpi/quickactions_arrowdown_left_holo_light.9.png
new file mode 100644
index 0000000..61e856a
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowdown_left_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowdown_right_holo_dark.9.png b/core/res/res/drawable-hdpi/quickactions_arrowdown_right_holo_dark.9.png
new file mode 100644
index 0000000..7632a16
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowdown_right_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowdown_right_holo_light.9.png b/core/res/res/drawable-hdpi/quickactions_arrowdown_right_holo_light.9.png
new file mode 100644
index 0000000..8e66ad1
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowdown_right_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowup_left_holo_dark.9.png b/core/res/res/drawable-hdpi/quickactions_arrowup_left_holo_dark.9.png
new file mode 100644
index 0000000..02618ca
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowup_left_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowup_left_holo_light.9.png b/core/res/res/drawable-hdpi/quickactions_arrowup_left_holo_light.9.png
new file mode 100644
index 0000000..939050d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowup_left_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowup_left_right_holo_dark.9.png b/core/res/res/drawable-hdpi/quickactions_arrowup_left_right_holo_dark.9.png
new file mode 100644
index 0000000..f5cf487
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowup_left_right_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/quickactions_arrowup_right_holo_light.9.png b/core/res/res/drawable-hdpi/quickactions_arrowup_right_holo_light.9.png
new file mode 100644
index 0000000..1237f26
--- /dev/null
+++ b/core/res/res/drawable-hdpi/quickactions_arrowup_right_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/scrubber_control_holo.png b/core/res/res/drawable-hdpi/scrubber_control_holo.png
new file mode 100644
index 0000000..3a72307
--- /dev/null
+++ b/core/res/res/drawable-hdpi/scrubber_control_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/scrubber_track_holo_dark.9.png b/core/res/res/drawable-hdpi/scrubber_track_holo_dark.9.png
new file mode 100644
index 0000000..e6d7123
--- /dev/null
+++ b/core/res/res/drawable-hdpi/scrubber_track_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/scrubber_track_holo_light.9.png b/core/res/res/drawable-hdpi/scrubber_track_holo_light.9.png
new file mode 100644
index 0000000..f75bfa0
--- /dev/null
+++ b/core/res/res/drawable-hdpi/scrubber_track_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disable_focused_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_off_disable_focused_holo_dark.png
deleted file mode 100644
index 3fac4aa..0000000
--- a/core/res/res/drawable-mdpi/btn_check_off_disable_focused_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disable_focused_holo_light.png b/core/res/res/drawable-mdpi/btn_check_off_disable_focused_holo_light.png
deleted file mode 100644
index 3da9a46..0000000
--- a/core/res/res/drawable-mdpi/btn_check_off_disable_focused_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disable_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_off_disable_holo_dark.png
deleted file mode 100644
index 3fac4aa..0000000
--- a/core/res/res/drawable-mdpi/btn_check_off_disable_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disable_holo_light.png b/core/res/res/drawable-mdpi/btn_check_off_disable_holo_light.png
deleted file mode 100644
index 3da9a46..0000000
--- a/core/res/res/drawable-mdpi/btn_check_off_disable_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disabled_focused_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_off_disabled_focused_holo_dark.png
new file mode 100644
index 0000000..7e58392
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disabled_focused_holo_light.png b/core/res/res/drawable-mdpi/btn_check_off_disabled_focused_holo_light.png
new file mode 100644
index 0000000..d5c1f7c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disabled_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_off_disabled_holo_dark.png
new file mode 100644
index 0000000..b6eec97
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disabled_holo_light.png b/core/res/res/drawable-mdpi/btn_check_off_disabled_holo_light.png
new file mode 100644
index 0000000..1bc34b6
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_focused_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_off_focused_holo_dark.png
new file mode 100644
index 0000000..894836f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_focused_holo_light.png b/core/res/res/drawable-mdpi/btn_check_off_focused_holo_light.png
new file mode 100644
index 0000000..ae81a5e
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_normal_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_off_normal_holo_dark.png
new file mode 100644
index 0000000..5434614
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_normal_holo_light.png b/core/res/res/drawable-mdpi/btn_check_off_normal_holo_light.png
new file mode 100644
index 0000000..0d43dc4
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_off_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_dark.png
index 0dcb9de..0f9f4f0 100644
--- a/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_light.png b/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_light.png
index b25fdc4..77ad452 100644
--- a/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_check_off_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_disabled_focused_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_on_disabled_focused_holo_dark.png
new file mode 100644
index 0000000..28bf7f6
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_disabled_focused_holo_light.png b/core/res/res/drawable-mdpi/btn_check_on_disabled_focused_holo_light.png
new file mode 100644
index 0000000..bb2d314
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_disabled_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_on_disabled_holo_dark.png
new file mode 100644
index 0000000..8cf4554
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_disabled_holo_light.png b/core/res/res/drawable-mdpi/btn_check_on_disabled_holo_light.png
new file mode 100644
index 0000000..ba37f93
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_focused_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_on_focused_holo_dark.png
new file mode 100644
index 0000000..1fca094
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_focused_holo_light.png b/core/res/res/drawable-mdpi/btn_check_on_focused_holo_light.png
new file mode 100644
index 0000000..21c33f0
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_normal_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_on_normal_holo_dark.png
new file mode 100644
index 0000000..e65c0b4
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_normal_holo_light.png b/core/res/res/drawable-mdpi/btn_check_on_normal_holo_light.png
new file mode 100644
index 0000000..9576bea
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_check_on_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_dark.png b/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_dark.png
index 0722cda..84733fb 100644
--- a/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_light.png b/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_light.png
index 4de166e..67a15d2 100644
--- a/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_check_on_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png
index 9bc1ee8..15003be 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png
index cc643ea..573f197 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png
index 0586d52..953a553 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png
index dd6c1a0..d79a61e 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png
index e8f07cb..897676e 100644
--- a/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png
index 0685f1e..b485925 100644
--- a/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png
index 6b33fa4..1cdbf66 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png
index eb728ed..ab7eb54 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png
index 4a15d9d..d95ef6d 100644
--- a/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png
index 6718ff7..60ed4fc 100644
--- a/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_dark.png
index f21142e..f937182 100644
--- a/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_light.png
index a1031fc..4c35fb3 100644
--- a/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_disabled_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_dark.png
index 61243c5..af38a4f 100644
--- a/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_light.png
index faa55e0..a368602 100644
--- a/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_disabled_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_dark.png
index 0c645da..695d0b9 100644
--- a/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_light.png
index 5efc321..6467bea 100644
--- a/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_focused_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_dark.png
index 96bcdc5..813a069 100644
--- a/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_light.png
index 5efc321..fe80d69 100644
--- a/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_focused_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_dark.png
index 96413ef..5b6d906 100644
--- a/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_light.png
index 1cb5432..e5132ef 100644
--- a/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_normal_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_dark.png
index 2e8404a..e216d35 100644
--- a/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_light.png
index b3e14b1..ed3946a 100644
--- a/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_normal_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_dark.png
index 5f74c70..9ab32d1 100644
--- a/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_light.png
index 408e50e..7175853 100644
--- a/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_pressed_off_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_dark.png b/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_dark.png
index ff60bc2..a6fa7b6 100644
--- a/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_dark.png
+++ b/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_light.png b/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_light.png
index 2125c24..e7a634d 100644
--- a/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_light.png
+++ b/core/res/res/drawable-mdpi/btn_radio_pressed_on_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_off_focused_holo_dark.png b/core/res/res/drawable-mdpi/btn_star_off_focused_holo_dark.png
new file mode 100644
index 0000000..153e50d
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_off_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_off_focused_holo_light.png b/core/res/res/drawable-mdpi/btn_star_off_focused_holo_light.png
new file mode 100644
index 0000000..379fd24
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_off_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_off_normal_holo_dark.png b/core/res/res/drawable-mdpi/btn_star_off_normal_holo_dark.png
new file mode 100644
index 0000000..fe35f1c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_off_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_off_normal_holo_light.png b/core/res/res/drawable-mdpi/btn_star_off_normal_holo_light.png
new file mode 100644
index 0000000..002237f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_off_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_on_focused_holo_dark.png b/core/res/res/drawable-mdpi/btn_star_on_focused_holo_dark.png
new file mode 100644
index 0000000..0ad2583
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_on_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_on_focused_holo_light.png b/core/res/res/drawable-mdpi/btn_star_on_focused_holo_light.png
new file mode 100644
index 0000000..ce7c3b4
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_on_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_on_normal_holo_dark.png b/core/res/res/drawable-mdpi/btn_star_on_normal_holo_dark.png
new file mode 100644
index 0000000..ee93e88
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_on_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_star_on_normal_holo_light.png b/core/res/res/drawable-mdpi/btn_star_on_normal_holo_light.png
new file mode 100644
index 0000000..597fd9a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_star_on_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
index 7d1e16d..deecc51 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png
index 92e86cd..76d4f05 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png
index 1cf473b..0ecd1ae 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png
index d6f2125..a7015ee 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png
index 31f7f8c..71949b2 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png
index 82425d5..351f76b 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png
index 16f19fc..44b9503 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png
index e2c7702..d70a1fc5 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png
index d61470c..5f9d2b1 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png
index 4019fee..6723757 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
index ba354e3..62b67a5 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png
index 9391b2e..b8418bc 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png
index 601ff2c..f9a11a5 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png
index 90c259a..e983c8a 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png
index 857c757..ed8407b 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png
index ef16a48..31f36b7 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png
index d47ec8f..e023c44 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png
index 2951caf..e4008cf 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png
index 141b4dd..56e1157 100755
--- a/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_pressed_holo_light.9.png
new file mode 100644
index 0000000..b6508fc
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_toggle_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_divider_holo_dark.png b/core/res/res/drawable-mdpi/cab_divider_holo_dark.png
index 57cc8a4..317263a 100755
--- a/core/res/res/drawable-mdpi/cab_divider_holo_dark.png
+++ b/core/res/res/drawable-mdpi/cab_divider_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_divider_holo_light.png b/core/res/res/drawable-mdpi/cab_divider_holo_light.png
index ec85701..824ad27 100755
--- a/core/res/res/drawable-mdpi/cab_divider_holo_light.png
+++ b/core/res/res/drawable-mdpi/cab_divider_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_holo_dark.9.png b/core/res/res/drawable-mdpi/cab_holo_dark.9.png
index 6c85300..7daae1f 100755
--- a/core/res/res/drawable-mdpi/cab_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/cab_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_holo_light.9.png b/core/res/res/drawable-mdpi/cab_holo_light.9.png
index c82352a..0e64c5c 100755
--- a/core/res/res/drawable-mdpi/cab_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/cab_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_ic_close_focused_holo.png b/core/res/res/drawable-mdpi/cab_ic_close_focused_holo.png
index df170c4..59149e4 100755
--- a/core/res/res/drawable-mdpi/cab_ic_close_focused_holo.png
+++ b/core/res/res/drawable-mdpi/cab_ic_close_focused_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_ic_close_normal_holo.png b/core/res/res/drawable-mdpi/cab_ic_close_normal_holo.png
index 9482ce7..b378885 100755
--- a/core/res/res/drawable-mdpi/cab_ic_close_normal_holo.png
+++ b/core/res/res/drawable-mdpi/cab_ic_close_normal_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/cab_ic_close_pressed_holo.png b/core/res/res/drawable-mdpi/cab_ic_close_pressed_holo.png
index d115d20..29b0407 100755
--- a/core/res/res/drawable-mdpi/cab_ic_close_pressed_holo.png
+++ b/core/res/res/drawable-mdpi/cab_ic_close_pressed_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
new file mode 100644
index 0000000..e3a30a9
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
new file mode 100644
index 0000000..f7f344a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
new file mode 100644
index 0000000..26bf28a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
new file mode 100644
index 0000000..0edfe85
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_ic_close_focused_holo_dark.png b/core/res/res/drawable-mdpi/dialog_ic_close_focused_holo_dark.png
new file mode 100644
index 0000000..4f08fb4
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_ic_close_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_ic_close_focused_holo_light.png b/core/res/res/drawable-mdpi/dialog_ic_close_focused_holo_light.png
new file mode 100644
index 0000000..cc535bd
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_ic_close_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_ic_close_normal_holo_dark.png b/core/res/res/drawable-mdpi/dialog_ic_close_normal_holo_dark.png
new file mode 100644
index 0000000..9d3e5b9
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_ic_close_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_ic_close_normal_holo_light.png b/core/res/res/drawable-mdpi/dialog_ic_close_normal_holo_light.png
new file mode 100644
index 0000000..74aff55
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_ic_close_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_ic_close_pressed_holo_dark.png b/core/res/res/drawable-mdpi/dialog_ic_close_pressed_holo_dark.png
new file mode 100644
index 0000000..c7f7699
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_ic_close_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_ic_close_pressed_holo_light.png b/core/res/res/drawable-mdpi/dialog_ic_close_pressed_holo_light.png
new file mode 100644
index 0000000..a10f9a6
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_ic_close_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
new file mode 100644
index 0000000..51e7ec3
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
new file mode 100644
index 0000000..c4b70625a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
new file mode 100644
index 0000000..7f97eae
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
new file mode 100644
index 0000000..341bb4b
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/dropdown_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..d9ad9d3
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/dropdown_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..3d82dc6
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/dropdown_disabled_holo_dark.9.png
new file mode 100644
index 0000000..15e2993
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/dropdown_disabled_holo_light.9.png
new file mode 100644
index 0000000..4831556
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/dropdown_focused_holo_dark.9.png
new file mode 100644
index 0000000..4021da8
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_focused_holo_light.9.png b/core/res/res/drawable-mdpi/dropdown_focused_holo_light.9.png
new file mode 100644
index 0000000..120fe9a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_focused_holo_dark.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_focused_holo_dark.png
new file mode 100644
index 0000000..d2b3557
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_focused_holo_light.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_focused_holo_light.png
new file mode 100644
index 0000000..cf50169
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_holo_dark.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_holo_dark.png
new file mode 100644
index 0000000..2663411
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_holo_light.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_holo_light.png
new file mode 100644
index 0000000..def24e4
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_focused_holo_dark.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_focused_holo_dark.png
new file mode 100644
index 0000000..9196b72
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_focused_holo_light.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_focused_holo_light.png
new file mode 100644
index 0000000..85372b9
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_normal_holo_dark.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_normal_holo_dark.png
new file mode 100644
index 0000000..566be42
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_normal_holo_light.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_normal_holo_light.png
new file mode 100644
index 0000000..e600500
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_pressed_holo_dark.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_pressed_holo_dark.png
new file mode 100644
index 0000000..ef21dc2
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_ic_arrow_pressed_holo_light.png b/core/res/res/drawable-mdpi/dropdown_ic_arrow_pressed_holo_light.png
new file mode 100644
index 0000000..52fc112
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_ic_arrow_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_normal_holo_dark.9.png b/core/res/res/drawable-mdpi/dropdown_normal_holo_dark.9.png
new file mode 100644
index 0000000..a5da0cd
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_normal_holo_light.9.png b/core/res/res/drawable-mdpi/dropdown_normal_holo_light.9.png
new file mode 100644
index 0000000..6695af9
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/dropdown_pressed_holo_dark.9.png
new file mode 100644
index 0000000..e7e70fb
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dropdown_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/dropdown_pressed_holo_light.9.png
new file mode 100644
index 0000000..f760c88
--- /dev/null
+++ b/core/res/res/drawable-mdpi/dropdown_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_menu_moreoverflow_focused_holo_dark.png b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_focused_holo_dark.png
new file mode 100644
index 0000000..6f87b11
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_menu_moreoverflow_focused_holo_light.png b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_focused_holo_light.png
new file mode 100644
index 0000000..04dac38
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png
new file mode 100644
index 0000000..5580af6
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_light.png b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_light.png
new file mode 100644
index 0000000..fc2081a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_menu_moreoverflow_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_section_header_holo_dark.9.png b/core/res/res/drawable-mdpi/list_section_header_holo_dark.9.png
new file mode 100644
index 0000000..48dfea0
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_section_header_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_section_header_holo_light.9.png b/core/res/res/drawable-mdpi/list_section_header_holo_light.9.png
new file mode 100644
index 0000000..36a046b
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_section_header_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_activated_holo_dark.9.png b/core/res/res/drawable-mdpi/list_selector_activated_holo_dark.9.png
new file mode 100644
index 0000000..66bc259
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_activated_holo_light.9.png b/core/res/res/drawable-mdpi/list_selector_activated_holo_light.9.png
new file mode 100644
index 0000000..c5822b1
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/list_selector_disabled_holo_dark.9.png
new file mode 100644
index 0000000..92da2f0
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/list_selector_disabled_holo_light.9.png
new file mode 100644
index 0000000..42cb646
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/list_selector_focused_holo_dark.9.png
new file mode 100644
index 0000000..eb4555d
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_focused_holo_light.9.png b/core/res/res/drawable-mdpi/list_selector_focused_holo_light.9.png
new file mode 100644
index 0000000..d799fbf
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_multiselect_holo_dark.9.png b/core/res/res/drawable-mdpi/list_selector_multiselect_holo_dark.9.png
new file mode 100644
index 0000000..2c3647e
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_multiselect_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_multiselect_holo_light.9.png b/core/res/res/drawable-mdpi/list_selector_multiselect_holo_light.9.png
new file mode 100644
index 0000000..860c58e
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_multiselect_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/list_selector_pressed_holo_dark.9.png
new file mode 100644
index 0000000..bf36a43
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/list_selector_pressed_holo_light.9.png
new file mode 100644
index 0000000..0f0be2a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/list_selector_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png
new file mode 100644
index 0000000..7d5c10c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
new file mode 100644
index 0000000..a0d3094d
--- /dev/null
+++ b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowdown_left_holo_dark.9.png b/core/res/res/drawable-mdpi/quickactions_arrowdown_left_holo_dark.9.png
new file mode 100644
index 0000000..ece6551
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowdown_left_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowdown_left_holo_light.9.png b/core/res/res/drawable-mdpi/quickactions_arrowdown_left_holo_light.9.png
new file mode 100644
index 0000000..819656f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowdown_left_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowdown_right_holo_dark.9.png b/core/res/res/drawable-mdpi/quickactions_arrowdown_right_holo_dark.9.png
new file mode 100644
index 0000000..8e95970
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowdown_right_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowdown_right_holo_light.9.png b/core/res/res/drawable-mdpi/quickactions_arrowdown_right_holo_light.9.png
new file mode 100644
index 0000000..d5bef51
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowdown_right_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowup_left_holo_dark.9.png b/core/res/res/drawable-mdpi/quickactions_arrowup_left_holo_dark.9.png
new file mode 100644
index 0000000..543e341
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowup_left_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowup_left_holo_light.9.png b/core/res/res/drawable-mdpi/quickactions_arrowup_left_holo_light.9.png
new file mode 100644
index 0000000..e40e91d
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowup_left_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowup_left_right_holo_dark.9.png b/core/res/res/drawable-mdpi/quickactions_arrowup_left_right_holo_dark.9.png
new file mode 100644
index 0000000..a4617e7
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowup_left_right_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/quickactions_arrowup_right_holo_light.9.png b/core/res/res/drawable-mdpi/quickactions_arrowup_right_holo_light.9.png
new file mode 100644
index 0000000..1e8e7a06
--- /dev/null
+++ b/core/res/res/drawable-mdpi/quickactions_arrowup_right_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/scrubber_control_holo.png b/core/res/res/drawable-mdpi/scrubber_control_holo.png
new file mode 100644
index 0000000..135b2aa
--- /dev/null
+++ b/core/res/res/drawable-mdpi/scrubber_control_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/scrubber_track_holo_dark.9.png b/core/res/res/drawable-mdpi/scrubber_track_holo_dark.9.png
new file mode 100644
index 0000000..7b48cf9
--- /dev/null
+++ b/core/res/res/drawable-mdpi/scrubber_track_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/scrubber_track_holo_light.9.png b/core/res/res/drawable-mdpi/scrubber_track_holo_light.9.png
new file mode 100644
index 0000000..7c84ac9
--- /dev/null
+++ b/core/res/res/drawable-mdpi/scrubber_track_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_holo_dark.xml b/core/res/res/drawable/btn_check_holo_dark.xml
index fd85d72..a163c2e 100644
--- a/core/res/res/drawable/btn_check_holo_dark.xml
+++ b/core/res/res/drawable/btn_check_holo_dark.xml
@@ -50,16 +50,16 @@
     <!-- Disabled states -->
 
     <item android:state_checked="true" android:state_window_focused="false"
-          android:drawable="@drawable/btn_check_on_disable_holo_dark" />
+          android:drawable="@drawable/btn_check_on_disabled_holo_dark" />
     <item android:state_checked="false" android:state_window_focused="false"
-          android:drawable="@drawable/btn_check_off_disable_holo_dark" />
+          android:drawable="@drawable/btn_check_off_disabled_holo_dark" />
 
     <item android:state_checked="true" android:state_focused="true"
-          android:drawable="@drawable/btn_check_on_disable_focused_holo_dark" />
+          android:drawable="@drawable/btn_check_on_disabled_focused_holo_dark" />
     <item android:state_checked="false" android:state_focused="true"
-          android:drawable="@drawable/btn_check_off_disable_focused_holo_dark" />
+          android:drawable="@drawable/btn_check_off_disabled_focused_holo_dark" />
 
-    <item android:state_checked="false" android:drawable="@drawable/btn_check_off_disable_holo_dark" />
-    <item android:state_checked="true" android:drawable="@drawable/btn_check_on_disable_holo_dark" />
+    <item android:state_checked="false" android:drawable="@drawable/btn_check_off_disabled_holo_dark" />
+    <item android:state_checked="true" android:drawable="@drawable/btn_check_on_disabled_holo_dark" />
 
 </selector>
diff --git a/core/res/res/drawable/btn_check_holo_light.xml b/core/res/res/drawable/btn_check_holo_light.xml
index 4fb16fa..5c49456 100644
--- a/core/res/res/drawable/btn_check_holo_light.xml
+++ b/core/res/res/drawable/btn_check_holo_light.xml
@@ -50,16 +50,16 @@
     <!-- Disabled states -->
 
     <item android:state_checked="true" android:state_window_focused="false"
-          android:drawable="@drawable/btn_check_on_disable_holo_light" />
+          android:drawable="@drawable/btn_check_on_disabled_holo_light" />
     <item android:state_checked="false" android:state_window_focused="false"
-          android:drawable="@drawable/btn_check_off_disable_holo_light" />
+          android:drawable="@drawable/btn_check_off_disabled_holo_light" />
 
     <item android:state_checked="true" android:state_focused="true"
-          android:drawable="@drawable/btn_check_on_disable_focused_holo_light" />
+          android:drawable="@drawable/btn_check_on_disabled_focused_holo_light" />
     <item android:state_checked="false" android:state_focused="true"
-          android:drawable="@drawable/btn_check_off_disable_focused_holo_light" />
+          android:drawable="@drawable/btn_check_off_disabled_focused_holo_light" />
 
-    <item android:state_checked="false" android:drawable="@drawable/btn_check_off_disable_holo_light" />
-    <item android:state_checked="true" android:drawable="@drawable/btn_check_on_disable_holo_light" />
+    <item android:state_checked="false" android:drawable="@drawable/btn_check_off_disabled_holo_light" />
+    <item android:state_checked="true" android:drawable="@drawable/btn_check_on_disabled_holo_light" />
 
 </selector>
diff --git a/core/res/res/drawable/ic_menu_moreoverflow_holo_dark.xml b/core/res/res/drawable/ic_menu_moreoverflow_holo_dark.xml
new file mode 100644
index 0000000..4691edf
--- /dev/null
+++ b/core/res/res/drawable/ic_menu_moreoverflow_holo_dark.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_focused="true" android:drawable="@drawable/ic_menu_moreoverflow_focused_holo_dark" />
+    <item android:drawable="@drawable/ic_menu_moreoverflow_normal_holo_dark" />
+</selector>
diff --git a/core/res/res/drawable/ic_menu_moreoverflow_holo_light.xml b/core/res/res/drawable/ic_menu_moreoverflow_holo_light.xml
new file mode 100644
index 0000000..5c52ff4
--- /dev/null
+++ b/core/res/res/drawable/ic_menu_moreoverflow_holo_light.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_focused="true" android:drawable="@drawable/ic_menu_moreoverflow_focused_holo_light" />
+    <item android:drawable="@drawable/ic_menu_moreoverflow_normal_holo_light" />
+</selector>
diff --git a/core/res/res/drawable/list_selector_holo_dark.xml b/core/res/res/drawable/list_selector_holo_dark.xml
new file mode 100644
index 0000000..ee59904
--- /dev/null
+++ b/core/res/res/drawable/list_selector_holo_dark.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_window_focused="false" android:drawable="@color/transparent" />
+
+    <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
+    <item android:state_focused="true"  android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_disabled_holo_dark" />
+    <item android:state_focused="true"  android:state_enabled="false"                              android:drawable="@drawable/list_selector_disabled_holo_dark" />
+    <item android:state_focused="true"                                android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
+    <item android:state_focused="false"                               android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
+    <item android:state_focused="true"                                                             android:drawable="@drawable/list_selector_focused_holo_dark" />
+    <item                                                                                          android:drawable="@drawable/list_selector_focused_holo_dark" />
+
+</selector>
diff --git a/core/res/res/drawable/list_selector_holo_light.xml b/core/res/res/drawable/list_selector_holo_light.xml
new file mode 100644
index 0000000..2dc39f6
--- /dev/null
+++ b/core/res/res/drawable/list_selector_holo_light.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_window_focused="false" android:drawable="@color/transparent" />
+
+    <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
+    <item android:state_focused="true"  android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_disabled_holo_light" />
+    <item android:state_focused="true"  android:state_enabled="false"                              android:drawable="@drawable/list_selector_disabled_holo_light" />
+    <item android:state_focused="true"                                android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
+    <item android:state_focused="false"                               android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
+    <item android:state_focused="true"                                                             android:drawable="@drawable/list_selector_focused_holo_light" />
+    <item                                                                                          android:drawable="@drawable/list_selector_focused_holo_light" />
+
+</selector>
diff --git a/core/res/res/drawable/scrubber_progress_horizontal_holo_dark.xml b/core/res/res/drawable/scrubber_progress_horizontal_holo_dark.xml
new file mode 100644
index 0000000..90172a5
--- /dev/null
+++ b/core/res/res/drawable/scrubber_progress_horizontal_holo_dark.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:id="@android:id/background"
+          android:drawable="@android:drawable/scrubber_track_holo_dark" />
+    <item android:id="@android:id/secondaryProgress"
+          android:drawable="@android:drawable/scrubber_track_holo_dark" />
+    <item android:id="@android:id/progress"
+          android:drawable="@android:drawable/scrubber_track_holo_dark" />
+</layer-list>
diff --git a/core/res/res/drawable/scrubber_progress_horizontal_holo_light.xml b/core/res/res/drawable/scrubber_progress_horizontal_holo_light.xml
new file mode 100644
index 0000000..5fc9697
--- /dev/null
+++ b/core/res/res/drawable/scrubber_progress_horizontal_holo_light.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:id="@android:id/background"
+          android:drawable="@android:drawable/scrubber_track_holo_light" />
+    <item android:id="@android:id/secondaryProgress"
+          android:drawable="@android:drawable/scrubber_track_holo_light" />
+    <item android:id="@android:id/progress"
+          android:drawable="@android:drawable/scrubber_track_holo_light" />
+</layer-list>
diff --git a/core/res/res/layout/fragment_bread_crumb_item.xml b/core/res/res/layout/fragment_bread_crumb_item.xml
index 408f6e8..517c570 100644
--- a/core/res/res/layout/fragment_bread_crumb_item.xml
+++ b/core/res/res/layout/fragment_bread_crumb_item.xml
@@ -19,7 +19,7 @@
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:gravity="center_vertical"
-        android:textAppearance="?android:attr/textAppearanceMediumInverse"
+        android:textAppearance="?android:attr/textAppearanceMedium"
         android:drawableLeft="@drawable/nav_divider"
         android:paddingLeft="12dp"
         android:drawablePadding="12dp"
diff --git a/core/res/res/layout/list_menu_item_layout.xml b/core/res/res/layout/list_menu_item_layout.xml
index 39c88722..57091a1 100644
--- a/core/res/res/layout/list_menu_item_layout.xml
+++ b/core/res/res/layout/list_menu_item_layout.xml
@@ -36,7 +36,7 @@
             android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
             android:layout_alignParentLeft="true"
-            android:textAppearance="?android:attr/textAppearanceLargeInverse"
+            android:textAppearance="?android:attr/textAppearanceLarge"
             android:singleLine="true"
             android:duplicateParentState="true"
             android:ellipsize="marquee"
@@ -48,7 +48,7 @@
             android:layout_height="wrap_content"
             android:layout_below="@id/title"
             android:layout_alignParentLeft="true"
-            android:textAppearance="?android:attr/textAppearanceSmallInverse"
+            android:textAppearance="?android:attr/textAppearanceSmall"
             android:singleLine="true"
             android:duplicateParentState="true" />
 
diff --git a/core/res/res/values-xlarge/config.xml b/core/res/res/values-xlarge/config.xml
index 7e5a27b..813651e 100644
--- a/core/res/res/values-xlarge/config.xml
+++ b/core/res/res/values-xlarge/config.xml
@@ -25,6 +25,9 @@
     <string name="config_statusBarComponent">com.android.systemui/com.android.systemui.statusbar.tablet.TabletStatusBarService</string>
     <bool name="config_statusBarCanHide">false</bool>
 
+    <!-- see comment in values/config.xml -->
+    <integer name="config_longPressOnPowerBehavior">2</integer>
+
     <!-- Show sliding tab before lockscreen -->
     <bool name="config_enableSlidingTabFirst">false</bool>
     <!-- Enable lockscreen rotation -->
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 33d3eeb..2a83b67 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -551,6 +551,10 @@
              anchor for positioning the cursor within text. -->
         <attr name="textSelectHandle" format="reference" />
 
+        <!-- Theme to use for dialogs spawned from this theme. -->
+        <attr name="dialogTheme" format="reference" />
+        <!-- Theme to use for alert dialogs spawned from this theme. -->
+        <attr name="alertDialogTheme" format="reference" />
     </declare-styleable>
 
     <!-- **************************************************************** -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 71967d4..d353db6 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -221,6 +221,13 @@
          closed.  The default is 0. -->
     <integer name="config_lidNavigationAccessibility">0</integer>
 
+    <!-- Control the behavior when the user long presses the power button.
+            0 - Nothing
+            1 - Global actions menu
+            2 - Power off (with confirmation)
+    -->
+    <integer name="config_longPressOnPowerBehavior">1</integer>
+
     <!-- Indicate whether the SD card is accessible without removing the battery. -->
     <bool name="config_batterySdCardAccessibility">false</bool>
 
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 2c3c4fc..ae25715 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1366,6 +1366,8 @@
   <public type="attr" name="listDividerAlertDialog" />
   <public type="attr" name="textColorAlertDialogListItem" />
   <public type="attr" name="loopViews" />
+  <public type="attr" name="dialogTheme" />
+  <public type="attr" name="alertDialogTheme" />
 
   <public type="anim" name="animator_fade_in" />
   <public type="anim" name="animator_fade_out" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 8b4f91f..0172827 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -280,9 +280,16 @@
     <!-- Shutdown Progress Dialog. This is shown if the user chooses to power off the phone. -->
     <string name="shutdown_progress">Shutting down\u2026</string>
 
-    <!-- Shutdown Confirmation Dialog.  When the user chooses to power off the phone, there will be a confirmation dialog.  This is the message. -->
+    <!-- Shutdown Confirmation Dialog.  When the user chooses to power off the phone, there will
+         be a confirmation dialog.  This is the message. -->
     <string name="shutdown_confirm">Your phone will shut down.</string>
 
+    <!-- Shutdown Confirmation Dialog.  When the user chooses to power off the phone, it asks
+         the user if they'd like to shut down.  This is the message.  This is used instead of
+         shutdown_confirm when the system is configured to use long press to go directly to the
+         power off dialog instead of the global actions menu. -->
+    <string name="shutdown_confirm_question">Would you like to shut down?</string>
+
     <!-- Recent Tasks dialog: title
      TODO: this should move to SystemUI.apk, but the code for the old 
             recent dialog is still in the framework
@@ -1639,7 +1646,7 @@
 
     <!-- Do not translate.  WebView User Agent string -->
     <string name="web_user_agent" translatable="false">Mozilla/5.0 (Linux; U; <xliff:g id="x">Android %s</xliff:g>)
-        AppleWebKit/534.9 (KHTML, like Gecko) Version/4.0 <xliff:g id="mobile">%s</xliff:g>Safari/534.9</string>
+        AppleWebKit/534.10 (KHTML, like Gecko) Version/4.0 <xliff:g id="mobile">%s</xliff:g>Safari/534.10</string>
     <!-- Do not translate.  WebView User Agent targeted content -->
     <string name="web_user_agent_target_content" translatable="false">"Mobile "</string>
 
@@ -2385,5 +2392,9 @@
         <item quantity="other"><xliff:g id="index" example="2">%d</xliff:g> of <xliff:g id="total" example="137">%d</xliff:g></item>
     </plurals>
 
+    <!-- Warning message about security implications of enabling an input method, displayed as a dialog message when the user selects to enable an IME. -->
+    <string name="ime_enabler_security_warning">This input method may be able to collect all the text you type, including personal data like passwords and credit card numbers. It comes from the application <xliff:g id="ime_application_name">%1$s</xliff:g>. Use this input method?</string>
+    <!-- Label for selecting the input method to use -->
+    <string name="ime_enabler_subtype_title">Select inputmethods in <xliff:g id="ime_application_name">%1$s</xliff:g></string>
 
 </resources>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 4b5047e..8f7ace9 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1091,12 +1091,15 @@
     </style>
 
     <style name="TextAppearance.Holo.Widget.PopupMenu" parent="TextAppearance.Widget.PopupMenu">
+        <item name="android:textColor">?android:attr/textColorPrimary</item>
     </style>
 
-    <style name="TextAppearance.Holo.Widget.PopupMenu.Large" parent="TextAppearance.Widget.PopupMenu.Large">
+    <style name="TextAppearance.Holo.Widget.PopupMenu.Large">
+        <item name="android:textSize">22sp</item>
     </style>
 
-    <style name="TextAppearance.Holo.Widget.PopupMenu.Small" parent="TextAppearance.Widget.PopupMenu.Small">
+    <style name="TextAppearance.Holo.Widget.PopupMenu.Small">
+        <item name="android:textSize">14sp</item>
     </style>
 
     <style name="TextAppearance.Holo.Widget.ActionBar.Title"
@@ -1139,13 +1142,13 @@
         <item name="android:textColorLink">?textColorLinkInverse</item>
     </style>
 
-    <style name="TextAppearance.Holo.Light.Large">
+    <style name="TextAppearance.Holo.Light.Large" parent="TextAppearance.Large">
     </style>
 
-    <style name="TextAppearance.Holo.Light.Medium">
+    <style name="TextAppearance.Holo.Light.Medium" parent="TextAppearance.Medium">
     </style>
 
-    <style name="TextAppearance.Holo.Light.Small">
+    <style name="TextAppearance.Holo.Light.Small" parent="TextAppearance.Small">
     </style>
  
    <style name="TextAppearance.Holo.Light.Large.Inverse">
@@ -1261,6 +1264,7 @@
     </style>
 
     <style name="Widget.Holo.TextView.ListSeparator" parent="Widget.TextView.ListSeparator">
+        <item name="android:background">@android:drawable/list_section_header_holo_dark</item>
     </style>
 
     <style name="Widget.Holo.TextSelectHandle" parent="Widget.TextSelectHandle">
@@ -1335,7 +1339,15 @@
     <style name="Widget.Holo.ProgressBar.Large.Inverse" parent="Widget.ProgressBar.Large.Inverse">
     </style>
 
-    <style name="Widget.Holo.SeekBar" parent="Widget.SeekBar">
+    <style name="Widget.Holo.SeekBar">
+        <item name="android:indeterminateOnly">false</item>
+        <item name="android:progressDrawable">@android:drawable/scrubber_progress_horizontal_holo_dark</item>
+        <item name="android:indeterminateDrawable">@android:drawable/scrubber_progress_horizontal_holo_dark</item>
+        <item name="android:minHeight">16dip</item>
+        <item name="android:maxHeight">16dip</item>
+        <item name="android:thumb">@android:drawable/scrubber_control_holo</item>
+        <item name="android:thumbOffset">16dip</item>
+        <item name="android:focusable">true</item>
     </style>
 
     <style name="Widget.Holo.RatingBar" parent="Widget.RatingBar">
@@ -1357,6 +1369,12 @@
     </style>
 
     <style name="Widget.Holo.Spinner" parent="Widget.Spinner.DropDown">
+        <item name="android:dropDownSelector">@android:drawable/list_selector_holo_dark</item>
+        <item name="android:popupBackground">@android:drawable/menu_dropdown_panel_holo_dark</item>
+        <item name="android:dropDownVerticalOffset">0dip</item>
+        <item name="android:dropDownHorizontalOffset">0dip</item>
+        <item name="android:dropDownWidth">wrap_content</item>
+        <item name="android:popupPromptView">@android:layout/simple_dropdown_hint</item>
     </style>
 
     <style name="Widget.Holo.Spinner.DropDown">
@@ -1405,15 +1423,21 @@
     </style>
 
     <style name="Widget.Holo.ListPopupWindow" parent="Widget.ListPopupWindow">
+        <item name="android:dropDownSelector">@android:drawable/list_selector_holo_dark</item>
+        <item name="android:popupBackground">@android:drawable/menu_dropdown_panel_holo_dark</item>
+        <item name="android:dropDownVerticalOffset">0dip</item>
+        <item name="android:dropDownHorizontalOffset">0dip</item>
+        <item name="android:dropDownWidth">wrap_content</item>
     </style>
 
-    <style name="Widget.Holo.PopupMenu" parent="Widget.PopupMenu">
+    <style name="Widget.Holo.PopupMenu" parent="Widget.Holo.ListPopupWindow">
     </style>
 
     <style name="Widget.Holo.ActionButton" parent="Widget.ActionButton">
     </style>
 
     <style name="Widget.Holo.ActionButton.Overflow" parent="Widget.ActionButton.Overflow">
+        <item name="android:src">@android:drawable/ic_menu_moreoverflow_holo_dark</item>
     </style>
 
     <style name="Widget.Holo.ActionBarView_TabView" parent="Widget.ActionBarView_TabView">
@@ -1441,6 +1465,7 @@
     <style name="Widget.Holo.ActionBar" parent="Widget.ActionBar">
         <item name="android:titleTextStyle">@android:style/TextAppearance.Holo.Widget.ActionBar.Title</item>
         <item name="android:subtitleTextStyle">@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle</item>
+        <item name="android:background">@null</item>
     </style>
 
     <!-- Light widget styles -->
@@ -1472,6 +1497,7 @@
     </style>
 
     <style name="Widget.Holo.Light.TextView.ListSeparator" parent="Widget.TextView.ListSeparator">
+        <item name="android:background">@android:drawable/list_section_header_holo_light</item>
     </style>
 
     <style name="Widget.Holo.Light.TextSelectHandle" parent="Widget.TextSelectHandle">
@@ -1546,7 +1572,9 @@
     <style name="Widget.Holo.Light.ProgressBar.Large.Inverse" parent="Widget.ProgressBar.Large.Inverse">
     </style>
 
-    <style name="Widget.Holo.Light.SeekBar" parent="Widget.SeekBar">
+    <style name="Widget.Holo.Light.SeekBar" parent="Widget.Holo.SeekBar">
+        <item name="android:progressDrawable">@android:drawable/scrubber_progress_horizontal_holo_light</item>
+        <item name="android:indeterminateDrawable">@android:drawable/scrubber_progress_horizontal_holo_light</item>
     </style>
 
     <style name="Widget.Holo.Light.RatingBar" parent="Widget.RatingBar">
@@ -1568,6 +1596,12 @@
     </style>
 
     <style name="Widget.Holo.Light.Spinner" parent="Widget.Spinner.DropDown">
+        <item name="android:dropDownSelector">@android:drawable/list_selector_holo_light</item>
+        <item name="android:popupBackground">@android:drawable/menu_dropdown_panel_holo_light</item>
+        <item name="android:dropDownVerticalOffset">0dip</item>
+        <item name="android:dropDownHorizontalOffset">0dip</item>
+        <item name="android:dropDownWidth">wrap_content</item>
+        <item name="android:popupPromptView">@android:layout/simple_dropdown_hint</item>
     </style>
 
     <style name="Widget.Holo.Light.Spinner.DropDown">
@@ -1616,15 +1650,21 @@
     </style>
 
     <style name="Widget.Holo.Light.ListPopupWindow" parent="Widget.ListPopupWindow">
+        <item name="android:dropDownSelector">@android:drawable/list_selector_holo_light</item>
+        <item name="android:popupBackground">@android:drawable/menu_dropdown_panel_holo_light</item>
+        <item name="android:dropDownVerticalOffset">0dip</item>
+        <item name="android:dropDownHorizontalOffset">0dip</item>
+        <item name="android:dropDownWidth">wrap_content</item>
     </style>
 
-    <style name="Widget.Holo.Light.PopupMenu" parent="Widget.PopupMenu">
+    <style name="Widget.Holo.Light.PopupMenu" parent="Widget.Holo.Light.ListPopupWindow">
     </style>
 
     <style name="Widget.Holo.Light.ActionButton" parent="Widget.ActionButton">
     </style>
 
     <style name="Widget.Holo.Light.ActionButton.Overflow" parent="Widget.ActionButton.Overflow">
+        <item name="android:src">@android:drawable/ic_menu_moreoverflow_holo_light</item>
     </style>
 
     <style name="Widget.Holo.Light.ActionBarView_TabView" parent="Widget.ActionBarView_TabView">
@@ -1648,6 +1688,7 @@
     <style name="Widget.Holo.Light.ActionBar" parent="Widget.ActionBar">
         <item name="android:titleTextStyle">@android:style/TextAppearance.Holo.Widget.ActionBar.Title</item>
         <item name="android:subtitleTextStyle">@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle</item>
+        <item name="android:background">@null</item>
     </style>
 
     <!-- Animation Styles -->
@@ -1664,16 +1705,29 @@
     <!-- Dialog styles -->
 
     <style name="AlertDialog.Holo" parent="AlertDialog">
-        <item name="fullDark">@android:drawable/dialog_full_holo</item>
-        <item name="topDark">@android:drawable/dialog_top_holo</item>
-        <item name="centerDark">@android:drawable/dialog_middle_holo</item>
-        <item name="bottomDark">@android:drawable/dialog_bottom_holo</item>
-        <item name="fullBright">@android:drawable/dialog_full_holo</item>
-        <item name="topBright">@android:drawable/dialog_top_holo</item>
-        <item name="centerBright">@android:drawable/dialog_middle_holo</item>
-        <item name="bottomBright">@android:drawable/dialog_bottom_holo</item>
-        <item name="bottomMedium">@android:drawable/dialog_bottom_holo</item>
-        <item name="centerMedium">@android:drawable/dialog_middle_holo</item>
+        <item name="fullDark">@android:drawable/dialog_full_holo_dark</item>
+        <item name="topDark">@android:drawable/dialog_top_holo_dark</item>
+        <item name="centerDark">@android:drawable/dialog_middle_holo_dark</item>
+        <item name="bottomDark">@android:drawable/dialog_bottom_holo_dark</item>
+        <item name="fullBright">@android:drawable/dialog_full_holo_dark</item>
+        <item name="topBright">@android:drawable/dialog_top_holo_dark</item>
+        <item name="centerBright">@android:drawable/dialog_middle_holo_dark</item>
+        <item name="bottomBright">@android:drawable/dialog_bottom_holo_dark</item>
+        <item name="bottomMedium">@android:drawable/dialog_bottom_holo_dark</item>
+        <item name="centerMedium">@android:drawable/dialog_middle_holo_dark</item>
+    </style>
+
+    <style name="AlertDialog.Holo.Light">
+        <item name="fullDark">@android:drawable/dialog_full_holo_light</item>
+        <item name="topDark">@android:drawable/dialog_top_holo_light</item>
+        <item name="centerDark">@android:drawable/dialog_middle_holo_light</item>
+        <item name="bottomDark">@android:drawable/dialog_bottom_holo_light</item>
+        <item name="fullBright">@android:drawable/dialog_full_holo_light</item>
+        <item name="topBright">@android:drawable/dialog_top_holo_light</item>
+        <item name="centerBright">@android:drawable/dialog_middle_holo_light</item>
+        <item name="bottomBright">@android:drawable/dialog_bottom_holo_light</item>
+        <item name="bottomMedium">@android:drawable/dialog_bottom_holo_light</item>
+        <item name="centerMedium">@android:drawable/dialog_middle_holo_light</item>
     </style>
 
     <!-- Window title -->
@@ -1694,4 +1748,10 @@
         <item name="android:textAppearance">@style/TextAppearance.Holo.DialogWindowTitle</item>
     </style>
 
+    <style name="DialogWindowTitle.Holo.Light">
+        <item name="android:maxLines">1</item>
+        <item name="android:scrollHorizontally">true</item>
+        <item name="android:textAppearance">@style/TextAppearance.Holo.Light.DialogWindowTitle</item>
+    </style>
+
 </resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 21d91ba..5d1e1c5 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -137,6 +137,8 @@
 
         <!-- Dialog attributes -->
         <item name="alertDialogStyle">@android:style/AlertDialog</item>
+        <item name="dialogTheme">@android:style/Theme.Dialog</item>
+        <item name="alertDialogTheme">@android:style/Theme.Dialog.Alert</item>
         
         <!-- Panel attributes -->
         <item name="panelBackground">@android:drawable/menu_background</item>
@@ -689,9 +691,9 @@
         <item name="listChoiceIndicatorSingle">@android:drawable/btn_radio_holo_dark</item>
         <item name="listChoiceIndicatorMultiple">@android:drawable/btn_check_holo_dark</item>
 
-        <item name="listChoiceBackgroundIndicator">@android:drawable/list_selected_background</item>
+        <item name="listChoiceBackgroundIndicator">@android:drawable/list_selector_holo_dark</item>
 
-        <item name="activatedBackgroundIndicator">@android:drawable/activated_background</item>
+        <item name="activatedBackgroundIndicator">@android:drawable/list_selector_activated_holo_dark</item>
 
         <item name="listDividerAlertDialog">@android:drawable/divider_horizontal_holo_dark</item>
 
@@ -715,7 +717,7 @@
         <item name="windowNoTitle">false</item>
         <item name="windowFullscreen">false</item>
         <item name="windowIsFloating">false</item>
-        <item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>
+        <item name="windowContentOverlay">@null</item>
         <item name="windowShowWallpaper">false</item>
         <item name="windowTitleStyle">@android:style/WindowTitle.Holo</item>
         <item name="windowTitleSize">25dip</item>
@@ -727,6 +729,8 @@
 
         <!-- Dialog attributes -->
         <item name="alertDialogStyle">@android:style/AlertDialog.Holo</item>
+        <item name="dialogTheme">@android:style/Theme.Holo.Dialog</item>
+        <item name="alertDialogTheme">@android:style/Theme.Holo.Dialog.Alert</item>
         
         <!-- Panel attributes -->
         <item name="panelBackground">@android:drawable/menu_background</item>
@@ -907,15 +911,15 @@
         <item name="listPreferredItemHeight">64dip</item>
         <!-- @hide -->
         <item name="searchResultListItemHeight">58dip</item>
-        <item name="listDivider">@drawable/divider_horizontal_holo_dark</item>
+        <item name="listDivider">@drawable/divider_horizontal_holo_light</item>
         <item name="listSeparatorTextViewStyle">@android:style/Widget.Holo.Light.TextView.ListSeparator</item>   
 
-        <item name="listChoiceIndicatorSingle">@android:drawable/btn_radio</item>
-        <item name="listChoiceIndicatorMultiple">@android:drawable/btn_check</item>
+        <item name="listChoiceIndicatorSingle">@android:drawable/btn_radio_holo_light</item>
+        <item name="listChoiceIndicatorMultiple">@android:drawable/btn_check_holo_light</item>
 
-        <item name="listChoiceBackgroundIndicator">@android:drawable/list_selected_background</item>
+        <item name="listChoiceBackgroundIndicator">@android:drawable/list_selector_holo_light</item>
 
-        <item name="activatedBackgroundIndicator">@android:drawable/activated_background</item>
+        <item name="activatedBackgroundIndicator">@android:drawable/list_selector_activated_holo_light</item>
 
         <item name="expandableListPreferredItemPaddingLeft">40dip</item>
         <item name="expandableListPreferredChildPaddingLeft">
@@ -928,7 +932,7 @@
         <item name="expandableListPreferredChildIndicatorRight">
                 ?android:attr/expandableListPreferredItemIndicatorRight</item>
 
-        <item name="listDividerAlertDialog">@android:drawable/divider_horizontal_holo_dark</item>
+        <item name="listDividerAlertDialog">@android:drawable/divider_horizontal_holo_light</item>
 
         <!-- Gallery attributes -->
         <item name="galleryItemBackground">@android:drawable/gallery_item_background</item>
@@ -939,7 +943,7 @@
         <item name="windowNoTitle">false</item>
         <item name="windowFullscreen">false</item>
         <item name="windowIsFloating">false</item>
-        <item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>
+        <item name="windowContentOverlay">@null</item>
         <item name="windowShowWallpaper">false</item>
         <item name="windowTitleStyle">@android:style/WindowTitle.Holo</item>
         <item name="windowTitleSize">25dip</item>
@@ -950,7 +954,9 @@
         <item name="windowActionModeOverlay">false</item>
 
         <!-- Dialog attributes -->
-        <item name="alertDialogStyle">@android:style/AlertDialog.Holo</item>
+        <item name="alertDialogStyle">@android:style/AlertDialog.Holo.Light</item>
+        <item name="dialogTheme">@android:style/Theme.Holo.Light.Dialog</item>
+        <item name="alertDialogTheme">@android:style/Theme.Holo.Light.Dialog.Alert</item>
         
         <!-- Panel attributes -->
         <item name="panelBackground">@android:drawable/menu_background</item>
@@ -1024,8 +1030,8 @@
         <item name="quickContactBadgeStyleSmallWindowSmall">@android:style/Widget.Holo.QuickContactBadgeSmall.WindowSmall</item>
         <item name="quickContactBadgeStyleSmallWindowMedium">@android:style/Widget.Holo.QuickContactBadgeSmall.WindowMedium</item>
         <item name="quickContactBadgeStyleSmallWindowLarge">@android:style/Widget.Holo.QuickContactBadgeSmall.WindowLarge</item>
-        <item name="listPopupWindowStyle">@android:style/Widget.Holo.ListPopupWindow</item>
-        <item name="popupMenuStyle">@android:style/Widget.Holo.PopupMenu</item>
+        <item name="listPopupWindowStyle">@android:style/Widget.Holo.Light.ListPopupWindow</item>
+        <item name="popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item>
         
         <!-- Preference styles -->
         <item name="preferenceScreenStyle">@android:style/Preference.PreferenceScreen</item>
@@ -1101,7 +1107,7 @@
     <style name="Theme.Holo.Dialog">
         <item name="android:windowFrame">@null</item>
         <item name="android:windowTitleStyle">@android:style/DialogWindowTitle.Holo</item>
-        <item name="android:windowBackground">@android:drawable/dialog_full_holo</item>
+        <item name="android:windowBackground">@android:drawable/dialog_full_holo_dark</item>
         <item name="android:windowIsFloating">true</item>
         <item name="android:windowContentOverlay">@null</item>
         <item name="android:windowAnimationStyle">@android:style/Animation.Holo.Dialog</item>
@@ -1138,4 +1144,40 @@
         <item name="windowContentOverlay">@null</item>
     </style>
 
+    <!-- Light holo dialog themes -->
+
+    <!-- Holo light theme for dialog windows and activities, which is used by the
+         {@link android.app.Dialog} class.  This changes the window to be
+         floating (not fill the entire screen), and puts a frame around its
+         contents.  You can set this theme on an activity if you would like to
+         make an activity that looks like a Dialog.
+         This is the default Dialog theme for applications targeting Honeycomb
+         or newer. -->
+    <style name="Theme.Holo.Light.Dialog">
+        <item name="android:windowFrame">@null</item>
+        <item name="android:windowTitleStyle">@android:style/DialogWindowTitle.Holo.Light</item>
+        <item name="android:windowBackground">@android:drawable/dialog_full_holo_light</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="android:windowContentOverlay">@null</item>
+        <item name="android:windowAnimationStyle">@android:style/Animation.Holo.Dialog</item>
+        <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
+        <item name="android:windowActionBar">false</item>
+
+        <item name="android:colorBackgroundCacheHint">@null</item>
+
+        <item name="textAppearance">@android:style/TextAppearance.Holo.Light</item>
+        <item name="textAppearanceInverse">@android:style/TextAppearance.Holo.Light.Inverse</item>
+    </style>
+
+    <!-- Holo light theme for alert dialog windows, which is used by the
+         {@link android.app.AlertDialog} class.  This is basically a dialog
+         but sets the background to empty so it can do two-tone backgrounds.
+         For applications targeting Honeycomb or newer, this is the default
+         AlertDialog theme. -->
+    <style name="Theme.Holo.Light.Dialog.Alert">
+        <item name="windowBackground">@android:color/transparent</item>
+        <item name="windowTitleStyle">@android:style/DialogWindowTitle.Holo.Light</item>
+        <item name="windowContentOverlay">@null</item>
+    </style>
+
 </resources>
diff --git a/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java b/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java
index ed42e64..37fc6c7 100644
--- a/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java
+++ b/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java
@@ -66,6 +66,7 @@
     protected MockWebServer mServer = null;
     protected String mFileType = "text/plain";
     protected Context mContext = null;
+    protected MultipleDownloadsCompletedReceiver mReceiver = null;
     protected static final int DEFAULT_FILE_SIZE = 130 * 1024;  // 130kb
     protected static final int FILE_BLOCK_READ_SIZE = 1024 * 1024;
 
@@ -131,12 +132,15 @@
          */
         @Override
         public void onReceive(Context context, Intent intent) {
+            Log.i(LOG_TAG, "Received Notification:");
             if (intent.getAction().equalsIgnoreCase(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
-                ++mNumDownloadsCompleted;
-                Log.i(LOG_TAG, "MultipleDownloadsCompletedReceiver got intent: " +
-                        intent.getAction() + " --> total count: " + mNumDownloadsCompleted);
-                Bundle extras = intent.getExtras();
-                downloadIds.add(new Long(extras.getLong(DownloadManager.EXTRA_DOWNLOAD_ID)));
+                synchronized(this) {
+                    ++mNumDownloadsCompleted;
+                    Log.i(LOG_TAG, "MultipleDownloadsCompletedReceiver got intent: " +
+                            intent.getAction() + " --> total count: " + mNumDownloadsCompleted);
+                    Bundle extras = intent.getExtras();
+                    downloadIds.add(new Long(extras.getLong(DownloadManager.EXTRA_DOWNLOAD_ID)));
+                }
             }
         }
 
@@ -212,6 +216,7 @@
         mContext = getInstrumentation().getContext();
         mDownloadManager = (DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE);
         mServer = new MockWebServer();
+        mReceiver = registerNewMultipleDownloadsReceiver();
         // Note: callers overriding this should call mServer.play() with the desired port #
     }
 
@@ -712,8 +717,9 @@
             Cursor cursor = mDownloadManager.query(query);
 
             try {
-                // If we've finished the downloads then we're done
-                if (cursor.getCount() == 0) {
+                // @TODO: there may be a little cleaner way to check for success, perhaps
+                // via STATUS_SUCCESSFUL and/or STATUS_FAILED
+                if (cursor.getCount() == 0 && mReceiver.numDownloadsCompleted() > 0) {
                     break;
                 }
                 currentWaitTime = timeoutWait(currentWaitTime, poll, timeoutMillis,
diff --git a/core/tests/coretests/src/android/app/DownloadManagerIntegrationTest.java b/core/tests/coretests/src/android/app/DownloadManagerIntegrationTest.java
index 27eea4d..cb7c2d2 100644
--- a/core/tests/coretests/src/android/app/DownloadManagerIntegrationTest.java
+++ b/core/tests/coretests/src/android/app/DownloadManagerIntegrationTest.java
@@ -61,7 +61,6 @@
             Environment.getRootDirectory().getAbsolutePath();
     private final static String CACHE_DIR =
             Environment.getDownloadCacheDirectory().getAbsolutePath();
-    protected MultipleDownloadsCompletedReceiver mReceiver = null;
 
     /**
      * {@inheritDoc}
@@ -72,7 +71,6 @@
         setWiFiStateOn(true);
         mServer.play();
         removeAllCurrentDownloads();
-        mReceiver = registerNewMultipleDownloadsReceiver();
     }
 
     /**
@@ -270,7 +268,7 @@
             try {
                 verifyInt(cursor, DownloadManager.COLUMN_STATUS, DownloadManager.STATUS_FAILED);
                 verifyInt(cursor, DownloadManager.COLUMN_REASON,
-                        DownloadManager.ERROR_FILE_ERROR);
+                        DownloadManager.ERROR_FILE_ALREADY_EXISTS);
             } finally {
                 cursor.close();
             }
@@ -429,6 +427,7 @@
                 }
             }
 
+            Log.i(LOG_TAG, "Done creating filler file.");
             assertTrue(DOWNLOAD_FILE_SIZE > (fs.getAvailableBlocks() * blockSize));
             byte[] blobData = generateData(DOWNLOAD_FILE_SIZE, DataType.TEXT);
             long dlRequest = doBasicDownload(blobData);
diff --git a/core/tests/coretests/src/android/content/SyncStorageEngineTest.java b/core/tests/coretests/src/android/content/SyncStorageEngineTest.java
index 0b494a7..ae41409 100644
--- a/core/tests/coretests/src/android/content/SyncStorageEngineTest.java
+++ b/core/tests/coretests/src/android/content/SyncStorageEngineTest.java
@@ -39,7 +39,8 @@
      * correcponding sync is finished. This can happen if the clock changes while we are syncing.
      *
      */
-    @SmallTest
+    // TODO: this test causes AidlTest to fail. Omit for now
+    // @SmallTest
     public void testPurgeActiveSync() throws Exception {
         final Account account = new Account("a@example.com", "example.type");
         final String authority = "testprovider";
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
index 1289a9e..276e281 100755
--- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
+++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
@@ -579,7 +579,6 @@
     private InstallParams installFromRawResource(String outFileName,
             int rawResId, int flags, boolean cleanUp, boolean fail, int result,
             int expInstallLocation) {
-        PackageManager pm = mContext.getPackageManager();
         InstallParams ip = new InstallParams(outFileName, rawResId);
         installFromRawResource(ip, flags, cleanUp, fail, result, expInstallLocation);
         return ip;
diff --git a/core/tests/coretests/src/com/android/internal/os/LoggingPrintStreamTest.java b/core/tests/coretests/src/com/android/internal/os/LoggingPrintStreamTest.java
index 4d016d1..fe62764 100644
--- a/core/tests/coretests/src/com/android/internal/os/LoggingPrintStreamTest.java
+++ b/core/tests/coretests/src/com/android/internal/os/LoggingPrintStreamTest.java
@@ -16,7 +16,7 @@
 
 package com.android.internal.os;
 
-import junit.framework.TestCase;
+import android.test.suitebuilder.annotation.Suppress;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -25,6 +25,10 @@
 import java.util.Collections;
 import java.util.List;
 
+import junit.framework.TestCase;
+
+// this test causes a IllegalAccessError: superclass not accessible
+@Suppress
 public class LoggingPrintStreamTest extends TestCase {
 
     TestPrintStream out = new TestPrintStream();
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 9793748..da8c927 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -278,6 +278,10 @@
               </li>
            </ul>
       </li>
+     <li><a href="<?cs var:toroot?>guide/topics/admin/device-admin.html">
+            <span class="en">Device Administration</span></a>
+            <span class="new">new!</span>
+    </li>
     </ul>
   </li>
 
diff --git a/docs/html/guide/topics/admin/device-admin.jd b/docs/html/guide/topics/admin/device-admin.jd
new file mode 100644
index 0000000..4d9a14f
--- /dev/null
+++ b/docs/html/guide/topics/admin/device-admin.jd
@@ -0,0 +1,494 @@
+page.title=Android Device Administration API
+@jd:body
+<div id="qv-wrapper">
+<div id="qv">
+    <h2>In this document</h2>
+    <ol>
+<li><a href="#overview">Device Administration API Overview</a>
+    <ol>
+      <li><a href="#policies">Policies</a></li>
+    </ol>
+  </li>
+  <li><a href="#how">How Does It Work?</a></li>
+  <li><a href="#sample">Sample Application</a></li>
+  <li><a href="#developing">Developing a Device Administration Application</a>
+    <ol>
+      <li><a href="#manifest">Creating the Manifest</a></li>
+      <li><a href="#code">Implementing the Code</a>
+      </li>
+    </ol>
+    </ol>
+  </div>
+</div>
+
+<p>Android 2.2 introduces support for enterprise applications by offering the
+Android Device Administration API. The Device Administration API provides device
+administration features at the system level.  These APIs allow you to create
+security-aware applications that are useful in enterprise settings, in which IT
+professionals require rich control over employee devices. For example, the
+built-in Android Email application has leveraged the new APIs to improve
+Exchange support. Through the Email application, Exchange administrators can
+enforce password policies &mdash;  including alphanumeric passwords or numeric
+PINs &mdash; across devices. Administrators can also remotely wipe (that is,
+restore factory defaults on) lost or stolen handsets. Exchange users can sync
+their email and calendar data.</p>
+
+<p>This document is intended for developers who want to develop enterprise
+solutions for Android-powered devices. It discusses the various features
+provided by the Device Administration API to provide stronger security for
+employee devices that are powered by Android.</p>
+<h2 id="overview">Device Administration API Overview</h2>
+<p>Here are examples of the types of applications that might use the Device Administration API:</p>
+<ul>
+  <li>Email clients.</li>
+  <li>Security applications that do remote wipe.</li>
+  <li>Device management services and applications.</li>
+</ul>
+
+<h3 id="how">How Does it Work?</h3>
+<p>You use the Device Administration API to write device admin applications that users
+install on their devices. The device admin application enforces the desired
+policies. Here's how it works:</p> <ul>
+  <li>A system administrator writes a device admin application that enforces
+remote/local device security policies. These policies could be hard-coded into
+the app, or the application could dynamically fetch policies from a third-party
+server. </li> 
+<li>The  application is installed on users' devices. Android does
+not currently have an automated provisioning solution. Some of the ways a sysadmin might
+distribute the application to users are as follows:
+<ul>
+<li>Android Market.</li>
+<li>Enabling non-market installation.</li>
+<li>Distributing the application through other means, such as email or websites.</li>
+
+</ul>
+
+
+</li>
+  <li>The system prompts the user to enable the device admin application. How
+and when this happens depends on how the application is implemented.</li>
+<li>Once  users enable the device admin application, they are subject to
+its policies. Complying with those policies typically confers benefits, such as 
+access to sensitive systems and data.</li>
+</ul>
+<p>If users do not enable the device admin app, it remains on the device, but in an inactive state. Users will not be subject to its policies, and they will conversely not get any of the application's benefits&mdash;for example, they may not be able to sync data.</p>
+<p>If a user fails to comply with the policies (for example, if a user sets a
+password that violates the guidelines), it is up to the application to decide
+how to handle this. However, typically this will result in the user not being
+able to sync data.</p>
+<p>If a device attempts to connect to a server that requires policies not
+supported in the Device Administration API, the connection will not
+be allowed. The Device Administration API does not currently allow partial
+provisioning. In other words, if a device (for example, a legacy device) does
+not support all of the stated policies, there is no way to allow the
+device to connect.</p>
+<p>If a device contains multiple enabled admin applications, the strictest policy is
+enforced. There is no way to target a particular admin
+application.</p>
+<p>To uninstall an existing device admin application, users need to
+first unregister the application as an administrator. </p>
+
+<h3 id ="policies">Policies</h3>
+<p>In an enterprise setting, it's often the case that employee devices must
+adhere to a strict set of policies that govern the use of the device. The
+Device Administration API supports the  policies listed in Table 1.
+Note that the Device Administration API currently only supports passwords for screen
+lock:</p> 
+<p class="table-caption"><strong>Table 1.</strong> Policies supported by the Device Administration API.</p>
+<table border="1">
+  <tr>
+    <th>Policy</th>
+    <th>Description</th>
+  </tr>
+  <tr>
+    <td>Password enabled</td>
+    <td>Requires that devices ask for PIN or passwords.</td>
+  </tr>
+  <tr>
+    <td>Minimum password length</td>
+    <td>Set the required number of characters for the password. For example, you
+can require PIN or passwords to have at least six characters. </td> </tr>
+  <tr>
+    <td>Alphanumeric password required</td> 
+    <td>Requires that passwords have a
+combination of letters and numbers. They may include symbolic characters.
+    </td>
+  </tr>
+  <tr>
+    <td>Maximum failed password attempts </td>
+    <td>Specifies how many times a user can enter the wrong password before the
+device wipes its data.  The Device Administration API also allows administrators to
+remotely reset the device to  factory defaults. This secures data in case the
+device is lost or stolen.</td>
+  </tr>
+  <tr>
+    <td>Maximum inactivity time lock</td>
+    <td>Sets the length of time since the user last touched the screen or
+pressed a button before the device locks the screen. When this happens, users
+need to enter their PIN or passwords again before they can use their devices and
+access data.  The value can be between 1 and 60 minutes.</td> </tr>
+</table>
+<h4>Other Features</h4>
+<p>In addition to supporting the policies listed in the above table, the Device
+Administration API lets you do the following:</p> <ul>
+  <li>Prompt user to set a new password.</li>
+  <li>Lock device immediately.</li>
+  <li>Wipe the device's data (that is, restore the device to its factory defaults).</li>
+</ul>
+
+
+<h2 id="sample">Sample Application</h2>
+<p>The examples used in this document are based on the <a
+href="{@docRoot}resources/samples/ApiDemos/src/com/example/
+android/apis/app/DeviceAdminSample.html">Device Administration API
+sample</a>, which is included in the SDK samples. For information on downloading and
+installing the SDK samples, see <a
+href="{@docRoot}resources/samples/get.html">
+Getting the Samples</a>. Here is the  <a
+href="{@docRoot}resources/samples/ApiDemos/src/com/example/
+android/apis/app/DeviceAdminSample.html">complete code</a> for
+the sample. </p> 
+<p>The
+sample application offers a demo of device admin features. It presents users
+with a user interface that lets them enable the device admin application. Once
+they've enabled the application, they can use the buttons in the user interface
+to do the following:</p>
+<ul>
+  <li>Set password quality.</li>
+  <li>Specify the minimum length for the user's password.</li>
+  <li>Set the password. If the password does not conform to the specified
+policies, the system  returns an error.</li>
+  <li>Set how many failed password attempts can occur before the device is wiped
+(that is, restored to factory settings).</li>
+  <li>Set the maximum amount of inactive time that can elapse before the device
+locks.</li>
+  <li>Make the device lock immediately.</li>
+  <li>Wipe the device's data (that is, restore factory settings).</li>
+</ul>
+
+<img src="{@docRoot}images/admin/device-admin-app.png"/>
+<p class="img-caption"><strong>Figure 1.</strong> Screenshot of the Sample Application</p>
+
+<h2 id="developing">Developing a Device Administration Application</h2>
+
+<p>System administrators can use the Device Administration API to write an application
+that enforces remote/local device security policy enforcement. This section
+summarizes the steps involved in creating a device administration
+application.</p>
+<h3 id="manifest">Creating the Manifest</h3>
+<p>To use the Device Administration API, the application's
+manifest must include the following:</p>
+<ul>
+  <li>A subclass of {@link android.app.admin.DeviceAdminReceiver} that includes the following:
+    <ul>
+      <li>The {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission.</li>
+      <li>The ability to  respond to the {@link android.app.admin.DeviceAdminReceiver#ACTION_DEVICE_ADMIN_ENABLED}
+intent, expressed in the manifest as an intent filter.</li>
+    </ul>
+  </li>
+  <li>A declaration of security policies used in metadata.</li>
+</ul>
+<p>Here is an excerpt from the Device Administration sample manifest:</p>
+<pre>&lt;activity android:name=&quot;.app.DeviceAdminSample$Controller&quot;
+          android:label=&quot;&#64;string/activity_sample_device_admin&quot;&gt;
+    &lt;intent-filter&gt;
+        &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
+        &lt;category android:name=&quot;android.intent.category.SAMPLE_CODE&quot; /&gt;
+    &lt;/intent-filter&gt;
+&lt;/activity&gt;
+
+&lt;receiver android:name=&quot;.app.DeviceAdminSample&quot;
+          android:label=&quot;&#64;string/sample_device_admin&quot;
+          android:description=&quot;&#64;string/sample_device_admin_description&quot;
+          android:permission=&quot;android.permission.BIND_DEVICE_ADMIN&quot;&gt;
+    &lt;meta-data android:name=&quot;android.app.device_admin&quot;
+               android:resource=&quot;&#64;xml/device_admin_sample&quot; /&gt;
+    &lt;intent-filter&gt;
+        &lt;action android:name=&quot;android.app.action.DEVICE_ADMIN_ENABLED&quot; /&gt;
+    &lt;/intent-filter&gt;
+&lt;/receiver&gt;</pre>
+ 
+ <p>Note that:</p>
+<ul>
+  <li>The activity in the sample application is an {@link android.app.Activity}
+subclass called <code>Controller</code>. The syntax
+<code>&quot;.app.DeviceAdminSample$Controller&quot;</code>  indicates that
+<code>Controller</code> is an inner class that is nested inside the
+<code>DeviceAdminSample</code> class. Note that an Activity does not need to be
+an inner class; it just is in this example.</li>
+
+<li>The following attributes refer to string resources that for the sample application reside in
+<code>ApiDemos/res/values/strings.xml</code>. For more information about resources, see 
+<a
+href="{@docRoot}guide/topics/resources/index.html">Application Resources</a>.
+<ul>
+<li><code>android:label=&quot;@string/activity_sample_device_admin&quot;</code> refers to the
+user-readable label for the activity.</li>
+
+<li><code>android:label=&quot;@string/sample_device_admin&quot;</code> refers to the
+user-readable label for the permission.</li>
+
+<li><code>android:description=&quot;@string/sample_device_admin_description&quot;</code> refers to
+the user-readable description of the permission. A descripton is typically longer and more
+informative than
+a label.</li>
+</ul>
+
+ 
+<li><code>android:permission=&quot;android.permission.BIND_DEVICE_ADMIN&quot; 
+</code> is a permission that a {@link android.app.admin.DeviceAdminReceiver} subclass must
+have, to ensure that only the system can interact with the receiver (no application can be granted this permission). This
+prevents other applications from abusing your device admin app.</li>
+<li><code>android.app.action.DEVICE_ADMIN_ENABLED</code> is the  the primary
+action that a {@link android.app.admin.DeviceAdminReceiver} subclass must handle to be
+allowed to manage a device. This is set to the receiver when the user enables
+the device admin app. Your code typically handles this in
+{@link android.app.admin.DeviceAdminReceiver#onEnabled onEnabled()}. To be supported, the receiver must also
+require the {@link android.Manifest.permission#BIND_DEVICE_ADMIN} permission so that other applications
+cannot abuse it.  </li>
+<li>When a user enables the device admin application, that gives the receiver
+permission to perform actions in response to the broadcast of particular system
+events. When suitable event arises, the application can impose a policy. For
+example, if the user attempts to set a new password that doesn't meet the policy
+requirements, the application can prompt the user to pick a different password
+that does meet the requirements.</li>
+
+  <li><code>android:resource=&quot;&#64;xml/device_admin_sample&quot;</code>
+declares the security policies used in metadata. The metadata provides additional
+information specific to the device administrator, as parsed by the {@link
+android.app.admin.DeviceAdminInfo} class. Here are the contents of
+<code>device_admin_sample.xml</code>:</li>
+</ul>
+<pre>&lt;device-admin xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
+  &lt;uses-policies&gt;
+    &lt;limit-password /&gt;
+    &lt;watch-login /&gt;
+    &lt;reset-password /&gt;
+    &lt;force-lock /&gt;
+    &lt;wipe-data /&gt;
+  &lt;/uses-policies&gt;
+&lt;/device-admin&gt;
+</pre>
+<p> In designing your device administration application, you don't need to
+include all of the policies, just the ones that are relevant for your app.
+</p>
+For more discussion of the manifest file, see the <a
+href="{@docRoot}guide/topics/manifest/manifest-intro.html">Android Developers Guide</a>. 
+<h2 id="code">Implementing the Code</h2>
+<p>The Device Administration API includes the following classes:</p>
+<dl>
+  <dt>{@link android.app.admin.DeviceAdminReceiver}</dt> 
+     <dd>Base class for implementing a device administration component. This class provides
+a convenience for interpreting the raw intent actions   that are sent by the
+system. Your Device Administration application must include a
+{@link android.app.admin.DeviceAdminReceiver} subclass.</dd>
+  <dt>{@link android.app.admin.DevicePolicyManager}</dt>
+<dd>A class for managing policies enforced on a device. Most clients of
+this class must have published a {@link android.app.admin.DeviceAdminReceiver} that the user
+has currently enabled. The {@link android.app.admin.DevicePolicyManager} manages policies for
+one or more {@link android.app.admin.DeviceAdminReceiver} instances</dd>
+  <dt>{@link android.app.admin.DeviceAdminInfo}</dt> 
+<dd>This class is used to specify metadata
+for a device administrator component.</dd>
+</dl>
+<p>These classes provide the foundation for a fully functional device administration application.
+The rest of this section describes how you use the {@link
+android.app.admin.DeviceAdminReceiver} and
+{@link android.app.admin.DevicePolicyManager} APIs to write a device admin application.</p>
+<h4 id="receiver">Subclassing DeviceAdminReceiver</h4>
+<p>To create a device admin application, you must subclass
+{@link android.app.admin.DeviceAdminReceiver}. The {@link android.app.admin.DeviceAdminReceiver} class
+consists of a series of callbacks that are triggered when particular events
+occur.</p>
+<p>In its {@link android.app.admin.DeviceAdminReceiver} subclass, the sample application
+simply displays a {@link android.widget.Toast} notification in response to particular
+events. For example:</p>
+<pre>public class DeviceAdminSample extends DeviceAdminReceiver {
+
+... 
+    &#64;Override
+    public void onEnabled(Context context, Intent intent) {
+        showToast(context, &quot;Sample Device Admin: enabled&quot;);
+    }
+
+    &#64;Override
+    public CharSequence onDisableRequested(Context context, Intent intent) {
+        return &quot;This is an optional message to warn the user about disabling.&quot;;
+    }
+
+    &#64;Override
+    public void onDisabled(Context context, Intent intent) {
+        showToast(context, &quot;Sample Device Admin: disabled&quot;);
+    }
+
+    &#64;Override
+    public void onPasswordChanged(Context context, Intent intent) {
+        showToast(context, &quot;Sample Device Admin: pw changed&quot;);
+    }
+
+    void showToast(Context context, CharSequence msg) {
+        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
+    }
+...
+}</pre>
+<h4 id="enabling">Enabling the Application</h4>
+<p>One of the major events a device admin application has to handle is the user
+enabling the application. The user must explicitly enable the application for
+the policies to be enforced. If the user chooses not to enable the application
+it will still be present on the device, but its policies will not be enforced, and the user will not
+get any of the application's benefits.</p>
+<p>The process of enabling the application begins when the user performs an
+action that triggers the {@link android.app.admin.DevicePolicyManager#ACTION_ADD_DEVICE_ADMIN} 
+intent. In the
+sample application, this happens when the user clicks the <strong>Enable
+Admin</strong> button. </p>
+<p>When the user clicks the <strong>Enable Admin</strong> button, the display
+changes to prompt the user to enable the device admin application, as shown in <strong>Figure 2</strong>.</p>
+
+<img src="{@docRoot}images/admin/device-admin-activate-prompt.png"/>
+<p class="img-caption"><strong>Figure 2.</strong> Sample Application: Activating the Application</p>
+<p>Below  is the code that gets executed when the user clicks the <strong>Enable
+Admin</strong> button shown in <strong>Figure 1</strong>. </p>
+
+<pre> private OnClickListener mEnableListener = new OnClickListener() {
+    public void onClick(View v) {
+        // Launch the activity to have the user enable our admin.
+        Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
+        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, 
+               mDeviceAdminSample);
+        intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
+               &quot;Additional text explaining why this needs to be added.&quot;);
+        startActivityForResult(intent, RESULT_ENABLE);
+    }
+};
+
+...
+// This code checks whether the device admin app was successfully enabled.
+&#64;Override
+protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+    switch (requestCode) {
+        case RESULT_ENABLE:
+            if (resultCode == Activity.RESULT_OK) {
+                Log.i(&quot;DeviceAdminSample&quot;, &quot;Administration enabled!&quot;);
+            } else {
+                Log.i(&quot;DeviceAdminSample&quot;, &quot;Administration enable FAILED!&quot;);
+            }
+            return;
+    }
+    super.onActivityResult(requestCode, resultCode, data);
+}</pre>
+
+<p>The line
+<code>intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, 
+mDeviceAdminSample)</code> states that <code>mDeviceAdminSample</code> (which is
+a {@link android.app.admin.DeviceAdminReceiver} component) is the target policy.
+This line invokes the user interface shown in <strong>Figure 2</strong>, which guides users through
+adding the device administrator to the system (or allows them to reject it).</p>
+
+<p>When the application needs to perform an operation that is contingent on the
+device admin application being enabled, it confirms that the application is
+active. To do this it uses the {@link android.app.admin.DevicePolicyManager} method
+{@link android.app.admin.DevicePolicyManager#isAdminActive(android.content.ComponentName) isAdminActive()}. Notice that the {@link android.app.admin.DevicePolicyManager}
+method {@link android.app.admin.DevicePolicyManager#isAdminActive(android.content.ComponentName) isAdminActive()} takes a {@link android.app.admin.DeviceAdminReceiver}
+component as its argument:</p>
+<pre>
+DevicePolicyManager mDPM;
+...
+boolean active = mDPM.isAdminActive(mDeviceAdminSample);
+if (active) {
+    // Admin app is active, so do some admin stuff
+               ...
+} else {
+    // do something else
+}
+</pre>
+<h3 id="admin_ops">Managing Policies</h3>
+<p>{@link android.app.admin.DevicePolicyManager} is a public class for managing policies
+enforced on a device. {@link android.app.admin.DevicePolicyManager} manages policies for one
+or more {@link android.app.admin.DeviceAdminReceiver} instances. </p>
+<p>You get a handle to the {@link android.app.admin.DevicePolicyManager} as follows: </p>
+<pre>DevicePolicyManager mDPM =
+(DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);<br
+/></pre>
+<p>This section describes how to use {@link android.app.admin.DevicePolicyManager} to perform
+ administrative tasks:</p>
+<ul>
+  <li><a href="#pwd">Set password policies</a></li>
+  <li><a href="#lock">Set  device lock</a></li>
+  <li><a href="#wipe">Perform data wipe</a></li>
+</ul>
+<h4 id="pwd">Set password policies</h4>
+<p>{@link android.app.admin.DevicePolicyManager} includes APIs for setting and enforcing the
+device password policy. In the Device Administration API, the password only applies to
+screen lock. This section describes common password-related tasks.</p>
+<h5>Set a password for the device</h5>
+<p>This code displays a user interface prompting the user to set a password:</p>
+<pre>Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
+startActivity(intent);
+</pre>
+<h5>Set the password quality</h5>
+<p>The password quality can be one of the following {@link android.app.admin.DevicePolicyManager} constants: </p>
+<dl>
+  <dt>{@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_ALPHABETIC}</dt><dd>The user must enter a  
+password containing at least alphabetic (or other symbol) characters.</dd>
+  <dt>{@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_ALPHANUMERIC}</dt><dd>The user must enter a  
+password containing at least <em>both</em> numeric <em>and</em> alphabetic (or
+other symbol) characters.</dd>
+  <dt>{@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_NUMERIC}</dt><dd>The user must enter a   password
+containing at least numeric characters.</dd>
+  <dt>{@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_SOMETHING}</dt><dd>The policy requires some kind  
+of password, but doesn't care what it is.</dd>
+  <dt>{@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_UNSPECIFIED}</dt><dd>
+  The policy has no requirements   for the password. </dd>
+</dl>
+<p>For example, this is how you would set the password policy to require an alphanumeric password:</p>
+<pre>
+DevicePolicyManager mDPM;
+ComponentName mDeviceAdminSample;
+...
+mDPM.setPasswordQuality(mDeviceAdminSample, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
+</pre>
+<h5>Set the minimum password length</h5>
+<p>You can specify that a password must be at least the specified minimum
+length. For example:</p>
+<pre>DevicePolicyManager mDPM;
+ComponentName mDeviceAdminSample;
+int pwLength;
+...
+mDPM.setPasswordMinimumLength(mDeviceAdminSample, pwLength);
+</pre>
+<h5>Set maximum failed password attempts</h5>
+<p>You can set the maximum number of allowed failed password attempts before the
+device is wiped (that is, reset to factory settings). For example:</p>
+<pre>DevicePolicyManager mDPM; 
+ComponentName mDeviceAdminSample; 
+int maxFailedPw;
+ ...
+mDPM.setMaximumFailedPasswordsForWipe(mDeviceAdminSample, maxFailedPw);</pre>
+<h4 id="lock">Set  device lock</h4>
+<p>You can set the maximum period of user inactivity that can occur before the
+device locks. For example:</p>
+<pre>
+DevicePolicyManager mDPM; 
+ComponentName mDeviceAdminSample;
+...
+long timeMs = 1000L*Long.parseLong(mTimeout.getText().toString());
+mDPM.setMaximumTimeToLock(mDeviceAdminSample, timeMs);
+</pre>
+<p>You can also programmatically tell the device to lock immediately:</p>
+<pre>
+DevicePolicyManager mDPM; 
+mDPM.lockNow();</pre>
+<h4 id="wipe">Perform data wipe</h4>
+<p>You can use the {@link android.app.admin.DevicePolicyManager} method
+{@link android.app.admin.DevicePolicyManager#wipeData wipeData()} to reset the device to factory settings. This is useful
+if the device is lost or stolen. Often the decision to wipe the device is the
+result of certain conditions being met. For example, you can use
+{@link android.app.admin.DevicePolicyManager#setMaximumFailedPasswordsForWipe setMaximumFailedPasswordsForWipe()} to state that a device should be
+wiped after a specific number of failed password attempts.</p>
+<p>You wipe data as follows:</p>
+<pre>
+DevicePolicyManager mDPM; 
+mDPM.wipeData(0);</pre>
+<p>The {@link android.app.admin.DevicePolicyManager#wipeData wipeData()} method takes as its parameter a bit mask of
+additional options. Currently the value must be 0. </p>
diff --git a/docs/html/images/admin/device-admin-activate-prompt.png b/docs/html/images/admin/device-admin-activate-prompt.png
new file mode 100755
index 0000000..fd001bd
--- /dev/null
+++ b/docs/html/images/admin/device-admin-activate-prompt.png
Binary files differ
diff --git a/docs/html/images/admin/device-admin-app.png b/docs/html/images/admin/device-admin-app.png
new file mode 100755
index 0000000..d966a28
--- /dev/null
+++ b/docs/html/images/admin/device-admin-app.png
Binary files differ
diff --git a/include/camera/CameraHardwareInterface.h b/include/camera/CameraHardwareInterface.h
index 3a77dd1..561a46d 100644
--- a/include/camera/CameraHardwareInterface.h
+++ b/include/camera/CameraHardwareInterface.h
@@ -21,6 +21,8 @@
 #include <ui/egl/android_natives.h>
 #include <utils/RefBase.h>
 #include <surfaceflinger/ISurface.h>
+#include <ui/android_native_buffer.h>
+#include <ui/GraphicBuffer.h>
 #include <camera/Camera.h>
 #include <camera/CameraParameters.h>
 
@@ -47,6 +49,17 @@
                               const sp<IMemory>& dataPtr,
                               void* user);
 
+#ifdef USE_GRAPHIC_VIDEO_BUFFERS
+/**
+ * Replace data_callback_timestamp. Once we are done, this
+ * should be renamed as data_callback_timestamp, and the existing
+ * data_callback_timestamp should be deleted.
+ */
+typedef void (*videobuffer_callback_timestamp)(nsecs_t timestamp,
+                                        int32_t msgType,
+                                        const sp<android_native_buffer_t>& buf,
+                                        void* user);
+#endif
 typedef void (*data_callback_timestamp)(nsecs_t timestamp,
                                         int32_t msgType,
                                         const sp<IMemory>& dataPtr,
@@ -87,6 +100,46 @@
 public:
     virtual ~CameraHardwareInterface() { }
 
+#ifdef USE_GRAPHIC_VIDEO_BUFFERS
+    /**
+     * Replace existing setCallbacks() method. Once we are done, the
+     * videobuffer_callback_timestamp parameter will be renamed to
+     * data_callback_timestamp, but its signature will be the same
+     * as videobuffer_callback_timestamp, which will be renamed
+     * to data_callback_timestamp and the exiting data_callback_timestamp
+     * will be deleted.
+     */
+    virtual void        setCallbacks(notify_callback notify_cb,
+                                data_callback data_cb,
+                                videobuffer_callback_timestamp data_cb_timestamp,
+                                void* user) = 0;
+
+    /**
+     * Replace releaseRecordingFrame(). releaseRecordingFrame() should be
+     * changed so that it has the same signature of releaseVideoBuffer(),
+     * once we are done, and releaseVideoBuffer() will be deleted.
+     */
+    virtual void        releaseVideoBuffer(const sp<android_native_buffer_t>& buf) = 0;
+
+    /**
+     * This method should be called after startRecording().
+     *
+     * @param nBuffers the total number of video buffers allocated by the camera
+     *  hal
+     * @param buffers an array allocated by the camera hal to hold the pointers
+     *  to the individual video buffers. The video buffers and the buffers array
+     *  should NOT be modified/released by camera hal until stopRecording() is
+     *  called and all outstanding video buffers previously sent out via
+     *  CAMERA_MSG_VIDEO_FRAME have been released via releaseVideoBuffer().
+     *  Camera hal client must not release the individual buffers and the buffers
+     *  array.
+     * @return no error if OK.
+     */
+    virtual status_t    getVideoBufferInfo(
+                            sp<android_native_buffer_t>** buffers,
+                            size_t *nBuffers) = 0;
+#endif
+
     /** Set the ANativeWindow to which preview frames are sent */
     virtual status_t setPreviewWindow(const sp<ANativeWindow>& buf) = 0;
 
diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h
index ed2f7d7..37af032 100644
--- a/include/media/stagefright/AudioPlayer.h
+++ b/include/media/stagefright/AudioPlayer.h
@@ -49,11 +49,9 @@
 
     status_t start(bool sourceAlreadyStarted = false);
 
-    void pause();
+    void pause(bool playPendingSamples = false);
     void resume();
 
-    void stop();
-
     // Returns the timestamp of the last buffer played (in us).
     int64_t getMediaTimeUs();
 
@@ -107,6 +105,8 @@
 
     int64_t getRealTimeUsLocked() const;
 
+    void reset();
+
     AudioPlayer(const AudioPlayer &);
     AudioPlayer &operator=(const AudioPlayer &);
 };
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index 70bd8e8..cff38b2 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -64,6 +64,7 @@
     FILE *mFile;
     bool mUse4ByteNalLength;
     bool mUse32BitOffset;
+    bool mIsFileSizeLimitExplicitlyRequested;
     bool mPaused;
     bool mStarted;
     off_t mOffset;
diff --git a/include/private/surfaceflinger/SharedBufferStack.h b/include/private/surfaceflinger/SharedBufferStack.h
index d689667..d6ae5e9 100644
--- a/include/private/surfaceflinger/SharedBufferStack.h
+++ b/include/private/surfaceflinger/SharedBufferStack.h
@@ -114,8 +114,9 @@
 
     int32_t     identity;       // surface's identity (const)
     int32_t     token;          // surface's token (for debugging)
-    int32_t     reserved32[1];
     Statistics  stats;
+    int8_t      headBuf;        // last retired buffer
+    uint8_t     reservedBytes[3];
     int32_t     reserved;
     BufferData  buffers[NUM_BUFFER_MAX];     // 1024 bytes
 };
@@ -201,6 +202,7 @@
     status_t undoDequeue(int buf);
     
     status_t lock(int buf);
+    status_t cancel(int buf);
     status_t queue(int buf);
     bool needNewBuffer(int buffer) const;
     status_t setDirtyRegion(int buffer, const Region& reg);
@@ -230,8 +232,9 @@
         inline ssize_t operator()();
     };
 
-    struct UndoDequeueUpdate : public UpdateBase {
-        inline UndoDequeueUpdate(SharedBufferBase* sbb);
+    struct CancelUpdate : public UpdateBase {
+        int tail, buf;
+        inline CancelUpdate(SharedBufferBase* sbb, int tail, int buf);
         inline ssize_t operator()();
     };
 
@@ -256,7 +259,6 @@
     int mNumBuffers;
 
     int32_t tail;
-    int32_t undoDequeueTail;
     int32_t queued_head;
     // statistics...
     nsecs_t mDequeueTime[SharedBufferStack::NUM_BUFFER_MAX];
diff --git a/include/surfaceflinger/Surface.h b/include/surfaceflinger/Surface.h
index a210880..cef439c 100644
--- a/include/surfaceflinger/Surface.h
+++ b/include/surfaceflinger/Surface.h
@@ -200,6 +200,7 @@
      */
     static int setSwapInterval(ANativeWindow* window, int interval);
     static int dequeueBuffer(ANativeWindow* window, android_native_buffer_t** buffer);
+    static int cancelBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
     static int lockBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
     static int queueBuffer(ANativeWindow* window, android_native_buffer_t* buffer);
     static int query(ANativeWindow* window, int what, int* value);
@@ -208,6 +209,7 @@
     int dequeueBuffer(android_native_buffer_t** buffer);
     int lockBuffer(android_native_buffer_t* buffer);
     int queueBuffer(android_native_buffer_t* buffer);
+    int cancelBuffer(android_native_buffer_t* buffer);
     int query(int what, int* value);
     int perform(int operation, va_list args);
 
diff --git a/include/ui/InputDispatcher.h b/include/ui/InputDispatcher.h
index 8d4654f..246df8f8 100644
--- a/include/ui/InputDispatcher.h
+++ b/include/ui/InputDispatcher.h
@@ -212,8 +212,15 @@
     int32_t ownerPid;
     int32_t ownerUid;
 
-    bool visibleFrameIntersects(const InputWindow* other) const;
     bool touchableAreaContainsPoint(int32_t x, int32_t y) const;
+    bool frameContainsPoint(int32_t x, int32_t y) const;
+
+    /* Returns true if the window is of a trusted type that is allowed to silently
+     * overlay other windows for the purpose of implementing the secure views feature.
+     * Trusted overlays, such as IME windows, can partly obscure other windows without causing
+     * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
+     */
+    bool isTrustedOverlay() const;
 };
 
 
@@ -973,7 +980,7 @@
     bool shouldPokeUserActivityForCurrentInputTargetsLocked();
     void pokeUserActivityLocked(nsecs_t eventTime, int32_t eventType);
     bool checkInjectionPermission(const InputWindow* window, const InjectionState* injectionState);
-    bool isWindowObscuredLocked(const InputWindow* window);
+    bool isWindowObscuredAtPointLocked(const InputWindow* window, int32_t x, int32_t y) const;
     bool isWindowFinishedWithPreviousInputLocked(const InputWindow* window);
     String8 getApplicationWindowLabelLocked(const InputApplication* application,
             const InputWindow* window);
diff --git a/include/ui/egl/android_natives.h b/include/ui/egl/android_natives.h
index d59d72b..654d0f3 100644
--- a/include/ui/egl/android_natives.h
+++ b/include/ui/egl/android_natives.h
@@ -218,7 +218,17 @@
     int     (*perform)(struct ANativeWindow* window,
                 int operation, ... );
     
-    void* reserved_proc[3];
+    /*
+     * hook used to cancel a buffer that has been dequeued.
+     * No synchronization is performed between dequeue() and cancel(), so
+     * either external synchronization is needed, or these functions must be
+     * called from the same thread.
+     */
+    int     (*cancelBuffer)(struct ANativeWindow* window,
+                struct android_native_buffer_t* buffer);
+
+
+    void* reserved_proc[2];
 };
 
 // Backwards compatibility...  please switch to ANativeWindow.
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index ce85d46..61e5408 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -342,7 +342,7 @@
     mHeight = height;
 }
 
-void DisplayListRenderer::prepare() {
+void DisplayListRenderer::prepare(bool opaque) {
     mSnapshot = new Snapshot(mFirstSnapshot,
             SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
     mSaveCount = 1;
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 5d02bd7..0fbfce1 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -209,7 +209,7 @@
     ~DisplayListRenderer();
 
     void setViewport(int width, int height);
-    void prepare();
+    void prepare(bool opaque);
 
     void acquireContext();
     void releaseContext();
diff --git a/libs/hwui/OpenGLDebugRenderer.cpp b/libs/hwui/OpenGLDebugRenderer.cpp
index 4e5123e..b9583e5 100644
--- a/libs/hwui/OpenGLDebugRenderer.cpp
+++ b/libs/hwui/OpenGLDebugRenderer.cpp
@@ -23,10 +23,10 @@
 namespace android {
 namespace uirenderer {
 
-void OpenGLDebugRenderer::prepare() {
+void OpenGLDebugRenderer::prepare(bool opaque) {
     mPrimitivesCount = 0;
     LOGD("========= Frame start =========");
-    OpenGLRenderer::prepare();
+    OpenGLRenderer::prepare(opaque);
 }
 
 void OpenGLDebugRenderer::finish() {
diff --git a/libs/hwui/OpenGLDebugRenderer.h b/libs/hwui/OpenGLDebugRenderer.h
index ce15512..2ac19ae 100644
--- a/libs/hwui/OpenGLDebugRenderer.h
+++ b/libs/hwui/OpenGLDebugRenderer.h
@@ -34,7 +34,7 @@
     ~OpenGLDebugRenderer() {
     }
 
-    void prepare();
+    void prepare(bool opaque);
     void finish();
 
     int saveLayer(float left, float top, float right, float bottom,
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index ee5fe22..5399668 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -150,7 +150,7 @@
     mFirstSnapshot->viewport.set(0, 0, width, height);
 }
 
-void OpenGLRenderer::prepare() {
+void OpenGLRenderer::prepare(bool opaque) {
     mSnapshot = new Snapshot(mFirstSnapshot,
             SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
     mSaveCount = 1;
@@ -160,8 +160,10 @@
     glDisable(GL_DITHER);
     glDisable(GL_SCISSOR_TEST);
 
-    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-    glClear(GL_COLOR_BUFFER_BIT);
+    if (!opaque) {
+        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+        glClear(GL_COLOR_BUFFER_BIT);
+    }
 
     glEnable(GL_SCISSOR_TEST);
     glScissor(0, 0, mWidth, mHeight);
@@ -325,7 +327,10 @@
  *   - Issue the drawing
  *
  * Switching rendering target n + 1 times per drawn primitive is extremely costly.
- * To avoid this, layers are implemented in a different way here.
+ * To avoid this, layers are implemented in a different way here, at least in the
+ * general case. FBOs are used, as an optimization, when the "clip to layer" flag
+ * is set. When this flag is set we can redirect all drawing operations into a
+ * single FBO.
  *
  * This implementation relies on the frame buffer being at least RGBA 8888. When
  * a layer is created, only a texture is created, not an FBO. The content of the
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index e3d4653..4caa8fb 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -67,7 +67,7 @@
 
     virtual void setViewport(int width, int height);
 
-    virtual void prepare();
+    virtual void prepare(bool opaque);
     virtual void finish();
 
     virtual void acquireContext();
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 3e9412c..439e6fb 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -35,17 +35,10 @@
         "uniform mat4 transform;\n";
 const char* gVS_Header_Uniforms_HasGradient[3] = {
         // Linear
-        "uniform float gradientLength;\n"
-        "uniform vec2 gradient;\n"
-        "uniform vec2 gradientStart;\n"
         "uniform mat4 screenSpace;\n",
         // Circular
-        "uniform vec2 gradientStart;\n"
-        "uniform mat4 gradientMatrix;\n"
         "uniform mat4 screenSpace;\n",
         // Sweep
-        "uniform vec2 gradientStart;\n"
-        "uniform mat4 gradientMatrix;\n"
         "uniform mat4 screenSpace;\n"
 };
 const char* gVS_Header_Uniforms_HasBitmap =
@@ -69,14 +62,11 @@
         "    outTexCoords = texCoords;\n";
 const char* gVS_Main_OutGradient[3] = {
         // Linear
-        "    vec4 location = screenSpace * position;\n"
-        "    index = dot(location.xy - gradientStart, gradient) * gradientLength;\n",
+        "    index = (screenSpace * position).x;\n",
         // Circular
-        "    vec4 location = screenSpace * position;\n"
-        "    circular = (gradientMatrix * vec4(location.xy - gradientStart, 0.0, 0.0)).xy;\n",
+        "    circular = (screenSpace * position).xy;\n",
         // Sweep
-        "    vec4 location = screenSpace * position;\n"
-        "    sweep = (gradientMatrix * vec4(location.xy - gradientStart, 0.0, 0.0)).xy;\n"
+        "    sweep = (screenSpace * position).xy;\n"
 };
 const char* gVS_Main_OutBitmapTexCoords =
         "    vec4 bitmapCoords = textureTransform * position;\n"
@@ -102,7 +92,6 @@
         // Linear
         "uniform sampler2D gradientSampler;\n",
         // Circular
-        "uniform float gradientRadius;\n"
         "uniform sampler2D gradientSampler;\n",
         // Sweep
         "uniform sampler2D gradientSampler;\n"
@@ -134,7 +123,7 @@
         // Linear
         "    vec4 gradientColor = texture2D(gradientSampler, vec2(index, 0.5));\n",
         // Circular
-        "    float index = length(circular) * gradientRadius;\n"
+        "    float index = length(circular);\n"
         "    vec4 gradientColor = texture2D(gradientSampler, vec2(index, 0.5));\n",
         // Sweep
         "    float index = atan(sweep.y, sweep.x) * 0.15915494309; // inv(2 * PI)\n"
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp
index 165c0da..fa85d20 100644
--- a/libs/hwui/SkiaShader.cpp
+++ b/libs/hwui/SkiaShader.cpp
@@ -49,7 +49,8 @@
 
 SkiaShader::SkiaShader(Type type, SkShader* key, SkShader::TileMode tileX,
         SkShader::TileMode tileY, SkMatrix* matrix, bool blend):
-        mType(type), mKey(key), mTileX(tileX), mTileY(tileY), mMatrix(matrix), mBlend(blend) {
+        mType(type), mKey(key), mTileX(tileX), mTileY(tileY), mBlend(blend) {
+    setMatrix(matrix);
 }
 
 SkiaShader::~SkiaShader() {
@@ -69,6 +70,11 @@
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT);
 }
 
+void SkiaShader::computeScreenSpaceMatrix(mat4& screenSpace, const mat4& modelView) {
+    screenSpace.loadMultiply(mUnitMatrix, mShaderMatrix);
+    screenSpace.multiply(modelView);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // Bitmap shader
 ///////////////////////////////////////////////////////////////////////////////
@@ -76,6 +82,7 @@
 SkiaBitmapShader::SkiaBitmapShader(SkBitmap* bitmap, SkShader* key, SkShader::TileMode tileX,
         SkShader::TileMode tileY, SkMatrix* matrix, bool blend):
         SkiaShader(kBitmap, key, tileX, tileY, matrix, blend), mBitmap(bitmap), mTexture(NULL) {
+    updateLocalMatrix(matrix);
 }
 
 void SkiaBitmapShader::describe(ProgramDescription& description, const Extensions& extensions) {
@@ -116,14 +123,7 @@
     const float height = texture->height;
 
     mat4 textureTransform;
-    if (mMatrix) {
-        SkMatrix inverse;
-        mMatrix->invert(&inverse);
-        textureTransform.load(inverse);
-        textureTransform.multiply(modelView);
-    } else {
-        textureTransform.load(modelView);
-    }
+    computeScreenSpaceMatrix(textureTransform, modelView);
 
     // Uniforms
     bindTexture(texture->id, mWrapS, mWrapT, textureSlot);
@@ -136,15 +136,7 @@
 void SkiaBitmapShader::updateTransforms(Program* program, const mat4& modelView,
         const Snapshot& snapshot) {
     mat4 textureTransform;
-    if (mMatrix) {
-        SkMatrix inverse;
-        mMatrix->invert(&inverse);
-        textureTransform.load(inverse);
-        textureTransform.multiply(modelView);
-    } else {
-        textureTransform.load(modelView);
-    }
-
+    computeScreenSpaceMatrix(textureTransform, modelView);
     glUniformMatrix4fv(program->getUniform("textureTransform"), 1,
             GL_FALSE, &textureTransform.data[0]);
 }
@@ -153,11 +145,31 @@
 // Linear gradient shader
 ///////////////////////////////////////////////////////////////////////////////
 
+static void toUnitMatrix(const SkPoint pts[2], SkMatrix* matrix) {
+    SkVector vec = pts[1] - pts[0];
+    const float mag = vec.length();
+    const float inv = mag ? 1.0f / mag : 0;
+
+    vec.scale(inv);
+    matrix->setSinCos(-vec.fY, vec.fX, pts[0].fX, pts[0].fY);
+    matrix->postTranslate(-pts[0].fX, -pts[0].fY);
+    matrix->postScale(inv, inv);
+}
+
 SkiaLinearGradientShader::SkiaLinearGradientShader(float* bounds, uint32_t* colors,
         float* positions, int count, SkShader* key, SkShader::TileMode tileMode,
         SkMatrix* matrix, bool blend):
         SkiaShader(kLinearGradient, key, tileMode, tileMode, matrix, blend),
         mBounds(bounds), mColors(colors), mPositions(positions), mCount(count) {
+    SkPoint points[2];
+    points[0].set(bounds[0], bounds[1]);
+    points[1].set(bounds[2], bounds[3]);
+
+    SkMatrix unitMatrix;
+    toUnitMatrix(points, &unitMatrix);
+    mUnitMatrix.load(unitMatrix);
+
+    updateLocalMatrix(matrix);
 }
 
 SkiaLinearGradientShader::~SkiaLinearGradientShader() {
@@ -182,34 +194,19 @@
         texture = mGradientCache->addLinearGradient(mKey, mColors, mPositions, mCount, mTileX);
     }
 
-    Rect start(mBounds[0], mBounds[1], mBounds[2], mBounds[3]);
-    if (mMatrix) {
-        mat4 shaderMatrix(*mMatrix);
-        shaderMatrix.mapPoint(start.left, start.top);
-        shaderMatrix.mapPoint(start.right, start.bottom);
-    }
-    snapshot.transform->mapRect(start);
-
-    const float gradientX = start.right - start.left;
-    const float gradientY = start.bottom - start.top;
-
-    mat4 screenSpace(*snapshot.transform);
-    screenSpace.multiply(modelView);
+    mat4 screenSpace;
+    computeScreenSpaceMatrix(screenSpace, modelView);
 
     // Uniforms
     bindTexture(texture->id, gTileModes[mTileX], gTileModes[mTileY], textureSlot);
     glUniform1i(program->getUniform("gradientSampler"), textureSlot);
-    glUniform2f(program->getUniform("gradientStart"), start.left, start.top);
-    glUniform2f(program->getUniform("gradient"), gradientX, gradientY);
-    glUniform1f(program->getUniform("gradientLength"),
-            1.0f / (gradientX * gradientX + gradientY * gradientY));
     glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
 }
 
 void SkiaLinearGradientShader::updateTransforms(Program* program, const mat4& modelView,
         const Snapshot& snapshot) {
-    mat4 screenSpace(*snapshot.transform);
-    screenSpace.multiply(modelView);
+    mat4 screenSpace;
+    computeScreenSpaceMatrix(screenSpace, modelView);
     glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
 }
 
@@ -217,12 +214,23 @@
 // Circular gradient shader
 ///////////////////////////////////////////////////////////////////////////////
 
+static void toCircularUnitMatrix(const float x, const float y, const float radius,
+        SkMatrix* matrix) {
+    const float inv = 1.0f / radius;
+    matrix->setTranslate(-x, -y);
+    matrix->postScale(inv, inv);
+}
+
 SkiaCircularGradientShader::SkiaCircularGradientShader(float x, float y, float radius,
         uint32_t* colors, float* positions, int count, SkShader* key, SkShader::TileMode tileMode,
         SkMatrix* matrix, bool blend):
         SkiaSweepGradientShader(kCircularGradient, x, y, colors, positions, count, key,
-                tileMode, matrix, blend),
-        mRadius(radius) {
+                tileMode, matrix, blend) {
+    SkMatrix unitMatrix;
+    toCircularUnitMatrix(x, y, radius, &unitMatrix);
+    mUnitMatrix.load(unitMatrix);
+
+    updateLocalMatrix(matrix);
 }
 
 void SkiaCircularGradientShader::describe(ProgramDescription& description,
@@ -231,28 +239,31 @@
     description.gradientType = ProgramDescription::kGradientCircular;
 }
 
-void SkiaCircularGradientShader::setupProgram(Program* program, const mat4& modelView,
-        const Snapshot& snapshot, GLuint* textureUnit) {
-    SkiaSweepGradientShader::setupProgram(program, modelView, snapshot, textureUnit);
-    glUniform1f(program->getUniform("gradientRadius"), 1.0f / mRadius);
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 // Sweep gradient shader
 ///////////////////////////////////////////////////////////////////////////////
 
+static void toSweepUnitMatrix(const float x, const float y, SkMatrix* matrix) {
+    matrix->setTranslate(-x, -y);
+}
+
 SkiaSweepGradientShader::SkiaSweepGradientShader(float x, float y, uint32_t* colors,
         float* positions, int count, SkShader* key, SkMatrix* matrix, bool blend):
         SkiaShader(kSweepGradient, key, SkShader::kClamp_TileMode,
                 SkShader::kClamp_TileMode, matrix, blend),
-        mX(x), mY(y), mColors(colors), mPositions(positions), mCount(count) {
+        mColors(colors), mPositions(positions), mCount(count) {
+    SkMatrix unitMatrix;
+    toSweepUnitMatrix(x, y, &unitMatrix);
+    mUnitMatrix.load(unitMatrix);
+
+    updateLocalMatrix(matrix);
 }
 
 SkiaSweepGradientShader::SkiaSweepGradientShader(Type type, float x, float y, uint32_t* colors,
         float* positions, int count, SkShader* key, SkShader::TileMode tileMode,
         SkMatrix* matrix, bool blend):
         SkiaShader(type, key, tileMode, tileMode, matrix, blend),
-        mX(x), mY(y), mColors(colors), mPositions(positions), mCount(count) {
+        mColors(colors), mPositions(positions), mCount(count) {
 }
 
 SkiaSweepGradientShader::~SkiaSweepGradientShader() {
@@ -276,35 +287,19 @@
         texture = mGradientCache->addLinearGradient(mKey, mColors, mPositions, mCount);
     }
 
-    float left = mX;
-    float top = mY;
-
-    mat4 shaderMatrix;
-    if (mMatrix) {
-        shaderMatrix.load(*mMatrix);
-        shaderMatrix.mapPoint(left, top);
-    }
-
-    mat4 copy(shaderMatrix);
-    shaderMatrix.loadInverse(copy);
-
-    snapshot.transform->mapPoint(left, top);
-
-    mat4 screenSpace(*snapshot.transform);
-    screenSpace.multiply(modelView);
+    mat4 screenSpace;
+    computeScreenSpaceMatrix(screenSpace, modelView);
 
     // Uniforms
     bindTexture(texture->id, gTileModes[mTileX], gTileModes[mTileY], textureSlot);
     glUniform1i(program->getUniform("gradientSampler"), textureSlot);
-    glUniformMatrix4fv(program->getUniform("gradientMatrix"), 1, GL_FALSE, &shaderMatrix.data[0]);
-    glUniform2f(program->getUniform("gradientStart"), left, top);
     glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
 }
 
 void SkiaSweepGradientShader::updateTransforms(Program* program, const mat4& modelView,
         const Snapshot& snapshot) {
-    mat4 screenSpace(*snapshot.transform);
-    screenSpace.multiply(modelView);
+    mat4 screenSpace;
+    computeScreenSpaceMatrix(screenSpace, modelView);
     glUniformMatrix4fv(program->getUniform("screenSpace"), 1, GL_FALSE, &screenSpace.data[0]);
 }
 
diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h
index 9f8778f..2565e65 100644
--- a/libs/hwui/SkiaShader.h
+++ b/libs/hwui/SkiaShader.h
@@ -78,9 +78,20 @@
     }
 
     void setMatrix(SkMatrix* matrix) {
-        mMatrix = matrix;
+        updateLocalMatrix(matrix);
     }
 
+    void updateLocalMatrix(const SkMatrix* matrix) {
+        if (matrix) {
+            mat4 localMatrix(*matrix);
+            mShaderMatrix.loadInverse(localMatrix);
+        } else {
+            mShaderMatrix.loadIdentity();
+        }
+    }
+
+    void computeScreenSpaceMatrix(mat4& screenSpace, const mat4& modelView);
+
 protected:
     inline void bindTexture(GLuint texture, GLenum wrapS, GLenum wrapT, GLuint textureUnit);
 
@@ -88,11 +99,13 @@
     SkShader* mKey;
     SkShader::TileMode mTileX;
     SkShader::TileMode mTileY;
-    SkMatrix* mMatrix;
     bool mBlend;
 
     TextureCache* mTextureCache;
     GradientCache* mGradientCache;
+
+    mat4 mUnitMatrix;
+    mat4 mShaderMatrix;
 }; // struct SkiaShader
 
 
@@ -155,7 +168,7 @@
     ~SkiaSweepGradientShader();
 
     virtual void describe(ProgramDescription& description, const Extensions& extensions);
-    virtual void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot,
+    void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot,
             GLuint* textureUnit);
     void updateTransforms(Program* program, const mat4& modelView, const Snapshot& snapshot);
 
@@ -163,7 +176,6 @@
     SkiaSweepGradientShader(Type type, float x, float y, uint32_t* colors, float* positions,
             int count, SkShader* key, SkShader::TileMode tileMode, SkMatrix* matrix, bool blend);
 
-    float mX, mY;
     uint32_t* mColors;
     float* mPositions;
     int mCount;
@@ -177,11 +189,6 @@
             int count, SkShader* key,SkShader::TileMode tileMode, SkMatrix* matrix, bool blend);
 
     void describe(ProgramDescription& description, const Extensions& extensions);
-    void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot,
-            GLuint* textureUnit);
-
-private:
-    float mRadius;
 }; // struct SkiaCircularGradientShader
 
 /**
diff --git a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
index 5312bcc..012af9c 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
+++ b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
@@ -2,15 +2,21 @@
 
 #pragma rs export_func(primitives_test)
 
+#pragma rs export_var(floatTest, doubleTest, charTest, shortTest, intTest, longTest, longlongTest)
+
 // Testing primitive types
 static float floatTest = 1.99f;
 static double doubleTest = 2.05;
 static char charTest = -8;
 static short shortTest = -16;
 static int intTest = -32;
+static long longTest = 17179869184l; // 1 << 34
+static long long longlongTest = 68719476736l; // 1 << 36
+
 static uchar ucharTest = 8;
 static ushort ushortTest = 16;
 static uint uintTest = 32;
+static int64_t int64_tTest = -17179869184l; // - 1 << 34
 
 static bool test_primitive_types(uint32_t index) {
     bool failed = false;
@@ -21,9 +27,13 @@
     _RS_ASSERT(charTest == -8);
     _RS_ASSERT(shortTest == -16);
     _RS_ASSERT(intTest == -32);
+    _RS_ASSERT(longTest == 17179869184l);
+    _RS_ASSERT(longlongTest == 68719476736l);
+
     _RS_ASSERT(ucharTest == 8);
     _RS_ASSERT(ushortTest == 16);
     _RS_ASSERT(uintTest == 32);
+    _RS_ASSERT(int64_tTest == -17179869184l);
 
     float time = end(index);
 
diff --git a/libs/rs/scriptc/rs_core.rsh b/libs/rs/scriptc/rs_core.rsh
index 99fc166..9950184 100644
--- a/libs/rs/scriptc/rs_core.rsh
+++ b/libs/rs/scriptc/rs_core.rsh
@@ -1,6 +1,30 @@
 #ifndef __RS_CORE_RSH__
 #define __RS_CORE_RSH__
 
+// Debugging, print to the LOG a description string and a value.
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float, float);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float, float, float);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float, float, float, float);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const rs_matrix4x4 *);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const rs_matrix3x3 *);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const rs_matrix2x2 *);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, int);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, uint);
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const void *);
+#define RS_DEBUG(a) rsDebug(#a, a)
+#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
+
 static void __attribute__((overloadable)) rsDebug(const char *s, float2 v) {
     rsDebug(s, v.x, v.y);
 }
diff --git a/libs/rs/scriptc/rs_math.rsh b/libs/rs/scriptc/rs_math.rsh
index 5720b05..d059997 100644
--- a/libs/rs/scriptc/rs_math.rsh
+++ b/libs/rs/scriptc/rs_math.rsh
@@ -1,34 +1,6 @@
 #ifndef __RS_MATH_RSH__
 #define __RS_MATH_RSH__
 
-// Debugging, print to the LOG a description string and a value.
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float, float);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float, float, float);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float, float, float, float);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const rs_matrix4x4 *);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const rs_matrix3x3 *);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const rs_matrix2x2 *);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, int);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, uint);
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const void *);
-#define RS_DEBUG(a) rsDebug(#a, a)
-#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
-
-
-#include "rs_cl.rsh"
-#include "rs_core.rsh"
-
 extern void __attribute__((overloadable))
     rsSetObject(rs_element *dst, rs_element src);
 extern void __attribute__((overloadable))
diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh
index dd42972..212eb83 100644
--- a/libs/rs/scriptc/rs_types.rsh
+++ b/libs/rs/scriptc/rs_types.rsh
@@ -1,3 +1,5 @@
+#ifndef __RS_TYPES_RSH__
+#define __RS_TYPES_RSH__
 
 typedef char int8_t;
 typedef short int16_t;
@@ -72,3 +74,4 @@
 
 #define RS_PACKED __attribute__((packed, aligned(4)))
 
+#endif
diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp
index a43b4402..8f583f06 100644
--- a/libs/surfaceflinger_client/SharedBufferStack.cpp
+++ b/libs/surfaceflinger_client/SharedBufferStack.cpp
@@ -285,10 +285,12 @@
     return NO_ERROR;
 }
 
-SharedBufferClient::UndoDequeueUpdate::UndoDequeueUpdate(SharedBufferBase* sbb)
-    : UpdateBase(sbb) {    
+SharedBufferClient::CancelUpdate::CancelUpdate(SharedBufferBase* sbb,
+        int tail, int buf)
+    : UpdateBase(sbb), tail(tail), buf(buf) {
 }
-ssize_t SharedBufferClient::UndoDequeueUpdate::operator()() {
+ssize_t SharedBufferClient::CancelUpdate::operator()() {
+    stack.index[tail] = buf;
     android_atomic_inc(&stack.available);
     return NO_ERROR;
 }
@@ -319,7 +321,7 @@
         return BAD_VALUE;
 
     // Preventively lock the current buffer before updating queued.
-    android_atomic_write(stack.index[head], &stack.inUse);
+    android_atomic_write(stack.headBuf, &stack.inUse);
 
     // Decrement the number of queued buffers 
     int32_t queued;
@@ -334,7 +336,9 @@
     // the buffer we preventively locked upon entering this function
 
     head = (head + 1) % numBuffers;
-    android_atomic_write(stack.index[head], &stack.inUse);
+    const int8_t headBuf = stack.index[head];
+    stack.headBuf = headBuf;
+    android_atomic_write(headBuf, &stack.inUse);
 
     // head is only modified here, so we don't need to use cmpxchg
     android_atomic_write(head, &stack.head);
@@ -359,7 +363,7 @@
 SharedBufferClient::SharedBufferClient(SharedClient* sharedClient,
         int surface, int num, int32_t identity)
     : SharedBufferBase(sharedClient, surface, identity),
-      mNumBuffers(num), tail(0), undoDequeueTail(0)
+      mNumBuffers(num), tail(0)
 {
     SharedBufferStack& stack( *mSharedStack );
     tail = computeTail();
@@ -390,7 +394,6 @@
     DequeueUpdate update(this);
     updateCondition( update );
 
-    undoDequeueTail = tail;
     int dequeued = stack.index[tail];
     tail = ((tail+1 >= mNumBuffers) ? 0 : tail+1);
     LOGD_IF(DEBUG_ATOMICS, "dequeued=%d, tail++=%d, %s",
@@ -403,14 +406,19 @@
 
 status_t SharedBufferClient::undoDequeue(int buf)
 {
+    return cancel(buf);
+}
+
+status_t SharedBufferClient::cancel(int buf)
+{
     RWLock::AutoRLock _rd(mLock);
 
-    // TODO: we can only undo the previous dequeue, we should
-    // enforce that in the api
-    UndoDequeueUpdate update(this);
+    // calculate the new position of the tail index (essentially tail--)
+    int localTail = (tail + mNumBuffers - 1) % mNumBuffers;
+    CancelUpdate update(this, localTail, buf);
     status_t err = updateCondition( update );
     if (err == NO_ERROR) {
-        tail = undoDequeueTail;
+        tail = localTail;
     }
     return err;
 }
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index c77d48e..ebb0cc9 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -416,6 +416,7 @@
 {
     ANativeWindow::setSwapInterval  = setSwapInterval;
     ANativeWindow::dequeueBuffer    = dequeueBuffer;
+    ANativeWindow::cancelBuffer     = cancelBuffer;
     ANativeWindow::lockBuffer       = lockBuffer;
     ANativeWindow::queueBuffer      = queueBuffer;
     ANativeWindow::query            = query;
@@ -527,6 +528,12 @@
     return self->dequeueBuffer(buffer);
 }
 
+int Surface::cancelBuffer(ANativeWindow* window,
+        android_native_buffer_t* buffer) {
+    Surface* self = getSelf(window);
+    return self->cancelBuffer(buffer);
+}
+
 int Surface::lockBuffer(ANativeWindow* window, 
         android_native_buffer_t* buffer) {
     Surface* self = getSelf(window);
@@ -627,6 +634,33 @@
     return err;
 }
 
+int Surface::cancelBuffer(android_native_buffer_t* buffer)
+{
+    status_t err = validate();
+    switch (err) {
+    case NO_ERROR:
+        // no error, common case
+        break;
+    case INVALID_OPERATION:
+        // legitimate errors here
+        return err;
+    default:
+        // other errors happen because the surface is now invalid,
+        // for instance because it has been destroyed. In this case,
+        // we just fail silently (canceling a buffer is not technically
+        // an error at this point)
+        return NO_ERROR;
+    }
+
+    int32_t bufIdx = getBufferIndex(GraphicBuffer::getSelf(buffer));
+
+    err = mSharedBufferClient->cancel(bufIdx);
+
+    LOGE_IF(err, "error canceling buffer %d (%s)", bufIdx, strerror(-err));
+    return err;
+}
+
+
 int Surface::lockBuffer(android_native_buffer_t* buffer)
 {
     status_t err = validate();
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index a6f5a1b..75b2294 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -134,18 +134,21 @@
 
 // --- InputWindow ---
 
-bool InputWindow::visibleFrameIntersects(const InputWindow* other) const {
-    return visibleFrameRight > other->visibleFrameLeft
-        && visibleFrameLeft < other->visibleFrameRight
-        && visibleFrameBottom > other->visibleFrameTop
-        && visibleFrameTop < other->visibleFrameBottom;
-}
-
 bool InputWindow::touchableAreaContainsPoint(int32_t x, int32_t y) const {
     return x >= touchableAreaLeft && x <= touchableAreaRight
             && y >= touchableAreaTop && y <= touchableAreaBottom;
 }
 
+bool InputWindow::frameContainsPoint(int32_t x, int32_t y) const {
+    return x >= frameLeft && x <= frameRight
+            && y >= frameTop && y <= frameBottom;
+}
+
+bool InputWindow::isTrustedOverlay() const {
+    return layoutParamsType == TYPE_INPUT_METHOD
+            || layoutParamsType == TYPE_INPUT_METHOD_DIALOG;
+}
+
 
 // --- InputDispatcher ---
 
@@ -1053,8 +1056,12 @@
 
                 if (maskedAction == AMOTION_EVENT_ACTION_DOWN
                         && (flags & InputWindow::FLAG_WATCH_OUTSIDE_TOUCH)) {
-                    mTempTouchState.addOrUpdateWindow(window,
-                            InputTarget::FLAG_OUTSIDE, BitSet32(0));
+                    int32_t outsideTargetFlags = InputTarget::FLAG_OUTSIDE;
+                    if (isWindowObscuredAtPointLocked(window, x, y)) {
+                        outsideTargetFlags |= InputTarget::FLAG_WINDOW_IS_OBSCURED;
+                    }
+
+                    mTempTouchState.addOrUpdateWindow(window, outsideTargetFlags, BitSet32(0));
                 }
             }
         }
@@ -1083,10 +1090,6 @@
             // (May be NULL which is why we put this code block before the next check.)
             newTouchedWindow = mTempTouchState.getFirstForegroundWindow();
         }
-        int32_t targetFlags = InputTarget::FLAG_FOREGROUND;
-        if (isSplit) {
-            targetFlags |= InputTarget::FLAG_SPLIT;
-        }
 
         // If we did not find a touched window then fail.
         if (! newTouchedWindow) {
@@ -1106,6 +1109,15 @@
             goto Failed;
         }
 
+        // Set target flags.
+        int32_t targetFlags = InputTarget::FLAG_FOREGROUND;
+        if (isSplit) {
+            targetFlags |= InputTarget::FLAG_SPLIT;
+        }
+        if (isWindowObscuredAtPointLocked(newTouchedWindow, x, y)) {
+            targetFlags |= InputTarget::FLAG_WINDOW_IS_OBSCURED;
+        }
+
         // Update the temporary touch state.
         BitSet32 pointerIds;
         if (isSplit) {
@@ -1186,23 +1198,13 @@
             for (size_t i = 0; i < mWindows.size(); i++) {
                 const InputWindow* window = & mWindows[i];
                 if (window->layoutParamsType == InputWindow::TYPE_WALLPAPER) {
-                    mTempTouchState.addOrUpdateWindow(window, 0, BitSet32(0));
+                    mTempTouchState.addOrUpdateWindow(window,
+                            InputTarget::FLAG_WINDOW_IS_OBSCURED, BitSet32(0));
                 }
             }
         }
     }
 
-    // If a touched window has been obscured at any point during the touch gesture, set
-    // the appropriate flag so we remember it for the entire gesture.
-    for (size_t i = 0; i < mTempTouchState.windows.size(); i++) {
-        TouchedWindow& touchedWindow = mTempTouchState.windows.editItemAt(i);
-        if ((touchedWindow.targetFlags & InputTarget::FLAG_WINDOW_IS_OBSCURED) == 0) {
-            if (isWindowObscuredLocked(touchedWindow.window)) {
-                touchedWindow.targetFlags |= InputTarget::FLAG_WINDOW_IS_OBSCURED;
-            }
-        }
-    }
-
     // Success!  Output targets.
     injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED;
 
@@ -1326,14 +1328,15 @@
     return true;
 }
 
-bool InputDispatcher::isWindowObscuredLocked(const InputWindow* window) {
+bool InputDispatcher::isWindowObscuredAtPointLocked(
+        const InputWindow* window, int32_t x, int32_t y) const {
     size_t numWindows = mWindows.size();
     for (size_t i = 0; i < numWindows; i++) {
         const InputWindow* other = & mWindows.itemAt(i);
         if (other == window) {
             break;
         }
-        if (other->visible && window->visibleFrameIntersects(other)) {
+        if (other->visible && ! other->isTrustedOverlay() && other->frameContainsPoint(x, y)) {
             return true;
         }
     }
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index bc5f9fa..e5fa0f8 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -117,6 +117,10 @@
             Files.FileColumns.DATE_MODIFIED, // 3
     };
 
+    private static final String[] ID_PROJECTION = new String[] {
+            Files.FileColumns._ID,
+    };
+
     private static final int FILES_PRESCAN_ID_COLUMN_INDEX = 0;
     private static final int FILES_PRESCAN_PATH_COLUMN_INDEX = 1;
     private static final int FILES_PRESCAN_FORMAT_COLUMN_INDEX = 2;
@@ -933,6 +937,14 @@
                 c.close();
             }
         }
+
+        // compute original size of images
+        mOriginalCount = 0;
+        c = mMediaProvider.query(mImagesUri, ID_PROJECTION, null, null, null);
+        if (c != null) {
+            mOriginalCount = c.getCount();
+            c.close();
+        }
     }
 
     private boolean inScanDirectory(String path, String[] directories) {
diff --git a/media/java/android/media/MtpCursor.java b/media/java/android/media/MtpCursor.java
index ff8799a..9b5ab95 100644
--- a/media/java/android/media/MtpCursor.java
+++ b/media/java/android/media/MtpCursor.java
@@ -50,6 +50,9 @@
 
     public MtpCursor(MtpClient client, int queryType, int deviceID, long storageID, long objectID,
             String[] projection) {
+        if (client == null) {
+            throw new NullPointerException("client null in MtpCursor constructor");
+        }
         mColumns = projection;
 
         HashMap<String, Integer> map;
diff --git a/media/java/android/media/videoeditor/AudioTrack.java b/media/java/android/media/videoeditor/AudioTrack.java
index 3ebad00..076cc31 100755
--- a/media/java/android/media/videoeditor/AudioTrack.java
+++ b/media/java/android/media/videoeditor/AudioTrack.java
@@ -18,17 +18,12 @@
 

 import java.io.IOException;

 

-import android.util.Log;

-

 /**

  * This class allows to handle an audio track. This audio file is mixed with the

  * audio samples of the MediaItems.

  * {@hide}

  */

 public class AudioTrack {

-    // Logging

-    private static final String TAG = "AudioTrack";

-

     // Instance variables

     private final String mUniqueId;

     private final String mFilename;

@@ -53,129 +48,6 @@
 

     // The audio waveform filename

     private String mAudioWaveformFilename;

-    private PlaybackThread mPlaybackThread;

-

-    /**

-     * This listener interface is used by the AudioTrack to emit playback

-     * progress notifications.

-     */

-    public interface PlaybackProgressListener {

-        /**

-         * This method notifies the listener of the current time position while

-         * playing an audio track

-         *

-         * @param audioTrack The audio track

-         * @param timeMs The current playback position (expressed in milliseconds

-         *            since the beginning of the audio track).

-         * @param end true if the end of the audio track was reached

-         */

-        public void onProgress(AudioTrack audioTrack, long timeMs, boolean end);

-    }

-

-    /**

-     * The playback thread

-     */

-    private class PlaybackThread extends Thread {

-        // Instance variables

-        private final PlaybackProgressListener mListener;

-        private final long mFromMs, mToMs;

-        private boolean mRun;

-        private final boolean mLoop;

-        private long mPositionMs;

-

-        /**

-         * Constructor

-         *

-         * @param fromMs The time (relative to the beginning of the audio track)

-         *            at which the playback will start

-         * @param toMs The time (relative to the beginning of the audio track) at

-         *            which the playback will stop. Use -1 to play to the end of

-         *            the audio track

-         * @param loop true if the playback should be looped once it reaches the

-         *            end

-         * @param listener The listener which will be notified of the playback

-         *            progress

-         */

-        public PlaybackThread(long fromMs, long toMs, boolean loop,

-                PlaybackProgressListener listener) {

-            mPositionMs = mFromMs = fromMs;

-            if (toMs < 0) {

-                mToMs = mDurationMs;

-            } else {

-                mToMs = toMs;

-            }

-            mLoop = loop;

-            mListener = listener;

-            mRun = true;

-        }

-

-        /*

-         * {@inheritDoc}

-         */

-        @Override

-        public void run() {

-            if (Log.isLoggable(TAG, Log.DEBUG)) {

-                Log.d(TAG, "===> PlaybackThread.run enter");

-            }

-

-            while (mRun) {

-                try {

-                    sleep(100);

-                } catch (InterruptedException ex) {

-                    break;

-                }

-

-                mPositionMs += 100;

-

-                if (mPositionMs >= mToMs) {

-                    if (!mLoop) {

-                        if (mListener != null) {

-                            mListener.onProgress(AudioTrack.this, mPositionMs, true);

-                        }

-                        if (Log.isLoggable(TAG, Log.DEBUG)) {

-                            Log.d(TAG, "PlaybackThread.run playback complete");

-                        }

-                        break;

-                    } else {

-                        // Fire a notification for the end of the clip

-                        if (mListener != null) {

-                            mListener.onProgress(AudioTrack.this, mToMs, false);

-                        }

-

-                        // Rewind

-                        mPositionMs = mFromMs;

-                        if (mListener != null) {

-                            mListener.onProgress(AudioTrack.this, mPositionMs, false);

-                        }

-                        if (Log.isLoggable(TAG, Log.DEBUG)) {

-                            Log.d(TAG, "PlaybackThread.run playback complete");

-                        }

-                    }

-                } else {

-                    if (mListener != null) {

-                        mListener.onProgress(AudioTrack.this, mPositionMs, false);

-                    }

-                }

-            }

-            if (Log.isLoggable(TAG, Log.DEBUG)) {

-                Log.d(TAG, "===> PlaybackThread.run exit");

-            }

-        }

-

-        /**

-         * Stop the playback

-         *

-         * @return The stop position

-         */

-        public long stopPlayback() {

-            mRun = false;

-            try {

-                join();

-            } catch (InterruptedException ex) {

-            }

-            return mPositionMs;

-        }

-    };

 

     /**

      * An object of this type cannot be instantiated by using the default

@@ -509,50 +381,6 @@
     }

 

     /**

-     * Start the playback of this audio track. This method does not block (does

-     * not wait for the playback to complete).

-     *

-     * @param fromMs The time (relative to the beginning of the audio track) at

-     *            which the playback will start

-     * @param toMs The time (relative to the beginning of the audio track) at

-     *            which the playback will stop. Use -1 to play to the end of the

-     *            audio track

-     * @param loop true if the playback should be looped once it reaches the end

-     * @param listener The listener which will be notified of the playback

-     *            progress

-     * @throws IllegalArgumentException if fromMs or toMs is beyond the playback

-     *             duration

-     * @throws IllegalStateException if a playback, preview or an export is

-     *             already in progress

-     */

-    public void startPlayback(long fromMs, long toMs, boolean loop,

-            PlaybackProgressListener listener) {

-        if (fromMs >= mDurationMs) {

-            return;

-        }

-        mPlaybackThread = new PlaybackThread(fromMs, toMs, loop, listener);

-        mPlaybackThread.start();

-    }

-

-    /**

-     * Stop the audio track playback. This method blocks until the ongoing

-     * playback is stopped.

-     *

-     * @return The accurate current time when stop is effective expressed in

-     *         milliseconds

-     */

-    public long stopPlayback() {

-        final long stopTimeMs;

-        if (mPlaybackThread != null) {

-            stopTimeMs = mPlaybackThread.stopPlayback();

-            mPlaybackThread = null;

-        } else {

-            stopTimeMs = 0;

-        }

-        return stopTimeMs;

-    }

-

-    /**

      * This API allows to generate a file containing the sample volume levels of

      * this audio track object. This function may take significant time and is

      * blocking. The filename can be retrieved using getAudioWaveformFilename().

diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java
index dd12336..f71f4f4 100755
--- a/media/java/android/media/videoeditor/MediaVideoItem.java
+++ b/media/java/android/media/videoeditor/MediaVideoItem.java
@@ -19,7 +19,6 @@
 import java.io.IOException;

 

 import android.graphics.Bitmap;

-import android.util.Log;

 import android.view.SurfaceHolder;

 

 /**

@@ -27,9 +26,6 @@
  * {@hide}

  */

 public class MediaVideoItem extends MediaItem {

-    // Logging

-    private static final String TAG = "MediaVideoItem";

-

     // Instance variables

     private final int mWidth;

     private final int mHeight;

@@ -50,142 +46,6 @@
     private int mVolumePercentage;

     private boolean mMuted;

     private String mAudioWaveformFilename;

-    private PlaybackThread mPlaybackThread;

-

-    /**

-     * This listener interface is used by the MediaVideoItem to emit playback

-     * progress notifications. This callback should be invoked after the

-     * number of frames specified by

-     * {@link #startPlayback(SurfaceHolder surfaceHolder, long fromMs,

-     *           int callbackAfterFrameCount, PlaybackProgressListener listener)}

-     */

-    public interface PlaybackProgressListener {

-        /**

-         * This method notifies the listener of the current time position while

-         * playing a media item

-         *

-         * @param mediaItem The media item

-         * @param timeMs The current playback position (expressed in milliseconds

-         *            since the beginning of the media item).

-         * @param end true if the end of the media item was reached

-         */

-        public void onProgress(MediaVideoItem mediaItem, long timeMs, boolean end);

-    }

-

-    /**

-     * The playback thread

-     */

-    private class PlaybackThread extends Thread {

-        // Instance variables

-        private final static long FRAME_DURATION = 33;

-        private final PlaybackProgressListener mListener;

-        private final int mCallbackAfterFrameCount;

-        private final long mFromMs, mToMs;

-        private boolean mRun;

-        private final boolean mLoop;

-        private long mPositionMs;

-

-        /**

-         * Constructor

-         *

-         * @param fromMs The time (relative to the beginning of the media item)

-         *            at which the playback will start

-         * @param toMs The time (relative to the beginning of the media item) at

-         *            which the playback will stop. Use -1 to play to the end of

-         *            the media item

-         * @param loop true if the playback should be looped once it reaches the

-         *            end

-         * @param callbackAfterFrameCount The listener interface should be

-         *            invoked after the number of frames specified by this

-         *            parameter.

-         * @param listener The listener which will be notified of the playback

-         *            progress

-         */

-        public PlaybackThread(long fromMs, long toMs, boolean loop, int callbackAfterFrameCount,

-                PlaybackProgressListener listener) {

-            mPositionMs = mFromMs = fromMs;

-            if (toMs < 0) {

-                mToMs = mDurationMs;

-            } else {

-                mToMs = toMs;

-            }

-            mLoop = loop;

-            mCallbackAfterFrameCount = callbackAfterFrameCount;

-            mListener = listener;

-            mRun = true;

-        }

-

-        /*

-         * {@inheritDoc}

-         */

-        @Override

-        public void run() {

-            if (Log.isLoggable(TAG, Log.DEBUG)) {

-                Log.d(TAG, "===> PlaybackThread.run enter");

-            }

-            int frameCount = 0;

-            while (mRun) {

-                try {

-                    sleep(FRAME_DURATION);

-                } catch (InterruptedException ex) {

-                    break;

-                }

-                frameCount++;

-                mPositionMs += FRAME_DURATION;

-

-                if (mPositionMs >= mToMs) {

-                    if (!mLoop) {

-                        if (mListener != null) {

-                            mListener.onProgress(MediaVideoItem.this, mPositionMs, true);

-                        }

-                        if (Log.isLoggable(TAG, Log.DEBUG)) {

-                            Log.d(TAG, "PlaybackThread.run playback complete");

-                        }

-                        break;

-                    } else {

-                        // Fire a notification for the end of the clip

-                        if (mListener != null) {

-                            mListener.onProgress(MediaVideoItem.this, mToMs, false);

-                        }

-

-                        // Rewind

-                        mPositionMs = mFromMs;

-                        if (mListener != null) {

-                            mListener.onProgress(MediaVideoItem.this, mPositionMs, false);

-                        }

-                        if (Log.isLoggable(TAG, Log.DEBUG)) {

-                            Log.d(TAG, "PlaybackThread.run playback complete");

-                        }

-                        frameCount = 0;

-                    }

-                } else {

-                    if (frameCount == mCallbackAfterFrameCount) {

-                        if (mListener != null) {

-                            mListener.onProgress(MediaVideoItem.this, mPositionMs, false);

-                        }

-                        frameCount = 0;

-                    }

-                }

-            }

-            if (Log.isLoggable(TAG, Log.DEBUG)) {

-                Log.d(TAG, "===> PlaybackThread.run exit");

-            }

-        }

-

-        /**

-         * Stop the playback

-         *

-         * @return The stop position

-         */

-        public long stopPlayback() {

-            mRun = false;

-            try {

-                join();

-            } catch (InterruptedException ex) {

-            }

-            return mPositionMs;

-        }

-    };

 

     /**

      * An object of this type cannot be instantiated with a default constructor

@@ -408,57 +268,6 @@
     }

 

     /**

-     * Start the playback of this media item. This method does not block (does

-     * not wait for the playback to complete). The PlaybackProgressListener

-     * allows to track the progress at the time interval determined by the

-     * callbackAfterFrameCount parameter. The SurfaceHolder has to be created

-     * and ready for use before calling this method.

-     *

-     * @param surfaceHolder SurfaceHolder where the frames are rendered.

-     * @param fromMs The time (relative to the beginning of the media item) at

-     *            which the playback will start

-     * @param toMs The time (relative to the beginning of the media item) at

-     *            which the playback will stop. Use -1 to play to the end of the

-     *            media item

-     * @param loop true if the playback should be looped once it reaches the end

-     * @param callbackAfterFrameCount The listener interface should be invoked

-     *            after the number of frames specified by this parameter.

-     * @param listener The listener which will be notified of the playback

-     *            progress

-     * @throws IllegalArgumentException if fromMs or toMs is beyond the playback

-     *             duration

-     * @throws IllegalStateException if a playback, preview or an export is

-     *             already in progress

-     */

-    public void startPlayback(SurfaceHolder surfaceHolder, long fromMs, long toMs, boolean loop,

-            int callbackAfterFrameCount, PlaybackProgressListener listener) {

-        if (fromMs >= mDurationMs) {

-            return;

-        }

-        mPlaybackThread = new PlaybackThread(fromMs, toMs, loop, callbackAfterFrameCount,

-                listener);

-        mPlaybackThread.start();

-    }

-

-    /**

-     * Stop the media item playback. This method blocks until the ongoing

-     * playback is stopped.

-     *

-     * @return The accurate current time when stop is effective expressed in

-     *         milliseconds

-     */

-    public long stopPlayback() {

-        final long stopTimeMs;

-        if (mPlaybackThread != null) {

-            stopTimeMs = mPlaybackThread.stopPlayback();

-            mPlaybackThread = null;

-        } else {

-            stopTimeMs = 0;

-        }

-        return stopTimeMs;

-    }

-

-    /**

      * This API allows to generate a file containing the sample volume levels of

      * the Audio track of this media item. This function may take significant

      * time and is blocking. The file can be retrieved using

diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index b314114..5ff934d 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -55,7 +55,7 @@
 
 AudioPlayer::~AudioPlayer() {
     if (mStarted) {
-        stop();
+        reset();
     }
 }
 
@@ -165,13 +165,21 @@
     return OK;
 }
 
-void AudioPlayer::pause() {
+void AudioPlayer::pause(bool playPendingSamples) {
     CHECK(mStarted);
 
-    if (mAudioSink.get() != NULL) {
-        mAudioSink->pause();
+    if (playPendingSamples) {
+        if (mAudioSink.get() != NULL) {
+            mAudioSink->stop();
+        } else {
+            mAudioTrack->stop();
+        }
     } else {
-        mAudioTrack->stop();
+        if (mAudioSink.get() != NULL) {
+            mAudioSink->pause();
+        } else {
+            mAudioTrack->pause();
+        }
     }
 }
 
@@ -185,7 +193,7 @@
     }
 }
 
-void AudioPlayer::stop() {
+void AudioPlayer::reset() {
     CHECK(mStarted);
 
     if (mAudioSink.get() != NULL) {
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 31c03ad..4f5ff75 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -579,7 +579,7 @@
         notifyListener_l(
                 MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, mStreamDoneStatus);
 
-        pause_l();
+        pause_l(true /* at eos */);
 
         mFlags |= AT_EOS;
         return;
@@ -603,7 +603,7 @@
         LOGV("MEDIA_PLAYBACK_COMPLETE");
         notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
 
-        pause_l();
+        pause_l(true /* at eos */);
 
         mFlags |= AT_EOS;
     }
@@ -752,7 +752,7 @@
     return pause_l();
 }
 
-status_t AwesomePlayer::pause_l() {
+status_t AwesomePlayer::pause_l(bool at_eos) {
     if (!(mFlags & PLAYING)) {
         return OK;
     }
@@ -760,7 +760,14 @@
     cancelPlayerEvents(true /* keepBufferingGoing */);
 
     if (mAudioPlayer != NULL) {
-        mAudioPlayer->pause();
+        if (at_eos) {
+            // If we played the audio stream to completion we
+            // want to make sure that all samples remaining in the audio
+            // track's queue are played out.
+            mAudioPlayer->pause(true /* playPendingSamples */);
+        } else {
+            mAudioPlayer->pause();
+        }
     }
 
     mFlags &= ~PLAYING;
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 90b1aab..6d00d7c 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -212,6 +212,7 @@
     : mFile(fopen(filename, "wb")),
       mUse4ByteNalLength(true),
       mUse32BitOffset(true),
+      mIsFileSizeLimitExplicitlyRequested(false),
       mPaused(false),
       mStarted(false),
       mOffset(0),
@@ -225,6 +226,7 @@
     : mFile(fdopen(fd, "wb")),
       mUse4ByteNalLength(true),
       mUse32BitOffset(true),
+      mIsFileSizeLimitExplicitlyRequested(false),
       mPaused(false),
       mStarted(false),
       mOffset(0),
@@ -322,7 +324,7 @@
     static const int64_t MAX_MOOV_BOX_SIZE = (180 * 3000000 * 6LL / 8000);
     int64_t size = MIN_MOOV_BOX_SIZE;
 
-    if (mMaxFileSizeLimitBytes != 0) {
+    if (mMaxFileSizeLimitBytes != 0 && mIsFileSizeLimitExplicitlyRequested) {
         size = mMaxFileSizeLimitBytes * 4 / 1000;
     } else if (mMaxFileDurationLimitUs != 0) {
         if (bitRate <= 0) {
@@ -342,7 +344,7 @@
         size = MAX_MOOV_BOX_SIZE;
     }
 
-    LOGV("limits: %lld/%lld bytes/us, bit rate: %d bps and the estimated"
+    LOGI("limits: %lld/%lld bytes/us, bit rate: %d bps and the estimated"
          " moov size %lld bytes",
          mMaxFileSizeLimitBytes, mMaxFileDurationLimitUs, bitRate, size);
     return factor * size;
@@ -353,6 +355,16 @@
         return UNKNOWN_ERROR;
     }
 
+    /*
+     * Check mMaxFileSizeLimitBytes at the beginning
+     * since mMaxFileSizeLimitBytes may be implicitly
+     * changed later for 32-bit file offset even if
+     * user does not ask to set it explicitly.
+     */
+    if (mMaxFileSizeLimitBytes != 0) {
+        mIsFileSizeLimitExplicitlyRequested = true;
+    }
+
     int32_t use64BitOffset;
     if (param &&
         param->findInt32(kKey64BitFileOffset, &use64BitOffset) &&
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 4d69dd3..a5341e3 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1838,8 +1838,31 @@
 
         case OMX_EventPortSettingsChanged:
         {
+            CODEC_LOGV("OMX_EventPortSettingsChanged(port=%ld, data2=0x%08lx)",
+                       data1, data2);
+
             if (data2 == 0 || data2 == OMX_IndexParamPortDefinition) {
                 onPortSettingsChanged(data1);
+            } else if (data1 == kPortIndexOutput
+                    && data2 == OMX_IndexConfigCommonOutputCrop) {
+
+                OMX_CONFIG_RECTTYPE rect;
+                rect.nPortIndex = kPortIndexOutput;
+                InitOMXParams(&rect);
+
+                status_t err =
+                         mOMX->getConfig(
+                             mNode, OMX_IndexConfigCommonOutputCrop,
+                             &rect, sizeof(rect));
+
+                if (err == OK) {
+                    CODEC_LOGV(
+                            "output crop (%ld, %ld, %ld, %ld)",
+                            rect.nLeft, rect.nTop, rect.nWidth, rect.nHeight);
+                } else {
+                    CODEC_LOGE("getConfig(OMX_IndexConfigCommonOutputCrop) "
+                               "returned error 0x%08x", err);
+                }
             }
             break;
         }
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index c204a94..662a84a 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -48,6 +48,9 @@
     LOGI("display = %d x %d, decoded = %d x %d",
             mDisplayWidth, mDisplayHeight, mDecodedWidth, mDecodedHeight);
 
+    mDecodedWidth = mDisplayWidth;
+    mDecodedHeight = mDisplayHeight;
+
     int halFormat;
     switch (mColorFormat) {
 #if HAS_YCBCR420_SP_ADRENO
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index db98253..e04a24d 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -223,7 +223,7 @@
     status_t setDataSource_l(const sp<MediaExtractor> &extractor);
     void reset_l();
     status_t seekTo_l(int64_t timeUs);
-    status_t pause_l();
+    status_t pause_l(bool at_eos = false);
     void initRenderer_l();
     void notifyVideoSize_l();
     void seekAudioIfNecessary_l();
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
index e442c85..3908d71 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
@@ -23,10 +23,13 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.Writer;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
 
 import android.hardware.Camera;
 import android.media.MediaPlayer;
 import android.media.MediaRecorder;
+import android.os.Handler;
 import android.os.Looper;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.suitebuilder.annotation.LargeTest;
@@ -51,27 +54,75 @@
     private static final int NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER = 200;
     private static final long WAIT_TIME_CAMERA_TEST = 3000;  // 3 second
     private static final long WAIT_TIME_RECORDER_TEST = 6000;  // 6 second
-    private static final long WAIT_TIME_RECORD = 10000;  // 10 seconds
-    private static final long WAIT_TIME_PLAYBACK = 6000;  // 6 second
     private static final String OUTPUT_FILE = "/sdcard/temp";
     private static final String OUTPUT_FILE_EXT = ".3gp";
     private static final String MEDIA_STRESS_OUTPUT =
         "/sdcard/mediaStressOutput.txt";
-    private Looper mCameraLooper = null;
-    private Looper mRecorderLooper = null;
-    private final Object lock = new Object();
-    private final Object recorderlock = new Object();
-    private static int WAIT_FOR_COMMAND_TO_COMPLETE = 10000;  // Milliseconds.
     private final CameraErrorCallback mCameraErrorCallback = new CameraErrorCallback();
     private final RecorderErrorCallback mRecorderErrorCallback = new RecorderErrorCallback();
 
+    private final static int WAIT_TIMEOUT = 10000;
+    private Thread mLooperThread;
+    private Handler mHandler;
+
     public MediaRecorderStressTest() {
         super("com.android.mediaframeworktest", MediaFrameworkTest.class);
     }
 
     protected void setUp() throws Exception {
+        final Semaphore sem = new Semaphore(0);
+        mLooperThread = new Thread() {
+            @Override
+            public void run() {
+                Log.v(TAG, "starting looper");
+                Looper.prepare();
+                mHandler = new Handler();
+                sem.release();
+                Looper.loop();
+                Log.v(TAG, "quit looper");
+            }
+        };
+        mLooperThread.start();
+        if (! sem.tryAcquire(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
+            fail("Failed to start the looper.");
+        }
+
         getActivity();
-        super.setUp();      
+        super.setUp();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mHandler != null) {
+            mHandler.getLooper().quit();
+            mHandler = null;
+        }
+        if (mLooperThread != null) {
+            mLooperThread.join(WAIT_TIMEOUT);
+            if (mLooperThread.isAlive()) {
+                fail("Failed to stop the looper.");
+            }
+            mLooperThread = null;
+        }
+
+        super.tearDown();
+    }
+
+    private void runOnLooper(final Runnable command) throws InterruptedException {
+        final Semaphore sem = new Semaphore(0);
+        mHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    command.run();
+                } finally {
+                    sem.release();
+                }
+            }
+        });
+        if (! sem.tryAcquire(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
+            fail("Failed to run the command on the looper.");
+        }
     }
 
     private final class CameraErrorCallback implements android.hardware.Camera.ErrorCallback {
@@ -89,69 +140,6 @@
         }
     }
 
-    private void initializeCameraMessageLooper() {
-        Log.v(TAG, "start looper");
-        new Thread() {
-            @Override
-            public void run() {
-                // Set up a looper to be used by camera.
-                Looper.prepare();
-                Log.v(TAG, "start loopRun");
-                mCameraLooper = Looper.myLooper();
-                mCamera = Camera.open();
-                synchronized (lock) {
-                    lock.notify();
-                }
-                Looper.loop();
-                Log.v(TAG, "initializeMessageLooper: quit.");
-            }
-        }.start();
-    }
-
-    private void initializeRecorderMessageLooper() {
-        Log.v(TAG, "start looper");
-        new Thread() {
-            @Override
-            public void run() {
-                Looper.prepare();
-                Log.v(TAG, "start loopRun");
-                mRecorderLooper = Looper.myLooper();
-                mRecorder = new MediaRecorder();
-                synchronized (recorderlock) {
-                    recorderlock.notify();
-                }
-                Looper.loop();  // Blocks forever until Looper.quit() is called.
-                Log.v(TAG, "initializeMessageLooper: quit.");
-            }
-        }.start();
-    }
-
-    /*
-     * Terminates the message looper thread.
-     */
-    private void terminateCameraMessageLooper() {
-        mCameraLooper.quit();
-        try {
-            Thread.sleep(1000);
-        } catch (Exception e){
-            Log.v(TAG, e.toString());
-        }
-        mCamera.release();
-    }
-
-    /*
-     * Terminates the message looper thread.
-     */
-    private void terminateRecorderMessageLooper() {
-        mRecorderLooper.quit();
-        try {
-            Thread.sleep(1000);
-        } catch (Exception e){
-            Log.v(TAG, e.toString());
-        }
-        mRecorder.release();
-    }
-
     //Test case for stressing the camera preview.
     @LargeTest
     public void testStressCamera() throws Exception {
@@ -166,21 +154,19 @@
             Log.v(TAG, "Start preview");
             output.write("No of loop: ");
 
-            for (int i = 0; i< NUMBER_OF_CAMERA_STRESS_LOOPS; i++){
-                synchronized (lock) {
-                    initializeCameraMessageLooper();
-                    try {
-                        lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
-                    } catch(Exception e) {
-                        Log.v(TAG, "wait was interrupted.");
+            for (int i = 0; i< NUMBER_OF_CAMERA_STRESS_LOOPS; i++) {
+                runOnLooper(new Runnable() {
+                    @Override
+                    public void run() {
+                        mCamera = Camera.open();
                     }
-                }
+                });
                 mCamera.setErrorCallback(mCameraErrorCallback);
                 mCamera.setPreviewDisplay(mSurfaceHolder);
                 mCamera.startPreview();
                 Thread.sleep(WAIT_TIME_CAMERA_TEST);
                 mCamera.stopPreview();
-                terminateCameraMessageLooper();
+                mCamera.release();
                 output.write(" ," + i);
             }
         } catch (Exception e) {
@@ -205,15 +191,13 @@
         try {
             output.write("No of loop: ");
             Log.v(TAG, "Start preview");
-            for (int i = 0; i < NUMBER_OF_RECORDER_STRESS_LOOPS; i++){
-                synchronized (recorderlock) {
-                    initializeRecorderMessageLooper();
-                    try {
-                        recorderlock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
-                    } catch(Exception e) {
-                        Log.v(TAG, "wait was interrupted.");
+            for (int i = 0; i < NUMBER_OF_RECORDER_STRESS_LOOPS; i++) {
+                runOnLooper(new Runnable() {
+                    @Override
+                    public void run() {
+                        mRecorder = new MediaRecorder();
                     }
-                }
+                });
                 Log.v(TAG, "counter = " + i);
                 filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
                 Log.v(TAG, filename);
@@ -233,7 +217,7 @@
                 Log.v(TAG, "before release");
                 Thread.sleep(WAIT_TIME_RECORDER_TEST);
                 mRecorder.reset();
-                terminateRecorderMessageLooper();
+                mRecorder.release();
                 output.write(", " + i);
             }
         } catch (Exception e) {
@@ -258,33 +242,29 @@
         try {
             Log.v(TAG, "Start preview");
             output.write("No of loop: ");
-            for (int i = 0; i < NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER; i++){
-                synchronized (lock) {
-                    initializeCameraMessageLooper();
-                    try {
-                        lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
-                    } catch(Exception e) {
-                        Log.v(TAG, "wait was interrupted.");
+            for (int i = 0; i < NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER; i++) {
+                runOnLooper(new Runnable() {
+                    @Override
+                    public void run() {
+                        mCamera = Camera.open();
                     }
-                }
+                });
                 mCamera.setErrorCallback(mCameraErrorCallback);
                 mCamera.setPreviewDisplay(mSurfaceHolder);
                 mCamera.startPreview();
                 Thread.sleep(WAIT_TIME_CAMERA_TEST);
                 mCamera.stopPreview();
-                terminateCameraMessageLooper();
+                mCamera.release();
                 mCamera = null;
                 Log.v(TAG, "release camera");
                 filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
                 Log.v(TAG, filename);
-                synchronized (recorderlock) {
-                    initializeRecorderMessageLooper();
-                    try {
-                        recorderlock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
-                    } catch(Exception e) {
-                        Log.v(TAG, "wait was interrupted.");
+                runOnLooper(new Runnable() {
+                    @Override
+                    public void run() {
+                        mRecorder = new MediaRecorder();
                     }
-                }
+                });
                 mRecorder.setOnErrorListener(mRecorderErrorCallback);
                 mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                 mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
@@ -299,7 +279,7 @@
                 mRecorder.prepare();
                 Log.v(TAG, "before release");
                 Thread.sleep(WAIT_TIME_CAMERA_TEST);
-                terminateRecorderMessageLooper();
+                mRecorder.release();
                 Log.v(TAG, "release video recorder");
                 output.write(", " + i);
             }
@@ -358,14 +338,12 @@
             for (int i = 0; i < iterations; i++){
                 filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
                 Log.v(TAG, filename);
-                synchronized (recorderlock) {
-                    initializeRecorderMessageLooper();
-                    try {
-                        recorderlock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
-                    } catch(Exception e) {
-                        Log.v(TAG, "wait was interrupted.");
+                runOnLooper(new Runnable() {
+                    @Override
+                    public void run() {
+                        mRecorder = new MediaRecorder();
                     }
-                }
+                });
                 Log.v(TAG, "iterations : " + iterations);
                 Log.v(TAG, "video_encoder : " + video_encoder);
                 Log.v(TAG, "audio_encoder : " + audio_encoder);
@@ -391,7 +369,7 @@
                 Thread.sleep(record_duration);
                 Log.v(TAG, "Before stop");
                 mRecorder.stop();
-                terminateRecorderMessageLooper();
+                mRecorder.release();
                 //start the playback
                 MediaPlayer mp = new MediaPlayer();
                 mp.setDataSource(filename);
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 460b74f..239dc05 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -1969,7 +1969,7 @@
     if (egl_display_t::is_valid(dpy) == EGL_FALSE)
         return setError(EGL_BAD_DISPLAY, EGL_FALSE);
     // TODO: eglSwapInterval()
-    return setError(EGL_BAD_PARAMETER, EGL_FALSE);
+    return EGL_TRUE;
 }
 
 // ----------------------------------------------------------------------------
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default.png
new file mode 100644
index 0000000..bf33c946
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default.png
Binary files differ
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml
index 6aee011..494dfa8 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml
@@ -28,11 +28,11 @@
         >
 
         <ImageView
-            class="com.android.systemui.statusbar.tablet.NotificationIconArea$MoreView"
             android:id="@+id/expand"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:src="@drawable/ic_sysbar_open"
+            android:background="@drawable/ic_sysbar_icon_bg"
             android:paddingLeft="6dip"
             android:onClick="notificationIconsClicked"
             />
@@ -100,8 +100,18 @@
                 android:background="@drawable/sysbar_hidenotification_handle"
                 android:layout_marginLeft="8dip"
                 />
+            <com.android.systemui.statusbar.tablet.InputMethodButton
+                android:id="@+id/imeButton"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="8dip"
+                android:src="@drawable/ic_sysbar_ime_default"
+                android:background="@drawable/ic_sysbar_icon_bg"
+                android:visibility="visible"
+                />
         </com.android.systemui.statusbar.tablet.NotificationIconArea>
 
+
         <FrameLayout
             android:id="@+id/ticker"
             android:layout_width="wrap_content"
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java
index 16a3c17..faea3fc 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java
@@ -51,7 +51,6 @@
 import android.graphics.drawable.Drawable;
 import android.graphics.PixelFormat;
 import android.os.Bundle;
-import android.os.Handler;
 import android.os.RemoteException;
 import android.util.Log;
 import android.view.View;
@@ -176,7 +175,6 @@
     }
 
     private class LocalCarouselViewHelper extends CarouselViewHelper {
-        private Paint mPaint = new Paint();
         private DetailTextureParameters mDetailParams = new DetailTextureParameters(10.0f, 20.0f);
 
         public LocalCarouselViewHelper(Context context) {
@@ -315,7 +313,9 @@
                 } else {
                     info.matrix = null;
                 }
-                mCarouselView.setTextureForItem(info.position, compositeBitmap(info));
+                // Force Carousel to request new textures for this item.
+                mCarouselView.setTextureForItem(info.position, null);
+                mCarouselView.setDetailTextureForItem(info.position, 0, 0, 0, 0, null);
             } else {
                 if (DBG) Log.v(TAG, "Can't find view for id " + id);
             }
@@ -351,10 +351,12 @@
         final View decorView = getWindow().getDecorView();
 
         getWindow().getDecorView().setBackgroundColor(0x80000000);
-        setContentView(R.layout.recent_apps_activity);
-
 
         if (mCarouselView == null) {
+            long t = System.currentTimeMillis();
+            setContentView(R.layout.recent_apps_activity);
+            long elapsed = System.currentTimeMillis() - t;
+            Log.v(TAG, "Recents layout took " + elapsed + "ms to load");
             mLoadingBitmap = BitmapFactory.decodeResource(res, R.drawable.recent_rez_border);
             mCarouselView = (CarouselView)findViewById(R.id.carousel);
             mHelper = new LocalCarouselViewHelper(this);
@@ -423,7 +425,6 @@
                 if (DBG) Log.v(TAG, "*** RUNNING THUMBNAIL WAS NULL ***");
             }
         }
-        mCarouselView.createCards(mActivityDescriptions.size());
     }
 
     private void updateRecentTasks() {
@@ -491,6 +492,14 @@
 
     private void showCarousel(boolean show) {
         if (show) {
+            mCarouselView.createCards(mActivityDescriptions.size());
+            for (int i = 1; i < mActivityDescriptions.size(); i++) {
+                // Force Carousel to update textures. Note we don't do this for the first item,
+                // since it will be updated when mThumbnailReceiver returns a thumbnail.
+                // TODO: only do this for apps that have changed.
+                mCarouselView.setTextureForItem(i, null);
+                mCarouselView.setDetailTextureForItem(i, 0, 0, 0, 0, null);
+            }
             // Make carousel visible
             mNoRecentsView.setVisibility(View.GONE);
             mCarouselView.setVisibility(View.VISIBLE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java
new file mode 100644
index 0000000..ba682b7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodButton.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.statusbar.tablet;
+
+import android.content.Context;
+import android.util.Slog;
+import android.view.View;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+import android.view.inputmethod.InputMethodManager;
+
+import com.android.server.InputMethodManagerService;
+
+public class InputMethodButton extends ImageView {
+
+    // other services we wish to talk to
+    InputMethodManager mImm;
+
+    public InputMethodButton(Context context, AttributeSet attrs) {
+        super(context, attrs);
+
+        // IME hookup
+        mImm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+        
+        // TODO: read the current icon & visibility state directly from the service
+
+        // TODO: register for notifications about changes to visibility & subtype from service
+
+        setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                mImm.showInputMethodSubtypePicker();
+            }
+        });
+    }
+}
+
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 3583ab9..1383354 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -214,6 +214,9 @@
     }
 
     class WaveViewMethods implements WaveView.OnTriggerListener {
+        private static final int WAIT_FOR_ANIMATION_TIMEOUT = 500;
+        private static final int STAY_ON_WHILE_GRABBED_TIMEOUT = 30000;
+
         /** {@inheritDoc} */
         public void onTrigger(View v, int whichHandle) {
             if (whichHandle == WaveView.OnTriggerListener.CENTER_HANDLE) {
@@ -222,13 +225,17 @@
                     public void run() {
                         mCallback.goToUnlockScreen();
                     }
-                }, 500);
+                }, WAIT_FOR_ANIMATION_TIMEOUT);
             }
         }
 
         /** {@inheritDoc} */
         public void onGrabbedStateChange(View v, int grabbedState) {
-            mCallback.pokeWakelock();
+            if (grabbedState == WaveView.OnTriggerListener.CENTER_HANDLE) {
+                mCallback.pokeWakelock(STAY_ON_WHILE_GRABBED_TIMEOUT);
+            } else {
+                mCallback.pokeWakelock();
+            }
         }
     }
 
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index c25df1d..24c9443 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -1504,7 +1504,11 @@
         sendCloseSystemWindows();
         Intent intent = new Intent(Intent.ACTION_CALL_BUTTON);
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        getContext().startActivity(intent);
+        try {
+            getContext().startActivity(intent);
+        } catch (ActivityNotFoundException e) {
+            Log.w(TAG, "No activity found for android.intent.action.CALL_BUTTON.");
+        }
     }
 
     @Override
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 33685ba..68e0e32 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -47,6 +47,7 @@
 import android.provider.Settings;
 
 import com.android.internal.R;
+import com.android.internal.app.ShutdownThread;
 import com.android.internal.policy.PolicyManager;
 import com.android.internal.statusbar.IStatusBarService;
 import com.android.internal.telephony.ITelephony;
@@ -128,6 +129,10 @@
     static final boolean DEBUG_LAYOUT = false;
     static final boolean SHOW_STARTING_ANIMATIONS = true;
     static final boolean SHOW_PROCESSES_ON_ALT_MENU = false;
+
+    static final int LONG_PRESS_POWER_NOTHING = 0;
+    static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
+    static final int LONG_PRESS_POWER_SHUT_OFF = 2;
     
     // wallpaper is at the bottom, though the window manager may move it.
     static final int WALLPAPER_LAYER = 2;
@@ -224,6 +229,7 @@
     boolean mDeskDockEnablesAccelerometer;
     int mLidKeyboardAccessibility;
     int mLidNavigationAccessibility;
+    int mLongPressOnPowerBehavior = -1;
     boolean mScreenOn = false;
     boolean mOrientationSensorEnabled = false;
     int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -467,10 +473,27 @@
 
     Runnable mPowerLongPress = new Runnable() {
         public void run() {
-            mShouldTurnOffOnKeyUp = false;
-            performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
-            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
-            showGlobalActionsDialog();
+            // The context isn't read
+            if (mLongPressOnPowerBehavior < 0) {
+                mLongPressOnPowerBehavior = mContext.getResources().getInteger(
+                        com.android.internal.R.integer.config_longPressOnPowerBehavior);
+            }
+            switch (mLongPressOnPowerBehavior) {
+            case LONG_PRESS_POWER_NOTHING:
+                break;
+            case LONG_PRESS_POWER_GLOBAL_ACTIONS:
+                mShouldTurnOffOnKeyUp = false;
+                performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+                sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
+                showGlobalActionsDialog();
+                break;
+            case LONG_PRESS_POWER_SHUT_OFF:
+                mShouldTurnOffOnKeyUp = false;
+                performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
+                sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
+                ShutdownThread.shutdown(mContext, true);
+                break;
+            }
         }
     };
 
diff --git a/policy/src/com/android/internal/policy/impl/PowerDialog.java b/policy/src/com/android/internal/policy/impl/PowerDialog.java
deleted file mode 100644
index de35bd7..0000000
--- a/policy/src/com/android/internal/policy/impl/PowerDialog.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.policy.impl;
-
-import com.android.internal.R;
-
-import android.app.Dialog;
-import android.app.StatusBarManager;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.RemoteException;
-import android.os.LocalPowerManager;
-import android.os.ServiceManager;
-import android.os.SystemClock;
-
-import com.android.internal.app.ShutdownThread;
-import com.android.internal.telephony.ITelephony;
-import android.view.KeyEvent;
-import android.util.Log;
-import android.view.View;
-import android.view.WindowManager;
-import android.view.View.OnClickListener;
-import android.view.View.OnKeyListener;
-import android.widget.Button;
-
-/**
- * @deprecated use {@link GlobalActions} instead.
- */
-public class PowerDialog extends Dialog implements OnClickListener,
-        OnKeyListener {
-    private static final String TAG = "PowerDialog";
-
-    static private StatusBarManager sStatusBar;
-    private Button mKeyguard;
-    private Button mPower;
-    private Button mRadioPower;
-    private Button mSilent;
-
-    private LocalPowerManager mPowerManager;
-
-    public PowerDialog(Context context, LocalPowerManager powerManager) {
-        super(context);
-        mPowerManager = powerManager;
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        Context context = getContext();
-
-        if (sStatusBar == null) {
-            sStatusBar = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE);
-        }
-
-        setContentView(com.android.internal.R.layout.power_dialog);
-
-        getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG);
-        if (!getContext().getResources().getBoolean(
-                com.android.internal.R.bool.config_sf_slowBlur)) {
-            getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
-                    WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
-        }
-        getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
-                WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
-
-        setTitle(context.getText(R.string.power_dialog));
-
-        mKeyguard = (Button) findViewById(R.id.keyguard);
-        mPower = (Button) findViewById(R.id.off);
-        mRadioPower = (Button) findViewById(R.id.radio_power);
-        mSilent = (Button) findViewById(R.id.silent);
-
-        if (mKeyguard != null) {
-            mKeyguard.setOnKeyListener(this);
-            mKeyguard.setOnClickListener(this);
-        }
-        if (mPower != null) {
-            mPower.setOnClickListener(this);
-        }
-        if (mRadioPower != null) {
-            mRadioPower.setOnClickListener(this);
-        }
-        if (mSilent != null) {
-            mSilent.setOnClickListener(this);
-            // XXX: HACK for now hide the silent until we get mute support
-            mSilent.setVisibility(View.GONE);
-        }
-
-        CharSequence text;
-
-        // set the keyguard button's text
-        text = context.getText(R.string.screen_lock);
-        mKeyguard.setText(text);
-        mKeyguard.requestFocus();
-
-        try {
-            ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
-            if (phone != null) {
-                text = phone.isRadioOn() ? context
-                        .getText(R.string.turn_off_radio) : context
-                        .getText(R.string.turn_on_radio);
-            }
-        } catch (RemoteException ex) {
-            // ignore it
-        }
-
-        mRadioPower.setText(text);
-    }
-
-    public void onClick(View v) {
-        this.dismiss();
-        if (v == mPower) {
-            // shutdown by making sure radio and power are handled accordingly.
-            ShutdownThread.shutdown(getContext(), true);
-        } else if (v == mRadioPower) {
-            try {
-                ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
-                if (phone != null) {
-                    phone.toggleRadioOnOff();
-                }
-            } catch (RemoteException ex) {
-                // ignore it
-            }
-        } else if (v == mSilent) {
-            // do something
-        } else if (v == mKeyguard) {
-            if (v.isInTouchMode()) {
-                // only in touch mode for the reasons explained in onKey.
-                this.dismiss();
-                mPowerManager.goToSleep(SystemClock.uptimeMillis() + 1);
-            }
-        }
-    }
-
-    public boolean onKey(View v, int keyCode, KeyEvent event) {
-        // The activate keyguard button needs to put the device to sleep on the
-        // key up event. If we try to put it to sleep on the click or down
-        // action
-        // the the up action will cause the device to wake back up.
-
-        // Log.i(TAG, "keyCode: " + keyCode + " action: " + event.getAction());
-        if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER
-                || event.getAction() != KeyEvent.ACTION_UP) {
-            // Log.i(TAG, "getting out of dodge...");
-            return false;
-        }
-
-        // Log.i(TAG, "Clicked mKeyguard! dimissing dialog");
-        this.dismiss();
-        // Log.i(TAG, "onKey: turning off the screen...");
-        // XXX: This is a hack for now
-        mPowerManager.goToSleep(event.getEventTime() + 1);
-        return true;
-    }
-
-    public void show() {
-        super.show();
-        Log.d(TAG, "show... disabling expand");
-        sStatusBar.disable(StatusBarManager.DISABLE_EXPAND);
-    }
-
-    public void dismiss() {
-        super.dismiss();
-        Log.d(TAG, "dismiss... reenabling expand");
-        sStatusBar.disable(StatusBarManager.DISABLE_NONE);
-    }
-}
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 8527059..cd9b07e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1715,7 +1715,7 @@
         // The first time a track is added we wait
         // for all its buffers to be filled before processing it
         mAudioMixer->setActiveTrack(track->name());
-        if (cblk->framesReady() && (track->isReady() || track->isStopped()) &&
+        if (cblk->framesReady() && track->isReady() &&
                 !track->isPaused() && !track->isTerminated())
         {
             //LOGV("track %d u=%08x, s=%08x [OK] on thread %p", track->name(), cblk->user, cblk->server, this);
@@ -2231,7 +2231,7 @@
 
                 // The first time a track is added we wait
                 // for all its buffers to be filled before processing it
-                if (cblk->framesReady() && (track->isReady() || track->isStopped()) &&
+                if (cblk->framesReady() && track->isReady() &&
                         !track->isPaused() && !track->isTerminated())
                 {
                     //LOGV("track %d u=%08x, s=%08x [OK]", track->name(), cblk->user, cblk->server);
@@ -3039,7 +3039,7 @@
 }
 
 bool AudioFlinger::PlaybackThread::Track::isReady() const {
-    if (mFillingUpStatus != FS_FILLING) return true;
+    if (mFillingUpStatus != FS_FILLING || isStopped() || isPausing()) return true;
 
     if (mCblk->framesReady() >= mCblk->frameCount ||
             (mCblk->flags & CBLK_FORCEREADY_MSK)) {
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java
index e6c32d9..a8ccfc0 100644
--- a/services/java/com/android/server/BatteryService.java
+++ b/services/java/com/android/server/BatteryService.java
@@ -99,6 +99,7 @@
     private int mBatteryTemperature;
     private String mBatteryTechnology;
     private boolean mBatteryLevelCritical;
+    private boolean mInvalidCharger;
 
     private int mLastBatteryStatus;
     private int mLastBatteryHealth;
@@ -107,6 +108,7 @@
     private int mLastBatteryVoltage;
     private int mLastBatteryTemperature;
     private boolean mLastBatteryLevelCritical;
+    private boolean mLastInvalidCharger;
 
     private int mLowBatteryWarningLevel;
     private int mLowBatteryCloseWarningLevel;
@@ -128,7 +130,12 @@
         mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
                 com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
 
-        mUEventObserver.startObserving("SUBSYSTEM=power_supply");
+        mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply");
+
+        // watch for invalid charger messages if the invalid_charger switch exists
+        if (new File("/sys/devices/virtual/switch/invalid_charger/state").exists()) {
+            mInvalidChargerObserver.startObserving("DEVPATH=/devices/virtual/switch/invalid_charger");
+        }
 
         // set initial status
         update();
@@ -162,13 +169,24 @@
         return mPlugType;
     }
 
-    private UEventObserver mUEventObserver = new UEventObserver() {
+    private UEventObserver mPowerSupplyObserver = new UEventObserver() {
         @Override
         public void onUEvent(UEventObserver.UEvent event) {
             update();
         }
     };
 
+    private UEventObserver mInvalidChargerObserver = new UEventObserver() {
+        @Override
+        public void onUEvent(UEventObserver.UEvent event) {
+            boolean invalidCharger = "1".equals(event.get("SWITCH_STATE"));
+            if (mInvalidCharger != invalidCharger) {
+                mInvalidCharger = invalidCharger;
+                update();
+            }
+        }
+    };
+
     // returns battery level as a percentage
     final int getBatteryLevel() {
         return mBatteryLevel;
@@ -237,7 +255,8 @@
                 mBatteryLevel != mLastBatteryLevel ||
                 mPlugType != mLastPlugType ||
                 mBatteryVoltage != mLastBatteryVoltage ||
-                mBatteryTemperature != mLastBatteryTemperature) {
+                mBatteryTemperature != mLastBatteryTemperature ||
+                mInvalidCharger != mLastInvalidCharger) {
 
             if (mPlugType != mLastPlugType) {
                 if (mLastPlugType == BATTERY_PLUGGED_NONE) {
@@ -334,6 +353,7 @@
             mLastBatteryVoltage = mBatteryVoltage;
             mLastBatteryTemperature = mBatteryTemperature;
             mLastBatteryLevelCritical = mBatteryLevelCritical;
+            mLastInvalidCharger = mInvalidCharger;
         }
     }
 
@@ -355,6 +375,7 @@
         intent.putExtra(BatteryManager.EXTRA_VOLTAGE, mBatteryVoltage);
         intent.putExtra(BatteryManager.EXTRA_TEMPERATURE, mBatteryTemperature);
         intent.putExtra(BatteryManager.EXTRA_TECHNOLOGY, mBatteryTechnology);
+        intent.putExtra(BatteryManager.EXTRA_INVALID_CHARGER, mInvalidCharger);
 
         if (false) {
             Slog.d(TAG, "updateBattery level:" + mBatteryLevel +
@@ -364,7 +385,7 @@
                     " temperature: " + mBatteryTemperature +
                     " technology: " + mBatteryTechnology +
                     " AC powered:" + mAcOnline + " USB powered:" + mUsbOnline +
-                    " icon:" + icon );
+                    " icon:" + icon  + " invalid charger:" + mInvalidCharger);
         }
 
         ActivityManagerNative.broadcastStickyIntent(intent, null);
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 9a5423c..70bde01 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -25,6 +25,7 @@
 import com.android.internal.view.IInputMethodManager;
 import com.android.internal.view.IInputMethodSession;
 import com.android.internal.view.InputBindResult;
+import com.android.internal.view.InputMethodAndSubtypeEnabler;
 
 import com.android.server.StatusBarManagerService;
 
@@ -83,6 +84,7 @@
 import java.text.Collator;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -97,6 +99,7 @@
 
     static final int MSG_SHOW_IM_PICKER = 1;
     static final int MSG_SHOW_IM_SUBTYPE_PICKER = 2;
+    static final int MSG_SHOW_IM_SUBTYPE_ENABLER = 3;
 
     static final int MSG_UNBIND_INPUT = 1000;
     static final int MSG_BIND_INPUT = 1010;
@@ -1225,7 +1228,7 @@
         synchronized (mMethodMap) {
             if (mCurClient == null || client == null
                     || mCurClient.client.asBinder() != client.asBinder()) {
-                Slog.w(TAG, "Ignoring showInputMethodDialogFromClient of uid "
+                Slog.w(TAG, "Ignoring showInputMethodPickerFromClient of uid "
                         + Binder.getCallingUid() + ": " + client);
             }
 
@@ -1237,13 +1240,26 @@
         synchronized (mMethodMap) {
             if (mCurClient == null || client == null
                     || mCurClient.client.asBinder() != client.asBinder()) {
-                Slog.w(TAG, "Ignoring showInputSubtypeMethodDialogFromClient of: " + client);
+                Slog.w(TAG, "Ignoring showInputMethodSubtypePickerFromClient of: " + client);
             }
 
             mHandler.sendEmptyMessage(MSG_SHOW_IM_SUBTYPE_PICKER);
         }
     }
 
+    public void showInputMethodAndSubtypeEnablerFromClient(
+            IInputMethodClient client, String topId) {
+        // TODO: Handle topId for setting the top position of the list activity
+        synchronized (mMethodMap) {
+            if (mCurClient == null || client == null
+                    || mCurClient.client.asBinder() != client.asBinder()) {
+                Slog.w(TAG, "Ignoring showInputMethodAndSubtypeEnablerFromClient of: " + client);
+            }
+
+            mHandler.sendEmptyMessage(MSG_SHOW_IM_SUBTYPE_ENABLER);
+        }
+    }
+
     public void setInputMethod(IBinder token, String id) {
         setInputMethodWithSubtype(token, id, NOT_A_SUBTYPE_ID);
     }
@@ -1336,6 +1352,10 @@
                 showInputMethodSubtypeMenu();
                 return true;
 
+            case MSG_SHOW_IM_SUBTYPE_ENABLER:
+                showInputMethodAndSubtypeEnabler();
+                return true;
+
             // ---------------------------------------------------------
 
             case MSG_UNBIND_INPUT:
@@ -1528,6 +1548,14 @@
         showInputMethodMenuInternal(true);
     }
 
+    private void showInputMethodAndSubtypeEnabler() {
+        Intent intent = new Intent();
+        intent.setClassName("android", InputMethodAndSubtypeEnabler.class.getCanonicalName());
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+        mContext.startActivity(intent);
+    }
+
     private void showInputMethodMenuInternal(boolean showSubtypes) {
         if (DEBUG) Slog.v(TAG, "Show switching menu");
 
@@ -1540,14 +1568,15 @@
         int lastInputMethodSubtypeId = getSelectedInputMethodSubtypeId(lastInputMethodId);
         if (DEBUG) Slog.v(TAG, "Current IME: " + lastInputMethodId);
 
-        final List<InputMethodInfo> immis = getEnabledInputMethodList();
-        ArrayList<Integer> subtypeIds = new ArrayList<Integer>();
-
-        if (immis == null) {
-            return;
-        }
-
         synchronized (mMethodMap) {
+            final List<Pair<InputMethodInfo, ArrayList<String>>> immis =
+                    mSettings.getEnabledInputMethodAndSubtypeListLocked();
+            ArrayList<Integer> subtypeIds = new ArrayList<Integer>();
+
+            if (immis == null || immis.size() == 0) {
+                return;
+            }
+
             hideInputMethodMenuLocked();
 
             int N = immis.size();
@@ -1556,32 +1585,38 @@
                 new TreeMap<CharSequence, Pair<InputMethodInfo, Integer>>(Collator.getInstance());
 
             for (int i = 0; i < N; ++i) {
-                InputMethodInfo property = immis.get(i);
+                InputMethodInfo property = immis.get(i).first;
+                final ArrayList<String> enabledSubtypeIds = immis.get(i).second;
+                HashSet<String> enabledSubtypeSet = new HashSet<String>();
+                for (String s : enabledSubtypeIds) {
+                    enabledSubtypeSet.add(s);
+                }
                 if (property == null) {
                     continue;
                 }
-                // TODO: Show only enabled subtypes
                 ArrayList<InputMethodSubtype> subtypes = property.getSubtypes();
                 CharSequence label = property.loadLabel(pm);
-                if (showSubtypes && subtypes.size() > 0) {
+                if (showSubtypes && enabledSubtypeSet.size() > 0) {
                     for (int j = 0; j < subtypes.size(); ++j) {
                         InputMethodSubtype subtype = subtypes.get(j);
-                        CharSequence title;
-                        int nameResId = subtype.getNameResId();
-                        int modeResId = subtype.getModeResId();
-                        if (nameResId != 0) {
-                            title = pm.getText(property.getPackageName(), nameResId,
-                                    property.getServiceInfo().applicationInfo);
-                        } else {
-                            CharSequence language = subtype.getLocale();
-                            CharSequence mode = modeResId == 0 ? null
-                                    : pm.getText(property.getPackageName(), modeResId,
-                                            property.getServiceInfo().applicationInfo);
-                            // TODO: Use more friendly Title and UI
-                            title = label + "," + (mode == null ? "" : mode) + ","
-                                    + (language == null ? "" : language);
+                        if (enabledSubtypeSet.contains(String.valueOf(subtype.hashCode()))) {
+                            CharSequence title;
+                            int nameResId = subtype.getNameResId();
+                            int modeResId = subtype.getModeResId();
+                            if (nameResId != 0) {
+                                title = pm.getText(property.getPackageName(), nameResId,
+                                        property.getServiceInfo().applicationInfo);
+                            } else {
+                                CharSequence language = subtype.getLocale();
+                                CharSequence mode = modeResId == 0 ? null
+                                        : pm.getText(property.getPackageName(), modeResId,
+                                                property.getServiceInfo().applicationInfo);
+                                // TODO: Use more friendly Title and UI
+                                title = label + "," + (mode == null ? "" : mode) + ","
+                                        + (language == null ? "" : language);
+                            }
+                            imMap.put(title, new Pair<InputMethodInfo, Integer>(property, j));
                         }
-                        imMap.put(title, new Pair<InputMethodInfo, Integer>(property, j));
                     }
                 } else {
                     imMap.put(label,
@@ -1651,6 +1686,20 @@
                         }
                     });
 
+            if (showSubtypes) {
+                mDialogBuilder.setPositiveButton(com.android.internal.R.string.more_item_label,
+                        new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int whichButton) {
+                                showInputMethodAndSubtypeEnabler();
+                            }
+                        });
+            }
+            mDialogBuilder.setNegativeButton(com.android.internal.R.string.cancel,
+                    new DialogInterface.OnClickListener() {
+                        public void onClick(DialogInterface dialog, int whichButton) {
+                            hideInputMethodMenu();
+                        }
+                    });
             mSwitchingDialog = mDialogBuilder.create();
             mSwitchingDialog.getWindow().setType(
                     WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG);
@@ -1837,6 +1886,12 @@
                     getEnabledInputMethodsAndSubtypeListLocked());
         }
 
+        public List<Pair<InputMethodInfo, ArrayList<String>>>
+                getEnabledInputMethodAndSubtypeListLocked() {
+            return createEnabledInputMethodAndSubtypeListLocked(
+                    getEnabledInputMethodsAndSubtypeListLocked());
+        }
+
         // At the initial boot, the settings for input methods are not set,
         // so we need to enable IME in that case.
         public void enableAllIMEsIfThereIsNoEnabledIME() {
@@ -1933,6 +1988,20 @@
             return res;
         }
 
+        private List<Pair<InputMethodInfo, ArrayList<String>>>
+                createEnabledInputMethodAndSubtypeListLocked(
+                        List<Pair<String, ArrayList<String>>> imsList) {
+            final ArrayList<Pair<InputMethodInfo, ArrayList<String>>> res
+                    = new ArrayList<Pair<InputMethodInfo, ArrayList<String>>>();
+            for (Pair<String, ArrayList<String>> ims : imsList) {
+                InputMethodInfo info = mMethodMap.get(ims.first);
+                if (info != null) {
+                    res.add(new Pair<InputMethodInfo, ArrayList<String>>(info, ims.second));
+                }
+            }
+            return res;
+        }
+
         private void putEnabledInputMethodsStr(String str) {
             Settings.Secure.putString(mResolver, Settings.Secure.ENABLED_INPUT_METHODS, str);
             mEnabledInputMethodsStrCache = str;
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index c4d2d4d..bcf1b96 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -140,7 +140,6 @@
     private static final boolean DEBUG_PREFERRED = false;
     private static final boolean DEBUG_UPGRADE = false;
     private static final boolean DEBUG_INSTALL = false;
-    private static final boolean DEBUG_NATIVE = false;
 
     private static final boolean MULTIPLE_APPLICATION_UIDS = true;
     private static final int RADIO_UID = Process.PHONE_UID;
@@ -3241,8 +3240,6 @@
                 }
             }
 
-            pkg.applicationInfo.nativeLibraryDir = pkgSetting.nativeLibraryPathString;
-
             /*
              * Set the data dir to the default "/data/data/<package name>/lib"
              * if we got here without anyone telling us different (e.g., apps
@@ -3252,10 +3249,14 @@
              * This happens during an upgrade from a package settings file that
              * doesn't have a native library path attribute at all.
              */
-            if (pkgSetting.nativeLibraryPathString == null && pkg.applicationInfo.dataDir != null) {
-                final String nativeLibraryPath = new File(dataPath, LIB_DIR_NAME).getPath();
-                pkg.applicationInfo.nativeLibraryDir = nativeLibraryPath;
-                pkgSetting.nativeLibraryPathString = nativeLibraryPath;
+            if (pkg.applicationInfo.nativeLibraryDir == null && pkg.applicationInfo.dataDir != null) {
+                if (pkgSetting.nativeLibraryPathString == null) {
+                    final String nativeLibraryPath = new File(dataPath, LIB_DIR_NAME).getPath();
+                    pkg.applicationInfo.nativeLibraryDir = nativeLibraryPath;
+                    pkgSetting.nativeLibraryPathString = nativeLibraryPath;
+                } else {
+                    pkg.applicationInfo.nativeLibraryDir = pkgSetting.nativeLibraryPathString;
+                }
             }
 
             pkgSetting.uidError = uidError;
@@ -3274,10 +3275,23 @@
              *        In other words, we're going to unpack the binaries
              *        only for non-system apps and system app upgrades.
              */
-            if ((!isSystemApp(pkg) || isUpdatedSystemApp(pkg)) && !isExternal(pkg)) {
-                Log.i(TAG, path + " changed; unpacking");
-                File sharedLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
-                NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
+            if (pkg.applicationInfo.nativeLibraryDir != null) {
+                final File sharedLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
+                if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
+                    /*
+                     * Upgrading from a previous version of the OS sometimes
+                     * leaves native libraries in the /data/data/<app>/lib
+                     * directory for system apps even when they shouldn't be.
+                     * Recent changes in the JNI library search path
+                     * necessitates we remove those to match previous behavior.
+                     */
+                    if (NativeLibraryHelper.removeNativeBinariesFromDirLI(sharedLibraryDir)) {
+                        Log.i(TAG, "removed obsolete native libraries for system package " + path);
+                    }
+                } else if (!isExternal(pkg)) {
+                    Log.i(TAG, path + " changed; unpacking");
+                    NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
+                }
             }
             pkg.mScanPath = path;
 
@@ -8051,7 +8065,7 @@
             if (p != null) {
                 if (!p.codePath.equals(codePath)) {
                     // Check to see if its a disabled system app
-                    if((p != null) && ((p.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0)) {
+                    if ((p.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                         // This is an updated system app with versions in both system
                         // and data partition. Just let the most recent version
                         // take precedence.
@@ -8062,6 +8076,13 @@
                         // let's log a message about it.
                         Slog.i(TAG, "Package " + name + " codePath changed from " + p.codePath
                                 + " to " + codePath + "; Retaining data and using new");
+                        /*
+                         * Since we've changed paths, we need to prefer the new
+                         * native library path over the one stored in the
+                         * package settings since we might have moved from
+                         * internal to external storage or vice versa.
+                         */
+                        p.nativeLibraryPathString = nativeLibraryPathString;
                     }
                 }
                 if (p.sharedUser != sharedUser) {
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 29a9a7e..5386a1a 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -220,6 +220,7 @@
     private Sensor mLightSensor;
     private boolean mLightSensorEnabled;
     private float mLightSensorValue = -1;
+    private boolean mProxIgnoredBecauseScreenTurnedOff = false;
     private int mHighestLightSensorValue = -1;
     private float mLightSensorPendingValue = -1;
     private int mLightSensorScreenBrightness = -1;
@@ -252,7 +253,7 @@
 
     // could be either static or controllable at runtime
     private static final boolean mSpew = false;
-    private static final boolean mDebugProximitySensor = (true || mSpew);
+    private static final boolean mDebugProximitySensor = (false || mSpew);
     private static final boolean mDebugLightSensor = (false || mSpew);
     
     private native void nativeInit();
@@ -638,7 +639,8 @@
         int n = flags & LOCK_MASK;
         return n == PowerManager.FULL_WAKE_LOCK
                 || n == PowerManager.SCREEN_BRIGHT_WAKE_LOCK
-                || n == PowerManager.SCREEN_DIM_WAKE_LOCK;
+                || n == PowerManager.SCREEN_DIM_WAKE_LOCK
+                || n == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK;
     }
 
     void enforceWakeSourcePermission(int uid, int pid) {
@@ -778,25 +780,33 @@
             // set it to whatever they want.  otherwise, we modulate that
             // by the current state so we never turn it more on than
             // it already is.
-            if ((wl.flags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0) {
-                int oldWakeLockState = mWakeLockState;
-                mWakeLockState = mLocks.reactivateScreenLocksLocked();
-                if (mSpew) {
-                    Slog.d(TAG, "wakeup here mUserState=0x" + Integer.toHexString(mUserState)
-                            + " mWakeLockState=0x"
-                            + Integer.toHexString(mWakeLockState)
-                            + " previous wakeLockState=0x" + Integer.toHexString(oldWakeLockState));
+            if ((flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) {
+                mProximityWakeLockCount++;
+                if (mProximityWakeLockCount == 1) {
+                    enableProximityLockLocked();
                 }
             } else {
-                if (mSpew) {
-                    Slog.d(TAG, "here mUserState=0x" + Integer.toHexString(mUserState)
-                            + " mLocks.gatherState()=0x"
-                            + Integer.toHexString(mLocks.gatherState())
-                            + " mWakeLockState=0x" + Integer.toHexString(mWakeLockState));
+                if ((wl.flags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0) {
+                    int oldWakeLockState = mWakeLockState;
+                    mWakeLockState = mLocks.reactivateScreenLocksLocked();
+                    if (mSpew) {
+                        Slog.d(TAG, "wakeup here mUserState=0x" + Integer.toHexString(mUserState)
+                                + " mWakeLockState=0x"
+                                + Integer.toHexString(mWakeLockState)
+                                + " previous wakeLockState=0x"
+                                + Integer.toHexString(oldWakeLockState));
+                    }
+                } else {
+                    if (mSpew) {
+                        Slog.d(TAG, "here mUserState=0x" + Integer.toHexString(mUserState)
+                                + " mLocks.gatherState()=0x"
+                                + Integer.toHexString(mLocks.gatherState())
+                                + " mWakeLockState=0x" + Integer.toHexString(mWakeLockState));
+                    }
+                    mWakeLockState = (mUserState | mWakeLockState) & mLocks.gatherState();
                 }
-                mWakeLockState = (mUserState | mWakeLockState) & mLocks.gatherState();
+                setPowerState(mWakeLockState | mUserState);
             }
-            setPowerState(mWakeLockState | mUserState);
         }
         else if ((flags & LOCK_MASK) == PowerManager.PARTIAL_WAKE_LOCK) {
             if (newlock) {
@@ -806,11 +816,6 @@
                 }
             }
             Power.acquireWakeLock(Power.PARTIAL_WAKE_LOCK,PARTIAL_NAME);
-        } else if ((flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) {
-            mProximityWakeLockCount++;
-            if (mProximityWakeLockCount == 1) {
-                enableProximityLockLocked();
-            }
         }
 
         if (diffsource) {
@@ -868,12 +873,27 @@
         }
 
         if (isScreenLock(wl.flags)) {
-            mWakeLockState = mLocks.gatherState();
-            // goes in the middle to reduce flicker
-            if ((wl.flags & PowerManager.ON_AFTER_RELEASE) != 0) {
-                userActivity(SystemClock.uptimeMillis(), -1, false, OTHER_EVENT, false);
+            if ((wl.flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) {
+                mProximityWakeLockCount--;
+                if (mProximityWakeLockCount == 0) {
+                    if (mProximitySensorActive &&
+                            ((flags & PowerManager.WAIT_FOR_PROXIMITY_NEGATIVE) != 0)) {
+                        // wait for proximity sensor to go negative before disabling sensor
+                        if (mDebugProximitySensor) {
+                            Slog.d(TAG, "waiting for proximity sensor to go negative");
+                        }
+                    } else {
+                        disableProximityLockLocked();
+                    }
+                }
+            } else {
+                mWakeLockState = mLocks.gatherState();
+                // goes in the middle to reduce flicker
+                if ((wl.flags & PowerManager.ON_AFTER_RELEASE) != 0) {
+                    userActivity(SystemClock.uptimeMillis(), -1, false, OTHER_EVENT, false);
+                }
+                setPowerState(mWakeLockState | mUserState);
             }
-            setPowerState(mWakeLockState | mUserState);
         }
         else if ((wl.flags & LOCK_MASK) == PowerManager.PARTIAL_WAKE_LOCK) {
             mPartialCount--;
@@ -881,19 +901,6 @@
                 if (LOG_PARTIAL_WL) EventLog.writeEvent(EventLogTags.POWER_PARTIAL_WAKE_STATE, 0, wl.tag);
                 Power.releaseWakeLock(PARTIAL_NAME);
             }
-        } else if ((wl.flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) {
-            mProximityWakeLockCount--;
-            if (mProximityWakeLockCount == 0) {
-                if (mProximitySensorActive &&
-                        ((flags & PowerManager.WAIT_FOR_PROXIMITY_NEGATIVE) != 0)) {
-                    // wait for proximity sensor to go negative before disabling sensor
-                    if (mDebugProximitySensor) {
-                        Slog.d(TAG, "waiting for proximity sensor to go negative");
-                    }
-                } else {
-                    disableProximityLockLocked();
-                }
-            }
         }
         // Unlink the lock from the binder.
         wl.binder.unlinkToDeath(wl, 0);
@@ -2433,11 +2440,23 @@
             mWakeLockState = SCREEN_OFF;
             int N = mLocks.size();
             int numCleared = 0;
+            boolean proxLock = false;
             for (int i=0; i<N; i++) {
                 WakeLock wl = mLocks.get(i);
                 if (isScreenLock(wl.flags)) {
-                    mLocks.get(i).activated = false;
-                    numCleared++;
+                    if (((wl.flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)
+                            && reason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) {
+                        proxLock = true;
+                    } else {
+                        mLocks.get(i).activated = false;
+                        numCleared++;
+                    }
+                }
+            }
+            if (!proxLock) {
+                mProxIgnoredBecauseScreenTurnedOff = true;
+                if (mDebugProximitySensor) {
+                    Slog.d(TAG, "setting mProxIgnoredBecauseScreenTurnedOff");
                 }
             }
             EventLog.writeEvent(EventLogTags.POWER_SLEEP_REQUESTED, numCleared);
@@ -2629,6 +2648,11 @@
                     result |= wl.minState;
                 }
             }
+            if (mDebugProximitySensor) {
+                Slog.d(TAG, "reactivateScreenLocksLocked mProxIgnoredBecauseScreenTurnedOff="
+                        + mProxIgnoredBecauseScreenTurnedOff);
+            }
+            mProxIgnoredBecauseScreenTurnedOff = false;
             return result;
         }
     }
@@ -2788,7 +2812,13 @@
             }
             if (mProximitySensorActive) {
                 mProximitySensorActive = false;
-                forceUserActivityLocked();
+                if (mDebugProximitySensor) {
+                    Slog.d(TAG, "disableProximityLockLocked mProxIgnoredBecauseScreenTurnedOff="
+                            + mProxIgnoredBecauseScreenTurnedOff);
+                }
+                if (!mProxIgnoredBecauseScreenTurnedOff) {
+                    forceUserActivityLocked();
+                }
             }
         }
     }
@@ -2802,15 +2832,27 @@
             return;
         }
         if (active) {
-            goToSleepLocked(SystemClock.uptimeMillis(),
-                    WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR);
+            if (mDebugProximitySensor) {
+                Slog.d(TAG, "b mProxIgnoredBecauseScreenTurnedOff="
+                        + mProxIgnoredBecauseScreenTurnedOff);
+            }
+            if (!mProxIgnoredBecauseScreenTurnedOff) {
+                goToSleepLocked(SystemClock.uptimeMillis(),
+                        WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR);
+            }
             mProximitySensorActive = true;
         } else {
             // proximity sensor negative events trigger as user activity.
             // temporarily set mUserActivityAllowed to true so this will work
             // even when the keyguard is on.
             mProximitySensorActive = false;
-            forceUserActivityLocked();
+            if (mDebugProximitySensor) {
+                Slog.d(TAG, "b mProxIgnoredBecauseScreenTurnedOff="
+                        + mProxIgnoredBecauseScreenTurnedOff);
+            }
+            if (!mProxIgnoredBecauseScreenTurnedOff) {
+                forceUserActivityLocked();
+            }
 
             if (mProximityWakeLockCount == 0) {
                 // disable sensor if we have no listeners left after proximity negative
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 30aed69..59f7434 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -505,7 +505,7 @@
         InputChannel mServerChannel, mClientChannel;
         WindowState mTargetWindow;
         ArrayList<WindowState> mNotifiedWindows;
-        boolean mDragEnded;
+        boolean mDragInProgress;
 
         private final Rect tmpRect = new Rect();
 
@@ -562,6 +562,7 @@
             // works correctly in calling out to the apps.
             mDataDescription = new ClipDescription(mData);
             mNotifiedWindows.clear();
+            mDragInProgress = true;
 
             if (DEBUG_DRAG) {
                 Slog.d(TAG, "broadcasting DRAG_STARTED of " + mDataDescription);
@@ -586,7 +587,7 @@
          * process, so it's safe for the caller to call recycle() on the event afterwards.
          */
         private void sendDragStartedLw(WindowState newWin, DragEvent event) {
-            if (!mDragEnded && newWin.isPotentialDragTarget()) {
+            if (mDragInProgress && newWin.isPotentialDragTarget()) {
                 try {
                     // clone for local callees since dispatch will recycle the event
                     if (Process.myPid() == newWin.mSession.mPid) {
@@ -606,20 +607,22 @@
          * was begun.  This is a rare case.
          */
         private void sendDragStartedIfNeededLw(WindowState newWin) {
-            // If we have sent the drag-started, we needn't do so again
-            for (WindowState ws : mNotifiedWindows) {
-                if (ws == newWin) {
-                    return;
+            if (mDragInProgress) {
+                // If we have sent the drag-started, we needn't do so again
+                for (WindowState ws : mNotifiedWindows) {
+                    if (ws == newWin) {
+                        return;
+                    }
                 }
+                if (DEBUG_DRAG) {
+                    Slog.d(TAG, "sending DRAG_STARTED to new window " + newWin);
+                }
+                DragEvent event = DragEvent.obtain(DragEvent.ACTION_DRAG_STARTED, 0, 0,
+                        mDataDescription, null);
+                // sendDragStartedLw() clones 'event' if the window is process-local
+                sendDragStartedLw(newWin, event);
+                event.recycle();
             }
-            if (DEBUG_DRAG) {
-                Slog.d(TAG, "sending DRAG_STARTED to new window " + newWin);
-            }
-            DragEvent event = DragEvent.obtain(DragEvent.ACTION_DRAG_STARTED, 0, 0,
-                    mDataDescription, null);
-            // sendDragStartedLw() clones 'event' if the window is process-local
-            sendDragStartedLw(newWin, event);
-            event.recycle();
         }
 
         void broadcastDragEnded() {
@@ -636,7 +639,7 @@
                     }
                 }
                 mNotifiedWindows.clear();
-                mDragEnded = true;
+                mDragInProgress = false;
             }
             evt.recycle();
         }
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index d008c90..3084c16 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2998,84 +2998,6 @@
         }
     }
     
-    final void decPersistentCountLocked(ProcessRecord app) {
-        app.persistentActivities--;
-        if (app.persistentActivities > 0) {
-            // Still more of 'em...
-            return;
-        }
-        if (app.persistent) {
-            // Ah, but the application itself is persistent.  Whatever!
-            return;
-        }
-
-        // App is no longer persistent...  make sure it and the ones
-        // following it in the LRU list have the correc oom_adj.
-        updateOomAdjLocked();
-    }
-
-    public void setPersistent(IBinder token, boolean isPersistent) {
-        if (checkCallingPermission(android.Manifest.permission.PERSISTENT_ACTIVITY)
-                != PackageManager.PERMISSION_GRANTED) {
-            String msg = "Permission Denial: setPersistent() from pid="
-                    + Binder.getCallingPid()
-                    + ", uid=" + Binder.getCallingUid()
-                    + " requires " + android.Manifest.permission.PERSISTENT_ACTIVITY;
-            Slog.w(TAG, msg);
-            throw new SecurityException(msg);
-        }
-
-        synchronized(this) {
-            int index = mMainStack.indexOfTokenLocked(token);
-            if (index < 0) {
-                return;
-            }
-            ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(index);
-            ProcessRecord app = r.app;
-
-            if (localLOGV) Slog.v(
-                TAG, "Setting persistence " + isPersistent + ": " + r);
-
-            if (isPersistent) {
-                if (r.persistent) {
-                    // Okay okay, I heard you already!
-                    if (localLOGV) Slog.v(TAG, "Already persistent!");
-                    return;
-                }
-                r.persistent = true;
-                app.persistentActivities++;
-                if (localLOGV) Slog.v(TAG, "Num persistent now: " + app.persistentActivities);
-                if (app.persistentActivities > 1) {
-                    // We aren't the first...
-                    if (localLOGV) Slog.v(TAG, "Not the first!");
-                    return;
-                }
-                if (app.persistent) {
-                    // This would be redundant.
-                    if (localLOGV) Slog.v(TAG, "App is persistent!");
-                    return;
-                }
-
-                // App is now persistent...  make sure it and the ones
-                // following it now have the correct oom_adj.
-                final long origId = Binder.clearCallingIdentity();
-                updateOomAdjLocked();
-                Binder.restoreCallingIdentity(origId);
-
-            } else {
-                if (!r.persistent) {
-                    // Okay okay, I heard you already!
-                    return;
-                }
-                r.persistent = false;
-                final long origId = Binder.clearCallingIdentity();
-                decPersistentCountLocked(app);
-                Binder.restoreCallingIdentity(origId);
-
-            }
-        }
-    }
-    
     public boolean clearApplicationUserData(final String packageName,
             final IPackageDataObserver observer) {
         int uid = Binder.getCallingUid();
@@ -11765,11 +11687,6 @@
             adj = FOREGROUND_APP_ADJ;
             schedGroup = Process.THREAD_GROUP_DEFAULT;
             app.adjType = "instrumentation";
-        } else if (app.persistentActivities > 0) {
-            // Special persistent activities...  shouldn't be used these days.
-            adj = FOREGROUND_APP_ADJ;
-            schedGroup = Process.THREAD_GROUP_DEFAULT;
-            app.adjType = "persistent";
         } else if (app.curReceiver != null ||
                 (mPendingBroadcast != null && mPendingBroadcast.curApp == app)) {
             // An app that is currently receiving a broadcast also
@@ -12493,8 +12410,7 @@
                     final ProcessRecord app = mLruProcesses.get(i);
 
                     if (app.persistent || app.services.size() != 0
-                            || app.curReceiver != null
-                            || app.persistentActivities > 0) {
+                            || app.curReceiver != null) {
                         // Don't count processes holding services against our
                         // maximum process count.
                         if (localLOGV) Slog.v(
@@ -12559,8 +12475,7 @@
                     // Quit the application only if we have a state saved for
                     // all of its activities.
                     boolean canQuit = !app.persistent && app.curReceiver == null
-                        && app.services.size() == 0
-                        && app.persistentActivities == 0;
+                        && app.services.size() == 0;
                     int NUMA = app.activities.size();
                     int j;
                     if (Config.LOGV) Slog.v(
@@ -12624,7 +12539,7 @@
                 // We can finish this one if we have its icicle saved and
                 // it is not persistent.
                 if ((r.haveState || !r.stateNotNeeded) && !r.visible
-                        && r.stopped && !r.persistent && !r.finishing) {
+                        && r.stopped && !r.finishing) {
                     final int origSize = mMainStack.mLRUActivities.size();
                     r.stack.destroyActivityLocked(r, true);
 
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
index 6bd89cc..47be6a2 100644
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -96,7 +96,6 @@
     int configChangeFlags;  // which config values have changed
     boolean keysPaused;     // has key dispatching been paused for it?
     boolean inHistory;      // are we in the history stack?
-    boolean persistent;     // requested to be persistent?
     int launchMode;         // the launch mode activity attribute.
     boolean visible;        // does this activity's window need to be shown?
     boolean waitingVisible; // true if waiting for a new act to become vis
@@ -161,7 +160,6 @@
                 pw.print(" finishing="); pw.println(finishing);
         pw.print(prefix); pw.print("keysPaused="); pw.print(keysPaused);
                 pw.print(" inHistory="); pw.print(inHistory);
-                pw.print(" persistent="); pw.print(persistent);
                 pw.print(" immersive="); pw.print(immersive);
                 pw.print(" launchMode="); pw.println(launchMode);
         pw.print(prefix); pw.print("fullscreen="); pw.print(fullscreen);
@@ -215,7 +213,6 @@
         configDestroy = false;
         keysPaused = false;
         inHistory = false;
-        persistent = false;
         visible = true;
         waitingVisible = false;
         nowVisible = false;
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 30395c0..016ddcd 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -515,7 +515,7 @@
                     r.info, r.icicle, results, newIntents, !andResume,
                     mService.isNextTransitionForward());
             
-            if ((app.info.flags&ApplicationInfo.CANT_SAVE_STATE) != 0) {
+            if ((app.info.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
                 // This may be a heavy-weight process!  Note that the package
                 // manager will ensure that only activity can run in the main
                 // process of the .apk, which is the only thing that will be
@@ -2442,7 +2442,7 @@
             final long origId = Binder.clearCallingIdentity();
             
             if (mMainStack && aInfo != null &&
-                    (aInfo.applicationInfo.flags&ApplicationInfo.CANT_SAVE_STATE) != 0) {
+                    (aInfo.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
                 // This may be a heavy-weight process!  Check to see if we already
                 // have another, different heavy-weight process running.
                 if (aInfo.processName.equals(aInfo.applicationInfo.packageName)) {
@@ -3151,9 +3151,6 @@
                     mService.mHandler.sendEmptyMessage(
                             ActivityManagerService.CANCEL_HEAVY_NOTIFICATION_MSG);
                 }
-                if (r.persistent) {
-                    mService.decPersistentCountLocked(r.app);
-                }
                 if (r.app.activities.size() == 0) {
                     // No longer have activities, so update location in
                     // LRU list.
@@ -3452,54 +3449,49 @@
             return true;
         }
         
-        // If the activity isn't persistent, there is a chance we will
-        // need to restart it.
-        if (!r.persistent) {
-
-            // Figure out what has changed between the two configurations.
-            int changes = oldConfig.diff(newConfig);
-            if (DEBUG_SWITCH || DEBUG_CONFIGURATION) {
-                Slog.v(TAG, "Checking to restart " + r.info.name + ": changed=0x"
-                        + Integer.toHexString(changes) + ", handles=0x"
-                        + Integer.toHexString(r.info.configChanges)
-                        + ", newConfig=" + newConfig);
+        // Figure out what has changed between the two configurations.
+        int changes = oldConfig.diff(newConfig);
+        if (DEBUG_SWITCH || DEBUG_CONFIGURATION) {
+            Slog.v(TAG, "Checking to restart " + r.info.name + ": changed=0x"
+                    + Integer.toHexString(changes) + ", handles=0x"
+                    + Integer.toHexString(r.info.configChanges)
+                    + ", newConfig=" + newConfig);
+        }
+        if ((changes&(~r.info.configChanges)) != 0) {
+            // Aha, the activity isn't handling the change, so DIE DIE DIE.
+            r.configChangeFlags |= changes;
+            r.startFreezingScreenLocked(r.app, globalChanges);
+            if (r.app == null || r.app.thread == null) {
+                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+                        "Switch is destroying non-running " + r);
+                destroyActivityLocked(r, true);
+            } else if (r.state == ActivityState.PAUSING) {
+                // A little annoying: we are waiting for this activity to
+                // finish pausing.  Let's not do anything now, but just
+                // flag that it needs to be restarted when done pausing.
+                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+                        "Switch is skipping already pausing " + r);
+                r.configDestroy = true;
+                return true;
+            } else if (r.state == ActivityState.RESUMED) {
+                // Try to optimize this case: the configuration is changing
+                // and we need to restart the top, resumed activity.
+                // Instead of doing the normal handshaking, just say
+                // "restart!".
+                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+                        "Switch is restarting resumed " + r);
+                relaunchActivityLocked(r, r.configChangeFlags, true);
+                r.configChangeFlags = 0;
+            } else {
+                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+                        "Switch is restarting non-resumed " + r);
+                relaunchActivityLocked(r, r.configChangeFlags, false);
+                r.configChangeFlags = 0;
             }
-            if ((changes&(~r.info.configChanges)) != 0) {
-                // Aha, the activity isn't handling the change, so DIE DIE DIE.
-                r.configChangeFlags |= changes;
-                r.startFreezingScreenLocked(r.app, globalChanges);
-                if (r.app == null || r.app.thread == null) {
-                    if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                            "Switch is destroying non-running " + r);
-                    destroyActivityLocked(r, true);
-                } else if (r.state == ActivityState.PAUSING) {
-                    // A little annoying: we are waiting for this activity to
-                    // finish pausing.  Let's not do anything now, but just
-                    // flag that it needs to be restarted when done pausing.
-                    if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                            "Switch is skipping already pausing " + r);
-                    r.configDestroy = true;
-                    return true;
-                } else if (r.state == ActivityState.RESUMED) {
-                    // Try to optimize this case: the configuration is changing
-                    // and we need to restart the top, resumed activity.
-                    // Instead of doing the normal handshaking, just say
-                    // "restart!".
-                    if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                            "Switch is restarting resumed " + r);
-                    relaunchActivityLocked(r, r.configChangeFlags, true);
-                    r.configChangeFlags = 0;
-                } else {
-                    if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                            "Switch is restarting non-resumed " + r);
-                    relaunchActivityLocked(r, r.configChangeFlags, false);
-                    r.configChangeFlags = 0;
-                }
-                
-                // All done...  tell the caller we weren't able to keep this
-                // activity around.
-                return false;
-            }
+            
+            // All done...  tell the caller we weren't able to keep this
+            // activity around.
+            return false;
         }
         
         // Default case: the activity can handle this new configuration, so
diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java
index 404c6be..353ff6d 100644
--- a/services/java/com/android/server/am/ProcessRecord.java
+++ b/services/java/com/android/server/am/ProcessRecord.java
@@ -115,7 +115,6 @@
     Dialog anrDialog;           // dialog being displayed due to app not resp.
     boolean removed;            // has app package been removed from device?
     boolean debugging;          // was app launched for debugging?
-    int persistentActivities;   // number of activities that are persistent
     boolean waitedForDebugger;  // has process show wait for debugger dialog?
     Dialog waitDialog;          // current wait for debugger dialog
     
@@ -181,8 +180,7 @@
                 pw.print(" foregroundServices="); pw.print(foregroundServices);
                 pw.print(" forcingToForeground="); pw.println(forcingToForeground);
         pw.print(prefix); pw.print("persistent="); pw.print(persistent);
-                pw.print(" removed="); pw.print(removed);
-                pw.print(" persistentActivities="); pw.println(persistentActivities);
+                pw.print(" removed="); pw.println(removed);
         pw.print(prefix); pw.print("adjSeq="); pw.print(adjSeq);
                 pw.print(" lruSeq="); pw.println(lruSeq);
         if (!keeping) {
@@ -259,7 +257,6 @@
         curAdj = setAdj = -100;
         persistent = false;
         removed = false;
-        persistentActivities = 0;
     }
 
     public void setPid(int _pid) {
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index bfac346..0623f5b 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -113,7 +113,7 @@
 
     private String[] mDnsServers;
     private static final String DNS_DEFAULT_SERVER1 = "8.8.8.8";
-    private static final String DNS_DEFAULT_SERVER2 = "4.2.2.2";
+    private static final String DNS_DEFAULT_SERVER2 = "8.8.4.4";
 
     // resampled each time we turn on tethering - used as cache for settings/config-val
     private boolean mDunRequired;  // configuration info - must use DUN apn on 3g
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index 39ce0b6..e9eb4f0 100755
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -46,6 +46,10 @@
 import android.os.SystemClock;
 import android.os.WorkSource;
 import android.provider.Settings;
+import android.provider.Telephony.Sms.Intents;
+import android.telephony.TelephonyManager;
+import android.telephony.gsm.GsmCellLocation;
+import android.telephony.SmsMessage;
 import android.util.Log;
 import android.util.SparseIntArray;
 
@@ -53,6 +57,9 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.location.GpsNetInitiatedHandler;
 import com.android.internal.location.GpsNetInitiatedHandler.GpsNiNotification;
+import com.android.internal.telephony.GsmAlphabet;
+import com.android.internal.telephony.SmsHeader;
+import com.android.internal.util.HexDump;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -153,6 +160,24 @@
     private static final int REMOVE_LISTENER = 9;
     private static final int REQUEST_SINGLE_SHOT = 10;
 
+    // Request setid
+    private static final int AGPS_RIL_REQUEST_SETID_IMSI = 1;
+    private static final int AGPS_RIL_REQUEST_SETID_MSISDN = 2;
+
+    // Request ref location
+    private static final int AGPS_RIL_REQUEST_REFLOC_CELLID = 1;
+    private static final int AGPS_RIL_REQUEST_REFLOC_MAC = 2;
+
+    // ref. location info
+    private static final int AGPS_REF_LOCATION_TYPE_GSM_CELLID = 1;
+    private static final int AGPS_REF_LOCATION_TYPE_UMTS_CELLID = 2;
+    private static final int AGPS_REG_LOCATION_TYPE_MAC        = 3;
+
+    // set id info
+    private static final int AGPS_SETID_TYPE_NONE = 0;
+    private static final int AGPS_SETID_TYPE_IMSI = 1;
+    private static final int AGPS_SETID_TYPE_MSISDN = 2;
+
     private static final String PROPERTIES_FILE = "/etc/gps.conf";
 
     private int mLocationFlags = LOCATION_INVALID;
@@ -328,10 +353,27 @@
             } else if (action.equals(ALARM_TIMEOUT)) {
                 if (DEBUG) Log.d(TAG, "ALARM_TIMEOUT");
                 hibernate();
-            }
+            } else if (action.equals(Intents.DATA_SMS_RECEIVED_ACTION)) {
+                checkSmsSuplInit(intent);
+            } else if (action.equals(Intents.WAP_PUSH_RECEIVED_ACTION)) {
+                checkWapSuplInit(intent);
+             }
         }
     };
 
+    private void checkSmsSuplInit(Intent intent) {
+        SmsMessage[] messages = Intents.getMessagesFromIntent(intent);
+        for (int i=0; i <messages.length; i++) {
+            byte[] supl_init = messages[i].getUserData();
+            native_agps_ni_message(supl_init,supl_init.length);
+        }
+    }
+
+    private void checkWapSuplInit(Intent intent) {
+        byte[] supl_init = (byte[]) intent.getExtra("data");
+        native_agps_ni_message(supl_init,supl_init.length);
+    }
+
     public static boolean isSupported() {
         return native_is_supported();
     }
@@ -352,6 +394,21 @@
         mWakeupIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ALARM_WAKEUP), 0);
         mTimeoutIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ALARM_TIMEOUT), 0);
 
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
+        intentFilter.addDataScheme("sms");
+        intentFilter.addDataAuthority("localhost","7275");
+        context.registerReceiver(mBroadcastReciever, intentFilter);
+
+        intentFilter = new IntentFilter();
+        intentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
+        try {
+            intentFilter.addDataType("application/vnd.omaloc-supl-init");
+        } catch (IntentFilter.MalformedMimeTypeException e) {
+            Log.w(TAG, "Malformed SUPL init mime type");
+        }
+        context.registerReceiver(mBroadcastReciever, intentFilter);
+
         mConnMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
         // Battery statistics service to be notified when GPS turns on or off
@@ -1255,22 +1312,20 @@
 
     //=============================================================
     // NI Client support
-	//=============================================================
+    //=============================================================
     private final INetInitiatedListener mNetInitiatedListener = new INetInitiatedListener.Stub() {
-    	// Sends a response for an NI reqeust to HAL.
-    	public boolean sendNiResponse(int notificationId, int userResponse)
-    	{
-        	// TODO Add Permission check
-    		
-    		StringBuilder extrasBuf = new StringBuilder();
+        // Sends a response for an NI reqeust to HAL.
+        public boolean sendNiResponse(int notificationId, int userResponse)
+        {
+            // TODO Add Permission check
 
-    		if (DEBUG) Log.d(TAG, "sendNiResponse, notifId: " + notificationId +
-    				", response: " + userResponse);
-    		
-    		native_send_ni_response(notificationId, userResponse);
-    		
-    		return true;
-    	}        
+            StringBuilder extrasBuf = new StringBuilder();
+
+            if (DEBUG) Log.d(TAG, "sendNiResponse, notifId: " + notificationId +
+                    ", response: " + userResponse);
+            native_send_ni_response(notificationId, userResponse);
+            return true;
+        }
     };
         
     public INetInitiatedListener getNetInitiatedListener() {
@@ -1278,70 +1333,132 @@
     }
 
     // Called by JNI function to report an NI request.
-	@SuppressWarnings("deprecation")
-	public void reportNiNotification(
-        	int notificationId,
-        	int niType,
-        	int notifyFlags,
-        	int timeout,
-        	int defaultResponse,
-        	String requestorId,
-        	String text,
-        	int requestorIdEncoding,
-        	int textEncoding,
-        	String extras  // Encoded extra data
+    public void reportNiNotification(
+            int notificationId,
+            int niType,
+            int notifyFlags,
+            int timeout,
+            int defaultResponse,
+            String requestorId,
+            String text,
+            int requestorIdEncoding,
+            int textEncoding,
+            String extras  // Encoded extra data
         )
-	{
-		Log.i(TAG, "reportNiNotification: entered");
-		Log.i(TAG, "notificationId: " + notificationId +
-				", niType: " + niType +
-				", notifyFlags: " + notifyFlags +
-				", timeout: " + timeout +
-				", defaultResponse: " + defaultResponse);
-		
-		Log.i(TAG, "requestorId: " + requestorId +
-				", text: " + text +
-				", requestorIdEncoding: " + requestorIdEncoding +
-				", textEncoding: " + textEncoding);
-		
-		GpsNiNotification notification = new GpsNiNotification();
-		
-		notification.notificationId = notificationId;
-		notification.niType = niType;
-		notification.needNotify = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_NEED_NOTIFY) != 0;
-		notification.needVerify = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_NEED_VERIFY) != 0;
-		notification.privacyOverride = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_PRIVACY_OVERRIDE) != 0;
-		notification.timeout = timeout;
-		notification.defaultResponse = defaultResponse;
-		notification.requestorId = requestorId;
-		notification.text = text;
-		notification.requestorIdEncoding = requestorIdEncoding;
-		notification.textEncoding = textEncoding;
-		
-		// Process extras, assuming the format is
-		// one of more lines of "key = value"
-		Bundle bundle = new Bundle();
-		
-		if (extras == null) extras = "";
-		Properties extraProp = new Properties();
-		
-		try {
-			extraProp.load(new StringBufferInputStream(extras));
-		}
-		catch (IOException e)
-		{
-			Log.e(TAG, "reportNiNotification cannot parse extras data: " + extras);
-		}
-		
-		for (Entry<Object, Object> ent : extraProp.entrySet())
-		{
-			bundle.putString((String) ent.getKey(), (String) ent.getValue());
-		}		
-		
-		notification.extras = bundle;
-		
-		mNIHandler.handleNiNotification(notification);		
-	}
+    {
+        Log.i(TAG, "reportNiNotification: entered");
+        Log.i(TAG, "notificationId: " + notificationId +
+                ", niType: " + niType +
+                ", notifyFlags: " + notifyFlags +
+                ", timeout: " + timeout +
+                ", defaultResponse: " + defaultResponse);
+
+        Log.i(TAG, "requestorId: " + requestorId +
+                ", text: " + text +
+                ", requestorIdEncoding: " + requestorIdEncoding +
+                ", textEncoding: " + textEncoding);
+
+        GpsNiNotification notification = new GpsNiNotification();
+
+        notification.notificationId = notificationId;
+        notification.niType = niType;
+        notification.needNotify = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_NEED_NOTIFY) != 0;
+        notification.needVerify = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_NEED_VERIFY) != 0;
+        notification.privacyOverride = (notifyFlags & GpsNetInitiatedHandler.GPS_NI_PRIVACY_OVERRIDE) != 0;
+        notification.timeout = timeout;
+        notification.defaultResponse = defaultResponse;
+        notification.requestorId = requestorId;
+        notification.text = text;
+        notification.requestorIdEncoding = requestorIdEncoding;
+        notification.textEncoding = textEncoding;
+
+        // Process extras, assuming the format is
+        // one of more lines of "key = value"
+        Bundle bundle = new Bundle();
+
+        if (extras == null) extras = "";
+        Properties extraProp = new Properties();
+
+        try {
+            extraProp.load(new StringBufferInputStream(extras));
+        }
+        catch (IOException e)
+        {
+            Log.e(TAG, "reportNiNotification cannot parse extras data: " + extras);
+        }
+
+        for (Entry<Object, Object> ent : extraProp.entrySet())
+        {
+            bundle.putString((String) ent.getKey(), (String) ent.getValue());
+        }
+
+        notification.extras = bundle;
+
+        mNIHandler.handleNiNotification(notification);
+    }
+
+    /**
+     * Called from native code to request set id info.
+     * We should be careful about receiving null string from the TelephonyManager,
+     * because sending null String to JNI function would cause a crash.
+     */
+
+    private void requestSetID(int flags) {
+        TelephonyManager phone = (TelephonyManager)
+                mContext.getSystemService(Context.TELEPHONY_SERVICE);
+        int    type = AGPS_SETID_TYPE_NONE;
+        String data = "";
+
+        if ((flags & AGPS_RIL_REQUEST_SETID_IMSI) == AGPS_RIL_REQUEST_SETID_IMSI) {
+            String data_temp = phone.getSubscriberId();
+            if (data_temp == null) {
+                // This means the framework does not have the SIM card ready.
+            } else {
+                // This means the framework has the SIM card.
+                data = data_temp;
+                type = AGPS_SETID_TYPE_IMSI;
+            }
+        }
+        else if ((flags & AGPS_RIL_REQUEST_SETID_MSISDN) == AGPS_RIL_REQUEST_SETID_MSISDN) {
+            String data_temp = phone.getLine1Number();
+            if (data_temp == null) {
+                // This means the framework does not have the SIM card ready.
+            } else {
+                // This means the framework has the SIM card.
+                data = data_temp;
+                type = AGPS_SETID_TYPE_MSISDN;
+            }
+        }
+        native_agps_set_id(type, data);
+    }
+
+    /**
+     * Called from native code to request reference location info
+     */
+
+    private void requestRefLocation(int flags) {
+        TelephonyManager phone = (TelephonyManager)
+                mContext.getSystemService(Context.TELEPHONY_SERVICE);
+        if (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
+            GsmCellLocation gsm_cell = (GsmCellLocation) phone.getCellLocation();
+            if ((gsm_cell != null) && (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM)
+                    && (phone.getNetworkOperator().length() > 3)) {
+                int type;
+                int mcc = Integer.parseInt(phone.getNetworkOperator().substring(0,3));
+                int mnc = Integer.parseInt(phone.getNetworkOperator().substring(3));
+                if (phone.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS)
+                    type = AGPS_REF_LOCATION_TYPE_UMTS_CELLID;
+                else
+                    type = AGPS_REF_LOCATION_TYPE_GSM_CELLID;
+                native_agps_set_ref_location_cellid(type, mcc, mnc,
+                        gsm_cell.getLac(), gsm_cell.getCid());
+            }
+            else
+                Log.e(TAG,"Error getting cell location info.");
+        }
+        else
+            Log.e(TAG,"CDMA not supported.");
+    }
 
     private void sendMessage(int message, int arg, Object obj) {
         // hold a wake lock while messages are pending
@@ -1472,8 +1589,14 @@
     private native void native_agps_data_conn_open(String apn);
     private native void native_agps_data_conn_closed();
     private native void native_agps_data_conn_failed();
+    private native void native_agps_ni_message(byte [] msg, int length);
     private native void native_set_agps_server(int type, String hostname, int port);
 
     // Network-initiated (NI) Support
     private native void native_send_ni_response(int notificationId, int userResponse);
+
+    // AGPS ril suport
+    private native void native_agps_set_ref_location_cellid(int type, int mcc, int mnc,
+            int lac, int cid);
+    private native void native_agps_set_id(int type, String setid);
 }
diff --git a/services/jni/com_android_server_location_GpsLocationProvider.cpp b/services/jni/com_android_server_location_GpsLocationProvider.cpp
index 93068e6..71c7aba 100755
--- a/services/jni/com_android_server_location_GpsLocationProvider.cpp
+++ b/services/jni/com_android_server_location_GpsLocationProvider.cpp
@@ -40,12 +40,15 @@
 static jmethodID method_setEngineCapabilities;
 static jmethodID method_xtraDownloadRequest;
 static jmethodID method_reportNiNotification;
+static jmethodID method_requestRefLocation;
+static jmethodID method_requestSetID;
 
 static const GpsInterface* sGpsInterface = NULL;
 static const GpsXtraInterface* sGpsXtraInterface = NULL;
 static const AGpsInterface* sAGpsInterface = NULL;
 static const GpsNiInterface* sGpsNiInterface = NULL;
 static const GpsDebugInterface* sGpsDebugInterface = NULL;
+static const AGpsRilInterface* sAGpsRilInterface = NULL;
 
 // temporary storage for GPS callbacks
 static GpsSvStatus  sGpsSvStatus;
@@ -193,17 +196,30 @@
     create_thread_callback,
 };
 
-static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, jclass clazz) {
-    method_reportLocation = env->GetMethodID(clazz, "reportLocation", "(IDDDFFFJ)V");
-    method_reportStatus = env->GetMethodID(clazz, "reportStatus", "(I)V");
-    method_reportSvStatus = env->GetMethodID(clazz, "reportSvStatus", "()V");
-    method_reportAGpsStatus = env->GetMethodID(clazz, "reportAGpsStatus", "(II)V");
-    method_reportNmea = env->GetMethodID(clazz, "reportNmea", "(J)V");
-    method_setEngineCapabilities = env->GetMethodID(clazz, "setEngineCapabilities", "(I)V");
-    method_xtraDownloadRequest = env->GetMethodID(clazz, "xtraDownloadRequest", "()V");
-    method_reportNiNotification = env->GetMethodID(clazz, "reportNiNotification", "(IIIIILjava/lang/String;Ljava/lang/String;IILjava/lang/String;)V");
+static void agps_request_set_id(uint32_t flags)
+{
+    LOGD("agps_request_set_id: flags (%d)", flags);
+
+    JNIEnv* env = AndroidRuntime::getJNIEnv();
+    env->CallVoidMethod(mCallbacksObj, method_requestSetID, flags);
+    checkAndClearExceptionFromCallback(env, __FUNCTION__);
 }
 
+static void agps_request_ref_location(uint32_t flags)
+{
+    LOGD("agps_ref_location: flags (%d)", flags);
+
+    JNIEnv* env = AndroidRuntime::getJNIEnv();
+    env->CallVoidMethod(mCallbacksObj, method_requestRefLocation, flags);
+    checkAndClearExceptionFromCallback(env, __FUNCTION__);
+}
+
+AGpsRilCallbacks sAGpsRilCallbacks = {
+    agps_request_set_id,
+    agps_request_ref_location,
+    create_thread_callback,
+};
+
 static const GpsInterface* get_gps_interface() {
     int err;
     hw_module_t* module;
@@ -222,6 +238,64 @@
     return interface;
 }
 
+static const AGpsInterface* GetAGpsInterface()
+{
+    if (!sGpsInterface)
+        sGpsInterface = get_gps_interface();
+    if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
+        return NULL;
+
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
+        if (sAGpsInterface)
+            sAGpsInterface->init(&sAGpsCallbacks);
+    }
+    return sAGpsInterface;
+}
+
+static const GpsNiInterface* GetNiInterface()
+{
+    if (!sGpsInterface)
+        sGpsInterface = get_gps_interface();
+    if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
+        return NULL;
+
+    if (!sGpsNiInterface) {
+       sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
+        if (sGpsNiInterface)
+           sGpsNiInterface->init(&sGpsNiCallbacks);
+    }
+    return sGpsNiInterface;
+}
+
+static const AGpsRilInterface* GetAGpsRilInterface()
+{
+    if (!sGpsInterface)
+        sGpsInterface = get_gps_interface();
+    if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
+        return NULL;
+
+    if (!sAGpsRilInterface) {
+       sAGpsRilInterface = (const AGpsRilInterface*)sGpsInterface->get_extension(AGPS_RIL_INTERFACE);
+        if (sAGpsRilInterface)
+            sAGpsRilInterface->init(&sAGpsRilCallbacks);
+    }
+    return sAGpsRilInterface;
+}
+
+static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, jclass clazz) {
+    method_reportLocation = env->GetMethodID(clazz, "reportLocation", "(IDDDFFFJ)V");
+    method_reportStatus = env->GetMethodID(clazz, "reportStatus", "(I)V");
+    method_reportSvStatus = env->GetMethodID(clazz, "reportSvStatus", "()V");
+    method_reportAGpsStatus = env->GetMethodID(clazz, "reportAGpsStatus", "(II)V");
+    method_reportNmea = env->GetMethodID(clazz, "reportNmea", "(J)V");
+    method_setEngineCapabilities = env->GetMethodID(clazz, "setEngineCapabilities", "(I)V");
+    method_xtraDownloadRequest = env->GetMethodID(clazz, "xtraDownloadRequest", "()V");
+    method_reportNiNotification = env->GetMethodID(clazz, "reportNiNotification", "(IIIIILjava/lang/String;Ljava/lang/String;IILjava/lang/String;)V");
+    method_requestRefLocation = env->GetMethodID(clazz,"requestRefLocation","(I)V");
+    method_requestSetID = env->GetMethodID(clazz,"requestSetID","(I)V");
+}
+
 static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* env, jclass clazz) {
     if (!sGpsInterface)
         sGpsInterface = get_gps_interface();
@@ -239,16 +313,6 @@
     if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
         return false;
 
-    if (!sAGpsInterface)
-        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
-    if (sAGpsInterface)
-        sAGpsInterface->init(&sAGpsCallbacks);
-
-    if (!sGpsNiInterface)
-        sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
-    if (sGpsNiInterface)
-        sGpsNiInterface->init(&sGpsNiCallbacks);
-
     if (!sGpsDebugInterface)
        sGpsDebugInterface = (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE);
 
@@ -313,6 +377,64 @@
     return num_svs;
 }
 
+static void android_location_GpsLocationProvider_agps_set_reference_location_cellid(JNIEnv* env,
+        jobject obj, jint type, jint mcc, jint mnc, jint lac, jint cid)
+{
+    AGpsRefLocation location;
+    const AGpsRilInterface* interface = GetAGpsRilInterface();
+    if (!interface) {
+        LOGE("no AGPS RIL interface in agps_set_reference_location_cellid");
+        return;
+    }
+
+    switch(type) {
+        case AGPS_REF_LOCATION_TYPE_GSM_CELLID:
+        case AGPS_REF_LOCATION_TYPE_UMTS_CELLID:
+            location.type = type;
+            location.u.cellID.mcc = mcc;
+            location.u.cellID.mnc = mnc;
+            location.u.cellID.lac = lac;
+            location.u.cellID.cid = cid;
+            break;
+        default:
+            LOGE("Neither a GSM nor a UMTS cellid (%s:%d).",__FUNCTION__,__LINE__);
+            return;
+            break;
+    }
+    interface->set_ref_location(&location, sizeof(location));
+}
+
+static void android_location_GpsLocationProvider_agps_send_ni_message(JNIEnv* env,
+        jobject obj, jbyteArray ni_msg, jint size)
+{
+    size_t sz;
+    const AGpsRilInterface* interface = GetAGpsRilInterface();
+    if (!interface) {
+        LOGE("no AGPS RIL interface in send_ni_message");
+        return;
+    }
+    if (size < 0)
+        return;
+    sz = (size_t)size;
+    jbyte* b = env->GetByteArrayElements(ni_msg, 0);
+    interface->ni_message((uint8_t *)b,sz);
+    env->ReleaseByteArrayElements(ni_msg,b,0);
+}
+
+static void android_location_GpsLocationProvider_agps_set_id(JNIEnv *env,
+        jobject obj, jint type, jstring  setid_string)
+{
+    const AGpsRilInterface* interface = GetAGpsRilInterface();
+    if (!interface) {
+        LOGE("no AGPS RIL interface in agps_set_id");
+        return;
+    }
+
+    const char *setid = env->GetStringUTFChars(setid_string, NULL);
+    interface->set_set_id(type, setid);
+    env->ReleaseStringUTFChars(setid_string, setid);
+}
+
 static jint android_location_GpsLocationProvider_read_nmea(JNIEnv* env, jobject obj,
                                             jbyteArray nmeaArray, jint buffer_size)
 {
@@ -363,60 +485,63 @@
 
 static void android_location_GpsLocationProvider_agps_data_conn_open(JNIEnv* env, jobject obj, jstring apn)
 {
-    if (!sAGpsInterface) {
-        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
+    const AGpsInterface* interface = GetAGpsInterface();
+    if (!interface) {
+        LOGE("no AGPS interface in agps_data_conn_open");
+        return;
     }
-    if (sAGpsInterface) {
-        if (apn == NULL) {
-            jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-            return;
-        }
-        const char *apnStr = env->GetStringUTFChars(apn, NULL);
-        sAGpsInterface->data_conn_open(apnStr);
-        env->ReleaseStringUTFChars(apn, apnStr);
+    if (apn == NULL) {
+        jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+        return;
     }
+    const char *apnStr = env->GetStringUTFChars(apn, NULL);
+    interface->data_conn_open(apnStr);
+    env->ReleaseStringUTFChars(apn, apnStr);
 }
 
 static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* env, jobject obj)
 {
-    if (!sAGpsInterface) {
-        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
+    const AGpsInterface* interface = GetAGpsInterface();
+    if (!interface) {
+        LOGE("no AGPS interface in agps_data_conn_open");
+        return;
     }
-    if (sAGpsInterface) {
-        sAGpsInterface->data_conn_closed();
-    }
+    interface->data_conn_closed();
 }
 
 static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* env, jobject obj)
 {
-    if (!sAGpsInterface) {
-        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
+    const AGpsInterface* interface = GetAGpsInterface();
+    if (!interface) {
+        LOGE("no AGPS interface in agps_data_conn_open");
+        return;
     }
-    if (sAGpsInterface) {
-        sAGpsInterface->data_conn_failed();
-    }
+    interface->data_conn_failed();
 }
 
 static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj,
         jint type, jstring hostname, jint port)
 {
-    if (!sAGpsInterface) {
-        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
+    const AGpsInterface* interface = GetAGpsInterface();
+    if (!interface) {
+        LOGE("no AGPS interface in agps_data_conn_open");
+        return;
     }
-    if (sAGpsInterface) {
-        const char *c_hostname = env->GetStringUTFChars(hostname, NULL);
-        sAGpsInterface->set_server(type, c_hostname, port);
-        env->ReleaseStringUTFChars(hostname, c_hostname);
-    }
+    const char *c_hostname = env->GetStringUTFChars(hostname, NULL);
+    interface->set_server(type, c_hostname, port);
+    env->ReleaseStringUTFChars(hostname, c_hostname);
 }
 
 static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, jobject obj,
       jint notifId, jint response)
 {
-    if (!sGpsNiInterface)
-        sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
-    if (sGpsNiInterface)
-        sGpsNiInterface->respond(notifId, response);
+    const GpsNiInterface* interface = GetNiInterface();
+    if (!interface) {
+        LOGE("no NI interface in send_ni_response");
+        return;
+    }
+
+    interface->respond(notifId, response);
 }
 
 static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* env, jobject obj)
@@ -452,8 +577,11 @@
     {"native_agps_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_agps_data_conn_open},
     {"native_agps_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_closed},
     {"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},
+    {"native_agps_set_id","(ILjava/lang/String;)V",(void*)android_location_GpsLocationProvider_agps_set_id},
+    {"native_agps_set_ref_location_cellid","(IIIII)V",(void*)android_location_GpsLocationProvider_agps_set_reference_location_cellid},
     {"native_set_agps_server", "(ILjava/lang/String;I)V", (void*)android_location_GpsLocationProvider_set_agps_server},
     {"native_send_ni_response", "(II)V", (void*)android_location_GpsLocationProvider_send_ni_response},
+    {"native_agps_ni_message", "([BI)V", (void *)android_location_GpsLocationProvider_agps_send_ni_message},
     {"native_get_internal_state", "()Ljava/lang/String;", (void*)android_location_GpsLocationProvider_get_internal_state},
 };
 
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index ff887e4..4af274b 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -84,7 +84,9 @@
 
 status_t HWComposer::commit() const {
     int err = mHwc->set(mHwc, mDpy, mSur, mList);
-    mList->flags &= ~HWC_GEOMETRY_CHANGED;
+    if (mList) {
+        mList->flags &= ~HWC_GEOMETRY_CHANGED;
+    }
     return (status_t)err;
 }
 
diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp
index d668e88..4fb1e61 100644
--- a/services/surfaceflinger/MessageQueue.cpp
+++ b/services/surfaceflinger/MessageQueue.cpp
@@ -91,17 +91,21 @@
                     mMessages.remove(cur);
                     break;
                 }
-                if (timeout>=0 && timeoutTime < now) {
-                    // we timed-out, return a NULL message
-                    result = 0;
-                    break;
-                }
                 nextEventTime = result->when;
                 result = 0;
             }
 
-            if (timeout >= 0 && nextEventTime > 0) {
-                if (nextEventTime > timeoutTime) {
+            if (timeout >= 0) {
+                if (timeoutTime < now) {
+                    // we timed-out, return a NULL message
+                    result = 0;
+                    break;
+                }
+                if (nextEventTime > 0) {
+                    if (nextEventTime > timeoutTime) {
+                        nextEventTime = timeoutTime;
+                    }
+                } else {
                     nextEventTime = timeoutTime;
                 }
             }
diff --git a/telephony/java/com/android/internal/telephony/CallManager.java b/telephony/java/com/android/internal/telephony/CallManager.java
index 09b7d05..7a026fa 100644
--- a/telephony/java/com/android/internal/telephony/CallManager.java
+++ b/telephony/java/com/android/internal/telephony/CallManager.java
@@ -1468,13 +1468,27 @@
      *
      */
     public Call getActiveFgCall() {
-        for (Call call : mForegroundCalls) {
-            if (call.getState() != Call.State.IDLE) {
+        Call call = getFirstNonIdleCall(mForegroundCalls);
+        if (call == null) {
+            call = (mDefaultPhone == null)
+                    ? null
+                    : mDefaultPhone.getForegroundCall();
+        }
+        return call;
+    }
+
+    // Returns the first call that is not in IDLE state. If both active calls
+    // and disconnecting/disconnected calls exist, return the first active call.
+    private Call getFirstNonIdleCall(List<Call> calls) {
+        Call result = null;
+        for (Call call : calls) {
+            if (!call.isIdle()) {
                 return call;
+            } else if (call.getState() != Call.State.IDLE) {
+                if (result == null) result = call;
             }
         }
-        return (mDefaultPhone == null) ?
-                null : mDefaultPhone.getForegroundCall();
+        return result;
     }
 
     /**
@@ -1491,13 +1505,13 @@
      * Complete background calls list can be get by getBackgroundCalls()
      */
     public Call getFirstActiveBgCall() {
-        for (Call call : mBackgroundCalls) {
-            if (call.getState() != Call.State.IDLE) {
-                return call;
-            }
+        Call call = getFirstNonIdleCall(mBackgroundCalls);
+        if (call == null) {
+            call = (mDefaultPhone == null)
+                    ? null
+                    : mDefaultPhone.getBackgroundCall();
         }
-        return (mDefaultPhone == null) ?
-                null : mDefaultPhone.getBackgroundCall();
+        return call;
     }
 
     /**
@@ -1514,13 +1528,13 @@
      * Complete ringing calls list can be get by getRingingCalls()
      */
     public Call getFirstActiveRingingCall() {
-        for (Call call : mRingingCalls) {
-            if (!call.isIdle()) {
-                return call;
-            }
+        Call call = getFirstNonIdleCall(mRingingCalls);
+        if (call == null) {
+            call = (mDefaultPhone == null)
+                    ? null
+                    : mDefaultPhone.getRingingCall();
         }
-        return (mDefaultPhone == null) ?
-                null : mDefaultPhone.getRingingCall();
+        return call;
     }
 
     /**
diff --git a/telephony/java/com/android/internal/telephony/Connection.java b/telephony/java/com/android/internal/telephony/Connection.java
index 0d983b5..07f90cd 100644
--- a/telephony/java/com/android/internal/telephony/Connection.java
+++ b/telephony/java/com/android/internal/telephony/Connection.java
@@ -40,6 +40,7 @@
         MMI,                            /* not presently used; dial() returns null */
         INVALID_NUMBER,                 /* invalid dial string */
         NUMBER_UNREACHABLE,             /* cannot reach the peer */
+        SERVER_UNREACHABLE,             /* cannot reach the server */
         INVALID_CREDENTIALS,            /* invalid credentials */
         OUT_OF_NETWORK,                 /* calling from out of network is not allowed */
         SERVER_ERROR,                   /* server error */
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
index 55e3002..878d30c 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
@@ -810,7 +810,10 @@
                 } catch (SipException e) {
                     throw new CallStateException("hangup(): " + e);
                 } finally {
-                    mAdapter.onCallEnded(DisconnectCause.LOCAL);
+                    mAdapter.onCallEnded(((mState == Call.State.INCOMING)
+                            || (mState == Call.State.WAITING))
+                            ? DisconnectCause.INCOMING_REJECTED
+                            : DisconnectCause.LOCAL);
                 }
             }
         }
@@ -874,6 +877,9 @@
         public void onError(SipAudioCall call, int errorCode,
                 String errorMessage) {
             switch (errorCode) {
+                case SipErrorCode.SERVER_UNREACHABLE:
+                    onError(Connection.DisconnectCause.SERVER_UNREACHABLE);
+                    break;
                 case SipErrorCode.PEER_NOT_REACHABLE:
                     onError(Connection.DisconnectCause.NUMBER_UNREACHABLE);
                     break;
diff --git a/tests/CoreTests/android/core/MiscRegressionTest.java b/tests/CoreTests/android/core/MiscRegressionTest.java
index 8281db0..7734397 100644
--- a/tests/CoreTests/android/core/MiscRegressionTest.java
+++ b/tests/CoreTests/android/core/MiscRegressionTest.java
@@ -66,37 +66,6 @@
         }
     }
 
-    // Regression test for #1061945: negative Shorts do not
-    // serialize/deserialize correctly
-    @SmallTest
-    public void testShortSerialization() throws Exception {
-        // create an instance of ObjectInputStream
-        String x = new String("serialize_foobar");
-        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
-        (new java.io.ObjectOutputStream(baos)).writeObject(x);
-        ObjectInputStream ois = new java.io.ObjectInputStream(
-                new java.io.ByteArrayInputStream(baos.toByteArray()));
-
-        // get the setField(...,, short val) method in question
-        Class<ObjectInputStream> oClass = ObjectInputStream.class;
-        Method m = oClass.getDeclaredMethod("setField", new Class[] { Object.class, Class.class, String.class, short.class});
-        // compose args
-        short start = 123;
-        short origval = -1; // 0xffff
-        Short obj = new Short(start);
-        Class<Short> declaringClass = Short.class;
-        String fieldDescName = "value";
-
-        // test the initial value
-        assertEquals(obj.shortValue(), start);
-        // invoke native method to set the field "value" of type short to the newval
-        m.setAccessible(true); // since the method is private
-        m.invoke(ois, new Object[]{ obj, declaringClass, fieldDescName, new Short(origval)} );
-        // test the set value
-        short res = obj.shortValue();
-        assertEquals("Read and written values must be equal", origval, res);
-    }
-    
     // Regression test for #951285: Suitable LogHandler should be chosen
     // depending on the environment.
     @MediumTest
diff --git a/tests/CoreTests/android/core/NIOTest.java b/tests/CoreTests/android/core/NIOTest.java
index fd279ca..9476d07 100644
--- a/tests/CoreTests/android/core/NIOTest.java
+++ b/tests/CoreTests/android/core/NIOTest.java
@@ -40,27 +40,31 @@
     }
 
     @SmallTest
-    public void testNIO() throws Exception {
-        ByteBuffer b;
-
+    public void testNIO_byte_array() throws Exception {
         // Test byte array-based buffer
-        b = ByteBuffer.allocate(12);
-        byteBufferTest(b);
+        byteBufferTest(ByteBuffer.allocate(12));
+    }
 
+    public void testNIO_direct() throws Exception {
         // Test native heap-allocated buffer
-        b = ByteBuffer.allocateDirect(12);
-        byteBufferTest(b);
+        byteBufferTest(ByteBuffer.allocateDirect(12));
+    }
 
+    public void testNIO_short_array() throws Exception {
         // Test short array-based buffer
         short[] shortArray = new short[8];
         ShortBuffer sb = ShortBuffer.wrap(shortArray);
         shortBufferTest(sb);
+    }
 
+    public void testNIO_int_array() throws Exception {
         // Test int array-based buffer
         int[] intArray = new int[8];
         IntBuffer ib = IntBuffer.wrap(intArray);
         intBufferTest(ib);
+    }
 
+    public void testNIO_float_array() throws Exception {
         // Test float array-based buffer
         float[] floatArray = new float[8];
         FloatBuffer fb = FloatBuffer.wrap(floatArray);
@@ -70,6 +74,12 @@
     private void byteBufferTest(ByteBuffer b) {
         checkBuffer(b);
 
+        // Duplicate buffers revert to big-endian.
+        b.order(ByteOrder.LITTLE_ENDIAN);
+        ByteBuffer dupe = b.duplicate();
+        assertEquals(ByteOrder.BIG_ENDIAN, dupe.order());
+        b.order(ByteOrder.BIG_ENDIAN);
+
         // Bounds checks
         try {
             b.put(-1, (byte) 0);
@@ -272,9 +282,9 @@
         // Check 'getFloat'
         b.order(ByteOrder.LITTLE_ENDIAN);
         b.position(0);
-        assertEquals(0xA3A2A1A0, Float.floatToIntBits(b.getFloat()));
-        assertEquals(0xA7A6A5A4, Float.floatToIntBits(b.getFloat()));
-        assertEquals(0xABAAA9A8, Float.floatToIntBits(b.getFloat()));
+        assertEquals(0xA3A2A1A0, Float.floatToRawIntBits(b.getFloat()));
+        assertEquals(0xA7A6A5A4, Float.floatToRawIntBits(b.getFloat()));
+        assertEquals(0xABAAA9A8, Float.floatToRawIntBits(b.getFloat()));
         try {
             b.getFloat();
             fail("expected exception not thrown");
@@ -284,9 +294,9 @@
 
         b.order(ByteOrder.BIG_ENDIAN);
         b.position(0);
-        assertEquals(0xA0A1A2A3, Float.floatToIntBits(b.getFloat()));
-        assertEquals(0xA4A5A6A7, Float.floatToIntBits(b.getFloat()));
-        assertEquals(0xA8A9AAAB, Float.floatToIntBits(b.getFloat()));
+        assertEquals(0xA0A1A2A3, Float.floatToRawIntBits(b.getFloat()));
+        assertEquals(0xA4A5A6A7, Float.floatToRawIntBits(b.getFloat()));
+        assertEquals(0xA8A9AAAB, Float.floatToRawIntBits(b.getFloat()));
         try {
             b.getFloat();
             fail("expected exception not thrown");
@@ -296,8 +306,8 @@
 
         // Check 'getDouble(int position)'
         b.order(ByteOrder.LITTLE_ENDIAN);
-        assertEquals(0xA7A6A5A4A3A2A1A0L, Double.doubleToLongBits(b.getDouble(0)));
-        assertEquals(0xA8A7A6A5A4A3A2A1L, Double.doubleToLongBits(b.getDouble(1)));
+        assertEquals(0xA7A6A5A4A3A2A1A0L, Double.doubleToRawLongBits(b.getDouble(0)));
+        assertEquals(0xA8A7A6A5A4A3A2A1L, Double.doubleToRawLongBits(b.getDouble(1)));
         try {
             b.getDouble(-1);
             fail("expected exception not thrown");
@@ -312,8 +322,8 @@
         }
 
         b.order(ByteOrder.BIG_ENDIAN);
-        assertEquals(0xA0A1A2A3A4A5A6A7L, Double.doubleToLongBits(b.getDouble(0)));
-        assertEquals(0xA1A2A3A4A5A6A7A8L, Double.doubleToLongBits(b.getDouble(1)));
+        assertEquals(0xA0A1A2A3A4A5A6A7L, Double.doubleToRawLongBits(b.getDouble(0)));
+        assertEquals(0xA1A2A3A4A5A6A7A8L, Double.doubleToRawLongBits(b.getDouble(1)));
         try {
             b.getDouble(-1);
             fail("expected exception not thrown");
@@ -333,6 +343,9 @@
         b.order(ByteOrder.LITTLE_ENDIAN);
         bb = b.slice();
         assertEquals(4, bb.capacity());
+        assertEquals(ByteOrder.BIG_ENDIAN, bb.order());
+        assertEquals(0xA1A2A3A4, bb.getInt(0));
+        bb.order(ByteOrder.LITTLE_ENDIAN);
         assertEquals(0xA4A3A2A1, bb.getInt(0));
 
         bb.order(ByteOrder.LITTLE_ENDIAN);
@@ -370,14 +383,14 @@
 
         checkBuffer(fb);
         assertEquals(1, fb.capacity());
-        assertEquals(0xA4A3A2A1, Float.floatToIntBits(fb.get()));
+        assertEquals(0xA4A3A2A1, Float.floatToRawIntBits(fb.get()));
 
         bb.order(ByteOrder.BIG_ENDIAN);
         fb = bb.asFloatBuffer();
 
         checkBuffer(fb);
         assertEquals(1, fb.capacity());
-        assertEquals(0xA1A2A3A4, Float.floatToIntBits(fb.get()));
+        assertEquals(0xA1A2A3A4, Float.floatToRawIntBits(fb.get()));
     }
 
     private void shortBufferTest(ShortBuffer sb) {
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GradientsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GradientsActivity.java
index b70f3a9..8fa626b 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GradientsActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GradientsActivity.java
@@ -18,13 +18,21 @@
 
 import android.app.Activity;
 import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.BitmapShader;
 import android.graphics.Canvas;
 import android.graphics.LinearGradient;
+import android.graphics.RadialGradient;
 import android.graphics.Matrix;
 import android.graphics.Paint;
 import android.graphics.Shader;
+import android.graphics.SweepGradient;
 import android.os.Bundle;
+import android.view.Gravity;
 import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.SeekBar;
 
 @SuppressWarnings({"UnusedDeclaration"})
 public class GradientsActivity extends Activity {
@@ -32,9 +40,157 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        setContentView(new ShadersView(this));
+        final FrameLayout layout = new FrameLayout(this);
+
+        final ShadersView shadersView = new ShadersView(this);
+        final GradientView gradientView = new GradientView(this);
+        final RadialGradientView radialGradientView = new RadialGradientView(this);
+        final SweepGradientView sweepGradientView = new SweepGradientView(this);
+        final BitmapView bitmapView = new BitmapView(this);
+
+        final SeekBar rotateView = new SeekBar(this);
+        rotateView.setMax(360);
+        rotateView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+            @Override
+            public void onStopTrackingTouch(SeekBar seekBar) {
+            }
+
+            @Override
+            public void onStartTrackingTouch(SeekBar seekBar) {
+            }
+
+            @Override
+            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+                gradientView.setRotationY((float) progress);
+                radialGradientView.setRotationX((float) progress);
+                sweepGradientView.setRotationY((float) progress);
+                bitmapView.setRotationX((float) progress);
+            }
+        });
+        
+        layout.addView(shadersView);
+        layout.addView(gradientView, new FrameLayout.LayoutParams(
+                200, 200, Gravity.CENTER));
+
+        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(200, 200, Gravity.CENTER);
+        lp.setMargins(220, 0, 0, 0);
+        layout.addView(radialGradientView, lp);
+
+        lp = new FrameLayout.LayoutParams(200, 200, Gravity.CENTER);
+        lp.setMargins(440, 0, 0, 0);
+        layout.addView(sweepGradientView, lp);
+
+        lp = new FrameLayout.LayoutParams(200, 200, Gravity.CENTER);
+        lp.setMargins(220, -220, 0, 0);
+        layout.addView(bitmapView, lp);
+
+        layout.addView(rotateView, new FrameLayout.LayoutParams(
+                300, FrameLayout.LayoutParams.WRAP_CONTENT,
+                Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
+
+        setContentView(layout);
+    }
+    
+    static class BitmapView extends View {
+        private final Paint mPaint;
+
+        BitmapView(Context c) {
+            super(c);
+
+            Bitmap texture = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1);
+            BitmapShader shader = new BitmapShader(texture, Shader.TileMode.REPEAT,
+                    Shader.TileMode.REPEAT);
+            mPaint = new Paint();
+            mPaint.setShader(shader);
+        }
+
+        @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+            setMeasuredDimension(200, 200);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
+        }
+    }
+    
+    static class GradientView extends View {
+        private final Paint mPaint;
+
+        GradientView(Context c) {
+            super(c);
+
+            LinearGradient gradient = new LinearGradient(0, 0, 200, 0, 0xFF000000, 0,
+                    Shader.TileMode.CLAMP);
+            mPaint = new Paint();
+            mPaint.setShader(gradient);
+        }
+
+        @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+            setMeasuredDimension(200, 200);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
+        }
     }
 
+    static class RadialGradientView extends View {
+        private final Paint mPaint;
+
+        RadialGradientView(Context c) {
+            super(c);
+
+            RadialGradient gradient = new RadialGradient(0.0f, 0.0f, 100.0f, 0xff000000, 0xffffffff,
+                    Shader.TileMode.MIRROR);
+            mPaint = new Paint();
+            mPaint.setShader(gradient);
+        }
+
+        @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+            setMeasuredDimension(200, 200);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
+        }
+    }
+    
+    static class SweepGradientView extends View {
+        private final Paint mPaint;
+
+        SweepGradientView(Context c) {
+            super(c);
+
+            SweepGradient gradient = new SweepGradient(100.0f, 100.0f, 0xff000000, 0xffffffff);                
+            mPaint = new Paint();
+            mPaint.setShader(gradient);
+        }
+
+        @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+            setMeasuredDimension(200, 200);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
+        }
+    }
+        
     static class ShadersView extends View {
         private final Paint mPaint;
         private final float mDrawWidth;
diff --git a/tests/StatusBar/src/com/android/statusbartest/PowerTest.java b/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
index f778cab..178fa92 100644
--- a/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/PowerTest.java
@@ -49,6 +49,8 @@
     int mPokeState = 0;
     IBinder mPokeToken = new Binder();
     Handler mHandler = new Handler();
+    PowerManager mPm;
+    PowerManager.WakeLock mProx;
 
     @Override
     protected String tag() {
@@ -58,10 +60,27 @@
     @Override
     protected Test[] tests() {
         mPowerManager = IPowerManager.Stub.asInterface(ServiceManager.getService("power"));
+        mPm = (PowerManager)getSystemService("power");
+        mProx = mPm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "PowerTest-prox");
         
         return mTests;
     }
     private Test[] mTests = new Test[] {
+        new Test("Enable proximity") {
+            public void run() {
+                mProx.acquire();
+            }
+        },
+        new Test("Disable proximity") {
+            public void run() {
+                mProx.release();
+            }
+        },
+        new Test("Disable proximity (WAIT_FOR_PROXIMITY_NEGATIVE)") {
+            public void run() {
+                mProx.release(PowerManager.WAIT_FOR_PROXIMITY_NEGATIVE);
+            }
+        },
         new Test("Cheek events don't poke") {
             public void run() {
                 mPokeState |= LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS;
@@ -72,6 +91,7 @@
                 }
             }
         },
+
         new Test("Cheek events poke") {
             public void run() {
                 mPokeState &= ~LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS;
diff --git a/voip/java/android/net/sip/ISipService.aidl b/voip/java/android/net/sip/ISipService.aidl
index 6c68213..3250bf9 100644
--- a/voip/java/android/net/sip/ISipService.aidl
+++ b/voip/java/android/net/sip/ISipService.aidl
@@ -16,6 +16,7 @@
 
 package android.net.sip;
 
+import android.app.PendingIntent;
 import android.net.sip.ISipSession;
 import android.net.sip.ISipSessionListener;
 import android.net.sip.SipProfile;
@@ -26,7 +27,7 @@
 interface ISipService {
     void open(in SipProfile localProfile);
     void open3(in SipProfile localProfile,
-            String incomingCallBroadcastAction,
+            in PendingIntent incomingCallPendingIntent,
             in ISipSessionListener listener);
     void close(in String localProfileUri);
     boolean isOpened(String localProfileUri);
diff --git a/voip/java/android/net/sip/SipErrorCode.java b/voip/java/android/net/sip/SipErrorCode.java
index eb7a1ae..a55ab25 100644
--- a/voip/java/android/net/sip/SipErrorCode.java
+++ b/voip/java/android/net/sip/SipErrorCode.java
@@ -61,6 +61,9 @@
     /** Cross-domain authentication required. */
     public static final int CROSS_DOMAIN_AUTHENTICATION = -11;
 
+    /** When the server is not reachable. */
+    public static final int SERVER_UNREACHABLE = -12;
+
     public static String toString(int errorCode) {
         switch (errorCode) {
             case NO_ERROR:
@@ -87,6 +90,8 @@
                 return "DATA_CONNECTION_LOST";
             case CROSS_DOMAIN_AUTHENTICATION:
                 return "CROSS_DOMAIN_AUTHENTICATION";
+            case SERVER_UNREACHABLE:
+                return "SERVER_UNREACHABLE";
             default:
                 return "UNKNOWN";
         }
diff --git a/voip/java/android/net/sip/SipManager.java b/voip/java/android/net/sip/SipManager.java
index bd859e8..80c35fb 100644
--- a/voip/java/android/net/sip/SipManager.java
+++ b/voip/java/android/net/sip/SipManager.java
@@ -16,6 +16,7 @@
 
 package android.net.sip;
 
+import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -34,7 +35,7 @@
  * <li>open a {@link SipProfile} to get ready for making outbound calls or have
  *      the background SIP service listen to incoming calls and broadcast them
  *      with registered command string. See
- *      {@link #open(SipProfile, String, SipRegistrationListener)},
+ *      {@link #open(SipProfile, PendingIntent, SipRegistrationListener)},
  *      {@link #open(SipProfile)}, {@link #close}, {@link #isOpened} and
  *      {@link #isRegistered}. It also facilitates handling of the incoming call
  *      broadcast intent. See
@@ -51,6 +52,19 @@
  */
 public class SipManager {
     /**
+     * The result code to be sent back with the incoming call
+     * {@link PendingIntent}.
+     * @see #open(SipProfile, PendingIntent, SipRegistrationListener)
+     */
+    public static final int INCOMING_CALL_RESULT_CODE = 101;
+
+    /** Part of the incoming call intent. */
+    public static final String EXTRA_CALL_ID = "android:sipCallID";
+
+    /** Part of the incoming call intent. */
+    public static final String EXTRA_OFFER_SD = "android:sipOfferSD";
+
+    /**
      * Action string for the incoming call intent for the Phone app.
      * Internal use only.
      * @hide
@@ -78,12 +92,6 @@
      */
     public static final String EXTRA_LOCAL_URI = "android:localSipUri";
 
-    /** Part of the incoming call intent. */
-    public static final String EXTRA_CALL_ID = "android:sipCallID";
-
-    /** Part of the incoming call intent. */
-    public static final String EXTRA_OFFER_SD = "android:sipOfferSD";
-
     private static final String TAG = "SipManager";
 
     private ISipService mSipService;
@@ -142,7 +150,8 @@
     /**
      * Opens the profile for making calls. The caller may make subsequent calls
      * through {@link #makeAudioCall}. If one also wants to receive calls on the
-     * profile, use {@link #open(SipProfile, String, SipRegistrationListener)}
+     * profile, use
+     * {@link #open(SipProfile, PendingIntent, SipRegistrationListener)}
      * instead.
      *
      * @param localProfile the SIP profile to make calls from
@@ -165,17 +174,29 @@
      * in order to receive calls from the provider.
      *
      * @param localProfile the SIP profile to receive incoming calls for
-     * @param incomingCallBroadcastAction the action to be broadcast when an
-     *      incoming call is received
+     * @param incomingCallPendingIntent When an incoming call is received, the
+     *      SIP service will call
+     *      {@link PendingIntent#send(Context, int, Intent)} to send back the
+     *      intent to the caller with {@link #INCOMING_CALL_RESULT_CODE} as the
+     *      result code and the intent to fill in the call ID and session
+     *      description information. It cannot be null.
      * @param listener to listen to registration events; can be null
+     * @see #getCallId
+     * @see #getOfferSessionDescription
+     * @see #takeAudioCall
+     * @throws NullPointerException if {@code incomingCallPendingIntent} is null
      * @throws SipException if the profile contains incorrect settings or
      *      calling the SIP service results in an error
      */
     public void open(SipProfile localProfile,
-            String incomingCallBroadcastAction,
+            PendingIntent incomingCallPendingIntent,
             SipRegistrationListener listener) throws SipException {
+        if (incomingCallPendingIntent == null) {
+            throw new NullPointerException(
+                    "incomingCallPendingIntent cannot be null");
+        }
         try {
-            mSipService.open3(localProfile, incomingCallBroadcastAction,
+            mSipService.open3(localProfile, incomingCallPendingIntent,
                     createRelay(listener, localProfile.getUriString()));
         } catch (RemoteException e) {
             throw new SipException("open()", e);
@@ -184,7 +205,8 @@
 
     /**
      * Sets the listener to listen to registration events. No effect if the
-     * profile has not been opened to receive calls (see {@link #open}).
+     * profile has not been opened to receive calls (see
+     * {@link #open(SipProfile, PendingIntent, SipRegistrationListener)}).
      *
      * @param localProfileUri the URI of the profile
      * @param listener to listen to registration events; can be null
@@ -282,9 +304,9 @@
     }
 
     /**
-     * Creates a {@link SipAudioCall} to make a call. To use this method, one
-     * must call {@link #open(SipProfile)} first. The attempt will be timed out
-     * if the call is not established within {@code timeout} seconds and
+     * Creates a {@link SipAudioCall} to make an audio call. The attempt will be
+     * timed out if the call is not established within {@code timeout} seconds
+     * and
      * {@code SipAudioCall.Listener.onError(SipAudioCall, SipErrorCode.TIME_OUT, String)}
      * will be called.
      *
@@ -416,9 +438,11 @@
 
     /**
      * Manually registers the profile to the corresponding SIP provider for
-     * receiving calls. {@link #open(SipProfile, String, SipRegistrationListener)}
-     * is still needed to be called at least once in order for the SIP service
-     * to broadcast an intent when an incoming call is received.
+     * receiving calls.
+     * {@link #open(SipProfile, PendingIntent, SipRegistrationListener)} is
+     * still needed to be called at least once in order for the SIP service to
+     * notify the caller with the {@code PendingIntent} when an incoming call is
+     * received.
      *
      * @param localProfile the SIP profile to register with
      * @param expiryTime registration expiration time (in seconds)
diff --git a/voip/java/com/android/server/sip/SipService.java b/voip/java/com/android/server/sip/SipService.java
index 405dff8..a7c61e5 100644
--- a/voip/java/com/android/server/sip/SipService.java
+++ b/voip/java/com/android/server/sip/SipService.java
@@ -134,14 +134,6 @@
 
     public void open(SipProfile localProfile) {
         localProfile.setCallingUid(Binder.getCallingUid());
-        if (localProfile.getAutoRegistration() && isCallerRadio()) {
-            openToReceiveCalls(localProfile);
-        } else {
-            openToMakeCalls(localProfile);
-        }
-    }
-
-    private void openToMakeCalls(SipProfile localProfile) {
         try {
             createGroup(localProfile);
         } catch (SipException e) {
@@ -150,28 +142,20 @@
         }
     }
 
-    private void openToReceiveCalls(SipProfile localProfile) {
-        open3(localProfile, SipManager.ACTION_SIP_INCOMING_CALL, null);
-    }
-
     public synchronized void open3(SipProfile localProfile,
-            String incomingCallBroadcastAction, ISipSessionListener listener) {
+            PendingIntent incomingCallPendingIntent,
+            ISipSessionListener listener) {
         localProfile.setCallingUid(Binder.getCallingUid());
-        if (TextUtils.isEmpty(incomingCallBroadcastAction)) {
-            Log.w(TAG, "empty broadcast action for incoming call");
-            return;
-        }
-        if (incomingCallBroadcastAction.equals(
-                SipManager.ACTION_SIP_INCOMING_CALL) && !isCallerRadio()) {
-            Log.w(TAG, "failed to open the profile; "
-                    + "the action string is reserved");
+        if (incomingCallPendingIntent == null) {
+            Log.w(TAG, "incomingCallPendingIntent cannot be null; "
+                    + "the profile is not opened");
             return;
         }
         if (DEBUG) Log.d(TAG, "open3: " + localProfile.getUriString() + ": "
-                + incomingCallBroadcastAction + ": " + listener);
+                + incomingCallPendingIntent + ": " + listener);
         try {
             SipSessionGroupExt group = createGroup(localProfile,
-                    incomingCallBroadcastAction, listener);
+                    incomingCallPendingIntent, listener);
             if (localProfile.getAutoRegistration()) {
                 group.openToReceiveCalls();
                 if (isWifiOn()) grabWifiLock();
@@ -287,20 +271,19 @@
     }
 
     private SipSessionGroupExt createGroup(SipProfile localProfile,
-            String incomingCallBroadcastAction, ISipSessionListener listener)
-            throws SipException {
+            PendingIntent incomingCallPendingIntent,
+            ISipSessionListener listener) throws SipException {
         String key = localProfile.getUriString();
         SipSessionGroupExt group = mSipGroups.get(key);
         if (group != null) {
             if (!isCallerCreator(group)) {
                 throw new SipException("only creator can access the profile");
             }
-            group.setIncomingCallBroadcastAction(
-                    incomingCallBroadcastAction);
+            group.setIncomingCallPendingIntent(incomingCallPendingIntent);
             group.setListener(listener);
         } else {
             group = new SipSessionGroupExt(localProfile,
-                    incomingCallBroadcastAction, listener);
+                    incomingCallPendingIntent, listener);
             mSipGroups.put(key, group);
             notifyProfileAdded(localProfile);
         }
@@ -405,19 +388,19 @@
 
     private class SipSessionGroupExt extends SipSessionAdapter {
         private SipSessionGroup mSipGroup;
-        private String mIncomingCallBroadcastAction;
+        private PendingIntent mIncomingCallPendingIntent;
         private boolean mOpened;
 
         private AutoRegistrationProcess mAutoRegistration =
                 new AutoRegistrationProcess();
 
         public SipSessionGroupExt(SipProfile localProfile,
-                String incomingCallBroadcastAction,
+                PendingIntent incomingCallPendingIntent,
                 ISipSessionListener listener) throws SipException {
             String password = localProfile.getPassword();
             SipProfile p = duplicate(localProfile);
             mSipGroup = createSipSessionGroup(mLocalIp, p, password);
-            mIncomingCallBroadcastAction = incomingCallBroadcastAction;
+            mIncomingCallPendingIntent = incomingCallPendingIntent;
             mAutoRegistration.setListener(listener);
         }
 
@@ -458,8 +441,8 @@
             mAutoRegistration.setListener(listener);
         }
 
-        public void setIncomingCallBroadcastAction(String action) {
-            mIncomingCallBroadcastAction = action;
+        public void setIncomingCallPendingIntent(PendingIntent pIntent) {
+            mIncomingCallPendingIntent = pIntent;
         }
 
         public void openToReceiveCalls() throws SipException {
@@ -469,7 +452,7 @@
                 mAutoRegistration.start(mSipGroup);
             }
             if (DEBUG) Log.d(TAG, "  openToReceiveCalls: " + getUri() + ": "
-                    + mIncomingCallBroadcastAction);
+                    + mIncomingCallPendingIntent);
         }
 
         public void onConnectivityChanged(boolean connected)
@@ -481,7 +464,7 @@
             } else {
                 // close mSipGroup but remember mOpened
                 if (DEBUG) Log.d(TAG, "  close auto reg temporarily: "
-                        + getUri() + ": " + mIncomingCallBroadcastAction);
+                        + getUri() + ": " + mIncomingCallPendingIntent);
                 mSipGroup.close();
                 mAutoRegistration.stop();
             }
@@ -508,7 +491,7 @@
             mSipGroup.close();
             mAutoRegistration.stop();
             if (DEBUG) Log.d(TAG, "   close: " + getUri() + ": "
-                    + mIncomingCallBroadcastAction);
+                    + mIncomingCallPendingIntent);
         }
 
         public ISipSession createSession(ISipSessionListener listener) {
@@ -516,8 +499,10 @@
         }
 
         @Override
-        public void onRinging(ISipSession session, SipProfile caller,
+        public void onRinging(ISipSession s, SipProfile caller,
                 String sessionDescription) {
+            SipSessionGroup.SipSessionImpl session =
+                    (SipSessionGroup.SipSessionImpl) s;
             synchronized (SipService.this) {
                 try {
                     if (!isRegistered()) {
@@ -528,15 +513,15 @@
                     // send out incoming call broadcast
                     addPendingSession(session);
                     Intent intent = SipManager.createIncomingCallBroadcast(
-                            session.getCallId(), sessionDescription)
-                            .setAction(mIncomingCallBroadcastAction);
+                            session.getCallId(), sessionDescription);
                     if (DEBUG) Log.d(TAG, " ringing~~ " + getUri() + ": "
                             + caller.getUri() + ": " + session.getCallId()
-                            + " " + mIncomingCallBroadcastAction);
-                    mContext.sendBroadcast(intent);
-                } catch (RemoteException e) {
-                    // should never happen with a local call
-                    Log.e(TAG, "processCall()", e);
+                            + " " + mIncomingCallPendingIntent);
+                    mIncomingCallPendingIntent.send(mContext,
+                            SipManager.INCOMING_CALL_RESULT_CODE, intent);
+                } catch (PendingIntent.CanceledException e) {
+                    Log.w(TAG, "pendingIntent is canceled, drop incoming call");
+                    session.endCall();
                 }
             }
         }
diff --git a/voip/java/com/android/server/sip/SipSessionGroup.java b/voip/java/com/android/server/sip/SipSessionGroup.java
index bc377cf..37fffa8 100644
--- a/voip/java/com/android/server/sip/SipSessionGroup.java
+++ b/voip/java/com/android/server/sip/SipSessionGroup.java
@@ -480,7 +480,7 @@
                     public void run() {
                         try {
                             processCommand(command);
-                        } catch (SipException e) {
+                        } catch (Throwable e) {
                             Log.w(TAG, "command error: " + command, e);
                             onError(e);
                         }
@@ -1218,7 +1218,7 @@
         private int getErrorCode(Throwable exception) {
             String message = exception.getMessage();
             if (exception instanceof UnknownHostException) {
-                return SipErrorCode.INVALID_REMOTE_URI;
+                return SipErrorCode.SERVER_UNREACHABLE;
             } else if (exception instanceof IOException) {
                 return SipErrorCode.SOCKET_ERROR;
             } else {