Merge "New QuickContactBadge holo style." into honeycomb
diff --git a/api/current.xml b/api/current.xml
index eda4026..41e7456 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -1471,17 +1471,6 @@
  visibility="public"
 >
 </constructor>
-<field name="accelerate_cubic_interpolator"
- type="int"
- transient="false"
- volatile="false"
- value="17432591"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="accelerate_decelerate_interpolator"
  type="int"
  transient="false"
@@ -1504,39 +1493,6 @@
  visibility="public"
 >
 </field>
-<field name="accelerate_quint_interpolator"
- type="int"
- transient="false"
- volatile="false"
- value="17432593"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="animator_fade_in"
- type="int"
- transient="false"
- volatile="false"
- value="17432589"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="animator_fade_out"
- type="int"
- transient="false"
- volatile="false"
- value="17432590"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="anticipate_interpolator"
  type="int"
  transient="false"
@@ -1581,17 +1537,6 @@
  visibility="public"
 >
 </field>
-<field name="decelerate_cubic_interpolator"
- type="int"
- transient="false"
- volatile="false"
- value="17432592"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="decelerate_interpolator"
  type="int"
  transient="false"
@@ -1603,17 +1548,6 @@
  visibility="public"
 >
 </field>
-<field name="decelerate_quint_interpolator"
- type="int"
- transient="false"
- volatile="false"
- value="17432594"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="fade_in"
  type="int"
  transient="false"
@@ -11059,6 +10993,28 @@
  visibility="public"
 >
 </field>
+<field name="windowMinWidthMajor"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843608"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="windowMinWidthMinor"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843609"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="windowNoDisplay"
  type="int"
  transient="false"
@@ -11473,6 +11429,28 @@
  visibility="public"
 >
 </field>
+<field name="dialog_min_width_major"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17104899"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="dialog_min_width_minor"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17104900"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="thumbnail_height"
  type="int"
  transient="false"
@@ -14464,6 +14442,34 @@
 >
 </constructor>
 </class>
+<class name="R.mipmap"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="R.mipmap"
+ type="android.R.mipmap"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<field name="sym_def_app_icon"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17629184"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
 <class name="R.plurals"
  extends="java.lang.Object"
  abstract="false"
@@ -14854,7 +14860,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974050"
+ value="16974053"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14865,7 +14871,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974052"
+ value="16974055"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14876,7 +14882,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974051"
+ value="16974054"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14887,7 +14893,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974053"
+ value="16974056"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14898,7 +14904,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974055"
+ value="16974058"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -14909,7 +14915,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974054"
+ value="16974057"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15228,7 +15234,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973949"
+ value="16973952"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15239,7 +15245,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973950"
+ value="16973953"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15356,22 +15362,11 @@
  visibility="public"
 >
 </field>
-<field name="Theme_Dialog_NoFrame"
- type="int"
- transient="false"
- volatile="false"
- value="16973930"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="Theme_Holo"
  type="int"
  transient="false"
  volatile="false"
- value="16973932"
+ value="16973931"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15382,7 +15377,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973937"
+ value="16973936"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15393,7 +15388,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973943"
+ value="16973944"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15404,18 +15399,18 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973944"
+ value="16973945"
  static="true"
  final="true"
  deprecated="not deprecated"
  visibility="public"
 >
 </field>
-<field name="Theme_Holo_Dialog_Alert"
+<field name="Theme_Holo_Dialog_MinWidth"
  type="int"
  transient="false"
  volatile="false"
- value="16973941"
+ value="16973937"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15433,18 +15428,7 @@
  visibility="public"
 >
 </field>
-<field name="Theme_Holo_Light"
- type="int"
- transient="false"
- volatile="false"
- value="16973936"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="Theme_Holo_Light_Dialog"
+<field name="Theme_Holo_Dialog_NoActionBar_MinWidth"
  type="int"
  transient="false"
  volatile="false"
@@ -15455,62 +15439,7 @@
  visibility="public"
 >
 </field>
-<field name="Theme_Holo_Light_DialogWhenLarge"
- type="int"
- transient="false"
- volatile="false"
- value="16973945"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="Theme_Holo_Light_DialogWhenLarge_NoActionBar"
- type="int"
- transient="false"
- volatile="false"
- value="16973946"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="Theme_Holo_Light_Dialog_Alert"
- type="int"
- transient="false"
- volatile="false"
- value="16973942"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="Theme_Holo_Light_Dialog_NoActionBar"
- type="int"
- transient="false"
- volatile="false"
- value="16973940"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="Theme_Holo_NoActionBar"
- type="int"
- transient="false"
- volatile="false"
- value="16973934"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="Theme_Holo_NoActionBar_Fullscreen"
+<field name="Theme_Holo_Light"
  type="int"
  transient="false"
  volatile="false"
@@ -15521,7 +15450,29 @@
  visibility="public"
 >
 </field>
-<field name="Theme_Holo_Wallpaper"
+<field name="Theme_Holo_Light_Dialog"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973940"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Light_DialogWhenLarge"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973946"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Light_DialogWhenLarge_NoActionBar"
  type="int"
  transient="false"
  volatile="false"
@@ -15532,7 +15483,73 @@
  visibility="public"
 >
 </field>
-<field name="Theme_Holo_Wallpaper_NoTitleBar"
+<field name="Theme_Holo_Light_Dialog_MinWidth"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973941"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Light_Dialog_NoActionBar"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973942"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Light_Dialog_NoActionBar_MinWidth"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973943"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Light_Panel"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973949"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_NoActionBar"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973933"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_NoActionBar_Fullscreen"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973934"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Panel"
  type="int"
  transient="false"
  volatile="false"
@@ -15543,6 +15560,28 @@
  visibility="public"
 >
 </field>
+<field name="Theme_Holo_Wallpaper"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973950"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Wallpaper_NoTitleBar"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16973951"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="Theme_InputMethod"
  type="int"
  transient="false"
@@ -15569,7 +15608,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973933"
+ value="16973932"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15657,7 +15696,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973931"
+ value="16973930"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15789,7 +15828,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973951"
+ value="16973954"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15800,7 +15839,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973953"
+ value="16973956"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15811,7 +15850,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973957"
+ value="16973960"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15822,7 +15861,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973956"
+ value="16973959"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15888,7 +15927,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974065"
+ value="16974068"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15976,7 +16015,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974057"
+ value="16974060"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -15998,7 +16037,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973958"
+ value="16973961"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16031,7 +16070,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973959"
+ value="16973962"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16042,7 +16081,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974001"
+ value="16974004"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16053,7 +16092,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973996"
+ value="16973999"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16064,7 +16103,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974000"
+ value="16974003"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16075,7 +16114,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973997"
+ value="16974000"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16086,7 +16125,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973998"
+ value="16974001"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16097,7 +16136,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973999"
+ value="16974002"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16108,7 +16147,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973965"
+ value="16973968"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16119,7 +16158,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973960"
+ value="16973963"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16130,7 +16169,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974047"
+ value="16974050"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16141,7 +16180,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973962"
+ value="16973965"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16152,7 +16191,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973961"
+ value="16973964"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16163,7 +16202,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973963"
+ value="16973966"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16174,7 +16213,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974066"
+ value="16974069"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16185,7 +16224,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973966"
+ value="16973969"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16196,7 +16235,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973983"
+ value="16973986"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16207,7 +16246,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973987"
+ value="16973990"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16218,7 +16257,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973991"
+ value="16973994"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16229,7 +16268,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973992"
+ value="16973995"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16240,7 +16279,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973968"
+ value="16973971"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16251,7 +16290,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974060"
+ value="16974063"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16262,7 +16301,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973969"
+ value="16973972"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16273,7 +16312,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973970"
+ value="16973973"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16284,7 +16323,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973985"
+ value="16973988"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16295,7 +16334,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973971"
+ value="16973974"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16306,7 +16345,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974061"
+ value="16974064"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16317,7 +16356,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974059"
+ value="16974062"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16328,7 +16367,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974002"
+ value="16974005"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16339,7 +16378,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974046"
+ value="16974049"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16350,7 +16389,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974042"
+ value="16974045"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16361,7 +16400,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974045"
+ value="16974048"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16372,7 +16411,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974043"
+ value="16974046"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16383,7 +16422,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974044"
+ value="16974047"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16394,7 +16433,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974008"
+ value="16974011"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16405,7 +16444,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974003"
+ value="16974006"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16416,7 +16455,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974005"
+ value="16974008"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16427,7 +16466,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974004"
+ value="16974007"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16438,7 +16477,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974006"
+ value="16974009"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16449,7 +16488,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974067"
+ value="16974070"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16460,7 +16499,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974009"
+ value="16974012"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16471,7 +16510,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974029"
+ value="16974032"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16482,7 +16521,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974033"
+ value="16974036"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16493,7 +16532,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974037"
+ value="16974040"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16504,7 +16543,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974038"
+ value="16974041"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16515,7 +16554,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974011"
+ value="16974014"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16526,7 +16565,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974063"
+ value="16974066"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16537,7 +16576,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974012"
+ value="16974015"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16548,7 +16587,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974013"
+ value="16974016"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16559,7 +16598,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974031"
+ value="16974034"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16570,7 +16609,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974014"
+ value="16974017"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16581,7 +16620,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974064"
+ value="16974067"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16592,7 +16631,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974062"
+ value="16974065"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16603,7 +16642,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974040"
+ value="16974043"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16614,7 +16653,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974015"
+ value="16974018"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16625,7 +16664,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974010"
+ value="16974013"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16636,7 +16675,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974041"
+ value="16974044"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16647,7 +16686,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974016"
+ value="16974019"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16658,7 +16697,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974017"
+ value="16974020"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16669,7 +16708,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974018"
+ value="16974021"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16680,7 +16719,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974022"
+ value="16974025"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16691,7 +16730,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974021"
+ value="16974024"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16702,7 +16741,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974024"
+ value="16974027"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16713,7 +16752,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974019"
+ value="16974022"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16724,7 +16763,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974023"
+ value="16974026"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16735,7 +16774,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974020"
+ value="16974023"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16746,7 +16785,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974026"
+ value="16974029"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16757,7 +16796,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974027"
+ value="16974030"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16768,7 +16807,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974028"
+ value="16974031"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16779,7 +16818,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974030"
+ value="16974033"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16790,7 +16829,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974025"
+ value="16974028"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16801,7 +16840,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974032"
+ value="16974035"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16812,7 +16851,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974049"
+ value="16974052"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16823,7 +16862,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974034"
+ value="16974037"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16834,7 +16873,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974007"
+ value="16974010"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16845,7 +16884,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974039"
+ value="16974042"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16856,7 +16895,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974035"
+ value="16974038"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16867,7 +16906,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974036"
+ value="16974039"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16878,7 +16917,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973994"
+ value="16973997"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16889,7 +16928,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973972"
+ value="16973975"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16900,7 +16939,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973967"
+ value="16973970"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16911,7 +16950,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973995"
+ value="16973998"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16922,7 +16961,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973973"
+ value="16973976"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16933,7 +16972,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973974"
+ value="16973977"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16944,7 +16983,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973975"
+ value="16973978"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16955,7 +16994,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973978"
+ value="16973981"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16966,7 +17005,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973976"
+ value="16973979"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16977,7 +17016,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973977"
+ value="16973980"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16988,7 +17027,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973980"
+ value="16973983"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -16999,7 +17038,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973981"
+ value="16973984"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17010,7 +17049,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973982"
+ value="16973985"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17021,7 +17060,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973984"
+ value="16973987"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17032,7 +17071,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973979"
+ value="16973982"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17043,7 +17082,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973986"
+ value="16973989"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17054,7 +17093,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974048"
+ value="16974051"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17065,7 +17104,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973988"
+ value="16973991"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17076,7 +17115,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973964"
+ value="16973967"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17087,7 +17126,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973993"
+ value="16973996"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17098,7 +17137,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973989"
+ value="16973992"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17109,7 +17148,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973990"
+ value="16973993"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17131,7 +17170,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974058"
+ value="16974061"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17142,7 +17181,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16974056"
+ value="16974059"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17175,7 +17214,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973954"
+ value="16973957"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17230,7 +17269,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973955"
+ value="16973958"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -17373,7 +17412,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16973952"
+ value="16973955"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -19985,6 +20024,42 @@
 </parameter>
 </method>
 </class>
+<class name="ArgbEvaluator"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.animation.TypeEvaluator">
+</implements>
+<constructor name="ArgbEvaluator"
+ type="android.animation.ArgbEvaluator"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="evaluate"
+ return="java.lang.Object"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fraction" type="float">
+</parameter>
+<parameter name="startValue" type="java.lang.Object">
+</parameter>
+<parameter name="endValue" type="java.lang.Object">
+</parameter>
+</method>
+</class>
 <class name="DoubleEvaluator"
  extends="java.lang.Object"
  abstract="false"
@@ -20951,42 +21026,6 @@
 </parameter>
 </method>
 </class>
-<class name="RGBEvaluator"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.animation.TypeEvaluator">
-</implements>
-<constructor name="RGBEvaluator"
- type="android.animation.RGBEvaluator"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="evaluate"
- return="java.lang.Object"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="fraction" type="float">
-</parameter>
-<parameter name="startValue" type="java.lang.Object">
-</parameter>
-<parameter name="endValue" type="java.lang.Object">
-</parameter>
-</method>
-</class>
 <interface name="TimeInterpolator"
  abstract="true"
  static="false"
@@ -28663,21 +28702,6 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="deprecated"
- visibility="public"
->
-<parameter name="activity" type="android.app.Activity">
-</parameter>
-<parameter name="tag" type="java.lang.String">
-</parameter>
-</method>
-<method name="show"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
  deprecated="not deprecated"
  visibility="public"
 >
@@ -34790,6 +34814,32 @@
 <parameter name="d" type="android.graphics.drawable.Drawable">
 </parameter>
 </method>
+<method name="setProgressNumberFormat"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="format" type="java.lang.String">
+</parameter>
+</method>
+<method name="setProgressPercentFormat"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="format" type="java.text.NumberFormat">
+</parameter>
+</method>
 <method name="setProgressStyle"
  return="void"
  abstract="false"
@@ -140828,6 +140878,17 @@
  visibility="public"
 >
 </method>
+<method name="isExternalStorageEmulated"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="isExternalStorageRemovable"
  return="boolean"
  abstract="false"
@@ -144148,23 +144209,6 @@
  visibility="public"
 >
 </method>
-<method name="fromData"
- return="android.os.ParcelFileDescriptor"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="deprecated"
- visibility="public"
->
-<parameter name="data" type="byte[]">
-</parameter>
-<parameter name="name" type="java.lang.String">
-</parameter>
-<exception name="IOException" type="java.io.IOException">
-</exception>
-</method>
 <method name="fromSocket"
  return="android.os.ParcelFileDescriptor"
  abstract="false"
@@ -166113,7 +166157,7 @@
 </parameter>
 <parameter name="h" type="int">
 </parameter>
-<parameter name="d" type="byte[]">
+<parameter name="data" type="byte[]">
 </parameter>
 </method>
 <method name="copy2DRangeFrom"
@@ -166134,7 +166178,7 @@
 </parameter>
 <parameter name="h" type="int">
 </parameter>
-<parameter name="d" type="short[]">
+<parameter name="data" type="short[]">
 </parameter>
 </method>
 <method name="copy2DRangeFrom"
@@ -166155,7 +166199,7 @@
 </parameter>
 <parameter name="h" type="int">
 </parameter>
-<parameter name="d" type="int[]">
+<parameter name="data" type="int[]">
 </parameter>
 </method>
 <method name="copy2DRangeFrom"
@@ -166176,7 +166220,7 @@
 </parameter>
 <parameter name="h" type="int">
 </parameter>
-<parameter name="d" type="float[]">
+<parameter name="data" type="float[]">
 </parameter>
 </method>
 <method name="copy2DRangeFrom"
@@ -166193,7 +166237,7 @@
 </parameter>
 <parameter name="yoff" type="int">
 </parameter>
-<parameter name="b" type="android.graphics.Bitmap">
+<parameter name="data" type="android.graphics.Bitmap">
 </parameter>
 </method>
 <method name="copyFrom"
@@ -166373,6 +166417,60 @@
 <parameter name="b" type="android.graphics.Bitmap">
 </parameter>
 </method>
+<method name="createCubemapFromCubeFaces"
+ return="android.renderscript.Allocation"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="rs" type="android.renderscript.RenderScript">
+</parameter>
+<parameter name="xpos" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="xneg" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="ypos" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="yneg" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="zpos" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="zneg" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="mips" type="android.renderscript.Allocation.MipmapControl">
+</parameter>
+<parameter name="usage" type="int">
+</parameter>
+</method>
+<method name="createCubemapFromCubeFaces"
+ return="android.renderscript.Allocation"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="rs" type="android.renderscript.RenderScript">
+</parameter>
+<parameter name="xpos" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="xneg" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="ypos" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="yneg" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="zpos" type="android.graphics.Bitmap">
+</parameter>
+<parameter name="zneg" type="android.graphics.Bitmap">
+</parameter>
+</method>
 <method name="createFromBitmap"
  return="android.renderscript.Allocation"
  abstract="false"
@@ -166549,6 +166647,17 @@
 <parameter name="type" type="android.renderscript.Type">
 </parameter>
 </method>
+<method name="generateMipmaps"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getType"
  return="android.renderscript.Type"
  abstract="false"
@@ -216490,10 +216599,10 @@
 </parameter>
 <parameter name="shadowBuilder" type="android.view.View.DragShadowBuilder">
 </parameter>
-<parameter name="myWindowOnly" type="boolean">
-</parameter>
 <parameter name="myLocalState" type="java.lang.Object">
 </parameter>
+<parameter name="flags" type="int">
+</parameter>
 </method>
 <method name="unscheduleDrawable"
  return="void"
@@ -232565,6 +232674,17 @@
  visibility="public"
 >
 </method>
+<method name="getAllowContentAccess"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getAllowFileAccess"
  return="boolean"
  abstract="false"
@@ -232983,6 +233103,19 @@
  visibility="public"
 >
 </method>
+<method name="setAllowContentAccess"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="allow" type="boolean">
+</parameter>
+</method>
 <method name="setAllowFileAccess"
  return="void"
  abstract="false"
diff --git a/core/java/android/animation/AnimatorInflater.java b/core/java/android/animation/AnimatorInflater.java
index 6e589e4..bcab66e 100644
--- a/core/java/android/animation/AnimatorInflater.java
+++ b/core/java/android/animation/AnimatorInflater.java
@@ -215,7 +215,7 @@
                 (toType <= TypedValue.TYPE_LAST_COLOR_INT))) {
             // special case for colors: ignore valueType and get ints
             getFloats = false;
-            anim.setEvaluator(new RGBEvaluator());
+            anim.setEvaluator(new ArgbEvaluator());
         }
 
         if (getFloats) {
diff --git a/core/java/android/animation/RGBEvaluator.java b/core/java/android/animation/ArgbEvaluator.java
similarity index 97%
rename from core/java/android/animation/RGBEvaluator.java
rename to core/java/android/animation/ArgbEvaluator.java
index bae0af0..c3875be 100644
--- a/core/java/android/animation/RGBEvaluator.java
+++ b/core/java/android/animation/ArgbEvaluator.java
@@ -20,7 +20,7 @@
  * This evaluator can be used to perform type interpolation between integer
  * values that represent ARGB colors.
  */
-public class RGBEvaluator implements TypeEvaluator {
+public class ArgbEvaluator implements TypeEvaluator {
 
     /**
      * This function returns the calculated in-between value for a color
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index cfecec1..f884473 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -862,7 +862,7 @@
      * of <code>startValue</code> and <code>endValue</code> in the constructor. But if these values
      * are not one of these primitive types, or if different evaluation is desired (such as is
      * necessary with int values that represent colors), a custom evaluator needs to be assigned.
-     * For example, when running an animation on color values, the {@link RGBEvaluator}
+     * For example, when running an animation on color values, the {@link ArgbEvaluator}
      * should be used to get correct RGB color interpolation.
      *
      * <p>If this ValueAnimator has only one set of values being animated between, this evaluator
diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java
index 72a455e..6194240 100644
--- a/core/java/android/app/DialogFragment.java
+++ b/core/java/android/app/DialogFragment.java
@@ -207,16 +207,6 @@
     }
 
     /**
-     * @deprecated Please use {@link #show(FragmentManager, String)}.
-     */
-    @Deprecated
-    public void show(Activity activity, String tag) {
-        FragmentTransaction ft = activity.getFragmentManager().openTransaction();
-        ft.add(this, tag);
-        ft.commit();
-    }
-
-    /**
      * Display the dialog, adding the fragment to the given FragmentManager.  This
      * is a convenience for explicitly creating a transaction, adding the
      * fragment to it with the given tag, and committing it.  This does
diff --git a/core/java/android/app/ProgressDialog.java b/core/java/android/app/ProgressDialog.java
index af1b294..d421173 100644
--- a/core/java/android/app/ProgressDialog.java
+++ b/core/java/android/app/ProgressDialog.java
@@ -18,7 +18,6 @@
 
 import android.content.Context;
 import android.graphics.drawable.Drawable;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
@@ -75,12 +74,20 @@
     
     public ProgressDialog(Context context) {
         super(context);
+        initFormats();
     }
 
     public ProgressDialog(Context context, int theme) {
         super(context, theme);
+        initFormats();
     }
 
+    private void initFormats() {
+        mProgressNumberFormat = "%1d/%2d";
+        mProgressPercentFormat = NumberFormat.getPercentInstance();
+        mProgressPercentFormat.setMaximumFractionDigits(0);
+    }
+    
     public static ProgressDialog show(Context context, CharSequence title,
             CharSequence message) {
         return show(context, title, message, false);
@@ -125,22 +132,27 @@
                     /* Update the number and percent */
                     int progress = mProgress.getProgress();
                     int max = mProgress.getMax();
-                    double percent = (double) progress / (double) max;
-                    String format = mProgressNumberFormat;
-                    mProgressNumber.setText(String.format(format, progress, max));
-                    SpannableString tmp = new SpannableString(mProgressPercentFormat.format(percent));
-                    tmp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
-                            0, tmp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-                    mProgressPercent.setText(tmp);
+                    if (mProgressNumberFormat != null) {
+                        String format = mProgressNumberFormat;
+                        mProgressNumber.setText(String.format(format, progress, max));
+                    } else {
+                        mProgressNumber.setText("");
+                    }
+                    if (mProgressPercentFormat != null) {
+                        double percent = (double) progress / (double) max;
+                        SpannableString tmp = new SpannableString(mProgressPercentFormat.format(percent));
+                        tmp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
+                                0, tmp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+                        mProgressPercent.setText(tmp);
+                    } else {
+                        mProgressPercent.setText("");
+                    }
                 }
             };
             View view = inflater.inflate(R.layout.alert_dialog_progress, null);
             mProgress = (ProgressBar) view.findViewById(R.id.progress);
             mProgressNumber = (TextView) view.findViewById(R.id.progress_number);
-            mProgressNumberFormat = "%d/%d";
             mProgressPercent = (TextView) view.findViewById(R.id.progress_percent);
-            mProgressPercentFormat = NumberFormat.getPercentInstance();
-            mProgressPercentFormat.setMaximumFractionDigits(0);
             setView(view);
         } else {
             View view = inflater.inflate(R.layout.progress_dialog, null);
@@ -304,19 +316,36 @@
     }
 
     /**
-     * Change the format of Progress Number. The default is "current/max".
+     * Change the format of the small text showing current and maximum units
+     * of progress.  The default is "%1d/%2d".
      * Should not be called during the number is progressing.
-     * @param format Should contain two "%d". The first is used for current number
-     * and the second is used for the maximum.
-     * @hide
+     * @param format A string passed to {@link String#format String.format()};
+     * use "%1d" for the current number and "%2d" for the maximum.  If null,
+     * nothing will be shown.
      */
     public void setProgressNumberFormat(String format) {
         mProgressNumberFormat = format;
+        onProgressChanged();
+    }
+
+    /**
+     * Change the format of the small text showing the percentage of progress.
+     * The default is
+     * {@link NumberFormat#getPercentInstance() NumberFormat.getPercentageInstnace().}
+     * Should not be called during the number is progressing.
+     * @param format An instance of a {@link NumberFormat} to generate the
+     * percentage text.  If null, nothing will be shown.
+     */
+    public void setProgressPercentFormat(NumberFormat format) {
+        mProgressPercentFormat = format;
+        onProgressChanged();
     }
     
     private void onProgressChanged() {
         if (mProgressStyle == STYLE_HORIZONTAL) {
-            mViewUpdateHandler.sendEmptyMessage(0);
+            if (!mViewUpdateHandler.hasMessages(0)) {
+                mViewUpdateHandler.sendEmptyMessage(0);
+            }
         }
     }
 }
diff --git a/core/java/android/content/AsyncTaskLoader.java b/core/java/android/content/AsyncTaskLoader.java
index 98710558..c6b9e80 100644
--- a/core/java/android/content/AsyncTaskLoader.java
+++ b/core/java/android/content/AsyncTaskLoader.java
@@ -19,6 +19,7 @@
 import android.os.AsyncTask;
 import android.os.Handler;
 import android.os.SystemClock;
+import android.util.Slog;
 import android.util.TimeUtils;
 
 import java.io.FileDescriptor;
@@ -31,9 +32,8 @@
  * @param <D> the data type to be loaded.
  */
 public abstract class AsyncTaskLoader<D> extends Loader<D> {
-
-
-    private static final String TAG = "AsyncTaskLoader";
+    static final String TAG = "AsyncTaskLoader";
+    static final boolean DEBUG = false;
 
     final class LoadTask extends AsyncTask<Void, Void, D> implements Runnable {
 
@@ -45,13 +45,16 @@
         /* Runs on a worker thread */
         @Override
         protected D doInBackground(Void... params) {
+            if (DEBUG) Slog.v(TAG, this + " >>> doInBackground");
             result = AsyncTaskLoader.this.onLoadInBackground();
+            if (DEBUG) Slog.v(TAG, this + "  <<< doInBackground");
             return result;
         }
 
         /* Runs on the UI thread */
         @Override
         protected void onPostExecute(D data) {
+            if (DEBUG) Slog.v(TAG, this + " onPostExecute");
             try {
                 AsyncTaskLoader.this.dispatchOnLoadComplete(this, data);
             } finally {
@@ -61,6 +64,7 @@
 
         @Override
         protected void onCancelled() {
+            if (DEBUG) Slog.v(TAG, this + " onCancelled");
             try {
                 AsyncTaskLoader.this.dispatchOnCancelled(this, result);
             } finally {
@@ -105,6 +109,7 @@
         super.onForceLoad();
         cancelLoad();
         mTask = new LoadTask();
+        if (DEBUG) Slog.v(TAG, "Preparing load: mTask=" + mTask);
         executePendingTask();
     }
 
@@ -125,10 +130,13 @@
      *         <tt>true</tt> otherwise.
      */
     public boolean cancelLoad() {
+        if (DEBUG) Slog.v(TAG, "cancelLoad: mTask=" + mTask);
         if (mTask != null) {
             if (mCancellingTask != null) {
                 // There was a pending task already waiting for a previous
                 // one being canceled; just drop it.
+                if (DEBUG) Slog.v(TAG,
+                        "cancelLoad: still waiting for cancelled task; dropping next");
                 if (mTask.waiting) {
                     mTask.waiting = false;
                     mHandler.removeCallbacks(mTask);
@@ -138,12 +146,14 @@
             } else if (mTask.waiting) {
                 // There is a task, but it is waiting for the time it should
                 // execute.  We can just toss it.
+                if (DEBUG) Slog.v(TAG, "cancelLoad: task is waiting, dropping it");
                 mTask.waiting = false;
                 mHandler.removeCallbacks(mTask);
                 mTask = null;
                 return false;
             } else {
                 boolean cancelled = mTask.cancel(false);
+                if (DEBUG) Slog.v(TAG, "cancelLoad: cancelled=" + cancelled);
                 if (cancelled) {
                     mCancellingTask = mTask;
                 }
@@ -171,11 +181,15 @@
                 long now = SystemClock.uptimeMillis();
                 if (now < (mLastLoadCompleteTime+mUpdateThrottle)) {
                     // Not yet time to do another load.
+                    if (DEBUG) Slog.v(TAG, "Waiting until "
+                            + (mLastLoadCompleteTime+mUpdateThrottle)
+                            + " to execute: " + mTask);
                     mTask.waiting = true;
                     mHandler.postAtTime(mTask, mLastLoadCompleteTime+mUpdateThrottle);
                     return;
                 }
             }
+            if (DEBUG) Slog.v(TAG, "Executing: " + mTask);
             mTask.execute((Void[]) null);
         }
     }
@@ -183,6 +197,7 @@
     void dispatchOnCancelled(LoadTask task, D data) {
         onCancelled(data);
         if (mCancellingTask == task) {
+            if (DEBUG) Slog.v(TAG, "Cancelled task is now canceled!");
             mLastLoadCompleteTime = SystemClock.uptimeMillis();
             mCancellingTask = null;
             executePendingTask();
@@ -191,10 +206,12 @@
 
     void dispatchOnLoadComplete(LoadTask task, D data) {
         if (mTask != task) {
+            if (DEBUG) Slog.v(TAG, "Load complete of old task, trying to cancel");
             dispatchOnCancelled(task, data);
         } else {
             mLastLoadCompleteTime = SystemClock.uptimeMillis();
             mTask = null;
+            if (DEBUG) Slog.v(TAG, "Delivering result");
             deliverResult(data);
         }
     }
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 0bce748..2fa2834 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -1377,8 +1377,8 @@
             // to have the most recent value used.
             try {
                 waitUntilReadyToRun();
-                NetworkInfo info = getConnectivityManager().getActiveNetworkInfo();
-                mDataConnectionIsConnected = (info != null) && info.isConnected();
+                NetworkInfo networkInfo = getConnectivityManager().getActiveNetworkInfo();
+                mDataConnectionIsConnected = (networkInfo != null) && networkInfo.isConnected();
                 mSyncManagerWakeLock.acquire();
                 // Always do this first so that we be sure that any periodic syncs that
                 // are ready to run have been converted into pending syncs. This allows the
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index c8ca080..b2937ba 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2630,14 +2630,8 @@
 
         int priority = sa.getInt(
                 com.android.internal.R.styleable.AndroidManifestIntentFilter_priority, 0);
-        if (priority > 0 && isActivity && (flags&PARSE_IS_SYSTEM) == 0) {
-            Log.w(TAG, "Activity with priority > 0, forcing to 0 at "
-                    + mArchiveSourcePath + " "
-                    + parser.getPositionDescription());
-            priority = 0;
-        }
         outInfo.setPriority(priority);
-        
+
         TypedValue v = sa.peekValue(
                 com.android.internal.R.styleable.AndroidManifestIntentFilter_label);
         if (v != null && (outInfo.labelRes=v.resourceId) == 0) {
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index 4688847..4f188f8 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -414,8 +414,6 @@
      * emulated. If true, the device does not have real external storage
      * and certain system services such as the package manager use this
      * to determine where to install an application.
-     *
-     * @hide
      */
     public static boolean isExternalStorageEmulated() {
         if (mIsExternalStorageEmulated == null) {
diff --git a/core/java/android/os/ParcelFileDescriptor.java b/core/java/android/os/ParcelFileDescriptor.java
index b6c2ed6..3a5d26b 100644
--- a/core/java/android/os/ParcelFileDescriptor.java
+++ b/core/java/android/os/ParcelFileDescriptor.java
@@ -153,7 +153,7 @@
     private static native int createPipeNative(FileDescriptor[] outFds);
 
     /**
-     * @deprecated Please use createPipe() or ContentProvider.openPipeHelper().
+     * @hide Please use createPipe() or ContentProvider.openPipeHelper().
      * Gets a file descriptor for a read-only copy of the given data.
      *
      * @param data Data to copy.
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index ae729d2d..31bc3fc 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -548,26 +548,22 @@
            }
         }
 
-        // STOPSHIP: Hack for MOT keyboards
-        boolean motKeyboard = false;
-        String name = mBluetoothService.getRemoteName(address);
-        if (name == null && address.startsWith("00:0F:F6") ||
-            (name != null && name.startsWith("Motorola"))) {
-                motKeyboard = true;
-        }
-
-        if (!motKeyboard) {
-            if (btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD ||
-                btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
-                // Its a keyboard. Follow the HID spec recommendation of creating the
-                // passkey and displaying it to the user.
-                // Generate a variable PIN. This is not truly random but good enough.
-                int pin = (int) Math.floor(Math.random() * 10000);
-                sendDisplayPinIntent(address, pin);
+        if (btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD ||
+            btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
+            // Its a keyboard. Follow the HID spec recommendation of creating the
+            // passkey and displaying it to the user. If the keyboard doesn't follow
+            // the spec recommendation, check if the keyboard has a fixed PIN zero
+            // and pair.
+            if (mBluetoothService.isFixedPinZerosAutoPairKeyboard(address)) {
+                mBluetoothService.setPin(address, BluetoothDevice.convertPinToBytes("0000"));
                 return;
             }
-        }
 
+            // Generate a variable PIN. This is not truly random but good enough.
+            int pin = (int) Math.floor(Math.random() * 10000);
+            sendDisplayPinIntent(address, pin);
+            return;
+        }
         // Acquire wakelock during PIN code request to bring up LCD display
         mWakeLock.acquire();
         Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 9261ff6..32e609c 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -678,6 +678,11 @@
         return false;
     }
 
+    /*package*/ synchronized boolean isFixedPinZerosAutoPairKeyboard(String address) {
+        // Check for keyboards which have fixed PIN 0000 as the pairing pin
+        return mBondState.isFixedPinZerosAutoPairKeyboard(address);
+    }
+
     /*package*/ synchronized void onCreatePairedDeviceResult(String address, int result) {
         if (result == BluetoothDevice.BOND_SUCCESS) {
             setBondState(address, BluetoothDevice.BOND_BONDED);
@@ -748,6 +753,7 @@
         private ArrayList<String>  mAutoPairingAddressBlacklist;
         private ArrayList<String> mAutoPairingExactNameBlacklist;
         private ArrayList<String> mAutoPairingPartialNameBlacklist;
+        private ArrayList<String> mAutoPairingFixedPinZerosKeyboardList;
         // Addresses added to blacklist dynamically based on usage.
         private ArrayList<String> mAutoPairingDynamicAddressBlacklist;
 
@@ -863,6 +869,19 @@
             return false;
         }
 
+        public boolean isFixedPinZerosAutoPairKeyboard(String address) {
+            // Note: the meaning of blacklist is reversed in this case.
+            // If its in the list, we can go ahead and auto pair since
+            // by default keyboard should have a variable PIN that we don't
+            // auto pair using 0000.
+            if (mAutoPairingFixedPinZerosKeyboardList != null) {
+                for (String blacklistAddress : mAutoPairingFixedPinZerosKeyboardList) {
+                    if (address.startsWith(blacklistAddress)) return true;
+                }
+            }
+            return false;
+        }
+
         public synchronized int getBondState(String address) {
             Integer state = mState.get(address);
             if (state == null) {
@@ -929,7 +948,6 @@
             FileOutputStream out = null;
             try {
                 file = new File(DYNAMIC_AUTO_PAIRING_BLACKLIST);
-                if (file.exists()) return;
 
                 in = new FileInputStream(AUTO_PAIRING_BLACKLIST);
                 out= new FileOutputStream(DYNAMIC_AUTO_PAIRING_BLACKLIST);
@@ -975,6 +993,9 @@
                         } else if (value[0].equalsIgnoreCase("PartialNameBlacklist")) {
                             mAutoPairingPartialNameBlacklist =
                                 new ArrayList<String>(Arrays.asList(val));
+                        } else if (value[0].equalsIgnoreCase("FixedPinZerosKeyboardBlacklist")) {
+                            mAutoPairingFixedPinZerosKeyboardList =
+                                new ArrayList<String>(Arrays.asList(val));
                         } else if (value[0].equalsIgnoreCase("DynamicAddressBlacklist")) {
                             mAutoPairingDynamicAddressBlacklist =
                                 new ArrayList<String>(Arrays.asList(val));
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 04a521e..7dd6cc6 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -73,9 +73,21 @@
     // Constructors
     ///////////////////////////////////////////////////////////////////////////
 
+    /**
+     * Creates a canvas to render directly on screen.
+     */
     GLES20Canvas(boolean translucent) {
         this(false, translucent);
     }
+
+    /**
+     * Creates a canvas to render into an FBO.
+     */
+    GLES20Canvas(int fbo, boolean translucent) {
+        mOpaque = !translucent;
+        mRenderer = nCreateLayerRenderer(fbo);
+        setupFinalizer();
+    }
     
     protected GLES20Canvas(boolean record, boolean translucent) {
         mOpaque = !translucent;
@@ -89,7 +101,11 @@
         } else {
             mRenderer = nCreateRenderer();
         }
-       
+
+        setupFinalizer();
+    }
+
+    private void setupFinalizer() {
         if (mRenderer == 0) {
             throw new IllegalStateException("Could not create GLES20Canvas renderer");
         } else {
@@ -97,7 +113,8 @@
         }
     }
 
-    private native int nCreateRenderer();
+    private static native int nCreateRenderer();
+    private static native int nCreateLayerRenderer(int fbo);
     private static native int nGetDisplayListRenderer(int renderer);
     private static native void nDestroyRenderer(int renderer);
 
@@ -136,6 +153,16 @@
     }
 
     ///////////////////////////////////////////////////////////////////////////
+    // Hardware layers
+    ///////////////////////////////////////////////////////////////////////////
+    
+    static native int nCreateLayer(int width, int height, int[] layerInfo);
+    static native void nResizeLayer(int layerId, int layerTextureId, int width, int height,
+            int[] layerInfo);
+    static native void nDestroyLayer(int layerId, int layerTextureId);    
+    static native void nDestroyLayerDeferred(int layerId, int layerTextureId);    
+
+    ///////////////////////////////////////////////////////////////////////////
     // Canvas management
     ///////////////////////////////////////////////////////////////////////////
 
@@ -227,6 +254,34 @@
     private native void nDrawDisplayList(int renderer, int displayList);
 
     ///////////////////////////////////////////////////////////////////////////
+    // Hardware layer
+    ///////////////////////////////////////////////////////////////////////////
+    
+    void drawHardwareLayer(float left, float top, float right, float bottom,
+            HardwareLayer layer, Paint paint) {
+        final GLES20Layer glLayer = (GLES20Layer) layer;
+        boolean hasColorFilter = paint != null && setupColorFilter(paint);
+        final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+        nDrawLayer(mRenderer, left, top, right, bottom, glLayer.mLayerTextureId,
+                glLayer.getU(), glLayer.getV(), nativePaint);
+        if (hasColorFilter) nResetModifiers(mRenderer);
+    }
+
+    private native void nDrawLayer(int renderer, float left, float top, float right, float bottom,
+            int layerTexture, float u, float v, int paint);
+    
+    void interrupt() {
+        nInterrupt(mRenderer);
+    }
+    
+    void resume() {
+        nResume(mRenderer);
+    }
+
+    private native void nInterrupt(int renderer);
+    private native void nResume(int renderer);
+
+    ///////////////////////////////////////////////////////////////////////////
     // Clipping
     ///////////////////////////////////////////////////////////////////////////
 
diff --git a/core/java/android/view/GLES20DisplayList.java b/core/java/android/view/GLES20DisplayList.java
index c548659..e813bc9 100644
--- a/core/java/android/view/GLES20DisplayList.java
+++ b/core/java/android/view/GLES20DisplayList.java
@@ -106,7 +106,11 @@
 
         @Override
         protected void finalize() throws Throwable {
-            replaceNativeObject(0);
+            try {
+                replaceNativeObject(0);
+            } finally {
+                super.finalize();
+            }
         }
     }
 }
diff --git a/core/java/android/view/GLES20Layer.java b/core/java/android/view/GLES20Layer.java
new file mode 100644
index 0000000..7587657
--- /dev/null
+++ b/core/java/android/view/GLES20Layer.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2011 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.view;
+
+import android.graphics.Canvas;
+
+/**
+ * An OpenGL ES 2.0 implementation of {@link HardwareLayer}.
+ */
+class GLES20Layer extends HardwareLayer {
+    private int mLayerId;
+    int mLayerTextureId;
+
+    private int mLayerWidth;
+    private int mLayerHeight;
+
+    private final GLES20Canvas mCanvas;
+
+    private float mU;
+    private float mV;
+
+    @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
+    private final Finalizer mFinalizer;
+
+    GLES20Layer(int width, int height, boolean isOpaque) {
+        super(width, height, isOpaque);
+
+        int[] layerInfo = new int[3];
+        mLayerId = GLES20Canvas.nCreateLayer(width, height, layerInfo);
+        if (mLayerId != 0) {
+            mLayerWidth = layerInfo[0];
+            mLayerHeight = layerInfo[1];
+            mLayerTextureId = layerInfo[2];
+
+            mCanvas = new GLES20Canvas(mLayerId, !isOpaque);
+            mFinalizer = new Finalizer(mLayerId, mLayerTextureId);
+            
+            mU = mWidth / (float) mLayerWidth;
+            mV = mHeight/ (float) mLayerHeight;
+        } else {
+            mCanvas = null;
+            mFinalizer = null;
+        }
+    }
+
+    float getU() {
+        return mU;
+    }
+
+    float getV() {
+        return mV;
+    }
+
+    @Override
+    boolean isValid() {
+        return mLayerId != 0 && mLayerWidth > 0 && mLayerHeight > 0;
+    }
+
+    @Override
+    void resize(int width, int height) {
+        if (!isValid() || width <= 0 || height <= 0) return;
+        if (width > mLayerWidth || height > mLayerHeight) {
+            mWidth = width;
+            mHeight = height;
+
+            int[] layerInfo = new int[3];
+
+            GLES20Canvas.nResizeLayer(mLayerId, mLayerTextureId, width, height, layerInfo);
+
+            mLayerWidth = layerInfo[0];
+            mLayerHeight = layerInfo[1];
+
+            mU = mWidth / (float) mLayerWidth;
+            mV = mHeight/ (float) mLayerHeight;            
+        }
+    }
+
+    @Override
+    HardwareCanvas getCanvas() {
+        return mCanvas;
+    }
+
+    @Override
+    void end(Canvas currentCanvas) {
+        if (currentCanvas instanceof GLES20Canvas) {
+            ((GLES20Canvas) currentCanvas).resume();
+        }
+    }
+
+    @Override
+    HardwareCanvas start(Canvas currentCanvas) {
+        if (currentCanvas instanceof GLES20Canvas) {
+            ((GLES20Canvas) currentCanvas).interrupt();
+        }
+        return getCanvas();
+    }
+
+    @Override
+    void destroy() {
+        mFinalizer.destroy();
+        mLayerId = mLayerTextureId = 0;
+    }
+
+    private static class Finalizer {
+        private int mLayerId;
+        private int mLayerTextureId;
+
+        public Finalizer(int layerId, int layerTextureId) {
+            mLayerId = layerId;
+            mLayerTextureId = layerTextureId;
+        }
+
+        @Override
+        protected void finalize() throws Throwable {
+            try {
+                if (mLayerId != 0 || mLayerTextureId != 0) {
+                    GLES20Canvas.nDestroyLayerDeferred(mLayerId, mLayerTextureId);
+                }
+            } finally {
+                super.finalize();
+            }
+        }
+
+        void destroy() {
+            GLES20Canvas.nDestroyLayer(mLayerId, mLayerTextureId);
+            mLayerId = mLayerTextureId = 0;
+        }
+    }
+}
diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java
index 7f86d99..2603281 100644
--- a/core/java/android/view/GLES20RecordingCanvas.java
+++ b/core/java/android/view/GLES20RecordingCanvas.java
@@ -36,7 +36,8 @@
 class GLES20RecordingCanvas extends GLES20Canvas {
     // These lists ensure that any Bitmaps recorded by a DisplayList are kept alive as long
     // as the DisplayList is alive.
-    private HashSet<Bitmap> mBitmaps = new HashSet<Bitmap>();
+    @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
+    private final HashSet<Bitmap> mBitmaps = new HashSet<Bitmap>();
 
     GLES20RecordingCanvas(boolean translucent) {
         super(true, translucent);
@@ -57,12 +58,6 @@
     }
 
     @Override
-    public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter,
-            Paint paint) {
-        super.drawArc(oval, startAngle, sweepAngle, useCenter, paint);
-    }
-
-    @Override
     public void drawPatch(Bitmap bitmap, byte[] chunks, RectF dst, Paint paint) {
         super.drawPatch(bitmap, chunks, dst, paint);
         mBitmaps.add(bitmap);
diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java
index 8b8d15e..1a5df98 100644
--- a/core/java/android/view/HardwareCanvas.java
+++ b/core/java/android/view/HardwareCanvas.java
@@ -18,6 +18,7 @@
 
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
+import android.graphics.Paint;
 
 /**
  * Hardware accelerated canvas. 
@@ -48,5 +49,18 @@
      * 
      * @param displayList The display list to replay.
      */
-    public abstract void drawDisplayList(DisplayList displayList);
+    abstract void drawDisplayList(DisplayList displayList);
+
+    /**
+     * Draws the specified layer onto this canvas.
+     *
+     * @param left The left coordinate of the layer
+     * @param top The top coordinate of the layer
+     * @param right The right coordinate of the layer
+     * @param bottom The bottom coordinate of the layer
+     * @param layer The layer to composite on this canvas
+     * @param paint The paint used to draw the layer
+     */
+    abstract void drawHardwareLayer(float left, float top, float right, float bottom,
+            HardwareLayer layer, Paint paint); 
 }
diff --git a/core/java/android/view/HardwareLayer.java b/core/java/android/view/HardwareLayer.java
new file mode 100644
index 0000000..d01b8ce
--- /dev/null
+++ b/core/java/android/view/HardwareLayer.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2011 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.view;
+
+import android.graphics.Canvas;
+
+/**
+ * A hardware layer can be used to render graphics operations into a hardware
+ * friendly buffer. For instance, with an OpenGL backend, a hardware layer
+ * would use a Frame Buffer Object (FBO.) The hardware layer can be used as
+ * a drawing cache when a complex set of graphics operations needs to be
+ * drawn several times.
+ */
+abstract class HardwareLayer {
+    int mWidth;
+    int mHeight;
+
+    final boolean mOpaque;
+
+    /**
+     * Creates a new hardware layer at least as large as the supplied
+     * dimensions.
+     * 
+     * @param width The minimum width of the layer
+     * @param height The minimum height of the layer
+     * @param isOpaque Whether the layer should be opaque or not
+     */
+    HardwareLayer(int width, int height, boolean isOpaque) {
+        mWidth = width;
+        mHeight = height;
+        mOpaque = isOpaque;
+    }
+
+    /**
+     * Returns the minimum width of the layer.
+     * 
+     * @return The minimum desired width of the hardware layer 
+     */
+    int getWidth() {
+        return mWidth;
+    }
+
+    /**
+     * Returns the minimum height of the layer.
+     * 
+     * @return The minimum desired height of the hardware layer 
+     */
+    int getHeight() {
+        return mHeight;
+    }
+
+    /**
+     * Returns whether or not this layer is opaque.
+     * 
+     * @return True if the layer is opaque, false otherwise
+     */
+    boolean isOpaque() {
+        return mOpaque;
+    }
+
+    /**
+     * Indicates whether this layer can be rendered.
+     * 
+     * @return True if the layer can be rendered into, false otherwise
+     */
+    abstract boolean isValid();
+
+    /**
+     * Resizes the layer, if necessary, to be at least as large
+     * as the supplied dimensions.
+     * 
+     * @param width The new desired minimum width for this layer
+     * @param height The new desired minimum height for this layer
+     */
+    abstract void resize(int width, int height);
+
+    /**
+     * Returns a hardware canvas that can be used to render onto
+     * this layer.
+     * 
+     * @return A hardware canvas, or null if a canvas cannot be created
+     */
+    abstract HardwareCanvas getCanvas();
+
+    /**
+     * Destroys resources without waiting for a GC. 
+     */
+    abstract void destroy();
+
+    /**
+     * This must be invoked before drawing onto this layer.
+     * @param currentCanvas
+     */
+    abstract HardwareCanvas start(Canvas currentCanvas);
+    
+    /**
+     * This must be invoked after drawing onto this layer.
+     * @param currentCanvas
+     */
+    abstract void end(Canvas currentCanvas);
+}
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 63490ee..05a9ff8 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -116,6 +116,17 @@
     abstract DisplayList createDisplayList();
 
     /**
+     * Creates a new hardware layer.
+     * 
+     * @param width The minimum width of the layer
+     * @param height The minimum height of the layer
+     * @param isOpaque Whether the layer should be opaque or not
+     * 
+     * @return A hardware layer
+     */
+    abstract HardwareLayer createHardwareLayer(int width, int height, boolean isOpaque);
+    
+    /**
      * Initializes the hardware renderer for the specified surface and setup the
      * renderer for drawing, if needed. This is invoked when the ViewRoot has
      * potentially lost the hardware renderer. The hardware renderer should be
@@ -682,6 +693,11 @@
         DisplayList createDisplayList() {
             return new GLES20DisplayList();
         }
+        
+        @Override
+        HardwareLayer createHardwareLayer(int width, int height, boolean isOpaque) {
+            return new GLES20Layer(width, height, isOpaque);
+        }
 
         static HardwareRenderer create(boolean translucent) {
             if (GLES20Canvas.isAvailable()) {
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 23fae42..a5f405a 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -121,7 +121,7 @@
      * the drag to the OS and passes that as the return value.  A return value of
      * null indicates failure.
      */
-    IBinder prepareDrag(IWindow window, boolean localOnly,
+    IBinder prepareDrag(IWindow window, int flags,
             int thumbnailWidth, int thumbnailHeight, out Surface outSurface);
 
     /**
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 32f0b14..39ec26d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2049,6 +2049,7 @@
     private Bitmap mDrawingCache;
     private Bitmap mUnscaledDrawingCache;
     private DisplayList mDisplayList;
+    private HardwareLayer mHardwareLayer;
 
     /**
      * When this view has focus and the next focus is {@link #FOCUS_LEFT},
@@ -2137,6 +2138,12 @@
     boolean mCanAcceptDrop;
 
     /**
+     * Flag indicating that a drag can cross window boundaries
+     * @hide
+     */
+    public static final int DRAG_FLAG_GLOBAL = 1;
+
+    /**
      * Position of the vertical scroll bar.
      */
     private int mVerticalScrollbarPosition;
@@ -2204,6 +2211,10 @@
      * 
      * <p>A hardware layer is useful to apply a specific color filter and/or
      * blending mode and/or translucency to a view and all its children.</p>
+     * <p>A hardware layer can be used to cache a complex view tree into a
+     * texture and reduce the complexity of drawing operations. For instance,
+     * when animating a complex view tree with a translation, a hardware layer can
+     * be used to render the view tree only once.</p>
      * <p>A hardware layer can also be used to increase the rendering quality when
      * rotation transformations are applied on a view. It can also be used to
      * prevent potential clipping issues when applying 3D transforms on a view.</p>
@@ -7551,9 +7562,16 @@
      */
     protected void onDetachedFromWindow() {
         mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
+
         removeUnsetPressCallback();
         removeLongPressCallback();
+
         destroyDrawingCache();
+
+        if (mHardwareLayer != null) {
+            mHardwareLayer.destroy();
+            mHardwareLayer = null;
+        }
     }
 
     /**
@@ -7868,23 +7886,36 @@
             throw new IllegalArgumentException("Layer type can only be one of: LAYER_TYPE_NONE, " 
                     + "LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE");
         }
+        
+        if (layerType == mLayerType) return;
 
         // Destroy any previous software drawing cache if needed
-        if (mLayerType == LAYER_TYPE_SOFTWARE && layerType != LAYER_TYPE_SOFTWARE) {
-            if (mDrawingCache != null) {
-                mDrawingCache.recycle();
-                mDrawingCache = null;
-            }
-
-            if (mUnscaledDrawingCache != null) {
-                mUnscaledDrawingCache.recycle();
-                mUnscaledDrawingCache = null;
-            }
+        switch (mLayerType) {
+            case LAYER_TYPE_SOFTWARE:
+                if (mDrawingCache != null) {
+                    mDrawingCache.recycle();
+                    mDrawingCache = null;
+                }
+    
+                if (mUnscaledDrawingCache != null) {
+                    mUnscaledDrawingCache.recycle();
+                    mUnscaledDrawingCache = null;
+                }
+                break;
+            case LAYER_TYPE_HARDWARE:
+                if (mHardwareLayer != null) {
+                    mHardwareLayer.destroy();
+                    mHardwareLayer = null;
+                }
+                break;
+            default:
+                break;
         }
 
         mLayerType = layerType;
         mLayerPaint = mLayerType == LAYER_TYPE_NONE ? null : paint;
 
+        // TODO: Make sure we invalidate the parent's display list
         invalidate();
     }
 
@@ -7905,6 +7936,62 @@
     public int getLayerType() {
         return mLayerType;
     }
+    
+    /**
+     * <p>Returns a hardware layer that can be used to draw this view again
+     * without executing its draw method.</p>
+     *
+     * @return A HardwareLayer ready to render, or null if an error occurred.
+     */
+    HardwareLayer getHardwareLayer(Canvas currentCanvas) {
+        if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
+            return null;
+        }
+
+        final int width = mRight - mLeft;
+        final int height = mBottom - mTop;
+        
+        if (width == 0 || height == 0) {
+            return null;
+        }
+
+        if ((mPrivateFlags & DRAWING_CACHE_VALID) == 0 || mHardwareLayer == null) {
+            if (mHardwareLayer == null) {
+                mHardwareLayer = mAttachInfo.mHardwareRenderer.createHardwareLayer(
+                        width, height, isOpaque());
+            } else if (mHardwareLayer.getWidth() != width || mHardwareLayer.getHeight() != height) {
+                mHardwareLayer.resize(width, height);
+            }
+
+            final HardwareCanvas canvas = mHardwareLayer.start(currentCanvas);
+            try {
+                canvas.setViewport(width, height);
+                canvas.onPreDraw();
+
+                computeScroll();
+                canvas.translate(-mScrollX, -mScrollY);
+
+                final int restoreCount = canvas.save();
+
+                mPrivateFlags |= DRAWN | DRAWING_CACHE_VALID;
+    
+                // Fast path for layouts with no backgrounds
+                if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
+                    mPrivateFlags &= ~DIRTY_MASK;
+                    dispatchDraw(canvas);
+                } else {
+                    draw(canvas);
+                }
+    
+                canvas.restoreToCount(restoreCount);
+            } finally {
+                canvas.onPostDraw();
+                mHardwareLayer.end(currentCanvas);
+            }
+        }
+
+        return mHardwareLayer;
+    }
 
     /**
      * <p>Enables or disables the drawing cache. When the drawing cache is enabled, the next call
@@ -10552,22 +10639,21 @@
      *
      * @param data !!! TODO
      * @param shadowBuilder !!! TODO
-     * @param myWindowOnly When {@code true}, indicates that the drag operation should be
-     *     restricted to the calling application. In this case only the calling application
-     *     will see any DragEvents related to this drag operation.
      * @param myLocalState An arbitrary object that will be passed as part of every DragEvent
      *     delivered to the calling application during the course of the current drag operation.
      *     This object is private to the application that called startDrag(), and is not
      *     visible to other applications. It provides a lightweight way for the application to
      *     propagate information from the initiator to the recipient of a drag within its own
      *     application; for example, to help disambiguate between 'copy' and 'move' semantics.
+     * @param flags Flags affecting the drag operation.  At present no flags are defined;
+     *     pass 0 for this parameter.
      * @return {@code true} if the drag operation was initiated successfully; {@code false} if
      *     an error prevented the drag from taking place.
      */
     public final boolean startDrag(ClipData data, DragShadowBuilder shadowBuilder,
-            boolean myWindowOnly, Object myLocalState) {
+            Object myLocalState, int flags) {
         if (ViewDebug.DEBUG_DRAG) {
-            Log.d(VIEW_LOG_TAG, "startDrag: data=" + data + " local=" + myWindowOnly);
+            Log.d(VIEW_LOG_TAG, "startDrag: data=" + data + " flags=" + flags);
         }
         boolean okay = false;
 
@@ -10587,7 +10673,7 @@
         Surface surface = new Surface();
         try {
             IBinder token = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
-                    myWindowOnly, shadowSize.x, shadowSize.y, surface);
+                    flags, shadowSize.x, shadowSize.y, surface);
             if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token=" + token
                     + " surface=" + surface);
             if (token != null) {
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 7af611e..ed5eed1 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2179,7 +2179,7 @@
 
         boolean scalingRequired = false;
         boolean caching;
-        final int layerType = child.getLayerType();
+        int layerType = child.getLayerType();
         
         if ((flags & FLAG_CHILDREN_DRAWN_WITH_CACHE) == FLAG_CHILDREN_DRAWN_WITH_CACHE ||
                 (flags & FLAG_ALWAYS_DRAWN_WITH_CACHE) == FLAG_ALWAYS_DRAWN_WITH_CACHE) {
@@ -2278,6 +2278,7 @@
         if (caching) {
             if (!canvas.isHardwareAccelerated()) {
                 if (layerType != LAYER_TYPE_NONE) {
+                    layerType = LAYER_TYPE_SOFTWARE;
                     child.buildDrawingCache(true);
                 }
                 cache = child.getDrawingCache(true);
@@ -2354,13 +2355,11 @@
                         }
                         if (layerType != LAYER_TYPE_NONE && child.mLayerPaint != null) {
                             child.mLayerPaint.setAlpha(multipliedAlpha);
-                            canvas.saveLayer(sx, sy, sx + cr - cl, sy + cb - ct,
-                                    child.mLayerPaint, layerFlags);
                         } else {
                             canvas.saveLayerAlpha(sx, sy, sx + cr - cl, sy + cb - ct,
                                     multipliedAlpha, layerFlags);
+                            layerSaved = true;
                         }
-                        layerSaved = true;
                     } else {
                         // Alpha is handled by the child directly, clobber the layer's alpha
                         if (layerType != LAYER_TYPE_NONE && child.mLayerPaint != null) {
@@ -2388,24 +2387,35 @@
         }
 
         if (hasNoCache) {
+            boolean layerRendered = false;
             if (!layerSaved && layerType == LAYER_TYPE_HARDWARE) {
-                canvas.saveLayer(sx, sy, sx + cr - cl, sy + cb - ct, child.mLayerPaint,
-                        Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
-            }
-            if (!hasDisplayList) {
-                // Fast path for layouts with no backgrounds
-                if ((child.mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
-                    if (ViewDebug.TRACE_HIERARCHY) {
-                        ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
-                    }
-                    child.mPrivateFlags &= ~DIRTY_MASK;
-                    child.dispatchDraw(canvas);
+                final HardwareLayer layer = child.getHardwareLayer(canvas);
+                if (layer != null && layer.isValid()) {
+                    ((HardwareCanvas) canvas).drawHardwareLayer(0, 0, cr - cl, cb - ct,
+                            layer, child.mLayerPaint);
+                    layerRendered = true;
                 } else {
-                    child.draw(canvas);
+                    canvas.saveLayer(sx, sy, sx + cr - cl, sy + cb - ct, child.mLayerPaint,
+                            Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
                 }
-            } else {
-                child.mPrivateFlags &= ~DIRTY_MASK;
-                ((HardwareCanvas) canvas).drawDisplayList(displayList);
+            }
+
+            if (!layerRendered) {
+                if (!hasDisplayList) {
+                    // Fast path for layouts with no backgrounds
+                    if ((child.mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
+                        if (ViewDebug.TRACE_HIERARCHY) {
+                            ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
+                        }
+                        child.mPrivateFlags &= ~DIRTY_MASK;
+                        child.dispatchDraw(canvas);
+                    } else {
+                        child.draw(canvas);
+                    }
+                } else {
+                    child.mPrivateFlags &= ~DIRTY_MASK;
+                    ((HardwareCanvas) canvas).drawDisplayList(displayList);
+                }
             }
         } else if (cache != null) {
             child.mPrivateFlags &= ~DIRTY_MASK;
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 366393c..7c55f7b 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1073,11 +1073,6 @@
                             }
                         }
                         surfaceChanged = true;
-
-                        if (mAttachInfo.mHardwareRenderer != null) {
-                            // This will bail out early if already initialized
-                            mAttachInfo.mHardwareRenderer.initialize(mHolder);
-                        }
                     }
                     if (surfaceChanged) {
                         mSurfaceHolderCallback.surfaceChanged(mSurfaceHolder,
diff --git a/core/java/android/webkit/AccessibilityInjector.java b/core/java/android/webkit/AccessibilityInjector.java
index 5198a0e..6bb4320 100644
--- a/core/java/android/webkit/AccessibilityInjector.java
+++ b/core/java/android/webkit/AccessibilityInjector.java
@@ -20,7 +20,6 @@
 import android.text.TextUtils;
 import android.text.TextUtils.SimpleStringSplitter;
 import android.util.Log;
-import android.util.SparseArray;
 import android.view.KeyEvent;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
@@ -41,7 +40,7 @@
  *       aware of one navigation axis which is in fact the default behavior
  *       of webViews while using the DPAD/TrackBall.
  * </p>
- * In general a key binding is a mapping from meta state + key code to
+ * In general a key binding is a mapping from modifiers + key code to
  * a sequence of actions. For more detail how to specify key bindings refer to
  * {@link android.provider.Settings.Secure#ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS}.
  * </p>
@@ -77,8 +76,8 @@
     private static final int NAVIGATION_AXIS_DEFAULT_WEB_VIEW_BEHAVIOR = 7;
 
     // these are the same for all instances so make them process wide
-    private static SparseArray<AccessibilityWebContentKeyBinding> sBindings =
-        new SparseArray<AccessibilityWebContentKeyBinding>();
+    private static ArrayList<AccessibilityWebContentKeyBinding> sBindings =
+        new ArrayList<AccessibilityWebContentKeyBinding>();
 
     // handle to the WebView this injector is associated with.
     private final WebView mWebView;
@@ -120,10 +119,15 @@
 
         mLastDownEventHandled = false;
 
-        int key = event.getMetaState() << AccessibilityWebContentKeyBinding.OFFSET_META_STATE |
-            event.getKeyCode() << AccessibilityWebContentKeyBinding.OFFSET_KEY_CODE;
+        AccessibilityWebContentKeyBinding binding = null;
+        for (AccessibilityWebContentKeyBinding candidate : sBindings) {
+            if (event.getKeyCode() == candidate.getKeyCode()
+                    && event.hasModifiers(candidate.getModifiers())) {
+                binding = candidate;
+                break;
+            }
+        }
 
-        AccessibilityWebContentKeyBinding binding = sBindings.get(key);
         if (binding == null) {
             return false;
         }
@@ -302,7 +306,12 @@
         if (DEBUG) {
             Log.d(LOG_TAG, "Dispatching: " + event);
         }
-        AccessibilityManager.getInstance(mWebView.getContext()).sendAccessibilityEvent(event);
+        // accessibility may be disabled while waiting for the selection string
+        AccessibilityManager accessibilityManager =
+            AccessibilityManager.getInstance(mWebView.getContext());
+        if (accessibilityManager.isEnabled()) {
+            accessibilityManager.sendAccessibilityEvent(event);
+        }
     }
 
     /**
@@ -332,9 +341,6 @@
         SimpleStringSplitter semiColonSplitter = new SimpleStringSplitter(';');
         semiColonSplitter.setString(webContentKeyBindingsString);
 
-        ArrayList<AccessibilityWebContentKeyBinding> bindings =
-            new ArrayList<AccessibilityWebContentKeyBinding>();
-
         while (semiColonSplitter.hasNext()) {
             String bindingString = semiColonSplitter.next();
             if (TextUtils.isEmpty(bindingString)) {
@@ -348,80 +354,58 @@
                 continue;
             }
             try {
-                int key = Integer.decode(keyValueArray[0].trim());
+                long keyCodeAndModifiers = Long.decode(keyValueArray[0].trim());
                 String[] actionStrings = keyValueArray[1].split(":");
                 int[] actions = new int[actionStrings.length];
                 for (int i = 0, count = actions.length; i < count; i++) {
                     actions[i] = Integer.decode(actionStrings[i].trim());
                 }
-                bindings.add(new AccessibilityWebContentKeyBinding(key, actions));
+                sBindings.add(new AccessibilityWebContentKeyBinding(keyCodeAndModifiers, actions));
             } catch (NumberFormatException nfe) {
                 Log.e(LOG_TAG, "Disregarding malformed key binding: " + bindingString);
             }
         }
-
-        for (AccessibilityWebContentKeyBinding binding : bindings) {
-            sBindings.put(binding.getKey(), binding);
-        }
     }
 
     /**
      * Represents a web content key-binding.
      */
-    private class AccessibilityWebContentKeyBinding {
+    private static final class AccessibilityWebContentKeyBinding {
 
-        private static final int OFFSET_META_STATE = 0x00000010;
+        private static final int MODIFIERS_OFFSET = 32;
+        private static final long MODIFIERS_MASK = 0xFFFFFFF00000000L;
 
-        private static final int MASK_META_STATE = 0xFFFF0000;
+        private static final int KEY_CODE_OFFSET = 0;
+        private static final long KEY_CODE_MASK = 0x00000000FFFFFFFFL;
 
-        private static final int OFFSET_KEY_CODE = 0x00000000;
+        private static final int ACTION_OFFSET = 24;
+        private static final int ACTION_MASK = 0xFF000000;
 
-        private static final int MASK_KEY_CODE = 0x0000FFFF;
+        private static final int FIRST_ARGUMENT_OFFSET = 16;
+        private static final int FIRST_ARGUMENT_MASK = 0x00FF0000;
 
-        private static final int OFFSET_ACTION = 0x00000018;
+        private static final int SECOND_ARGUMENT_OFFSET = 8;
+        private static final int SECOND_ARGUMENT_MASK = 0x0000FF00;
 
-        private static final int MASK_ACTION = 0xFF000000;
+        private static final int THIRD_ARGUMENT_OFFSET = 0;
+        private static final int THIRD_ARGUMENT_MASK = 0x000000FF;
 
-        private static final int OFFSET_FIRST_ARGUMENT = 0x00000010;
+        private final long mKeyCodeAndModifiers;
 
-        private static final int MASK_FIRST_ARGUMENT = 0x00FF0000;
-
-        private static final int OFFSET_SECOND_ARGUMENT = 0x00000008;
-
-        private static final int MASK_SECOND_ARGUMENT = 0x0000FF00;
-
-        private static final int OFFSET_THIRD_ARGUMENT = 0x00000000;
-
-        private static final int MASK_THIRD_ARGUMENT = 0x000000FF;
-
-        private int mKey;
-
-        private int [] mActionSequence;
-
-        /**
-         * @return The binding key with key code and meta state.
-         *
-         * @see #MASK_KEY_CODE
-         * @see #MASK_META_STATE
-         * @see #OFFSET_KEY_CODE
-         * @see #OFFSET_META_STATE
-         */
-        public int getKey() {
-            return mKey;
-        }
+        private final int [] mActionSequence;
 
         /**
          * @return The key code of the binding key.
          */
         public int getKeyCode() {
-            return (mKey & MASK_KEY_CODE) >> OFFSET_KEY_CODE;
+            return (int) ((mKeyCodeAndModifiers & KEY_CODE_MASK) >> KEY_CODE_OFFSET);
         }
 
         /**
          * @return The meta state of the binding key.
          */
-        public int getMetaState() {
-            return (mKey & MASK_META_STATE) >> OFFSET_META_STATE;
+        public int getModifiers() {
+            return (int) ((mKeyCodeAndModifiers & MODIFIERS_MASK) >> MODIFIERS_OFFSET);
         }
 
         /**
@@ -442,48 +426,45 @@
          * @param index The action code for a given action <code>index</code>.
          */
         public int getActionCode(int index) {
-            return (mActionSequence[index] & MASK_ACTION) >> OFFSET_ACTION;
+            return (mActionSequence[index] & ACTION_MASK) >> ACTION_OFFSET;
         }
 
         /**
          * @param index The first argument for a given action <code>index</code>.
          */
         public int getFirstArgument(int index) {
-            return (mActionSequence[index] & MASK_FIRST_ARGUMENT) >> OFFSET_FIRST_ARGUMENT;
+            return (mActionSequence[index] & FIRST_ARGUMENT_MASK) >> FIRST_ARGUMENT_OFFSET;
         }
 
         /**
          * @param index The second argument for a given action <code>index</code>.
          */
         public int getSecondArgument(int index) {
-            return (mActionSequence[index] & MASK_SECOND_ARGUMENT) >> OFFSET_SECOND_ARGUMENT;
+            return (mActionSequence[index] & SECOND_ARGUMENT_MASK) >> SECOND_ARGUMENT_OFFSET;
         }
 
         /**
          * @param index The third argument for a given action <code>index</code>.
          */
         public int getThirdArgument(int index) {
-            return (mActionSequence[index] & MASK_THIRD_ARGUMENT) >> OFFSET_THIRD_ARGUMENT;
+            return (mActionSequence[index] & THIRD_ARGUMENT_MASK) >> THIRD_ARGUMENT_OFFSET;
         }
 
         /**
          * Creates a new instance.
-         * @param key The key for the binding (key and meta state)
+         * @param keyCodeAndModifiers The key for the binding (key and modifiers).
          * @param actionSequence The sequence of action for the binding.
-         * @see #getKey()
          */
-        public AccessibilityWebContentKeyBinding(int key, int[] actionSequence) {
-            mKey = key;
+        public AccessibilityWebContentKeyBinding(long keyCodeAndModifiers, int[] actionSequence) {
+            mKeyCodeAndModifiers = keyCodeAndModifiers;
             mActionSequence = actionSequence;
         }
 
         @Override
         public String toString() {
             StringBuilder builder = new StringBuilder();
-            builder.append("key: ");
-            builder.append(getKey());
-            builder.append(", metaState: ");
-            builder.append(getMetaState());
+            builder.append("modifiers: ");
+            builder.append(getModifiers());
             builder.append(", keyCode: ");
             builder.append(getKeyCode());
             builder.append(", actions[");
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index de1faa2..e246717 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -738,7 +738,8 @@
             }
 
         // content://
-        } else if (url.startsWith(ANDROID_CONTENT)) {
+        } else if (mSettings.getAllowContentAccess() &&
+                   url.startsWith(ANDROID_CONTENT)) {
             try {
                 // Strip off mimetype, for compatibility with ContentLoader.java
                 // If we don't do this, we can fail to load Gmail attachments,
diff --git a/core/java/android/webkit/FindActionModeCallback.java b/core/java/android/webkit/FindActionModeCallback.java
index 700d313..a322fa3d 100644
--- a/core/java/android/webkit/FindActionModeCallback.java
+++ b/core/java/android/webkit/FindActionModeCallback.java
@@ -34,7 +34,7 @@
 import android.view.inputmethod.InputMethodManager;
 
 class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
-        View.OnLongClickListener {
+        View.OnLongClickListener, View.OnClickListener {
     private View mCustomView;
     private EditText mEditText;
     private TextView mMatches;
@@ -53,6 +53,7 @@
         // Override long click so that select ActionMode is not opened, which
         // would exit find ActionMode.
         mEditText.setOnLongClickListener(this);
+        mEditText.setOnClickListener(this);
         setText("");
         mMatches = (TextView) mCustomView.findViewById(
                 com.android.internal.R.id.matches);
@@ -105,7 +106,17 @@
             throw new AssertionError(
                     "No WebView for FindActionModeCallback::findNext");
         }
+        if (!mMatchesFound) {
+            findAll();
+            return;
+        }
+        if (0 == mNumberOfMatches) {
+            // There are no matches, so moving to the next match will not do
+            // anything.
+            return;
+        }
         mWebView.findNext(next);
+        updateMatchesString();
     }
 
     /*
@@ -158,6 +169,13 @@
     @Override
     public boolean onLongClick(View v) { return true; }
 
+    // OnClickListener implementation
+
+    @Override
+    public void onClick(View v) {
+        findNext(true);
+    }
+
     // ActionMode.Callback implementation
 
     @Override
@@ -193,15 +211,6 @@
                     "No WebView for FindActionModeCallback::onActionItemClicked");
         }
         mInput.hideSoftInputFromWindow(mWebView.getWindowToken(), 0);
-        if (!mMatchesFound) {
-            findAll();
-            return true;
-        }
-        if (0 == mNumberOfMatches) {
-            // There are no matches, so moving to the next match will not do
-            // anything.
-            return true;
-        }
         switch(item.getItemId()) {
             case com.android.internal.R.id.find_prev:
                 findNext(false);
@@ -212,7 +221,6 @@
             default:
                 return false;
         }
-        updateMatchesString();
         return true;
     }
 
diff --git a/core/java/android/webkit/FrameLoader.java b/core/java/android/webkit/FrameLoader.java
index 2b44775..0d80302 100644
--- a/core/java/android/webkit/FrameLoader.java
+++ b/core/java/android/webkit/FrameLoader.java
@@ -203,7 +203,8 @@
                                 settings.getAllowFileAccess())).sendToTarget();
             }
             return true;
-        } else if (URLUtil.isContentUrl(url)) {
+        } else if (settings.getAllowContentAccess() &&
+                   URLUtil.isContentUrl(url)) {
             // Send the raw url to the ContentLoader because it will do a
             // permission check and the url has to match.
             if (loadListener.isSynchronous()) {
diff --git a/core/java/android/webkit/JniUtil.java b/core/java/android/webkit/JniUtil.java
index 704d4da..62b415c 100644
--- a/core/java/android/webkit/JniUtil.java
+++ b/core/java/android/webkit/JniUtil.java
@@ -17,8 +17,13 @@
 package android.webkit;
 
 import android.content.Context;
+import android.net.Uri;
+import android.util.Log;
+
+import java.io.InputStream;
 
 class JniUtil {
+    private static final String LOGTAG = "webkit";
     private JniUtil() {} // Utility class, do not instantiate.
 
     // Used by the Chromium HTTP stack.
@@ -69,6 +74,75 @@
         return sCacheDirectory;
     }
 
+    private static final String ANDROID_CONTENT = "content:";
+
+    /**
+     * Called by JNI. Calculates the size of an input stream by reading it.
+     * @return long The size of the stream
+     */
+    private static synchronized long contentUrlSize(String url) {
+        // content://
+        if (url.startsWith(ANDROID_CONTENT)) {
+            try {
+                // Strip off mimetype, for compatibility with ContentLoader.java
+                // If we don't do this, we can fail to load Gmail attachments,
+                // because the URL being loaded doesn't exactly match the URL we
+                // have permission to read.
+                int mimeIndex = url.lastIndexOf('?');
+                if (mimeIndex != -1) {
+                    url = url.substring(0, mimeIndex);
+                }
+                Uri uri = Uri.parse(url);
+                InputStream is = sContext.getContentResolver().openInputStream(uri);
+                byte[] buffer = new byte[1024];
+                int n;
+                long size = 0;
+                try {
+                    while ((n = is.read(buffer)) != -1) {
+                        size += n;
+                    }
+                } finally {
+                    is.close();
+                }
+                return size;
+            } catch (Exception e) {
+                Log.e(LOGTAG, "Exception: " + url);
+                return 0;
+            }
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * Called by JNI.
+     *
+     * @return  Opened input stream to content
+     * TODO: Make all content loading use this instead of BrowserFrame.java
+     */
+    private static synchronized InputStream contentUrlStream(String url) {
+        // content://
+        if (url.startsWith(ANDROID_CONTENT)) {
+            try {
+                // Strip off mimetype, for compatibility with ContentLoader.java
+                // If we don't do this, we can fail to load Gmail attachments,
+                // because the URL being loaded doesn't exactly match the URL we
+                // have permission to read.
+                int mimeIndex = url.lastIndexOf('?');
+                if (mimeIndex != -1) {
+                    url = url.substring(0, mimeIndex);
+                }
+                Uri uri = Uri.parse(url);
+                return sContext.getContentResolver().openInputStream(uri);
+            } catch (Exception e) {
+                Log.e(LOGTAG, "Exception: " + url);
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
+
     /**
      * Returns true if we're using the Chromium HTTP stack.
      *
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 6750422..0670c4e 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -215,6 +215,7 @@
     private boolean         mBuiltInZoomControls = false;
     private boolean         mDisplayZoomControls = true;
     private boolean         mAllowFileAccess = true;
+    private boolean         mAllowContentAccess = true;
     private boolean         mLoadWithOverviewMode = false;
     private boolean         mEnableSmoothTransition = false;
 
@@ -587,7 +588,9 @@
 
     /**
      * Enable or disable file access within WebView. File access is enabled by
-     * default.
+     * default.  Note that this enables or disables file system access only.
+     * Assets and resources are still accessible using file:///android_asset and
+     * file:///android_res.
      */
     public void setAllowFileAccess(boolean allow) {
         mAllowFileAccess = allow;
@@ -601,6 +604,22 @@
     }
 
     /**
+     * Enable or disable content url access within WebView.  Content url access
+     * allows WebView to load content from a content provider installed in the
+     * system.  The default is enabled.
+     */
+    public void setAllowContentAccess(boolean allow) {
+        mAllowContentAccess = allow;
+    }
+
+    /**
+     * Returns true if this WebView supports content url access.
+     */
+    public boolean getAllowContentAccess() {
+        return mAllowContentAccess;
+    }
+
+    /**
      * Set whether the WebView loads a page with overview mode.
      */
     public void setLoadWithOverviewMode(boolean overview) {
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index e8283a6..7eaab82 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2618,10 +2618,6 @@
     private int computeRealHorizontalScrollRange() {
         if (mDrawHistory) {
             return mHistoryWidth;
-        } else if (mHorizontalScrollBarMode == SCROLLBAR_ALWAYSOFF
-                && !mZoomManager.canZoomOut()) {
-            // only honor the scrollbar mode when it is at minimum zoom level
-            return computeHorizontalScrollExtent();
         } else {
             // to avoid rounding error caused unnecessary scrollbar, use floor
             return (int) Math.floor(mContentWidth * mZoomManager.getScale());
@@ -2652,10 +2648,6 @@
     private int computeRealVerticalScrollRange() {
         if (mDrawHistory) {
             return mHistoryHeight;
-        } else if (mVerticalScrollBarMode == SCROLLBAR_ALWAYSOFF
-                && !mZoomManager.canZoomOut()) {
-            // only honor the scrollbar mode when it is at minimum zoom level
-            return computeVerticalScrollExtent();
         } else {
             // to avoid rounding error caused unnecessary scrollbar, use floor
             return (int) Math.floor(mContentHeight * mZoomManager.getScale());
@@ -4553,16 +4545,28 @@
 
         // accessibility support
         if (accessibilityScriptInjected()) {
-            // if an accessibility script is injected we delegate to it the key handling.
-            // this script is a screen reader which is a fully fledged solution for blind
-            // users to navigate in and interact with web pages.
-            mWebViewCore.sendMessage(EventHub.KEY_DOWN, event);
-            return true;
-        } else if (mAccessibilityInjector != null && mAccessibilityInjector.onKeyEvent(event)) {
-            // if an accessibility injector is present (no JavaScript enabled or the site opts
-            // out injecting our JavaScript screen reader) we let it decide whether to act on
-            // and consume the event.
-            return true;
+            if (AccessibilityManager.getInstance(mContext).isEnabled()) {
+                // if an accessibility script is injected we delegate to it the key handling.
+                // this script is a screen reader which is a fully fledged solution for blind
+                // users to navigate in and interact with web pages.
+                mWebViewCore.sendMessage(EventHub.KEY_DOWN, event);
+                return true;
+            } else {
+                // Clean up if accessibility was disabled after loading the current URL.
+                mAccessibilityScriptInjected = false;
+            }
+        } else if (mAccessibilityInjector != null) {
+            if (AccessibilityManager.getInstance(mContext).isEnabled()) {
+                if (mAccessibilityInjector.onKeyEvent(event)) {
+                    // if an accessibility injector is present (no JavaScript enabled or the site
+                    // opts out injecting our JavaScript screen reader) we let it decide whether
+                    // to act on and consume the event.
+                    return true;
+                }
+            } else {
+                // Clean up if accessibility was disabled after loading the current URL.
+                mAccessibilityInjector = null;
+            }
         }
 
         if (keyCode == KeyEvent.KEYCODE_PAGE_UP) {
@@ -4676,8 +4680,8 @@
 
         if (nativeCursorIsTextInput()) {
             // This message will put the node in focus, for the DOM's notion
-            // of focus, and make the focuscontroller active
-            mWebViewCore.sendMessage(EventHub.CLICK, nativeCursorFramePointer(),
+            // of focus.
+            mWebViewCore.sendMessage(EventHub.FAKE_CLICK, nativeCursorFramePointer(),
                     nativeCursorNodePointer());
             // This will bring up the WebTextView and put it in focus, for
             // our view system's notion of focus
@@ -4741,16 +4745,28 @@
 
         // accessibility support
         if (accessibilityScriptInjected()) {
-            // if an accessibility script is injected we delegate to it the key handling.
-            // this script is a screen reader which is a fully fledged solution for blind
-            // users to navigate in and interact with web pages.
-            mWebViewCore.sendMessage(EventHub.KEY_UP, event);
-            return true;
-        } else if (mAccessibilityInjector != null && mAccessibilityInjector.onKeyEvent(event)) {
-            // if an accessibility injector is present (no JavaScript enabled or the site opts
-            // out injecting our JavaScript screen reader) we let it decide whether to act on
-            // and consume the event.
-            return true;
+            if (AccessibilityManager.getInstance(mContext).isEnabled()) {
+                // if an accessibility script is injected we delegate to it the key handling.
+                // this script is a screen reader which is a fully fledged solution for blind
+                // users to navigate in and interact with web pages.
+                mWebViewCore.sendMessage(EventHub.KEY_UP, event);
+                return true;
+            } else {
+                // Clean up if accessibility was disabled after loading the current URL.
+                mAccessibilityScriptInjected = false;
+            }
+        } else if (mAccessibilityInjector != null) {
+            if (AccessibilityManager.getInstance(mContext).isEnabled()) {
+                if (mAccessibilityInjector.onKeyEvent(event)) {
+                    // if an accessibility injector is present (no JavaScript enabled or the site
+                    // opts out injecting our JavaScript screen reader) we let it decide whether to
+                    // act on and consume the event.
+                    return true;
+                }
+            } else {
+                // Clean up if accessibility was disabled after loading the current URL.
+                mAccessibilityInjector = null;
+            }
         }
 
         if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
@@ -4939,7 +4955,7 @@
     public boolean copySelection() {
         boolean copiedSomething = false;
         String selection = getSelection();
-        if (selection != "") {
+        if (selection != null && selection != "") {
             if (DebugFlags.WEB_VIEW) {
                 Log.v(LOGTAG, "copySelection \"" + selection + "\"");
             }
@@ -5520,8 +5536,9 @@
                             + "mPreventDefault = " + mPreventDefault
                             + " mDeferTouchProcess = " + mDeferTouchProcess
                             + " mTouchMode = " + mTouchMode);
+                } else {
+                    mVelocityTracker.addMovement(ev);
                 }
-                mVelocityTracker.addMovement(ev);
                 if (mSelectingText && mSelectionStarted) {
                     if (DebugFlags.WEB_VIEW) {
                         Log.v(LOGTAG, "extend=" + contentX + "," + contentY);
@@ -5760,8 +5777,9 @@
                                         + mPreventDefault
                                         + " mDeferTouchProcess = "
                                         + mDeferTouchProcess);
+                            } else {
+                                mVelocityTracker.addMovement(ev);
                             }
-                            mVelocityTracker.addMovement(ev);
                             // set to MOTIONLESS_IGNORE so that it won't keep
                             // removing and sending message in
                             // drawCoreAndCursorRing()
@@ -5836,6 +5854,11 @@
 
         final ScaleGestureDetector detector =
             mZoomManager.getMultiTouchGestureDetector();
+
+        // A few apps use WebView but don't instantiate gesture detector.
+        // We don't need to support multi touch for them.
+        if (detector == null) return false;
+
         int action = ev.getAction();
         float x = ev.getX();
         float y = ev.getY();
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index c874160..2ea20ee 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -115,8 +115,8 @@
      */
     private int mViewportDensityDpi = -1;
 
-    private int mRestoredScale = 0;
-    private int mRestoredTextWrapScale = 0;
+    private float mRestoredScale = 0;
+    private float mRestoredTextWrapScale = 0;
     private int mRestoredX = 0;
     private int mRestoredY = 0;
 
@@ -516,7 +516,7 @@
             int repeatCount, boolean isShift, boolean isAlt, boolean isSym,
             boolean isDown);
 
-    private native void nativeClick(int framePtr, int nodePtr);
+    private native void nativeClick(int framePtr, int nodePtr, boolean fake);
 
     private native void nativeSendListBoxChoices(boolean[] choices, int size);
 
@@ -866,7 +866,7 @@
             "CLICK", // = 118;
             "SET_NETWORK_STATE", // = 119;
             "DOC_HAS_IMAGES", // = 120;
-            "121", // = 121;
+            "FAKE_CLICK", // = 121;
             "DELETE_SELECTION", // = 122;
             "LISTBOX_CHOICES", // = 123;
             "SINGLE_LISTBOX_CHOICE", // = 124;
@@ -924,6 +924,7 @@
         static final int CLICK = 118;
         static final int SET_NETWORK_STATE = 119;
         static final int DOC_HAS_IMAGES = 120;
+        static final int FAKE_CLICK = 121;
         static final int DELETE_SELECTION = 122;
         static final int LISTBOX_CHOICES = 123;
         static final int SINGLE_LISTBOX_CHOICE = 124;
@@ -1173,8 +1174,12 @@
                             key((KeyEvent) msg.obj, false);
                             break;
 
+                        case FAKE_CLICK:
+                            nativeClick(msg.arg1, msg.arg2, true);
+                            break;
+
                         case CLICK:
-                            nativeClick(msg.arg1, msg.arg2);
+                            nativeClick(msg.arg1, msg.arg2, false);
                             break;
 
                         case VIEW_SIZE_CHANGED: {
@@ -2245,8 +2250,8 @@
         }
 
         // reset the scroll position, the restored offset and scales
-        mWebkitScrollX = mWebkitScrollY = mRestoredX = mRestoredY
-                = mRestoredScale = mRestoredTextWrapScale = 0;
+        mWebkitScrollX = mWebkitScrollY = mRestoredX = mRestoredY = 0;
+        mRestoredScale = mRestoredTextWrapScale = 0;
     }
 
     // called by JNI
@@ -2352,9 +2357,9 @@
         mInitialViewState.mMobileSite = (0 == mViewportWidth);
         if (mRestoredScale > 0) {
             mInitialViewState.mIsRestored = true;
-            mInitialViewState.mViewScale = mRestoredScale / 100.0f;
+            mInitialViewState.mViewScale = mRestoredScale;
             if (mRestoredTextWrapScale > 0) {
-                mInitialViewState.mTextWrapScale = mRestoredTextWrapScale / 100.0f;
+                mInitialViewState.mTextWrapScale = mRestoredTextWrapScale;
             } else {
                 mInitialViewState.mTextWrapScale = mInitialViewState.mViewScale;
             }
@@ -2411,7 +2416,7 @@
                 // know the exact scale. If mRestoredScale is non-zero, use it;
                 // otherwise just use mTextWrapScale as the initial scale.
                 data.mScale = mInitialViewState.mViewScale == 0
-                        ? (mRestoredScale > 0 ? mRestoredScale / 100.0f
+                        ? (mRestoredScale > 0 ? mRestoredScale
                                 : mInitialViewState.mTextWrapScale)
                         : mInitialViewState.mViewScale;
                 if (DebugFlags.WEB_VIEW_CORE) {
@@ -2444,7 +2449,7 @@
     }
 
     // called by JNI
-    private void restoreScale(int scale, int textWrapScale) {
+    private void restoreScale(float scale, float textWrapScale) {
         if (mBrowserFrame.firstLayoutDone() == false) {
             mRestoredScale = scale;
             if (mSettings.getUseWideViewPort()) {
diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java
index 7b9def0..e1392ae 100644
--- a/core/java/android/webkit/WebViewDatabase.java
+++ b/core/java/android/webkit/WebViewDatabase.java
@@ -223,6 +223,7 @@
                         null);
             }
         }
+        mDatabase.enableWriteAheadLogging();
 
         // mDatabase should not be null,
         // the only case is RequestAPI test has problem to create db
@@ -233,7 +234,7 @@
         }
 
         if (mDatabase.getVersion() != DATABASE_VERSION) {
-            mDatabase.beginTransaction();
+            mDatabase.beginTransactionNonExclusive();
             try {
                 upgradeDatabase();
                 mDatabase.setTransactionSuccessful();
@@ -261,6 +262,7 @@
                         CACHE_DATABASE_FILE, 0, null);
             }
         }
+        mCacheDatabase.enableWriteAheadLogging();
 
         // mCacheDatabase should not be null,
         // the only case is RequestAPI test has problem to create db
@@ -271,7 +273,7 @@
         }
 
         if (mCacheDatabase.getVersion() != CACHE_DATABASE_VERSION) {
-            mCacheDatabase.beginTransaction();
+            mCacheDatabase.beginTransactionNonExclusive();
             try {
                 upgradeCacheDatabase();
                 bootstrapCacheDatabase();
@@ -648,7 +650,7 @@
                         + "WebViewWorkerThread instead of from "
                         + Thread.currentThread().getName());
             }
-            mCacheDatabase.beginTransaction();
+            mCacheDatabase.beginTransactionNonExclusive();
             return true;
         }
         return false;
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index 2fd5bb1..b4a33de 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -150,6 +150,12 @@
     private static float MINIMUM_SCALE_INCREMENT = 0.01f;
 
     /*
+     *  The touch points could be changed even the fingers stop moving.
+     *  We use the following to filter out the zooming jitters.
+     */
+    private static float MINIMUM_SCALE_WITHOUT_JITTER = 0.05f;
+
+    /*
      * The following member variables are only to be used for animating zoom. If
      * mZoomScale is non-zero then we are in the middle of a zoom animation. The
      * other variables are used as a cache (e.g. inverse) or as a way to store
@@ -684,6 +690,10 @@
                 } else {
                     scale = Math.max(scale, mActualScale * 0.8f);
                 }
+                // if the scale change is too small, regard it as jitter and skip it.
+                if (Math.abs(scale - mActualScale) < MINIMUM_SCALE_WITHOUT_JITTER) {
+                    return false;
+                }
                 setZoomCenter(detector.getFocusX(), detector.getFocusY());
                 setZoomScale(scale, false);
                 mWebView.invalidate();
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 821e1f6..fce2449 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -514,10 +514,11 @@
      * inconsistent date the values are normalized before updating the spinners.
      */
     private void updateSpinners(int year, int month, int dayOfMonth) {
-        mCurrentDate.set(Calendar.YEAR, year);
+        // compute the deltas before modifying the current date
         int deltaMonths = getDelataMonth(month);
-        mCurrentDate.add(Calendar.MONTH, deltaMonths);
         int deltaDays = getDelataDayOfMonth(dayOfMonth);
+        mCurrentDate.set(Calendar.YEAR, year);
+        mCurrentDate.add(Calendar.MONTH, deltaMonths);
         mCurrentDate.add(Calendar.DAY_OF_MONTH, deltaDays);
 
         if (mCurrentDate.before(mMinDate)) {
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java
index c06fe64..d4ef044 100644
--- a/core/java/android/widget/FastScroller.java
+++ b/core/java/android/widget/FastScroller.java
@@ -606,7 +606,7 @@
         final int positionsInSection = nextSectionPos - sectionPos;
 
         final View child = mList.getChildAt(0);
-        final float incrementalPos = firstVisibleItem +
+        final float incrementalPos = child == null ? 0 : firstVisibleItem +
                 (float) (mList.getPaddingTop() - child.getTop()) / child.getHeight();
         final float posWithinSection = (incrementalPos - sectionPos) / positionsInSection;
         int result = (int) ((section + posWithinSection) / sectionCount * trackHeight);
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index 69bc479..ba46a3f 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -478,7 +478,7 @@
         mDecrementButton.setOnLongClickListener(onLongClickListener);
 
         // input text
-        mInputText = (EditText) findViewById(R.id.timepicker_input);
+        mInputText = (EditText) findViewById(R.id.numberpicker_input);
         mInputText.setOnFocusChangeListener(new OnFocusChangeListener() {
             public void onFocusChange(View v, boolean hasFocus) {
                 if (!hasFocus) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 7675e0c..b892fe2 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4672,6 +4672,9 @@
                     // don't let it be inserted into the text.
                     if ((event.getFlags() & KeyEvent.FLAG_EDITOR_ACTION) != 0
                             || shouldAdvanceFocusOnEnter()) {
+                        if (mOnClickListener != null) {
+                            return 0;
+                        }
                         return -1;
                     }
                 }
@@ -8101,7 +8104,7 @@
                 CharSequence selectedText = mTransformed.subSequence(start, end);
                 ClipData data = ClipData.newPlainText(null, null, selectedText);
                 DragLocalState localState = new DragLocalState(this, start, end);
-                startDrag(data, getTextThumbnailBuilder(selectedText), false, localState);
+                startDrag(data, getTextThumbnailBuilder(selectedText), localState, 0);
                 stopSelectionActionMode();
             } else {
                 updateSelectedRegion();
diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java
index e384320..a139d31 100644
--- a/core/java/com/android/internal/app/AlertController.java
+++ b/core/java/com/android/internal/app/AlertController.java
@@ -412,9 +412,17 @@
         /* Only display the divider if we have a title and a 
          * custom view or a message.
          */
-        if (hasTitle && ((mMessage != null) || (mView != null))) {
-            View divider = mWindow.findViewById(R.id.titleDivider);
-            divider.setVisibility(View.VISIBLE);
+        if (hasTitle) {
+            View divider = null;
+            if (mMessage != null || mView != null || mListView != null) {
+                divider = mWindow.findViewById(R.id.titleDivider);
+            } else {
+                divider = mWindow.findViewById(R.id.titleDividerTop);
+            }
+
+            if (divider != null) {
+                divider.setVisibility(View.VISIBLE);
+            }
         }
         
         setBackground(topPanel, contentPanel, customPanel, hasButtons, a, hasTitle, buttonPanel);
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index b4c868f..4aed9b1 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -32,6 +32,7 @@
 #include <SkXfermode.h>
 
 #include <DisplayListRenderer.h>
+#include <LayerRenderer.h>
 #include <OpenGLDebugRenderer.h>
 #include <OpenGLRenderer.h>
 #include <SkiaShader.h>
@@ -77,7 +78,7 @@
 // Constructors
 // ----------------------------------------------------------------------------
 
-static OpenGLRenderer* android_view_GLES20Canvas_createRenderer(JNIEnv* env, jobject canvas) {
+static OpenGLRenderer* android_view_GLES20Canvas_createRenderer(JNIEnv* env, jobject clazz) {
     RENDERER_LOGD("Create OpenGLRenderer");
 #if PROFILE_RENDERER
     return new OpenGLDebugRenderer;
@@ -442,6 +443,76 @@
     renderer->drawDisplayList(displayList);
 }
 
+// ----------------------------------------------------------------------------
+// Layers
+// ----------------------------------------------------------------------------
+
+static void android_view_GLES20Canvas_interrupt(JNIEnv* env, jobject canvas,
+        OpenGLRenderer* renderer) {
+    renderer->interrupt();
+}
+
+static void android_view_GLES20Canvas_resume(JNIEnv* env, jobject canvas,
+        OpenGLRenderer* renderer) {
+    renderer->resume();
+}
+
+static OpenGLRenderer* android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env,
+        jobject clazz, jint fbo) {
+    return new LayerRenderer(fbo);
+}
+
+static jint android_view_GLES20Canvas_createLayer(JNIEnv* env,
+        jobject clazz, jint width, jint height, jintArray layerInfo) {
+    uint32_t layerWidth = 0;
+    uint32_t layerHeight = 0;
+    GLuint textureId = 0;
+
+    jint layerId = LayerRenderer::createLayer(width, height,
+            &layerWidth, &layerHeight, &textureId);
+
+    if (layerId) {
+        jint* storage = env->GetIntArrayElements(layerInfo, NULL);
+        storage[0] = layerWidth;
+        storage[1] = layerHeight;
+        storage[2] = textureId;
+        env->ReleaseIntArrayElements(layerInfo, storage, 0);
+    }
+
+    return layerId;
+}
+
+static void android_view_GLES20Canvas_resizeLayer(JNIEnv* env,
+        jobject clazz, jint layerId, jint layerTextureId, jint width, jint height,
+        jintArray layerInfo) {
+    uint32_t layerWidth = 0;
+    uint32_t layerHeight = 0;
+
+    LayerRenderer::resizeLayer(layerId, layerTextureId, width, height, &layerWidth, &layerHeight);
+
+    jint* storage = env->GetIntArrayElements(layerInfo, NULL);
+    storage[0] = layerWidth;
+    storage[1] = layerHeight;
+    env->ReleaseIntArrayElements(layerInfo, storage, 0);
+}
+
+static void android_view_GLES20Canvas_destroyLayer(JNIEnv* env,
+        jobject clazz, jint layerId, jint layerTextureId) {
+    LayerRenderer::destroyLayer(layerId, layerTextureId);
+}
+
+static void android_view_GLES20Canvas_destroyLayerDeferred(JNIEnv* env,
+        jobject clazz, jint layerId, jint layerTextureId) {
+    LayerRenderer::destroyLayerDeferred(layerId, layerTextureId);
+}
+
+static void android_view_GLES20Canvas_drawLayer(JNIEnv* env,
+        jobject canvas, OpenGLRenderer* renderer,
+        jfloat left, jfloat top, jfloat right, jfloat bottom,
+        jint layerTexture, jfloat u, jfloat v, SkPaint* paint) {
+    renderer->drawLayer(layerTexture, left, top, right, bottom, u, v, paint);
+}
+
 #endif // USE_OPENGL_RENDERER
 
 // ----------------------------------------------------------------------------
@@ -522,10 +593,21 @@
     { "nGetClipBounds",     "(ILandroid/graphics/Rect;)Z",
             (void*) android_view_GLES20Canvas_getClipBounds },
 
-    { "nGetDisplayList",  "(I)I",           (void*) android_view_GLES20Canvas_getDisplayList },
-    { "nDestroyDisplayList", "(I)V",           (void*) android_view_GLES20Canvas_destroyDisplayList },
-    { "nGetDisplayListRenderer", "(I)I",     (void*) android_view_GLES20Canvas_getDisplayListRenderer },
-    { "nDrawDisplayList",    "(II)V",          (void*) android_view_GLES20Canvas_drawDisplayList },
+    { "nGetDisplayList",         "(I)I",       (void*) android_view_GLES20Canvas_getDisplayList },
+    { "nDestroyDisplayList",     "(I)V",       (void*) android_view_GLES20Canvas_destroyDisplayList },
+    { "nGetDisplayListRenderer", "(I)I",       (void*) android_view_GLES20Canvas_getDisplayListRenderer },
+    { "nDrawDisplayList",        "(II)V",      (void*) android_view_GLES20Canvas_drawDisplayList },
+
+    { "nInterrupt",              "(I)V",       (void*) android_view_GLES20Canvas_interrupt },
+    { "nResume",                 "(I)V",       (void*) android_view_GLES20Canvas_resume },
+
+    { "nCreateLayerRenderer",    "(I)I",       (void*) android_view_GLES20Canvas_createLayerRenderer },
+    { "nCreateLayer",            "(II[I)I",    (void*) android_view_GLES20Canvas_createLayer },
+    { "nResizeLayer",            "(IIII[I)V",  (void*) android_view_GLES20Canvas_resizeLayer },
+    { "nDestroyLayer",           "(II)V",      (void*) android_view_GLES20Canvas_destroyLayer },
+    { "nDestroyLayerDeferred",   "(II)V",      (void*) android_view_GLES20Canvas_destroyLayerDeferred },
+    { "nDrawLayer",              "(IFFFFIFFI)V",
+            (void*) android_view_GLES20Canvas_drawLayer },
 
 #endif
 };
diff --git a/core/res/res/anim/accelerate_cubic_interpolator.xml b/core/res/res/anim/accelerate_cubic_interpolator.xml
deleted file mode 100644
index 90f62da..0000000
--- a/core/res/res/anim/accelerate_cubic_interpolator.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<accelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-        android:factor="1.5" />
diff --git a/core/res/res/anim/accelerate_quint_interpolator.xml b/core/res/res/anim/accelerate_quint_interpolator.xml
deleted file mode 100644
index cd3595c..0000000
--- a/core/res/res/anim/accelerate_quint_interpolator.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<accelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-        android:factor="2.5" />
diff --git a/core/res/res/anim/animator_fade_out.xml b/core/res/res/anim/animator_fade_out.xml
deleted file mode 100644
index 6a3d5ee..0000000
--- a/core/res/res/anim/animator_fade_out.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@interpolator/accelerate_quad"
-    android:valueFrom="1.0"
-    android:valueTo="0.0"
-    android:propertyName="alpha"
-    android:duration="@android:integer/config_mediumAnimTime"
-/>
diff --git a/core/res/res/anim/decelerate_cubic_interpolator.xml b/core/res/res/anim/decelerate_cubic_interpolator.xml
deleted file mode 100644
index 550a591..0000000
--- a/core/res/res/anim/decelerate_cubic_interpolator.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<decelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-        android:factor="1.5" />
diff --git a/core/res/res/anim/decelerate_quint_interpolator.xml b/core/res/res/anim/decelerate_quint_interpolator.xml
deleted file mode 100644
index 7545b17..0000000
--- a/core/res/res/anim/decelerate_quint_interpolator.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<decelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-        android:factor="2.5" />
diff --git a/core/res/res/anim/fragment_close_enter.xml b/core/res/res/anim/fragment_close_enter.xml
deleted file mode 100644
index c0abbc5..0000000
--- a/core/res/res/anim/fragment_close_enter.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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. 
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-	android:zAdjustment="normal">
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_quint"
-        android:valueFrom="0.975" android:valueTo="1.0"
-        android:valueType="floatType"
-        android:propertyName="scaleY"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_quint"
-        android:valueFrom="0.975" android:valueTo="1.0"
-        android:valueType="floatType"
-        android:propertyName="scaleX"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="0.0" android:valueTo="1.0"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/anim/fragment_close_exit.xml b/core/res/res/anim/fragment_close_exit.xml
deleted file mode 100644
index 9a5708c..0000000
--- a/core/res/res/anim/fragment_close_exit.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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. 
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-	android:zAdjustment="top">
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_quint"
-        android:valueFrom="1.0" android:valueTo="1.075"
-        android:valueType="floatType"
-        android:propertyName="scaleY"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_quint"
-        android:valueFrom="1.0" android:valueTo="1.075"
-        android:valueType="floatType"
-        android:propertyName="scaleX"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="1.0" android:valueTo="0.0"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/anim/fragment_next_enter.xml b/core/res/res/anim/fragment_next_enter.xml
deleted file mode 100644
index 13b15f3..0000000
--- a/core/res/res/anim/fragment_next_enter.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-	android:zAdjustment="top">
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="0"
-        android:valueTo="1"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/anim/fragment_next_exit.xml b/core/res/res/anim/fragment_next_exit.xml
deleted file mode 100644
index 503b7ad..0000000
--- a/core/res/res/anim/fragment_next_exit.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-	android:zAdjustment="normal">
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="1"
-        android:valueTo="0"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityShortDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/anim/fragment_open_enter.xml b/core/res/res/anim/fragment_open_enter.xml
deleted file mode 100644
index 6b16cb4..0000000
--- a/core/res/res/anim/fragment_open_enter.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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. 
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android">
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_quint"
-        android:valueFrom="1.125" android:valueTo="1.0"
-        android:valueType="floatType"
-        android:propertyName="scaleY"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_quint"
-        android:valueFrom="1.125" android:valueTo="1.0"
-        android:valueType="floatType"
-        android:propertyName="scaleX"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="0.0" android:valueTo="1.0"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/anim/fragment_open_exit.xml b/core/res/res/anim/fragment_open_exit.xml
deleted file mode 100644
index d77ee8e..0000000
--- a/core/res/res/anim/fragment_open_exit.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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. 
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android">
-    <objectAnimator
-        android:interpolator="@interpolator/linear"
-        android:valueFrom="1.0" android:valueTo="0.975"
-        android:valueType="floatType"
-        android:propertyName="scaleY"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/linear"
-        android:valueFrom="1.0" android:valueTo="0.975"
-        android:valueType="floatType"
-        android:propertyName="scaleX"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="1.0" android:valueTo="0.0"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/anim/fragment_prev_enter.xml b/core/res/res/anim/fragment_prev_enter.xml
deleted file mode 100644
index 13b15f3..0000000
--- a/core/res/res/anim/fragment_prev_enter.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-	android:zAdjustment="top">
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="0"
-        android:valueTo="1"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityDefaultDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/anim/fragment_prev_exit.xml b/core/res/res/anim/fragment_prev_exit.xml
deleted file mode 100644
index 503b7ad..0000000
--- a/core/res/res/anim/fragment_prev_exit.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-<set xmlns:android="http://schemas.android.com/apk/res/android"
-	android:zAdjustment="normal">
-    <objectAnimator
-        android:interpolator="@interpolator/decelerate_cubic"
-        android:valueFrom="1"
-        android:valueTo="0"
-        android:valueType="floatType"
-        android:propertyName="alpha"
-        android:duration="@android:integer/config_activityShortDur"/>
-</set>
\ No newline at end of file
diff --git a/core/res/res/animator/fade_in.xml b/core/res/res/animator/fade_in.xml
index 2a28b4d..cff98cf 100644
--- a/core/res/res/animator/fade_in.xml
+++ b/core/res/res/animator/fade_in.xml
@@ -18,7 +18,7 @@
 -->
 
 <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@anim/accelerate_interpolator"
+    android:interpolator="@interpolator/accelerate_quad"
     android:valueFrom="0"
     android:valueTo="1"
     android:propertyName="alpha"
diff --git a/core/res/res/animator/fade_out.xml b/core/res/res/animator/fade_out.xml
index 4db6591..6a3d5ee 100644
--- a/core/res/res/animator/fade_out.xml
+++ b/core/res/res/animator/fade_out.xml
@@ -18,7 +18,7 @@
 -->
 
 <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@anim/accelerate_interpolator"
+    android:interpolator="@interpolator/accelerate_quad"
     android:valueFrom="1.0"
     android:valueTo="0.0"
     android:propertyName="alpha"
diff --git a/core/res/res/drawable-hdpi/btn_check_off.png b/core/res/res/drawable-hdpi/btn_check_off.png
old mode 100644
new mode 100755
index aad9ef7..bb62e6f
--- a/core/res/res/drawable-hdpi/btn_check_off.png
+++ b/core/res/res/drawable-hdpi/btn_check_off.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_disable.png b/core/res/res/drawable-hdpi/btn_check_off_disable.png
old mode 100644
new mode 100755
index eaee9e0..b346381
--- a/core/res/res/drawable-hdpi/btn_check_off_disable.png
+++ b/core/res/res/drawable-hdpi/btn_check_off_disable.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_disable_focused.png b/core/res/res/drawable-hdpi/btn_check_off_disable_focused.png
old mode 100644
new mode 100755
index 6d2c293..8663369
--- a/core/res/res/drawable-hdpi/btn_check_off_disable_focused.png
+++ b/core/res/res/drawable-hdpi/btn_check_off_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_pressed.png b/core/res/res/drawable-hdpi/btn_check_off_pressed.png
old mode 100644
new mode 100755
index 1c442e9..67e49df
--- a/core/res/res/drawable-hdpi/btn_check_off_pressed.png
+++ b/core/res/res/drawable-hdpi/btn_check_off_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_off_selected.png b/core/res/res/drawable-hdpi/btn_check_off_selected.png
old mode 100644
new mode 100755
index b852b2c..1791d1f
--- a/core/res/res/drawable-hdpi/btn_check_off_selected.png
+++ b/core/res/res/drawable-hdpi/btn_check_off_selected.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on.png b/core/res/res/drawable-hdpi/btn_check_on.png
old mode 100644
new mode 100755
index cd5c181..15cd25e
--- a/core/res/res/drawable-hdpi/btn_check_on.png
+++ b/core/res/res/drawable-hdpi/btn_check_on.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_disable.png b/core/res/res/drawable-hdpi/btn_check_on_disable.png
old mode 100644
new mode 100755
index b4fc51a..e3fe323
--- a/core/res/res/drawable-hdpi/btn_check_on_disable.png
+++ b/core/res/res/drawable-hdpi/btn_check_on_disable.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_disable_focused.png b/core/res/res/drawable-hdpi/btn_check_on_disable_focused.png
old mode 100644
new mode 100755
index bf34647..fa41bb7
--- a/core/res/res/drawable-hdpi/btn_check_on_disable_focused.png
+++ b/core/res/res/drawable-hdpi/btn_check_on_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_pressed.png b/core/res/res/drawable-hdpi/btn_check_on_pressed.png
old mode 100644
new mode 100755
index fa5c7a2..906e283
--- a/core/res/res/drawable-hdpi/btn_check_on_pressed.png
+++ b/core/res/res/drawable-hdpi/btn_check_on_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_check_on_selected.png b/core/res/res/drawable-hdpi/btn_check_on_selected.png
old mode 100644
new mode 100755
index a6a21ad..eb496a8
--- a/core/res/res/drawable-hdpi/btn_check_on_selected.png
+++ b/core/res/res/drawable-hdpi/btn_check_on_selected.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_circle_disable.png b/core/res/res/drawable-hdpi/btn_circle_disable.png
old mode 100644
new mode 100755
index d829716..39652a8
--- a/core/res/res/drawable-hdpi/btn_circle_disable.png
+++ b/core/res/res/drawable-hdpi/btn_circle_disable.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_circle_disable_focused.png b/core/res/res/drawable-hdpi/btn_circle_disable_focused.png
old mode 100644
new mode 100755
index c1b5b6e..1aa7ffe
--- a/core/res/res/drawable-hdpi/btn_circle_disable_focused.png
+++ b/core/res/res/drawable-hdpi/btn_circle_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_circle_normal.png b/core/res/res/drawable-hdpi/btn_circle_normal.png
old mode 100644
new mode 100755
index bf3fb5a..6011219
--- a/core/res/res/drawable-hdpi/btn_circle_normal.png
+++ b/core/res/res/drawable-hdpi/btn_circle_normal.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_circle_pressed.png b/core/res/res/drawable-hdpi/btn_circle_pressed.png
old mode 100644
new mode 100755
index 50e22e6..4942e50
--- a/core/res/res/drawable-hdpi/btn_circle_pressed.png
+++ b/core/res/res/drawable-hdpi/btn_circle_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_circle_selected.png b/core/res/res/drawable-hdpi/btn_circle_selected.png
old mode 100644
new mode 100755
index cfc68fb..fe49a40
--- a/core/res/res/drawable-hdpi/btn_circle_selected.png
+++ b/core/res/res/drawable-hdpi/btn_circle_selected.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_close_normal.png b/core/res/res/drawable-hdpi/btn_close_normal.png
old mode 100644
new mode 100755
index 38b49f1..47f11e5
--- a/core/res/res/drawable-hdpi/btn_close_normal.png
+++ b/core/res/res/drawable-hdpi/btn_close_normal.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_close_pressed.png b/core/res/res/drawable-hdpi/btn_close_pressed.png
old mode 100644
new mode 100755
index aa9ea49f0..5b96b4e
--- a/core/res/res/drawable-hdpi/btn_close_pressed.png
+++ b/core/res/res/drawable-hdpi/btn_close_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_close_selected.png b/core/res/res/drawable-hdpi/btn_close_selected.png
old mode 100644
new mode 100755
index 870c670..e27d684
--- a/core/res/res/drawable-hdpi/btn_close_selected.png
+++ b/core/res/res/drawable-hdpi/btn_close_selected.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal.9.png b/core/res/res/drawable-hdpi/btn_default_normal.9.png
old mode 100644
new mode 100755
index 329ce6e..803651b
--- a/core/res/res/drawable-hdpi/btn_default_normal.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal_disable.9.png b/core/res/res/drawable-hdpi/btn_default_normal_disable.9.png
old mode 100644
new mode 100755
index a518c6b..f4f01c7
--- a/core/res/res/drawable-hdpi/btn_default_normal_disable.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal_disable.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal_disable_focused.9.png b/core/res/res/drawable-hdpi/btn_default_normal_disable_focused.9.png
old mode 100644
new mode 100755
index 71a05b7..5376db2
--- a/core/res/res/drawable-hdpi/btn_default_normal_disable_focused.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal_disable_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_pressed.9.png b/core/res/res/drawable-hdpi/btn_default_pressed.9.png
old mode 100644
new mode 100755
index d9d02bf..4312c27
--- a/core/res/res/drawable-hdpi/btn_default_pressed.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_selected.9.png b/core/res/res/drawable-hdpi/btn_default_selected.9.png
old mode 100644
new mode 100755
index ab7c612..06b7790
--- a/core/res/res/drawable-hdpi/btn_default_selected.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_small_normal.9.png b/core/res/res/drawable-hdpi/btn_default_small_normal.9.png
old mode 100644
new mode 100755
index baafed6..6d3ea9a
--- a/core/res/res/drawable-hdpi/btn_default_small_normal.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_small_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_small_normal_disable.9.png b/core/res/res/drawable-hdpi/btn_default_small_normal_disable.9.png
old mode 100644
new mode 100755
index 175197b..2646ba0
--- a/core/res/res/drawable-hdpi/btn_default_small_normal_disable.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_small_normal_disable.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_small_normal_disable_focused.9.png b/core/res/res/drawable-hdpi/btn_default_small_normal_disable_focused.9.png
old mode 100644
new mode 100755
index ec1feff..013210c
--- a/core/res/res/drawable-hdpi/btn_default_small_normal_disable_focused.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_small_normal_disable_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_small_pressed.9.png b/core/res/res/drawable-hdpi/btn_default_small_pressed.9.png
old mode 100644
new mode 100755
index c1f9a0f..24cefd4
--- a/core/res/res/drawable-hdpi/btn_default_small_pressed.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_small_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_small_selected.9.png b/core/res/res/drawable-hdpi/btn_default_small_selected.9.png
old mode 100644
new mode 100755
index 0ea3f40..bedbceb
--- a/core/res/res/drawable-hdpi/btn_default_small_selected.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_small_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_dropdown_disabled.9.png b/core/res/res/drawable-hdpi/btn_dropdown_disabled.9.png
index c6503c7..0d25b6e 100644
--- a/core/res/res/drawable-hdpi/btn_dropdown_disabled.9.png
+++ b/core/res/res/drawable-hdpi/btn_dropdown_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_dropdown_disabled_focused.9.png b/core/res/res/drawable-hdpi/btn_dropdown_disabled_focused.9.png
index 152de8b..e21fd75 100644
--- a/core/res/res/drawable-hdpi/btn_dropdown_disabled_focused.9.png
+++ b/core/res/res/drawable-hdpi/btn_dropdown_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_dropdown_normal.9.png b/core/res/res/drawable-hdpi/btn_dropdown_normal.9.png
old mode 100644
new mode 100755
index 9392495..f10402f
--- a/core/res/res/drawable-hdpi/btn_dropdown_normal.9.png
+++ b/core/res/res/drawable-hdpi/btn_dropdown_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_dropdown_pressed.9.png b/core/res/res/drawable-hdpi/btn_dropdown_pressed.9.png
old mode 100644
new mode 100755
index beaba45..366c6e0
--- a/core/res/res/drawable-hdpi/btn_dropdown_pressed.9.png
+++ b/core/res/res/drawable-hdpi/btn_dropdown_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_dropdown_selected.9.png b/core/res/res/drawable-hdpi/btn_dropdown_selected.9.png
old mode 100644
new mode 100755
index ec51fc9e..f063c8d
--- a/core/res/res/drawable-hdpi/btn_dropdown_selected.9.png
+++ b/core/res/res/drawable-hdpi/btn_dropdown_selected.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
index f0b2041..3b9e0cf 100644
--- a/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
+++ 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
index 5b93be7..0665b08 100644
--- a/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/expander_ic_maximized.9.png b/core/res/res/drawable-hdpi/expander_ic_maximized.9.png
index 04943aa..2ec27af 100644
--- a/core/res/res/drawable-hdpi/expander_ic_maximized.9.png
+++ b/core/res/res/drawable-hdpi/expander_ic_maximized.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/expander_ic_minimized.9.png b/core/res/res/drawable-hdpi/expander_ic_minimized.9.png
index 7bddbce..0c19bb7 100644
--- a/core/res/res/drawable-hdpi/expander_ic_minimized.9.png
+++ b/core/res/res/drawable-hdpi/expander_ic_minimized.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_menu_help.png b/core/res/res/drawable-hdpi/ic_menu_help.png
index 4300e86..01a77da 100644
--- a/core/res/res/drawable-hdpi/ic_menu_help.png
+++ b/core/res/res/drawable-hdpi/ic_menu_help.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_background_disabled.9.png b/core/res/res/drawable-hdpi/list_selector_background_disabled.9.png
old mode 100644
new mode 100755
index ab377d8..9e1c42a
--- a/core/res/res/drawable-hdpi/list_selector_background_disabled.9.png
+++ b/core/res/res/drawable-hdpi/list_selector_background_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_background_focus.9.png b/core/res/res/drawable-hdpi/list_selector_background_focus.9.png
old mode 100644
new mode 100755
index 94a9fba..5563c80
--- a/core/res/res/drawable-hdpi/list_selector_background_focus.9.png
+++ b/core/res/res/drawable-hdpi/list_selector_background_focus.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_background_longpress.9.png b/core/res/res/drawable-hdpi/list_selector_background_longpress.9.png
old mode 100644
new mode 100755
index bd74426..72d3a08
--- a/core/res/res/drawable-hdpi/list_selector_background_longpress.9.png
+++ b/core/res/res/drawable-hdpi/list_selector_background_longpress.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/list_selector_background_pressed.9.png b/core/res/res/drawable-hdpi/list_selector_background_pressed.9.png
old mode 100644
new mode 100755
index d18d6f7..7568b30
--- a/core/res/res/drawable-hdpi/list_selector_background_pressed.9.png
+++ b/core/res/res/drawable-hdpi/list_selector_background_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/menu_background.9.png b/core/res/res/drawable-hdpi/menu_background.9.png
index 60f0731..f4c9e08 100644
--- a/core/res/res/drawable-hdpi/menu_background.9.png
+++ b/core/res/res/drawable-hdpi/menu_background.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/menu_background_fill_parent_width.9.png b/core/res/res/drawable-hdpi/menu_background_fill_parent_width.9.png
index 09eac9b..a3cec11 100644
--- a/core/res/res/drawable-hdpi/menu_background_fill_parent_width.9.png
+++ b/core/res/res/drawable-hdpi/menu_background_fill_parent_width.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_disabled.9.png b/core/res/res/drawable-hdpi/numberpicker_down_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_disabled.9.png
rename to core/res/res/drawable-hdpi/numberpicker_down_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_disabled_focused.9.png b/core/res/res/drawable-hdpi/numberpicker_down_disabled_focused.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_disabled_focused.9.png
rename to core/res/res/drawable-hdpi/numberpicker_down_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_disabled_focused_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_down_disabled_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_disabled_focused_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_down_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_disabled_focused_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_down_disabled_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_disabled_focused_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_down_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_disabled_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_down_disabled_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_disabled_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_down_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_disabled_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_down_disabled_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_disabled_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_down_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_focused_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_down_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_focused_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_down_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_focused_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_down_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_focused_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_down_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_longpressed_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_down_longpressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_longpressed_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_down_longpressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_longpressed_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_down_longpressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_longpressed_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_down_longpressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_normal.9.png b/core/res/res/drawable-hdpi/numberpicker_down_normal.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_normal.9.png
rename to core/res/res/drawable-hdpi/numberpicker_down_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_normal_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_down_normal_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_normal_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_down_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_normal_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_down_normal_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_normal_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_down_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_pressed.9.png b/core/res/res/drawable-hdpi/numberpicker_down_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_pressed.9.png
rename to core/res/res/drawable-hdpi/numberpicker_down_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_pressed_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_down_pressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_pressed_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_down_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_pressed_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_down_pressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_pressed_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_down_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_down_selected.9.png b/core/res/res/drawable-hdpi/numberpicker_down_selected.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_down_selected.9.png
rename to core/res/res/drawable-hdpi/numberpicker_down_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_input_disabled.9.png b/core/res/res/drawable-hdpi/numberpicker_input_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_input_disabled.9.png
rename to core/res/res/drawable-hdpi/numberpicker_input_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_input_normal.9.png b/core/res/res/drawable-hdpi/numberpicker_input_normal.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_input_normal.9.png
rename to core/res/res/drawable-hdpi/numberpicker_input_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_input_pressed.9.png b/core/res/res/drawable-hdpi/numberpicker_input_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_input_pressed.9.png
rename to core/res/res/drawable-hdpi/numberpicker_input_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_input_selected.9.png b/core/res/res/drawable-hdpi/numberpicker_input_selected.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_input_selected.9.png
rename to core/res/res/drawable-hdpi/numberpicker_input_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_disabled.9.png b/core/res/res/drawable-hdpi/numberpicker_up_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_disabled.9.png
rename to core/res/res/drawable-hdpi/numberpicker_up_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_disabled_focused.9.png b/core/res/res/drawable-hdpi/numberpicker_up_disabled_focused.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_disabled_focused.9.png
rename to core/res/res/drawable-hdpi/numberpicker_up_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_disabled_focused_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_up_disabled_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_disabled_focused_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_up_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_disabled_focused_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_up_disabled_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_disabled_focused_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_up_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_disabled_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_up_disabled_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_disabled_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_up_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_disabled_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_up_disabled_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_disabled_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_up_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_focused_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_up_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_focused_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_up_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_focused_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_up_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_focused_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_up_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_longpressed_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_up_longpressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_longpressed_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_up_longpressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_longpressed_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_up_longpressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_longpressed_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_up_longpressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_normal.9.png b/core/res/res/drawable-hdpi/numberpicker_up_normal.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_normal.9.png
rename to core/res/res/drawable-hdpi/numberpicker_up_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_normal_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_up_normal_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_normal_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_up_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_normal_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_up_normal_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_normal_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_up_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_pressed.9.png b/core/res/res/drawable-hdpi/numberpicker_up_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_pressed.9.png
rename to core/res/res/drawable-hdpi/numberpicker_up_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_pressed_holo_dark.png b/core/res/res/drawable-hdpi/numberpicker_up_pressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_pressed_holo_dark.png
rename to core/res/res/drawable-hdpi/numberpicker_up_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_pressed_holo_light.png b/core/res/res/drawable-hdpi/numberpicker_up_pressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_pressed_holo_light.png
rename to core/res/res/drawable-hdpi/numberpicker_up_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/timepicker_up_selected.9.png b/core/res/res/drawable-hdpi/numberpicker_up_selected.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/timepicker_up_selected.9.png
rename to core/res/res/drawable-hdpi/numberpicker_up_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/panel_background.9.png b/core/res/res/drawable-hdpi/panel_background.9.png
index bfe5713..03175d4 100644
--- a/core/res/res/drawable-hdpi/panel_background.9.png
+++ b/core/res/res/drawable-hdpi/panel_background.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_bottom_bright.9.png b/core/res/res/drawable-hdpi/popup_bottom_bright.9.png
index cca47d3..6e5fbb5 100644
--- a/core/res/res/drawable-hdpi/popup_bottom_bright.9.png
+++ b/core/res/res/drawable-hdpi/popup_bottom_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_bottom_dark.9.png b/core/res/res/drawable-hdpi/popup_bottom_dark.9.png
index 62a0bd0..3434b2d 100644
--- a/core/res/res/drawable-hdpi/popup_bottom_dark.9.png
+++ b/core/res/res/drawable-hdpi/popup_bottom_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_bottom_medium.9.png b/core/res/res/drawable-hdpi/popup_bottom_medium.9.png
index 6ebb4f7..673a509 100644
--- a/core/res/res/drawable-hdpi/popup_bottom_medium.9.png
+++ b/core/res/res/drawable-hdpi/popup_bottom_medium.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_center_bright.9.png b/core/res/res/drawable-hdpi/popup_center_bright.9.png
index 756e9ed..c2a739c 100644
--- a/core/res/res/drawable-hdpi/popup_center_bright.9.png
+++ b/core/res/res/drawable-hdpi/popup_center_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_center_dark.9.png b/core/res/res/drawable-hdpi/popup_center_dark.9.png
index 77b4524..9d2bfb1 100644
--- a/core/res/res/drawable-hdpi/popup_center_dark.9.png
+++ b/core/res/res/drawable-hdpi/popup_center_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_center_medium.9.png b/core/res/res/drawable-hdpi/popup_center_medium.9.png
index de4be2a..4375bf2d 100644
--- a/core/res/res/drawable-hdpi/popup_center_medium.9.png
+++ b/core/res/res/drawable-hdpi/popup_center_medium.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_full_bright.9.png b/core/res/res/drawable-hdpi/popup_full_bright.9.png
index 6c30bec..6b8aa9d 100644
--- a/core/res/res/drawable-hdpi/popup_full_bright.9.png
+++ b/core/res/res/drawable-hdpi/popup_full_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_full_dark.9.png b/core/res/res/drawable-hdpi/popup_full_dark.9.png
index fc8c00e..2884abe 100644
--- a/core/res/res/drawable-hdpi/popup_full_dark.9.png
+++ b/core/res/res/drawable-hdpi/popup_full_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_top_bright.9.png b/core/res/res/drawable-hdpi/popup_top_bright.9.png
index ddd30ab..76c35ec 100644
--- a/core/res/res/drawable-hdpi/popup_top_bright.9.png
+++ b/core/res/res/drawable-hdpi/popup_top_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/popup_top_dark.9.png b/core/res/res/drawable-hdpi/popup_top_dark.9.png
index 144d0fc..f317330 100644
--- a/core/res/res/drawable-hdpi/popup_top_dark.9.png
+++ b/core/res/res/drawable-hdpi/popup_top_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/simple_week_dayline_holo_light.9.png b/core/res/res/drawable-hdpi/simple_week_dayline_holo_light.9.png
deleted file mode 100644
index ed1a5e9..0000000
--- a/core/res/res/drawable-hdpi/simple_week_dayline_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_down_disabled.9.png b/core/res/res/drawable-ldpi/numberpicker_down_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_down_disabled.9.png
rename to core/res/res/drawable-ldpi/numberpicker_down_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_down_disabled_focused.9.png b/core/res/res/drawable-ldpi/numberpicker_down_disabled_focused.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_down_disabled_focused.9.png
rename to core/res/res/drawable-ldpi/numberpicker_down_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_down_normal.9.png b/core/res/res/drawable-ldpi/numberpicker_down_normal.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_down_normal.9.png
rename to core/res/res/drawable-ldpi/numberpicker_down_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_down_pressed.9.png b/core/res/res/drawable-ldpi/numberpicker_down_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_down_pressed.9.png
rename to core/res/res/drawable-ldpi/numberpicker_down_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_down_selected.9.png b/core/res/res/drawable-ldpi/numberpicker_down_selected.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_down_selected.9.png
rename to core/res/res/drawable-ldpi/numberpicker_down_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_input_disabled.9.png b/core/res/res/drawable-ldpi/numberpicker_input_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_input_disabled.9.png
rename to core/res/res/drawable-ldpi/numberpicker_input_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_input_normal.9.png b/core/res/res/drawable-ldpi/numberpicker_input_normal.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_input_normal.9.png
rename to core/res/res/drawable-ldpi/numberpicker_input_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_input_pressed.9.png b/core/res/res/drawable-ldpi/numberpicker_input_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_input_pressed.9.png
rename to core/res/res/drawable-ldpi/numberpicker_input_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_input_selected.9.png b/core/res/res/drawable-ldpi/numberpicker_input_selected.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_input_selected.9.png
rename to core/res/res/drawable-ldpi/numberpicker_input_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_up_disabled.9.png b/core/res/res/drawable-ldpi/numberpicker_up_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_up_disabled.9.png
rename to core/res/res/drawable-ldpi/numberpicker_up_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_up_disabled_focused.9.png b/core/res/res/drawable-ldpi/numberpicker_up_disabled_focused.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_up_disabled_focused.9.png
rename to core/res/res/drawable-ldpi/numberpicker_up_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_up_normal.9.png b/core/res/res/drawable-ldpi/numberpicker_up_normal.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_up_normal.9.png
rename to core/res/res/drawable-ldpi/numberpicker_up_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_up_pressed.9.png b/core/res/res/drawable-ldpi/numberpicker_up_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_up_pressed.9.png
rename to core/res/res/drawable-ldpi/numberpicker_up_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/timepicker_up_selected.9.png b/core/res/res/drawable-ldpi/numberpicker_up_selected.9.png
similarity index 100%
rename from core/res/res/drawable-ldpi/timepicker_up_selected.9.png
rename to core/res/res/drawable-ldpi/numberpicker_up_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off.png b/core/res/res/drawable-mdpi/btn_check_off.png
index 56d3861..251ddff 100644
--- a/core/res/res/drawable-mdpi/btn_check_off.png
+++ b/core/res/res/drawable-mdpi/btn_check_off.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disable.png b/core/res/res/drawable-mdpi/btn_check_off_disable.png
index e012afd..45e6804 100644
--- a/core/res/res/drawable-mdpi/btn_check_off_disable.png
+++ b/core/res/res/drawable-mdpi/btn_check_off_disable.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_disable_focused.png b/core/res/res/drawable-mdpi/btn_check_off_disable_focused.png
index 0837bbd..193acd2 100644
--- a/core/res/res/drawable-mdpi/btn_check_off_disable_focused.png
+++ b/core/res/res/drawable-mdpi/btn_check_off_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_pressed.png b/core/res/res/drawable-mdpi/btn_check_off_pressed.png
index 984dfd7..807901c 100644
--- a/core/res/res/drawable-mdpi/btn_check_off_pressed.png
+++ b/core/res/res/drawable-mdpi/btn_check_off_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_off_selected.png b/core/res/res/drawable-mdpi/btn_check_off_selected.png
index 20842d4..dbc3beb 100644
--- a/core/res/res/drawable-mdpi/btn_check_off_selected.png
+++ b/core/res/res/drawable-mdpi/btn_check_off_selected.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on.png b/core/res/res/drawable-mdpi/btn_check_on.png
index 791ac1d..4c83e2e 100644
--- a/core/res/res/drawable-mdpi/btn_check_on.png
+++ b/core/res/res/drawable-mdpi/btn_check_on.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_disable.png b/core/res/res/drawable-mdpi/btn_check_on_disable.png
index 6cb02f3..f1bf178 100644
--- a/core/res/res/drawable-mdpi/btn_check_on_disable.png
+++ b/core/res/res/drawable-mdpi/btn_check_on_disable.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_disable_focused.png b/core/res/res/drawable-mdpi/btn_check_on_disable_focused.png
index 8a73b33..ea232ee 100644
--- a/core/res/res/drawable-mdpi/btn_check_on_disable_focused.png
+++ b/core/res/res/drawable-mdpi/btn_check_on_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_pressed.png b/core/res/res/drawable-mdpi/btn_check_on_pressed.png
index 300d64a..0de8a4c 100644
--- a/core/res/res/drawable-mdpi/btn_check_on_pressed.png
+++ b/core/res/res/drawable-mdpi/btn_check_on_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_check_on_selected.png b/core/res/res/drawable-mdpi/btn_check_on_selected.png
index 0b36adb..20294f3 100644
--- a/core/res/res/drawable-mdpi/btn_check_on_selected.png
+++ b/core/res/res/drawable-mdpi/btn_check_on_selected.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_circle_disable.png b/core/res/res/drawable-mdpi/btn_circle_disable.png
index 33b74a6..29e227c 100644
--- a/core/res/res/drawable-mdpi/btn_circle_disable.png
+++ b/core/res/res/drawable-mdpi/btn_circle_disable.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_circle_disable_focused.png b/core/res/res/drawable-mdpi/btn_circle_disable_focused.png
index 005ad8d..c5aa3c5 100644
--- a/core/res/res/drawable-mdpi/btn_circle_disable_focused.png
+++ b/core/res/res/drawable-mdpi/btn_circle_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_circle_normal.png b/core/res/res/drawable-mdpi/btn_circle_normal.png
index fc5af1c..6358351 100644
--- a/core/res/res/drawable-mdpi/btn_circle_normal.png
+++ b/core/res/res/drawable-mdpi/btn_circle_normal.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_circle_pressed.png b/core/res/res/drawable-mdpi/btn_circle_pressed.png
index 8f40afd..dc07a61 100644
--- a/core/res/res/drawable-mdpi/btn_circle_pressed.png
+++ b/core/res/res/drawable-mdpi/btn_circle_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_circle_selected.png b/core/res/res/drawable-mdpi/btn_circle_selected.png
index c74fac2..6eb2ff5 100644
--- a/core/res/res/drawable-mdpi/btn_circle_selected.png
+++ b/core/res/res/drawable-mdpi/btn_circle_selected.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_close_normal.png b/core/res/res/drawable-mdpi/btn_close_normal.png
index 4c6e79d..eca5828 100644
--- a/core/res/res/drawable-mdpi/btn_close_normal.png
+++ b/core/res/res/drawable-mdpi/btn_close_normal.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_close_pressed.png b/core/res/res/drawable-mdpi/btn_close_pressed.png
index fc983af..3c745bb 100644
--- a/core/res/res/drawable-mdpi/btn_close_pressed.png
+++ b/core/res/res/drawable-mdpi/btn_close_pressed.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_close_selected.png b/core/res/res/drawable-mdpi/btn_close_selected.png
index f2bf91a..c41f039 100644
--- a/core/res/res/drawable-mdpi/btn_close_selected.png
+++ b/core/res/res/drawable-mdpi/btn_close_selected.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal.9.png b/core/res/res/drawable-mdpi/btn_default_normal.9.png
index a2d5ccd..7ff74b2 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal_disable.9.png b/core/res/res/drawable-mdpi/btn_default_normal_disable.9.png
index edd3a3e..d3e11b5 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal_disable.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal_disable.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal_disable_focused.9.png b/core/res/res/drawable-mdpi/btn_default_normal_disable_focused.9.png
index f506179..843ca7a 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal_disable_focused.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal_disable_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_pressed.9.png b/core/res/res/drawable-mdpi/btn_default_pressed.9.png
index 033bf89..74fd58b 100644
--- a/core/res/res/drawable-mdpi/btn_default_pressed.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_selected.9.png b/core/res/res/drawable-mdpi/btn_default_selected.9.png
index 1e900bf..415b145 100644
--- a/core/res/res/drawable-mdpi/btn_default_selected.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_small_normal.9.png b/core/res/res/drawable-mdpi/btn_default_small_normal.9.png
index bcedd5f..5dddd46 100644
--- a/core/res/res/drawable-mdpi/btn_default_small_normal.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_small_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_small_normal_disable.9.png b/core/res/res/drawable-mdpi/btn_default_small_normal_disable.9.png
index ac6260f..6ab5c4a 100644
--- a/core/res/res/drawable-mdpi/btn_default_small_normal_disable.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_small_normal_disable.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_small_normal_disable_focused.9.png b/core/res/res/drawable-mdpi/btn_default_small_normal_disable_focused.9.png
index 4ee1b3f..c65bace 100644
--- a/core/res/res/drawable-mdpi/btn_default_small_normal_disable_focused.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_small_normal_disable_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_small_pressed.9.png b/core/res/res/drawable-mdpi/btn_default_small_pressed.9.png
index 25e38f4..43e82f9 100644
--- a/core/res/res/drawable-mdpi/btn_default_small_pressed.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_small_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_small_selected.9.png b/core/res/res/drawable-mdpi/btn_default_small_selected.9.png
index cc209c6..7a376a9 100644
--- a/core/res/res/drawable-mdpi/btn_default_small_selected.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_small_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_dropdown_disabled.9.png b/core/res/res/drawable-mdpi/btn_dropdown_disabled.9.png
index f7464c7..72915b5 100644
--- a/core/res/res/drawable-mdpi/btn_dropdown_disabled.9.png
+++ b/core/res/res/drawable-mdpi/btn_dropdown_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_dropdown_disabled_focused.9.png b/core/res/res/drawable-mdpi/btn_dropdown_disabled_focused.9.png
index ffe219f..438c06a 100644
--- a/core/res/res/drawable-mdpi/btn_dropdown_disabled_focused.9.png
+++ b/core/res/res/drawable-mdpi/btn_dropdown_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_dropdown_normal.9.png b/core/res/res/drawable-mdpi/btn_dropdown_normal.9.png
index f6e9a19..8540501 100644
--- a/core/res/res/drawable-mdpi/btn_dropdown_normal.9.png
+++ b/core/res/res/drawable-mdpi/btn_dropdown_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_dropdown_pressed.9.png b/core/res/res/drawable-mdpi/btn_dropdown_pressed.9.png
index 3bdf52d..9a50396 100644
--- a/core/res/res/drawable-mdpi/btn_dropdown_pressed.9.png
+++ b/core/res/res/drawable-mdpi/btn_dropdown_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_dropdown_selected.9.png b/core/res/res/drawable-mdpi/btn_dropdown_selected.9.png
index 087956e..a0a3fef 100644
--- a/core/res/res/drawable-mdpi/btn_dropdown_selected.9.png
+++ b/core/res/res/drawable-mdpi/btn_dropdown_selected.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
index a71af8d..bd5f9e0 100644
--- a/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
+++ 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
index 4017bf7..45e9712 100644
--- a/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/expander_ic_maximized.9.png b/core/res/res/drawable-mdpi/expander_ic_maximized.9.png
index 465cabd..d5c3276 100644
--- a/core/res/res/drawable-mdpi/expander_ic_maximized.9.png
+++ b/core/res/res/drawable-mdpi/expander_ic_maximized.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/expander_ic_minimized.9.png b/core/res/res/drawable-mdpi/expander_ic_minimized.9.png
index 9967ecb..4515b42 100644
--- a/core/res/res/drawable-mdpi/expander_ic_minimized.9.png
+++ b/core/res/res/drawable-mdpi/expander_ic_minimized.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_bullet_key_permission.png b/core/res/res/drawable-mdpi/ic_bullet_key_permission.png
index ccb010f..68ad039 100644
--- a/core/res/res/drawable-mdpi/ic_bullet_key_permission.png
+++ b/core/res/res/drawable-mdpi/ic_bullet_key_permission.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_menu_help.png b/core/res/res/drawable-mdpi/ic_menu_help.png
index 7c55dfd..12ca235 100644
--- a/core/res/res/drawable-mdpi/ic_menu_help.png
+++ b/core/res/res/drawable-mdpi/ic_menu_help.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_background_disabled.9.png b/core/res/res/drawable-mdpi/list_selector_background_disabled.9.png
index 60f19fe..43c36cb 100644
--- a/core/res/res/drawable-mdpi/list_selector_background_disabled.9.png
+++ b/core/res/res/drawable-mdpi/list_selector_background_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_background_focus.9.png b/core/res/res/drawable-mdpi/list_selector_background_focus.9.png
index 421e734..53a7eac 100644
--- a/core/res/res/drawable-mdpi/list_selector_background_focus.9.png
+++ b/core/res/res/drawable-mdpi/list_selector_background_focus.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_background_longpress.9.png b/core/res/res/drawable-mdpi/list_selector_background_longpress.9.png
index 7817667..0818761 100644
--- a/core/res/res/drawable-mdpi/list_selector_background_longpress.9.png
+++ b/core/res/res/drawable-mdpi/list_selector_background_longpress.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/list_selector_background_pressed.9.png b/core/res/res/drawable-mdpi/list_selector_background_pressed.9.png
index 1531d9d..8bd86b2 100644
--- a/core/res/res/drawable-mdpi/list_selector_background_pressed.9.png
+++ b/core/res/res/drawable-mdpi/list_selector_background_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_background.9.png b/core/res/res/drawable-mdpi/menu_background.9.png
index 9f16df9..41a3d34 100644
--- a/core/res/res/drawable-mdpi/menu_background.9.png
+++ b/core/res/res/drawable-mdpi/menu_background.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_background_fill_parent_width.9.png b/core/res/res/drawable-mdpi/menu_background_fill_parent_width.9.png
index da3011b..1ddf091 100644
--- a/core/res/res/drawable-mdpi/menu_background_fill_parent_width.9.png
+++ b/core/res/res/drawable-mdpi/menu_background_fill_parent_width.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_disabled.9.png b/core/res/res/drawable-mdpi/numberpicker_down_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_disabled.9.png
rename to core/res/res/drawable-mdpi/numberpicker_down_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_disabled_focused.9.png b/core/res/res/drawable-mdpi/numberpicker_down_disabled_focused.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_disabled_focused.9.png
rename to core/res/res/drawable-mdpi/numberpicker_down_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_disabled_focused_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_down_disabled_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_disabled_focused_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_down_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_disabled_focused_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_down_disabled_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_disabled_focused_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_down_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_disabled_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_down_disabled_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_disabled_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_down_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_disabled_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_down_disabled_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_disabled_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_down_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_focused_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_down_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_focused_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_down_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_focused_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_down_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_focused_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_down_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_longpressed_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_down_longpressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_longpressed_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_down_longpressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_longpressed_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_down_longpressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_longpressed_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_down_longpressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_normal.9.png b/core/res/res/drawable-mdpi/numberpicker_down_normal.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_normal.9.png
rename to core/res/res/drawable-mdpi/numberpicker_down_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_normal_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_down_normal_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_normal_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_down_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_normal_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_down_normal_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_normal_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_down_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_pressed.9.png b/core/res/res/drawable-mdpi/numberpicker_down_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_pressed.9.png
rename to core/res/res/drawable-mdpi/numberpicker_down_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_pressed_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_down_pressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_pressed_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_down_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_pressed_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_down_pressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_pressed_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_down_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_down_selected.9.png b/core/res/res/drawable-mdpi/numberpicker_down_selected.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_down_selected.9.png
rename to core/res/res/drawable-mdpi/numberpicker_down_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_input_disabled.9.png b/core/res/res/drawable-mdpi/numberpicker_input_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_input_disabled.9.png
rename to core/res/res/drawable-mdpi/numberpicker_input_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_input_normal.9.png b/core/res/res/drawable-mdpi/numberpicker_input_normal.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_input_normal.9.png
rename to core/res/res/drawable-mdpi/numberpicker_input_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_input_pressed.9.png b/core/res/res/drawable-mdpi/numberpicker_input_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_input_pressed.9.png
rename to core/res/res/drawable-mdpi/numberpicker_input_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_input_selected.9.png b/core/res/res/drawable-mdpi/numberpicker_input_selected.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_input_selected.9.png
rename to core/res/res/drawable-mdpi/numberpicker_input_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_disabled.9.png b/core/res/res/drawable-mdpi/numberpicker_up_disabled.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_disabled.9.png
rename to core/res/res/drawable-mdpi/numberpicker_up_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_disabled_focused.9.png b/core/res/res/drawable-mdpi/numberpicker_up_disabled_focused.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_disabled_focused.9.png
rename to core/res/res/drawable-mdpi/numberpicker_up_disabled_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_disabled_focused_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_up_disabled_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_disabled_focused_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_up_disabled_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_disabled_focused_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_up_disabled_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_disabled_focused_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_up_disabled_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_disabled_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_up_disabled_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_disabled_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_up_disabled_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_disabled_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_up_disabled_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_disabled_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_up_disabled_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_focused_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_up_focused_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_focused_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_up_focused_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_focused_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_up_focused_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_focused_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_up_focused_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_longpressed_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_up_longpressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_longpressed_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_up_longpressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_longpressed_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_up_longpressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_longpressed_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_up_longpressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_normal.9.png b/core/res/res/drawable-mdpi/numberpicker_up_normal.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_normal.9.png
rename to core/res/res/drawable-mdpi/numberpicker_up_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_normal_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_up_normal_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_normal_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_up_normal_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_normal_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_up_normal_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_normal_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_up_normal_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_pressed.9.png b/core/res/res/drawable-mdpi/numberpicker_up_pressed.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_pressed.9.png
rename to core/res/res/drawable-mdpi/numberpicker_up_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_pressed_holo_dark.png b/core/res/res/drawable-mdpi/numberpicker_up_pressed_holo_dark.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_pressed_holo_dark.png
rename to core/res/res/drawable-mdpi/numberpicker_up_pressed_holo_dark.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_pressed_holo_light.png b/core/res/res/drawable-mdpi/numberpicker_up_pressed_holo_light.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_pressed_holo_light.png
rename to core/res/res/drawable-mdpi/numberpicker_up_pressed_holo_light.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/timepicker_up_selected.9.png b/core/res/res/drawable-mdpi/numberpicker_up_selected.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/timepicker_up_selected.9.png
rename to core/res/res/drawable-mdpi/numberpicker_up_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/panel_background.9.png b/core/res/res/drawable-mdpi/panel_background.9.png
index 2305be4..822b6c6 100644
--- a/core/res/res/drawable-mdpi/panel_background.9.png
+++ b/core/res/res/drawable-mdpi/panel_background.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_bottom_bright.9.png b/core/res/res/drawable-mdpi/popup_bottom_bright.9.png
index e8e203b3..e7b713d 100644
--- a/core/res/res/drawable-mdpi/popup_bottom_bright.9.png
+++ b/core/res/res/drawable-mdpi/popup_bottom_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_bottom_dark.9.png b/core/res/res/drawable-mdpi/popup_bottom_dark.9.png
index 76a2a7f..88ce336 100644
--- a/core/res/res/drawable-mdpi/popup_bottom_dark.9.png
+++ b/core/res/res/drawable-mdpi/popup_bottom_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_bottom_medium.9.png b/core/res/res/drawable-mdpi/popup_bottom_medium.9.png
old mode 100755
new mode 100644
index dee6d6b..e5aaad0
--- a/core/res/res/drawable-mdpi/popup_bottom_medium.9.png
+++ b/core/res/res/drawable-mdpi/popup_bottom_medium.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_center_bright.9.png b/core/res/res/drawable-mdpi/popup_center_bright.9.png
index c817338db..a259356 100644
--- a/core/res/res/drawable-mdpi/popup_center_bright.9.png
+++ b/core/res/res/drawable-mdpi/popup_center_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_center_dark.9.png b/core/res/res/drawable-mdpi/popup_center_dark.9.png
index 79ffdaa..9378dbf 100644
--- a/core/res/res/drawable-mdpi/popup_center_dark.9.png
+++ b/core/res/res/drawable-mdpi/popup_center_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_center_medium.9.png b/core/res/res/drawable-mdpi/popup_center_medium.9.png
old mode 100755
new mode 100644
index ba2e9bf..885403c
--- a/core/res/res/drawable-mdpi/popup_center_medium.9.png
+++ b/core/res/res/drawable-mdpi/popup_center_medium.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_full_bright.9.png b/core/res/res/drawable-mdpi/popup_full_bright.9.png
index d33ff2b..d7fb3db 100644
--- a/core/res/res/drawable-mdpi/popup_full_bright.9.png
+++ b/core/res/res/drawable-mdpi/popup_full_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_full_dark.9.png b/core/res/res/drawable-mdpi/popup_full_dark.9.png
index 2305be4..7b9f291 100644
--- a/core/res/res/drawable-mdpi/popup_full_dark.9.png
+++ b/core/res/res/drawable-mdpi/popup_full_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_top_bright.9.png b/core/res/res/drawable-mdpi/popup_top_bright.9.png
index 727a948..72d82f0 100644
--- a/core/res/res/drawable-mdpi/popup_top_bright.9.png
+++ b/core/res/res/drawable-mdpi/popup_top_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/popup_top_dark.9.png b/core/res/res/drawable-mdpi/popup_top_dark.9.png
index af511f2..616d80f 100644
--- a/core/res/res/drawable-mdpi/popup_top_dark.9.png
+++ b/core/res/res/drawable-mdpi/popup_top_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/simple_week_dayline_holo_light.9.png b/core/res/res/drawable-mdpi/simple_week_dayline_holo_light.9.png
deleted file mode 100644
index f264cb6..0000000
--- a/core/res/res/drawable-mdpi/simple_week_dayline_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/timepicker_down_btn.xml b/core/res/res/drawable/numberpicker_down_btn.xml
similarity index 79%
copy from core/res/res/drawable/timepicker_down_btn.xml
copy to core/res/res/drawable/numberpicker_down_btn.xml
index d4908cb..0046df5 100644
--- a/core/res/res/drawable/timepicker_down_btn.xml
+++ b/core/res/res/drawable/numberpicker_down_btn.xml
@@ -19,25 +19,25 @@
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_normal" />
+          android:drawable="@drawable/numberpicker_down_normal" />
 
     <item android:state_pressed="true"
           android:state_enabled="true"
-          android:drawable="@drawable/timepicker_down_pressed" />
+          android:drawable="@drawable/numberpicker_down_pressed" />
 
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_selected" />
+          android:drawable="@drawable/numberpicker_down_selected" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_disabled" />
+          android:drawable="@drawable/numberpicker_down_disabled" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_disabled_focused" />
+          android:drawable="@drawable/numberpicker_down_disabled_focused" />
 
 </selector>
diff --git a/core/res/res/drawable/timepicker_down_btn_holo_dark.xml b/core/res/res/drawable/numberpicker_down_btn_holo_dark.xml
similarity index 77%
copy from core/res/res/drawable/timepicker_down_btn_holo_dark.xml
copy to core/res/res/drawable/numberpicker_down_btn_holo_dark.xml
index b4b824d..dd6332d 100644
--- a/core/res/res/drawable/timepicker_down_btn_holo_dark.xml
+++ b/core/res/res/drawable/numberpicker_down_btn_holo_dark.xml
@@ -19,25 +19,25 @@
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_normal_holo_dark" />
+          android:drawable="@drawable/numberpicker_down_normal_holo_dark" />
 
     <item android:state_pressed="true"
           android:state_enabled="true"
-          android:drawable="@drawable/timepicker_down_pressed_holo_dark" />
+          android:drawable="@drawable/numberpicker_down_pressed_holo_dark" />
 
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_focused_holo_dark" />
+          android:drawable="@drawable/numberpicker_down_focused_holo_dark" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_disabled_holo_dark" />
+          android:drawable="@drawable/numberpicker_down_disabled_holo_dark" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_disabled_focused_holo_dark" />
+          android:drawable="@drawable/numberpicker_down_disabled_focused_holo_dark" />
 
 </selector>
diff --git a/core/res/res/drawable/timepicker_down_btn_holo_light.xml b/core/res/res/drawable/numberpicker_down_btn_holo_light.xml
similarity index 77%
copy from core/res/res/drawable/timepicker_down_btn_holo_light.xml
copy to core/res/res/drawable/numberpicker_down_btn_holo_light.xml
index 7ae5e53..565fd86 100644
--- a/core/res/res/drawable/timepicker_down_btn_holo_light.xml
+++ b/core/res/res/drawable/numberpicker_down_btn_holo_light.xml
@@ -19,25 +19,25 @@
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_normal_holo_light" />
+          android:drawable="@drawable/numberpicker_down_normal_holo_light" />
 
     <item android:state_pressed="true"
           android:state_enabled="true"
-          android:drawable="@drawable/timepicker_down_pressed_holo_light" />
+          android:drawable="@drawable/numberpicker_down_pressed_holo_light" />
 
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_focused_holo_light" />
+          android:drawable="@drawable/numberpicker_down_focused_holo_light" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_disabled_holo_light" />
+          android:drawable="@drawable/numberpicker_down_disabled_holo_light" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_disabled_focused_holo_light" />
+          android:drawable="@drawable/numberpicker_down_disabled_focused_holo_light" />
 
 </selector>
diff --git a/core/res/res/drawable/timepicker_input.xml b/core/res/res/drawable/numberpicker_input.xml
similarity index 79%
rename from core/res/res/drawable/timepicker_input.xml
rename to core/res/res/drawable/numberpicker_input.xml
index 17686738..e4ebde2 100644
--- a/core/res/res/drawable/timepicker_input.xml
+++ b/core/res/res/drawable/numberpicker_input.xml
@@ -19,25 +19,25 @@
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_input_normal" />
+          android:drawable="@drawable/numberpicker_input_normal" />
 
     <item android:state_pressed="true"
           android:state_enabled="true"
-          android:drawable="@drawable/timepicker_input_pressed" />
+          android:drawable="@drawable/numberpicker_input_pressed" />
 
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_input_selected" />
+          android:drawable="@drawable/numberpicker_input_selected" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_input_disabled" />
+          android:drawable="@drawable/numberpicker_input_disabled" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_input_normal" />
+          android:drawable="@drawable/numberpicker_input_normal" />
 
 </selector>
diff --git a/core/res/res/drawable/timepicker_down_btn.xml b/core/res/res/drawable/numberpicker_up_btn.xml
similarity index 80%
rename from core/res/res/drawable/timepicker_down_btn.xml
rename to core/res/res/drawable/numberpicker_up_btn.xml
index d4908cb..6ea1a33 100644
--- a/core/res/res/drawable/timepicker_down_btn.xml
+++ b/core/res/res/drawable/numberpicker_up_btn.xml
@@ -19,25 +19,25 @@
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_normal" />
+          android:drawable="@drawable/numberpicker_up_normal" />
 
     <item android:state_pressed="true"
           android:state_enabled="true"
-          android:drawable="@drawable/timepicker_down_pressed" />
+          android:drawable="@drawable/numberpicker_up_pressed" />
 
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_selected" />
+          android:drawable="@drawable/numberpicker_up_selected" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_disabled" />
+          android:drawable="@drawable/numberpicker_up_disabled" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_disabled_focused" />
+          android:drawable="@drawable/numberpicker_up_disabled_focused" />
 
 </selector>
diff --git a/core/res/res/drawable/timepicker_down_btn_holo_dark.xml b/core/res/res/drawable/numberpicker_up_btn_holo_dark.xml
similarity index 81%
rename from core/res/res/drawable/timepicker_down_btn_holo_dark.xml
rename to core/res/res/drawable/numberpicker_up_btn_holo_dark.xml
index b4b824d..7af3ee4 100644
--- a/core/res/res/drawable/timepicker_down_btn_holo_dark.xml
+++ b/core/res/res/drawable/numberpicker_up_btn_holo_dark.xml
@@ -19,25 +19,25 @@
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_normal_holo_dark" />
+          android:drawable="@drawable/numberpicker_up_normal_holo_dark" />
 
     <item android:state_pressed="true"
           android:state_enabled="true"
-          android:drawable="@drawable/timepicker_down_pressed_holo_dark" />
+          android:drawable="@drawable/numberpicker_up_pressed_holo_dark" />
 
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_focused_holo_dark" />
+          android:drawable="@drawable/numberpicker_up_focused_holo_dark" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_disabled_holo_dark" />
+          android:drawable="@drawable/numberpicker_up_disabled_holo_dark" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_disabled_focused_holo_dark" />
+          android:drawable="@drawable/numberpicker_up_disabled_focused_holo_dark" />
 
 </selector>
diff --git a/core/res/res/drawable/timepicker_down_btn_holo_light.xml b/core/res/res/drawable/numberpicker_up_btn_holo_light.xml
similarity index 80%
rename from core/res/res/drawable/timepicker_down_btn_holo_light.xml
rename to core/res/res/drawable/numberpicker_up_btn_holo_light.xml
index 7ae5e53..cbcbb07 100644
--- a/core/res/res/drawable/timepicker_down_btn_holo_light.xml
+++ b/core/res/res/drawable/numberpicker_up_btn_holo_light.xml
@@ -19,25 +19,25 @@
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_normal_holo_light" />
+          android:drawable="@drawable/numberpicker_up_normal_holo_light" />
 
     <item android:state_pressed="true"
           android:state_enabled="true"
-          android:drawable="@drawable/timepicker_down_pressed_holo_light" />
+          android:drawable="@drawable/numberpicker_up_pressed_holo_light" />
 
     <item android:state_pressed="false"
           android:state_enabled="true"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_focused_holo_light" />
+          android:drawable="@drawable/numberpicker_up_focused_holo_light" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="false"
-          android:drawable="@drawable/timepicker_down_disabled_holo_light" />
+          android:drawable="@drawable/numberpicker_up_focused_holo_light" />
 
     <item android:state_pressed="false"
           android:state_enabled="false"
           android:state_focused="true"
-          android:drawable="@drawable/timepicker_down_disabled_focused_holo_light" />
+          android:drawable="@drawable/numberpicker_up_disabled_focused_holo_light" />
 
 </selector>
diff --git a/core/res/res/drawable/timepicker_up_btn.xml b/core/res/res/drawable/timepicker_up_btn.xml
deleted file mode 100644
index fbaed08..0000000
--- a/core/res/res/drawable/timepicker_up_btn.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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_pressed="false"
-          android:state_enabled="true"
-          android:state_focused="false"
-          android:drawable="@drawable/timepicker_up_normal" />
-
-    <item android:state_pressed="true"
-          android:state_enabled="true"
-          android:drawable="@drawable/timepicker_up_pressed" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="true"
-          android:state_focused="true"
-          android:drawable="@drawable/timepicker_up_selected" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="false"
-          android:state_focused="false"
-          android:drawable="@drawable/timepicker_up_disabled" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="false"
-          android:state_focused="true"
-          android:drawable="@drawable/timepicker_up_disabled_focused" />
-
-</selector>
diff --git a/core/res/res/drawable/timepicker_up_btn_holo_dark.xml b/core/res/res/drawable/timepicker_up_btn_holo_dark.xml
deleted file mode 100644
index af5f6eb..0000000
--- a/core/res/res/drawable/timepicker_up_btn_holo_dark.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?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_pressed="false"
-          android:state_enabled="true"
-          android:state_focused="false"
-          android:drawable="@drawable/timepicker_up_normal_holo_dark" />
-
-    <item android:state_pressed="true"
-          android:state_enabled="true"
-          android:drawable="@drawable/timepicker_up_pressed_holo_dark" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="true"
-          android:state_focused="true"
-          android:drawable="@drawable/timepicker_up_focused_holo_dark" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="false"
-          android:state_focused="false"
-          android:drawable="@drawable/timepicker_up_disabled_holo_dark" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="false"
-          android:state_focused="true"
-          android:drawable="@drawable/timepicker_up_disabled_focused_holo_dark" />
-
-</selector>
diff --git a/core/res/res/drawable/timepicker_up_btn_holo_light.xml b/core/res/res/drawable/timepicker_up_btn_holo_light.xml
deleted file mode 100644
index 6025d3ad..0000000
--- a/core/res/res/drawable/timepicker_up_btn_holo_light.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?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_pressed="false"
-          android:state_enabled="true"
-          android:state_focused="false"
-          android:drawable="@drawable/timepicker_up_normal_holo_light" />
-
-    <item android:state_pressed="true"
-          android:state_enabled="true"
-          android:drawable="@drawable/timepicker_up_pressed_holo_light" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="true"
-          android:state_focused="true"
-          android:drawable="@drawable/timepicker_up_focused_holo_light" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="false"
-          android:state_focused="false"
-          android:drawable="@drawable/timepicker_up_focused_holo_light" />
-
-    <item android:state_pressed="false"
-          android:state_enabled="false"
-          android:state_focused="true"
-          android:drawable="@drawable/timepicker_up_disabled_focused_holo_light" />
-
-</selector>
diff --git a/core/res/res/layout-xlarge/alert_dialog.xml b/core/res/res/layout-xlarge/alert_dialog.xml
deleted file mode 100644
index 9444206..0000000
--- a/core/res/res/layout-xlarge/alert_dialog.xml
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/common/res/layout/alert_dialog.xml
-**
-** Copyright 2006, 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.
-*/
--->
-
-<com.android.internal.widget.WeightedLinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/parentPanel"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    android:paddingTop="9dip"
-    android:paddingBottom="3dip"
-    android:paddingLeft="3dip"
-    android:paddingRight="1dip"
-    android:majorWeightMin="0.45"
-    android:minorWeightMin="0.72">
-
-    <LinearLayout android:id="@+id/topPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="54dip"
-        android:orientation="vertical">
-        <LinearLayout android:id="@+id/title_template"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:gravity="center_vertical"
-            android:layout_marginTop="6dip"
-            android:layout_marginBottom="9dip"
-            android:layout_marginLeft="10dip"
-            android:layout_marginRight="10dip">
-            <ImageView android:id="@+id/icon"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="top"
-                android:paddingTop="6dip"
-                android:paddingRight="10dip"
-                android:src="@drawable/ic_dialog_info" />
-            <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
-                style="?android:attr/textAppearanceLarge"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
-        </LinearLayout>
-        <ImageView android:id="@+id/titleDivider"
-            android:layout_width="match_parent"
-            android:layout_height="1dip"
-            android:visibility="gone"
-            android:scaleType="fitXY"
-            android:gravity="fill_horizontal"
-            android:src="@android:drawable/divider_horizontal_dark" />
-        <!-- If the client uses a customTitle, it will be added here. -->
-    </LinearLayout>
-
-    <LinearLayout android:id="@+id/contentPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical">
-        <ScrollView android:id="@+id/scrollView"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingTop="2dip"
-            android:paddingBottom="12dip"
-            android:paddingLeft="14dip"
-            android:paddingRight="10dip">
-            <TextView android:id="@+id/message"
-                style="?android:attr/textAppearanceMedium"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:padding="5dip" />
-        </ScrollView>
-    </LinearLayout>
-
-    <FrameLayout android:id="@+id/customPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_weight="1">
-        <FrameLayout android:id="@+android:id/custom"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingTop="5dip"
-            android:paddingBottom="5dip" />
-    </FrameLayout>
-
-    <LinearLayout android:id="@+id/buttonPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="54dip"
-        android:orientation="vertical" >
-        <LinearLayout
-            style="?android:attr/buttonBarStyle"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:paddingTop="4dip"
-            android:paddingLeft="2dip"
-            android:paddingRight="2dip"
-            android:measureWithLargestChild="true">
-            <LinearLayout android:id="@+id/leftSpacer"
-                android:layout_weight="0.25"
-                android:layout_width="0dip"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:visibility="gone" />
-            <Button android:id="@+id/button1"
-                android:layout_width="0dip"
-                android:layout_gravity="left"
-                android:layout_weight="1"
-                style="?android:attr/buttonBarButtonStyle"
-                android:maxLines="2"
-                android:layout_height="wrap_content" />
-            <Button android:id="@+id/button3"
-                android:layout_width="0dip"
-                android:layout_gravity="center_horizontal"
-                android:layout_weight="1"
-                style="?android:attr/buttonBarButtonStyle"
-                android:maxLines="2"
-                android:layout_height="wrap_content" />
-            <Button android:id="@+id/button2"
-                android:layout_width="0dip"
-                android:layout_gravity="right"
-                android:layout_weight="1"
-                style="?android:attr/buttonBarButtonStyle"
-                android:maxLines="2"
-                android:layout_height="wrap_content" />
-            <LinearLayout android:id="@+id/rightSpacer"
-                android:layout_width="0dip"
-                android:layout_weight="0.25"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:visibility="gone" />
-        </LinearLayout>
-     </LinearLayout>
-</com.android.internal.widget.WeightedLinearLayout>
diff --git a/core/res/res/layout-xlarge/alert_dialog_holo.xml b/core/res/res/layout-xlarge/alert_dialog_holo.xml
deleted file mode 100644
index 2ae8db7..0000000
--- a/core/res/res/layout-xlarge/alert_dialog_holo.xml
+++ /dev/null
@@ -1,157 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 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.
-*/
--->
-
-<com.android.internal.widget.WeightedLinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/parentPanel"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    android:paddingTop="9dip"
-    android:paddingBottom="3dip"
-    android:paddingLeft="3dip"
-    android:paddingRight="1dip"
-    android:majorWeightMin="0.45"
-    android:minorWeightMin="0.72">
-
-    <LinearLayout android:id="@+id/topPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="64dip"
-        android:orientation="vertical">
-        <LinearLayout android:id="@+id/title_template"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:gravity="center_vertical"
-            android:layout_marginTop="8dip"
-            android:layout_marginBottom="8dip"
-            android:layout_marginLeft="32dip"
-            android:layout_marginRight="32dip">
-            <ImageView android:id="@+id/icon"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:paddingRight="16dip"
-                android:src="@null" />
-            <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
-                style="?android:attr/textAppearanceMedium"
-                android:singleLine="true"
-                android:ellipsize="end"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
-        </LinearLayout>
-        <ImageView android:id="@+id/titleDivider"
-            android:layout_width="match_parent"
-            android:layout_height="4dip"
-            android:visibility="gone"
-            android:scaleType="fitXY"
-            android:gravity="fill_horizontal"
-            android:paddingLeft="16dip"
-            android:paddingRight="16dip"
-            android:src="@android:drawable/divider_strong_holo" />
-        <!-- If the client uses a customTitle, it will be added here. -->
-    </LinearLayout>
-
-    <LinearLayout android:id="@+id/contentPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical">
-        <ScrollView android:id="@+id/scrollView"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginLeft="16dip"
-            android:layout_marginRight="16dip"
-            android:paddingTop="32dip"
-            android:paddingBottom="32dip"
-            android:clipToPadding="false">
-            <TextView android:id="@+id/message"
-                style="?android:attr/textAppearanceMedium"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:paddingLeft="16dip"
-                android:paddingRight="16dip" />
-        </ScrollView>
-    </LinearLayout>
-
-    <FrameLayout android:id="@+id/customPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_weight="1">
-        <FrameLayout android:id="@+android:id/custom"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingTop="8dip"
-            android:paddingBottom="8dip"
-            android:paddingLeft="32dip"
-            android:paddingRight="32dip" />
-    </FrameLayout>
-
-    <LinearLayout android:id="@+id/buttonPanel"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="54dip"
-        android:orientation="vertical"
-        android:divider="?android:attr/dividerHorizontal"
-        android:showDividers="beginning"
-        android:dividerPadding="16dip">
-        <LinearLayout
-            style="?android:attr/buttonBarStyle"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:paddingLeft="2dip"
-            android:paddingRight="2dip"
-            android:measureWithLargestChild="true">
-            <LinearLayout android:id="@+id/leftSpacer"
-                android:layout_weight="0.25"
-                android:layout_width="0dip"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:visibility="gone" />
-            <Button android:id="@+id/button1"
-                android:layout_width="0dip"
-                android:layout_gravity="left"
-                android:layout_weight="1"
-                android:maxLines="2"
-                style="?android:attr/buttonBarButtonStyle"
-                android:layout_height="wrap_content" />
-            <Button android:id="@+id/button3"
-                android:layout_width="0dip"
-                android:layout_gravity="center_horizontal"
-                android:layout_weight="1"
-                android:maxLines="2"
-                style="?android:attr/buttonBarButtonStyle"
-                android:layout_height="wrap_content" />
-            <Button android:id="@+id/button2"
-                android:layout_width="0dip"
-                android:layout_gravity="right"
-                android:layout_weight="1"
-                android:maxLines="2"
-                style="?android:attr/buttonBarButtonStyle"
-                android:layout_height="wrap_content" />
-            <LinearLayout android:id="@+id/rightSpacer"
-                android:layout_width="0dip"
-                android:layout_weight="0.25"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:visibility="gone" />
-        </LinearLayout>
-     </LinearLayout>
-</com.android.internal.widget.WeightedLinearLayout>
diff --git a/core/res/res/layout-xlarge/keyguard_screen_lock.xml b/core/res/res/layout-xlarge/keyguard_screen_lock.xml
index 733a350..c7aa654 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_lock.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_lock.xml
@@ -16,7 +16,7 @@
 ** limitations under the License.
 */
 -->
-        
+
 <!-- This is the general lock screen which shows information about the
   state of the device, as well as instructions on how to get past it
   depending on the state of the device.  It is the same for landscape
@@ -25,9 +25,7 @@
     android:orientation="vertical"
     android:gravity="bottom"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="#ff800000"
-        >
+    android:layout_height="match_parent">
 
     <LinearLayout
         android:orientation="vertical"
diff --git a/core/res/res/layout-xlarge/keyguard_screen_tab_unlock.xml b/core/res/res/layout-xlarge/keyguard_screen_tab_unlock.xml
index 1c7b7e2..c9c1692 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_tab_unlock.xml
@@ -26,8 +26,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:id="@+id/root"
-    android:background="#70000000">
+    android:id="@+id/root">
 
     <!-- top: status -->
     <RelativeLayout
diff --git a/core/res/res/layout-xlarge/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout-xlarge/keyguard_screen_tab_unlock_land.xml
index c24eecc..fbb9983 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_tab_unlock_land.xml
@@ -25,7 +25,6 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="horizontal"
-    android:background="#70000000"
     android:id="@+id/root">
 
     <!-- left side: status -->
diff --git a/core/res/res/layout-xlarge/keyguard_screen_unlock_landscape.xml b/core/res/res/layout-xlarge/keyguard_screen_unlock_landscape.xml
index ec7c272..8acb656 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_unlock_landscape.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_unlock_landscape.xml
@@ -25,8 +25,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="horizontal"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="#70000000">
+    android:layout_height="match_parent">
 
     <!-- left side: status  -->
     <RelativeLayout
diff --git a/core/res/res/layout-xlarge/keyguard_screen_unlock_portrait.xml b/core/res/res/layout-xlarge/keyguard_screen_unlock_portrait.xml
index 84ddd6a..f35897e 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_unlock_portrait.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_unlock_portrait.xml
@@ -21,9 +21,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="#70000000"
-        >
+    android:layout_height="match_parent">
 
     <!-- top: status -->
     <LinearLayout
diff --git a/core/res/res/layout/alert_dialog.xml b/core/res/res/layout/alert_dialog.xml
index a1498f7..4477e07 100644
--- a/core/res/res/layout/alert_dialog.xml
+++ b/core/res/res/layout/alert_dialog.xml
@@ -18,7 +18,7 @@
 */
 -->
 
-<com.android.internal.widget.WeightedLinearLayout
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/parentPanel"
     android:layout_width="match_parent"
@@ -27,9 +27,7 @@
     android:paddingTop="9dip"
     android:paddingBottom="3dip"
     android:paddingLeft="3dip"
-    android:paddingRight="1dip"
-    android:majorWeightMin="0.65"
-    android:minorWeightMin="0.9">
+    android:paddingRight="1dip">
 
     <LinearLayout android:id="@+id/topPanel"
         android:layout_width="match_parent"
@@ -150,4 +148,4 @@
                 android:visibility="gone" />
         </LinearLayout>
      </LinearLayout>
-</com.android.internal.widget.WeightedLinearLayout>
+</LinearLayout>
diff --git a/core/res/res/layout/alert_dialog_holo.xml b/core/res/res/layout/alert_dialog_holo.xml
index 07a2853..1002c4b 100644
--- a/core/res/res/layout/alert_dialog_holo.xml
+++ b/core/res/res/layout/alert_dialog_holo.xml
@@ -17,24 +17,27 @@
 */
 -->
 
-<com.android.internal.widget.WeightedLinearLayout
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/parentPanel"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:orientation="vertical"
-    android:paddingTop="9dip"
-    android:paddingBottom="3dip"
-    android:paddingLeft="3dip"
-    android:paddingRight="1dip"
-    android:majorWeightMin="0.65"
-    android:minorWeightMin="0.9">
+    android:orientation="vertical">
 
     <LinearLayout android:id="@+id/topPanel"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:minHeight="64dip"
         android:orientation="vertical">
+        <ImageView android:id="@+id/titleDividerTop"
+            android:layout_width="match_parent"
+            android:layout_height="4dip"
+            android:visibility="gone"
+            android:scaleType="fitXY"
+            android:gravity="fill_horizontal"
+            android:paddingLeft="16dip"
+            android:paddingRight="16dip"
+            android:src="@android:drawable/divider_strong_holo" />
         <LinearLayout android:id="@+id/title_template"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
@@ -154,4 +157,4 @@
                 android:visibility="gone" />
         </LinearLayout>
      </LinearLayout>
-</com.android.internal.widget.WeightedLinearLayout>
+</LinearLayout>
diff --git a/core/res/res/layout/alert_dialog_progress.xml b/core/res/res/layout/alert_dialog_progress.xml
index c519692..ac95cdb 100644
--- a/core/res/res/layout/alert_dialog_progress.xml
+++ b/core/res/res/layout/alert_dialog_progress.xml
@@ -40,9 +40,9 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingBottom="12dip"
-            android:layout_marginLeft="50dip"
-            android:layout_marginRight="15dip"
-            android:layout_alignParentLeft="true"
+            android:layout_marginLeft="10dip"
+            android:layout_marginRight="10dip"
+            android:layout_alignParentRight="true"
             android:layout_below="@id/progress"
         />
 </RelativeLayout>
diff --git a/core/res/res/layout/dialog_custom_title_holo.xml b/core/res/res/layout/dialog_custom_title_holo.xml
new file mode 100644
index 0000000..854873f
--- /dev/null
+++ b/core/res/res/layout/dialog_custom_title_holo.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!--
+This is an custom layout for a dialog.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:fitsSystemWindows="true">
+    <FrameLayout android:id="@android:id/title_container"
+        android:layout_width="match_parent"
+        android:layout_height="24dip"
+        android:layout_weight="0"
+        style="?android:attr/windowTitleBackgroundStyle">
+    </FrameLayout>
+    <FrameLayout
+        android:layout_width="match_parent" android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:foreground="?android:attr/windowContentOverlay">
+        <FrameLayout android:id="@android:id/content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:paddingTop="6dip"
+            android:paddingBottom="10dip"
+            android:paddingLeft="10dip"
+            android:paddingRight="10dip" />
+    </FrameLayout>
+</LinearLayout>
diff --git a/core/res/res/layout/dialog_title_holo.xml b/core/res/res/layout/dialog_title_holo.xml
new file mode 100644
index 0000000..534dd8d
--- /dev/null
+++ b/core/res/res/layout/dialog_title_holo.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2011, 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.
+*/
+
+This is an optimized layout for a screen, with the minimum set of features
+enabled.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:fitsSystemWindows="true">
+    <TextView android:id="@android:id/title" style="?android:attr/windowTitleStyle"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:minHeight="60dip"
+        android:paddingLeft="32dip"
+        android:paddingRight="32dip"
+        android:gravity="center_vertical|left" />
+    <ImageView android:id="@+id/titleDivider"
+            android:layout_width="match_parent"
+            android:layout_height="4dip"
+            android:scaleType="fitXY"
+            android:gravity="fill_horizontal"
+            android:paddingLeft="16dip"
+            android:paddingRight="16dip"
+            android:src="@android:drawable/divider_strong_holo" />
+    <FrameLayout
+        android:layout_width="match_parent" android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:foreground="?android:attr/windowContentOverlay">
+        <FrameLayout android:id="@android:id/content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+    </FrameLayout>
+</LinearLayout>
diff --git a/core/res/res/layout/dialog_title_icons_holo.xml b/core/res/res/layout/dialog_title_icons_holo.xml
new file mode 100644
index 0000000..a3cd3af
--- /dev/null
+++ b/core/res/res/layout/dialog_title_icons_holo.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!--
+This is an optimized layout for a screen, with the minimum set of features
+enabled.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:fitsSystemWindows="true">
+
+    <LinearLayout android:id="@+id/title_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:gravity="center_vertical"
+        android:minHeight="60dip"
+        android:paddingLeft="32dip"
+        android:paddingRight="32dip">
+        <ImageView android:id="@+id/left_icon"
+            android:layout_width="32dip"
+            android:layout_height="32dip"
+            android:scaleType="fitCenter"
+            android:layout_marginRight="8dip" />
+        <TextView android:id="@android:id/title"
+		style="?android:attr/windowTitleStyle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="0" />
+        <ImageView android:id="@+id/right_icon"
+            android:layout_width="32dip"
+            android:layout_height="32dip"
+            android:scaleType="fitCenter"
+            android:layout_marginLeft="8dip" />
+    </LinearLayout>
+
+    <ImageView android:id="@+id/titleDivider"
+            android:layout_width="match_parent"
+            android:layout_height="4dip"
+            android:scaleType="fitXY"
+            android:gravity="fill_horizontal"
+            android:paddingLeft="16dip"
+            android:paddingRight="16dip"
+            android:src="@android:drawable/divider_strong_holo" />
+
+    <FrameLayout
+        android:layout_width="match_parent" android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:orientation="vertical"
+        android:foreground="?android:attr/windowContentOverlay">
+        <FrameLayout android:id="@android:id/content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+    </FrameLayout>
+</LinearLayout>
diff --git a/core/res/res/layout/keyguard_screen_password_landscape.xml b/core/res/res/layout/keyguard_screen_password_landscape.xml
index 3d52f71..4d8c688 100644
--- a/core/res/res/layout/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_password_landscape.xml
@@ -20,7 +20,6 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:background="#70000000"
     android:gravity="center_horizontal">
 
     <LinearLayout
diff --git a/core/res/res/layout/keyguard_screen_password_portrait.xml b/core/res/res/layout/keyguard_screen_password_portrait.xml
index af8a3ef..93966de 100644
--- a/core/res/res/layout/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_password_portrait.xml
@@ -20,7 +20,6 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:background="#70000000"
     android:gravity="center_horizontal">
 
     <!-- "Enter PIN(Password) to unlock" -->
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock.xml b/core/res/res/layout/keyguard_screen_tab_unlock.xml
index 8367157..5fe38d5 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock.xml
@@ -25,7 +25,6 @@
     xmlns:tabunlock="http://schemas.android.com/apk/res/com.android.tabunlock"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="#70000000"
     android:gravity="center_horizontal"
     android:id="@+id/root">
 
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
index 9547660..3c2ad9a 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
@@ -25,7 +25,6 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="horizontal"
-    android:background="#70000000"
     android:id="@+id/root">
 
     <!-- left side -->
diff --git a/core/res/res/layout/keyguard_screen_unlock_landscape.xml b/core/res/res/layout/keyguard_screen_unlock_landscape.xml
index 759c906..c7b78c4 100644
--- a/core/res/res/layout/keyguard_screen_unlock_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_landscape.xml
@@ -25,9 +25,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="horizontal"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="#70000000"
-        >
+    android:layout_height="match_parent">
 
     <!-- left side: instructions and emergency call button -->
     <LinearLayout
diff --git a/core/res/res/layout/keyguard_screen_unlock_portrait.xml b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
index c438412..15f2afb 100644
--- a/core/res/res/layout/keyguard_screen_unlock_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
@@ -25,9 +25,7 @@
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:gravity="center_horizontal"
-    android:background="#70000000"
-    >
+    android:gravity="center_horizontal">
 
     <RelativeLayout
         android:layout_width="match_parent"
diff --git a/core/res/res/layout/number_picker.xml b/core/res/res/layout/number_picker.xml
index 44c99cf..f92c1bc 100644
--- a/core/res/res/layout/number_picker.xml
+++ b/core/res/res/layout/number_picker.xml
@@ -24,7 +24,7 @@
         android:layout_height="wrap_content"
         style="?android:attr/numberPickerUpButtonStyle" />
 
-    <EditText android:id="@+id/timepicker_input"
+    <EditText android:id="@+id/numberpicker_input"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         style="?android:attr/numberPickerInputTextStyle" />
diff --git a/core/res/res/mipmap-hdpi/sym_app_on_sd_unavailable_icon.png b/core/res/res/mipmap-hdpi/sym_app_on_sd_unavailable_icon.png
new file mode 100644
index 0000000..d915d41
--- /dev/null
+++ b/core/res/res/mipmap-hdpi/sym_app_on_sd_unavailable_icon.png
Binary files differ
diff --git a/core/res/res/mipmap-hdpi/sym_def_app_icon.png b/core/res/res/mipmap-hdpi/sym_def_app_icon.png
new file mode 100644
index 0000000..075d908
--- /dev/null
+++ b/core/res/res/mipmap-hdpi/sym_def_app_icon.png
Binary files differ
diff --git a/core/res/res/mipmap-ldpi/sym_app_on_sd_unavailable_icon.png b/core/res/res/mipmap-ldpi/sym_app_on_sd_unavailable_icon.png
new file mode 100644
index 0000000..d88250a
--- /dev/null
+++ b/core/res/res/mipmap-ldpi/sym_app_on_sd_unavailable_icon.png
Binary files differ
diff --git a/core/res/res/mipmap-ldpi/sym_def_app_icon.png b/core/res/res/mipmap-ldpi/sym_def_app_icon.png
new file mode 100644
index 0000000..2c205c8
--- /dev/null
+++ b/core/res/res/mipmap-ldpi/sym_def_app_icon.png
Binary files differ
diff --git a/core/res/res/mipmap-mdpi/sym_app_on_sd_unavailable_icon.png b/core/res/res/mipmap-mdpi/sym_app_on_sd_unavailable_icon.png
new file mode 100644
index 0000000..47306683f
--- /dev/null
+++ b/core/res/res/mipmap-mdpi/sym_app_on_sd_unavailable_icon.png
Binary files differ
diff --git a/core/res/res/mipmap-mdpi/sym_def_app_icon.png b/core/res/res/mipmap-mdpi/sym_def_app_icon.png
new file mode 100644
index 0000000..9777d11
--- /dev/null
+++ b/core/res/res/mipmap-mdpi/sym_def_app_icon.png
Binary files differ
diff --git a/core/res/res/values-es-rUS-xlarge/strings.xml b/core/res/res/values-es-rUS-xlarge/strings.xml
index cef8d12..4743ac5 100644
--- a/core/res/res/values-es-rUS-xlarge/strings.xml
+++ b/core/res/res/values-es-rUS-xlarge/strings.xml
@@ -301,6 +301,8 @@
     <!-- XL -->
     <string name="websearch" msgid="904596193450917688">"Búsqueda web"</string>
     <!-- XL -->
+    <string name="status_bar_notification_info_overflow" msgid="1081154808901480710">"100+"</string>
+    <!-- XL -->
     <string name="permlab_mediaStorageWrite" product="default" msgid="5585262071354704256">"modificar/eliminar los contenidos del almacenamientos de medios internos"</string>
     <!-- XL -->
     <string name="permdesc_mediaStorageWrite" product="default" msgid="2372999661142345443">"Permite que una aplicación modifique los contenidos del almacenamiento interno de medios."</string>
diff --git a/core/res/res/anim/animator_fade_in.xml b/core/res/res/values-large/dimens.xml
similarity index 64%
rename from core/res/res/anim/animator_fade_in.xml
rename to core/res/res/values-large/dimens.xml
index cff98cf..5691548 100644
--- a/core/res/res/anim/animator_fade_in.xml
+++ b/core/res/res/values-large/dimens.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
 /*
-** Copyright 2010, The Android Open Source Project
+** Copyright 2011, 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.
@@ -16,11 +16,7 @@
 ** limitations under the License.
 */
 -->
-
-<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@interpolator/accelerate_quad"
-    android:valueFrom="0"
-    android:valueTo="1"
-    android:propertyName="alpha"
-    android:duration="@android:integer/config_mediumAnimTime"
-/>
+<resources>
+    <item type="dimen" name="dialog_min_width_major">55%</item>
+    <item type="dimen" name="dialog_min_width_minor">80%</item>
+</resources>
diff --git a/core/res/res/values-large/themes.xml b/core/res/res/values-large/themes.xml
index f5c35f6..9e3e0bb 100644
--- a/core/res/res/values-large/themes.xml
+++ b/core/res/res/values-large/themes.xml
@@ -18,17 +18,17 @@
 -->
 <resources>
     <style name="Theme.Holo.DialogWhenLarge"
-            parent="@android:style/Theme.Holo.Dialog">
+            parent="@android:style/Theme.Holo.Dialog.MinWidth">
         <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
     </style>
     <style name="Theme.Holo.DialogWhenLarge.NoActionBar"
-            parent="@android:style/Theme.Holo.Dialog.NoActionBar">
+            parent="@android:style/Theme.Holo.Dialog.NoActionBar.MinWidth">
         <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
     </style>
     <style name="Theme.Holo.Light.DialogWhenLarge"
-            parent="@android:style/Theme.Holo.Light.Dialog">
+            parent="@android:style/Theme.Holo.Light.Dialog.MinWidth">
     </style>
     <style name="Theme.Holo.Light.DialogWhenLarge.NoActionBar"
-            parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar">
+            parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar.MinWidth">
     </style>
 </resources>
diff --git a/core/res/res/values-xlarge/dimens.xml b/core/res/res/values-xlarge/dimens.xml
index 18090ba..5b0ea30 100644
--- a/core/res/res/values-xlarge/dimens.xml
+++ b/core/res/res/values-xlarge/dimens.xml
@@ -43,4 +43,7 @@
     <dimen name="app_icon_size">64dip</dimen>
     <!-- Minimum width of the search view text entry area. -->
     <dimen name="search_view_text_min_width">192dip</dimen>
+
+    <item type="dimen" name="dialog_min_width_major">45%</item>
+    <item type="dimen" name="dialog_min_width_minor">72%</item>
 </resources>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 08dacf8..3a3ca36 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -634,6 +634,12 @@
 
         <!-- Theme to use for dialogs spawned from this theme. -->
         <attr name="dialogTheme" format="reference" />
+        <!-- Window decor layout to use in dialog mode with icons -->
+        <attr name="dialogTitleIconsDecorLayout" format="reference" />
+        <!-- Window decor layout to use in dialog mode with custom titles -->
+        <attr name="dialogCustomTitleDecorLayout" format="reference" />
+        <!-- Window decor layout to use in dialog mode with title only -->
+        <attr name="dialogTitleDecorLayout" format="reference" />
         <!-- Theme to use for alert dialogs spawned from this theme. -->
         <attr name="alertDialogTheme" format="reference" />
         <!-- Icon drawable to use for alerts -->
@@ -1333,6 +1339,16 @@
         <attr name="windowActionModeOverlay" />
         <attr name="windowActionBarOverlay" />
         <attr name="windowEnableSplitTouch" />
+        <!-- The minimum width the window is allowed to be, along the major
+             axis of the screen.  That is, when in landscape.  Can be either
+             an absolute dimension or a fraction of the screen size in that
+             dimension. -->
+        <attr name="windowMinWidthMajor" format="dimension|fraction" />
+        <!-- The minimum width the window is allowed to be, along the minor
+             axis of the screen.  That is, when in portrait.  Can be either
+             an absolute dimension or a fraction of the screen size in that
+             dimension. -->
+        <attr name="windowMinWidthMinor" format="dimension|fraction" />
     </declare-styleable>
 
     <!-- The set of attributes that describe a AlertDialog's theme. -->
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 2e87883..1a6f404 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -91,7 +91,7 @@
     <color name="search_url_text_selected">@android:color/black</color>
     <color name="search_url_text_pressed">@android:color/black</color>
     <color name="search_widget_corpus_item_background">@android:color/lighter_gray</color>
-    
+
     <!-- SlidingTab -->
     <color name="sliding_tab_text_color_active">@android:color/black</color>
     <color name="sliding_tab_text_color_shadow">@android:color/black</color>
@@ -105,7 +105,7 @@
 
     <!-- keyguard clock -->
     <color name="lockscreen_clock_background">#b3ffffff</color>
-    <color name="lockscreen_clock_foreground">#40000000</color>
+    <color name="lockscreen_clock_foreground">#7affffff</color>
     <color name="lockscreen_clock_am_pm">#ff9a9a9a</color>
     <color name="lockscreen_owner_info">#ff9a9a9a</color>
 
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 53d4e42..e5b6563 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -58,4 +58,14 @@
     <dimen name="preference_screen_side_margin_negative">0dp</dimen>
     <!-- Preference widget area width (to the left of the text) -->
     <dimen name="preference_widget_width">56dp</dimen>
+
+    <!-- The platform's desired minimum size for a dialog's width when it
+         is along the major axis (that is the screen is landscape).  This may
+         be either a fraction or a dimension. -->
+    <item type="dimen" name="dialog_min_width_major">65%</item>
+
+    <!-- The platform's desired minimum size for a dialog's width when it
+         is along the minor axis (that is the screen is portrait).  This may
+         be either a fraction or a dimension. -->
+    <item type="dimen" name="dialog_min_width_minor">95%</item>
 </resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index c2a848d..6d79569 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1422,6 +1422,8 @@
   <public type="attr" name="horizontalScrollViewStyle" />
   <public type="attr" name="layerType" />
   <public type="attr" name="alertDialogIcon" />
+  <public type="attr" name="windowMinWidthMajor" />
+  <public type="attr" name="windowMinWidthMinor" />
 
   <!-- A simple fade-in animation. -->
   <public type="animator" name="fade_in" id="0x010b0000" />
@@ -1458,24 +1460,15 @@
        sinusoidal pattern. -->
   <public type="interpolator" name="cycle" />
 
-  <public type="anim" name="animator_fade_in" />
-  <public type="anim" name="animator_fade_out" />
-
-  <!-- Acceleration curve matching a cubic ease in function. -->
-  <public type="anim" name="accelerate_cubic_interpolator" />
-  <!-- Acceleration curve matching a cubic ease out function. -->
-  <public type="anim" name="decelerate_cubic_interpolator" />
-  <!-- Acceleration curve matching a quint ease in function. -->
-  <public type="anim" name="accelerate_quint_interpolator" />
-  <!-- Acceleration curve matching a quint ease out function. -->
-  <public type="anim" name="decelerate_quint_interpolator" />
-
   <public type="id" name="home" />
   <!-- Context menu ID for the "Select text..." menu item to switch to text
        selection context mode in text views. -->
   <public type="id" name="selectTextMode" />
   <public type="id" name="up" />
 
+  <public type="dimen" name="dialog_min_width_major" />
+  <public type="dimen" name="dialog_min_width_minor" />
+
   <!-- Standard content view for a {@link android.app.ListFragment}.
        If you are implementing a subclass of ListFragment with your
        own customized content, you can include this layout in that
@@ -1497,7 +1490,6 @@
   <public type="layout" name="simple_list_item_activated_2" />
 
   <public type="style" name="Theme.WithActionBar" />
-  <public type="style" name="Theme.Dialog.NoFrame" />
   <public type="style" name="Theme.NoTitleBar.OverlayActionModes" />
 
   <public type="style" name="Theme.Holo" />
@@ -1506,15 +1498,19 @@
   <public type="style" name="Theme.Holo.NoActionBar.Fullscreen" />
   <public type="style" name="Theme.Holo.Light" />
   <public type="style" name="Theme.Holo.Dialog" />
+  <public type="style" name="Theme.Holo.Dialog.MinWidth" />
   <public type="style" name="Theme.Holo.Dialog.NoActionBar" />
+  <public type="style" name="Theme.Holo.Dialog.NoActionBar.MinWidth" />
   <public type="style" name="Theme.Holo.Light.Dialog" />
+  <public type="style" name="Theme.Holo.Light.Dialog.MinWidth" />
   <public type="style" name="Theme.Holo.Light.Dialog.NoActionBar" />
-  <public type="style" name="Theme.Holo.Dialog.Alert" />
-  <public type="style" name="Theme.Holo.Light.Dialog.Alert" />
+  <public type="style" name="Theme.Holo.Light.Dialog.NoActionBar.MinWidth" />
   <public type="style" name="Theme.Holo.DialogWhenLarge" />
   <public type="style" name="Theme.Holo.DialogWhenLarge.NoActionBar" />
   <public type="style" name="Theme.Holo.Light.DialogWhenLarge" />
   <public type="style" name="Theme.Holo.Light.DialogWhenLarge.NoActionBar" />
+  <public type="style" name="Theme.Holo.Panel" />
+  <public type="style" name="Theme.Holo.Light.Panel" />
   <public type="style" name="Theme.Holo.Wallpaper" />
   <public type="style" name="Theme.Holo.Wallpaper.NoTitleBar" />
 
@@ -1638,6 +1634,9 @@
   <public type="style" name="Widget.CalendarView" />
   <public type="style" name="Widget.Holo.CalendarView" />
   <public type="style" name="Widget.Holo.Light.CalendarView" />
+
   <public type="string" name="selectTextMode" />
 
+  <!-- Default icon for applications that don't specify an icon. -->
+  <public type="mipmap" name="sym_def_app_icon" id="0x010d0000" />
 </resources>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 711dd32..f52be0d 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -81,14 +81,14 @@
         <item name="wallpaperIntraOpenExitAnimation">@anim/wallpaper_intra_open_exit</item>
         <item name="wallpaperIntraCloseEnterAnimation">@anim/wallpaper_intra_close_enter</item>
         <item name="wallpaperIntraCloseExitAnimation">@anim/wallpaper_intra_close_exit</item>
-        <item name="fragmentOpenEnterAnimation">@anim/fragment_open_enter</item>
-        <item name="fragmentOpenExitAnimation">@anim/fragment_open_exit</item>
-        <item name="fragmentCloseEnterAnimation">@anim/fragment_close_enter</item>
-        <item name="fragmentCloseExitAnimation">@anim/fragment_close_exit</item>
-        <item name="fragmentNextEnterAnimation">@anim/fragment_next_enter</item>
-        <item name="fragmentNextExitAnimation">@anim/fragment_next_exit</item>
-        <item name="fragmentPrevEnterAnimation">@anim/fragment_prev_enter</item>
-        <item name="fragmentPrevExitAnimation">@anim/fragment_prev_exit</item>
+        <item name="fragmentOpenEnterAnimation">@animator/fragment_open_enter</item>
+        <item name="fragmentOpenExitAnimation">@animator/fragment_open_exit</item>
+        <item name="fragmentCloseEnterAnimation">@animator/fragment_close_enter</item>
+        <item name="fragmentCloseExitAnimation">@animator/fragment_close_exit</item>
+        <item name="fragmentNextEnterAnimation">@animator/fragment_next_enter</item>
+        <item name="fragmentNextExitAnimation">@animator/fragment_next_exit</item>
+        <item name="fragmentPrevEnterAnimation">@animator/fragment_prev_enter</item>
+        <item name="fragmentPrevExitAnimation">@animator/fragment_prev_exit</item>
     </style>
 
     <!-- Standard animations for a non-full-screen window or activity. -->
@@ -495,18 +495,18 @@
     </style>
 
     <style name="Widget.ImageButton.NumberPickerUpButton">
-        <item name="android:background">@android:drawable/timepicker_up_btn</item>
+        <item name="android:background">@android:drawable/numberpicker_up_btn</item>
     </style>
 
     <style name="Widget.ImageButton.NumberPickerDownButton">
-        <item name="android:background">@android:drawable/timepicker_down_btn</item>
+        <item name="android:background">@android:drawable/numberpicker_down_btn</item>
     </style>
 
     <style name="Widget.EditText.NumberPickerInputText">
         <item name="android:textAppearance">@style/TextAppearance.Large.Inverse.NumberPickerInputText</item>
         <item name="android:gravity">center</item>
         <item name="android:singleLine">true</item>
-        <item name="android:background">@drawable/timepicker_input</item>
+        <item name="android:background">@drawable/numberpicker_input</item>
     </style>
 
     <style name="Widget.AutoCompleteTextView" parent="Widget.EditText">
@@ -1464,14 +1464,14 @@
 
     <style name="Widget.Holo.ImageButton.NumberPickerUpButton">
         <item name="android:background">@null</item>
-        <item name="android:src">@android:drawable/timepicker_up_btn_holo_dark</item>
+        <item name="android:src">@android:drawable/numberpicker_up_btn_holo_dark</item>
         <item name="android:paddingTop">26dip</item>
         <item name="android:paddingBottom">26dip</item>
     </style>
 
     <style name="Widget.Holo.ImageButton.NumberPickerDownButton">
         <item name="android:background">@null</item>
-        <item name="android:src">@android:drawable/timepicker_down_btn_holo_dark</item>
+        <item name="android:src">@android:drawable/numberpicker_down_btn_holo_dark</item>
         <item name="android:paddingTop">26dip</item>
         <item name="android:paddingBottom">26dip</item>
     </style>
@@ -1512,8 +1512,8 @@
     <style name="Widget.Holo.ProgressBar.Horizontal" parent="Widget.ProgressBar.Horizontal">
         <item name="android:progressDrawable">@android:drawable/progress_horizontal_holo_dark</item>
         <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal_holo</item>
-        <item name="android:minHeight">24dip</item>
-        <item name="android:maxHeight">24dip</item>
+        <item name="android:minHeight">16dip</item>
+        <item name="android:maxHeight">16dip</item>
     </style>
 
     <style name="Widget.Holo.ProgressBar.Small" parent="Widget.ProgressBar.Small">
@@ -1728,7 +1728,7 @@
 
     <style name="Widget.Holo.Light.Button" parent="Widget.Button">
         <item name="android:background">@android:drawable/btn_default_holo_light</item>
-        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+        <item name="android:textAppearance">?android:attr/textAppearanceMediumInverse</item>
         <item name="android:textColor">@android:color/primary_text_holo_light</item>
         <item name="android:minHeight">48dip</item>
         <item name="android:paddingLeft">32dip</item>
@@ -1833,11 +1833,11 @@
     </style>
 
     <style name="Widget.Holo.Light.ImageButton.NumberPickerUpButton" parent="Widget.Holo.ImageButton.NumberPickerUpButton">
-        <item name="android:src">@android:drawable/timepicker_up_btn_holo_light</item>
+        <item name="android:src">@android:drawable/numberpicker_up_btn_holo_light</item>
     </style>
 
     <style name="Widget.Holo.Light.ImageButton.NumberPickerDownButton" parent="Widget.Holo.ImageButton.NumberPickerDownButton">
-        <item name="android:src">@android:drawable/timepicker_down_btn_holo_light</item>
+        <item name="android:src">@android:drawable/numberpicker_down_btn_holo_light</item>
     </style>
 
     <style name="Widget.Holo.Light.EditText.NumberPickerInputText" parent="Widget.Holo.EditText.NumberPickerInputText">
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index e20e08f..d070c30 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -142,6 +142,9 @@
         <!-- Dialog attributes -->
         <item name="alertDialogStyle">@android:style/AlertDialog</item>
         <item name="dialogTheme">@android:style/Theme.Dialog</item>
+        <item name="dialogTitleIconsDecorLayout">@layout/dialog_title_icons</item>
+        <item name="dialogCustomTitleDecorLayout">@layout/dialog_custom_title</item>
+        <item name="dialogTitleDecorLayout">@layout/dialog_title</item>
         <item name="alertDialogTheme">@android:style/Theme.Dialog.Alert</item>
         <item name="alertDialogCenterButtons">true</item>
         <item name="alertDialogIcon">@android:drawable/ic_dialog_alert</item>
@@ -368,6 +371,8 @@
         <item name="searchViewGoIcon">@android:drawable/ic_go_search_api_holo_light</item>
         <item name="searchViewVoiceIcon">@android:drawable/ic_voice_search_api_holo_light</item>
         <item name="searchViewEditQuery">@android:drawable/ic_commit_search_api_holo_light</item>
+
+        <item name="detailsElementBackground">@android:drawable/panel_bg_holo_light</item>
     </style>
 
     <!-- Variant of the light theme with no title bar -->
@@ -562,6 +567,7 @@
         <item name="android:colorBackgroundCacheHint">@null</item>
         <item name="android:windowFrame">@null</item>
         <item name="android:windowContentOverlay">@null</item>
+        <item name="android:windowAnimationStyle">@null</item>
         <item name="android:windowIsFloating">true</item>
         <item name="android:backgroundDimEnabled">false</item>
         <item name="android:windowIsTranslucent">true</item>
@@ -577,6 +583,23 @@
         <item name="android:colorBackgroundCacheHint">@null</item>
         <item name="android:windowFrame">@null</item>
         <item name="android:windowContentOverlay">@null</item>
+        <item name="android:windowAnimationStyle">@null</item>
+        <item name="android:windowIsFloating">true</item>
+        <item name="android:backgroundDimEnabled">false</item>
+        <item name="android:windowIsTranslucent">true</item>
+        <item name="android:windowNoTitle">true</item>
+    </style>
+
+    <!-- Default holo dark theme for panel windows.  This removes all extraneous
+         window decorations, so you basically have an empty rectangle in which
+         to place your content.  It makes the window floating, with a transparent
+         background, and turns off dimming behind the window. -->
+    <style name="Theme.Holo.Panel">
+        <item name="android:windowBackground">@android:color/transparent</item>
+        <item name="android:colorBackgroundCacheHint">@null</item>
+        <item name="android:windowFrame">@null</item>
+        <item name="android:windowContentOverlay">@null</item>
+        <item name="android:windowAnimationStyle">@null</item>
         <item name="android:windowIsFloating">true</item>
         <item name="android:backgroundDimEnabled">false</item>
         <item name="android:windowIsTranslucent">true</item>
@@ -592,6 +615,7 @@
         <item name="android:colorBackgroundCacheHint">@null</item>
         <item name="android:windowFrame">@null</item>
         <item name="android:windowContentOverlay">@null</item>
+        <item name="android:windowAnimationStyle">@null</item>
         <item name="android:windowIsFloating">true</item>
         <item name="android:backgroundDimEnabled">false</item>
         <item name="android:windowIsTranslucent">true</item>
@@ -809,6 +833,9 @@
         <!-- Dialog attributes -->
         <item name="alertDialogStyle">@android:style/AlertDialog.Holo</item>
         <item name="dialogTheme">@android:style/Theme.Holo.Dialog</item>
+        <item name="dialogTitleIconsDecorLayout">@layout/dialog_title_icons_holo</item>
+        <item name="dialogCustomTitleDecorLayout">@layout/dialog_custom_title_holo</item>
+        <item name="dialogTitleDecorLayout">@layout/dialog_title_holo</item>
         <item name="alertDialogTheme">@android:style/Theme.Holo.Dialog.Alert</item>
         <item name="alertDialogCenterButtons">false</item>
         <item name="alertDialogIcon">@android:drawable/ic_dialog_alert_holo_dark</item>
@@ -1067,6 +1094,9 @@
         <!-- Dialog attributes -->
         <item name="alertDialogStyle">@android:style/AlertDialog.Holo.Light</item>
         <item name="dialogTheme">@android:style/Theme.Holo.Light.Dialog</item>
+        <item name="dialogTitleIconsDecorLayout">@layout/dialog_title_icons_holo</item>
+        <item name="dialogCustomTitleDecorLayout">@layout/dialog_custom_title_holo</item>
+        <item name="dialogTitleDecorLayout">@layout/dialog_title_holo</item>
         <item name="alertDialogTheme">@android:style/Theme.Holo.Light.Dialog.Alert</item>
         <item name="alertDialogIcon">@android:drawable/ic_dialog_alert_holo_light</item>
         
@@ -1259,12 +1289,26 @@
         <item name="textAppearanceInverse">@android:style/TextAppearance.Holo.Inverse</item>
     </style>
 
+    <!-- Variation of Theme.Holo.Dialog that has a nice minumum width for
+         a regular dialog. -->
+    <style name="Theme.Holo.Dialog.MinWidth">
+        <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
+        <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_major</item>
+    </style>
+
     <!-- Variation of Theme.Holo.Dialog that does not include a title bar. -->
     <style name="Theme.Holo.Dialog.NoActionBar">
         <item name="android:windowActionBar">false</item>
         <item name="android:windowNoTitle">true</item>
     </style>
 
+    <!-- Variation of Theme.Holo.Dialog.NoActionVar that has a nice minumum width for
+         a regular dialog. -->
+    <style name="Theme.Holo.Dialog.NoActionBar.MinWidth">
+        <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
+        <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_major</item>
+    </style>
+
     <!-- Variation of Theme.Holo.Dialog that does not include a frame (or background).
          The view hierarchy of the dialog is responsible for drawing all of
          its pixels. -->
@@ -1287,6 +1331,8 @@
         <item name="windowBackground">@android:color/transparent</item>
         <item name="windowTitleStyle">@android:style/DialogWindowTitle.Holo</item>
         <item name="windowContentOverlay">@null</item>
+        <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
+        <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_major</item>
     </style>
 
     <!-- Theme for a window that will be displayed either full-screen on
@@ -1329,12 +1375,26 @@
         <item name="textAppearanceInverse">@android:style/TextAppearance.Holo.Light.Inverse</item>
     </style>
 
+    <!-- Variation of Theme.Holo.Light.Dialog that has a nice minumum width for
+         a regular dialog. -->
+    <style name="Theme.Holo.Light.Dialog.MinWidth">
+        <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
+        <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_major</item>
+    </style>
+
     <!-- Variation of Theme.Holo.Light.Dialog that does not include a title bar. -->
     <style name="Theme.Holo.Light.Dialog.NoActionBar">
         <item name="android:windowActionBar">false</item>
         <item name="android:windowNoTitle">true</item>
     </style>
 
+    <!-- Variation of Theme.Holo.Light.Dialog.NoActionBar that has a nice minumum width for
+         a regular dialog. -->
+    <style name="Theme.Holo.Light.Dialog.NoActionBar.MinWidth">
+        <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
+        <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_major</item>
+    </style>
+
     <!-- Theme for a window that will be displayed either full-screen on
          smaller screens (small, normal) or as a dialog on larger screens
          (large, xlarge). -->
@@ -1357,6 +1417,8 @@
         <item name="windowBackground">@android:color/transparent</item>
         <item name="windowTitleStyle">@android:style/DialogWindowTitle.Holo.Light</item>
         <item name="windowContentOverlay">@null</item>
+        <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
+        <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_major</item>
     </style>
 
     <!-- Default holographic (dark) for windows that want to have the user's selected
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
index 30a43c3..0e65df5 100755
--- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
+++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
@@ -623,6 +623,11 @@
 
     @LargeTest
     public void testInstallSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         mountMedia();
         sampleInstallFromRawResource(PackageManager.INSTALL_EXTERNAL, true);
     }
@@ -724,6 +729,11 @@
 
     @LargeTest
     public void testReplaceFailSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         sampleReplaceFromRawResource(PackageManager.INSTALL_EXTERNAL);
     }
 
@@ -740,6 +750,11 @@
 
     @LargeTest
     public void testReplaceSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING |
                 PackageManager.INSTALL_EXTERNAL);
     }
@@ -864,6 +879,11 @@
 
     @LargeTest
     public void testDeleteSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         deleteFromRawResource(PackageManager.INSTALL_EXTERNAL, 0);
     }
 
@@ -879,6 +899,11 @@
 
     @LargeTest
     public void testDeleteSdcardRetainData() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         deleteFromRawResource(PackageManager.INSTALL_EXTERNAL, PackageManager.DONT_DELETE_DATA);
     }
 
@@ -977,6 +1002,11 @@
     }
 
     boolean mountMedia() {
+        // We can't mount emulated storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return true;
+        }
+
         if (checkMediaState(Environment.MEDIA_MOUNTED)) {
             return true;
         }
@@ -1011,6 +1041,11 @@
     }
 
     private boolean unmountMedia() {
+        // We can't unmount emulated storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return true;
+        }
+
         if (checkMediaState(Environment.MEDIA_UNMOUNTED)) {
             return true;
         }
@@ -1100,6 +1135,11 @@
      */
     @LargeTest
     public void testMountSdNormalInternal() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         assertTrue(mountFromRawResource());
     }
 
@@ -1137,6 +1177,11 @@
 
     @LargeTest
     public void testManifestInstallLocationSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         installFromRawResource("install.apk", R.raw.install_loc_sdcard,
                 0, true, false, -1, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
     }
@@ -1155,6 +1200,11 @@
 
     @LargeTest
     public void testManifestInstallLocationFwdLockedFlagSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         installFromRawResource("install.apk", R.raw.install_loc_unspecified,
                 PackageManager.INSTALL_FORWARD_LOCK |
                 PackageManager.INSTALL_EXTERNAL, true, true,
@@ -1164,6 +1214,11 @@
 
     @LargeTest
     public void testManifestInstallLocationFwdLockedSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         installFromRawResource("install.apk", R.raw.install_loc_sdcard,
                 PackageManager.INSTALL_FORWARD_LOCK, true, false,
                 -1,
@@ -1177,6 +1232,11 @@
      */
     @LargeTest
     public void testReplaceFlagInternalSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int iFlags = 0;
         int rFlags = PackageManager.INSTALL_EXTERNAL;
         InstallParams ip = sampleInstallFromRawResource(iFlags, false);
@@ -1199,6 +1259,11 @@
      */
     @LargeTest
     public void testReplaceFlagSdcardInternal() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int iFlags = PackageManager.INSTALL_EXTERNAL;
         int rFlags = 0;
         InstallParams ip = sampleInstallFromRawResource(iFlags, false);
@@ -1216,6 +1281,11 @@
 
     @LargeTest
     public void testManifestInstallLocationReplaceInternalSdcard() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int iFlags = 0;
         int iApk = R.raw.install_loc_internal;
         int rFlags = 0;
@@ -1239,6 +1309,11 @@
 
     @LargeTest
     public void testManifestInstallLocationReplaceSdcardInternal() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int iFlags = 0;
         int iApk = R.raw.install_loc_sdcard;
         int rFlags = 0;
@@ -1471,6 +1546,11 @@
 
     @LargeTest
     public void testMoveAppInternalToExternal() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int installFlags = PackageManager.INSTALL_INTERNAL;
         int moveFlags = PackageManager.MOVE_EXTERNAL_MEDIA;
         boolean fail = false;
@@ -1489,30 +1569,53 @@
 
     @LargeTest
     public void testMoveAppExternalToExternal() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int installFlags = PackageManager.INSTALL_EXTERNAL;
         int moveFlags = PackageManager.MOVE_EXTERNAL_MEDIA;
         boolean fail = true;
         int result = PackageManager.MOVE_FAILED_INVALID_LOCATION;
         sampleMoveFromRawResource(installFlags, moveFlags, fail, result);
     }
+
     @LargeTest
     public void testMoveAppExternalToInternal() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int installFlags = PackageManager.INSTALL_EXTERNAL;
         int moveFlags = PackageManager.MOVE_INTERNAL;
         boolean fail = false;
         int result = PackageManager.MOVE_SUCCEEDED;
         sampleMoveFromRawResource(installFlags, moveFlags, fail, result);
     }
+
     @LargeTest
     public void testMoveAppForwardLocked() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int installFlags = PackageManager.INSTALL_FORWARD_LOCK;
         int moveFlags = PackageManager.MOVE_EXTERNAL_MEDIA;
         boolean fail = true;
         int result = PackageManager.MOVE_FAILED_FORWARD_LOCKED;
         sampleMoveFromRawResource(installFlags, moveFlags, fail, result);
     }
+
     @LargeTest
     public void testMoveAppFailInternalToExternalDelete() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         int installFlags = 0;
         int moveFlags = PackageManager.MOVE_EXTERNAL_MEDIA;
         boolean fail = true;
@@ -1541,12 +1644,18 @@
             setInstallLoc(origDefaultLoc);
         }
     }
+
     /*
      * Test that an install error code is returned when media is unmounted
      * and package installed on sdcard via package manager flag.
      */
     @LargeTest
     public void testInstallSdcardUnmount() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         boolean origState = checkMediaState(Environment.MEDIA_MOUNTED);
         try {
             // Unmount sdcard
@@ -1572,6 +1681,11 @@
      */
     @LargeTest
     public void testInstallManifestSdcardUnmount() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         boolean origState = checkMediaState(Environment.MEDIA_MOUNTED);
         try {
             // Unmount sdcard
@@ -1599,71 +1713,83 @@
     * User: UserI, UserE, UserA, User suffix absent if not existing.
     *
     */
-   /*
-    * Install an app on internal flash
-    */
-   @LargeTest
-   public void testFlagI() {
-       sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, true);
-   }
-   /*
-    * Install an app on sdcard.
-    */
-   @LargeTest
-   public void testFlagE() {
-       sampleInstallFromRawResource(PackageManager.INSTALL_EXTERNAL, true);
-   }
 
-   /*
-    * Install an app on sdcard.
-    */
-   @LargeTest
-   public void testFlagF() {
-       sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, true);
-   }
-   /*
-    * Install an app with both internal and external flags set. should fail
-    */
-   @LargeTest
-   public void testFlagIE() {
-       installFromRawResource("install.apk", R.raw.install,
-               PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_INTERNAL,
-               false,
-               true, PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION,
-               PackageInfo.INSTALL_LOCATION_AUTO);
-   }
+    /*
+     * Install an app on internal flash
+     */
+    @LargeTest
+    public void testFlagI() {
+        sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, true);
+    }
 
-   /*
-    * Install an app with both internal and external flags set. should fail
-    */
-   @LargeTest
-   public void testFlagIF() {
-       sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK |
-               PackageManager.INSTALL_INTERNAL, true);
-   }
-   /*
-    * Install an app with both internal and external flags set. should fail
-    */
-   @LargeTest
-   public void testFlagEF() {
-       installFromRawResource("install.apk", R.raw.install,
-               PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_EXTERNAL,
-               false,
-               true, PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION,
-               PackageInfo.INSTALL_LOCATION_AUTO);
-   }
-   /*
-    * Install an app with both internal and external flags set. should fail
-    */
-   @LargeTest
-   public void testFlagIEF() {
-       installFromRawResource("install.apk", R.raw.install,
-               PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_INTERNAL |
-               PackageManager.INSTALL_EXTERNAL,
-               false,
-               true, PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION,
-               PackageInfo.INSTALL_LOCATION_AUTO);
-   }
+    /*
+     * Install an app on sdcard.
+     */
+    @LargeTest
+    public void testFlagE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        sampleInstallFromRawResource(PackageManager.INSTALL_EXTERNAL, true);
+    }
+
+    /*
+     * Install an app forward-locked.
+     */
+    @LargeTest
+    public void testFlagF() {
+        sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, true);
+    }
+
+    /*
+     * Install an app with both internal and external flags set. should fail
+     */
+    @LargeTest
+    public void testFlagIE() {
+        installFromRawResource("install.apk", R.raw.install,
+                PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_INTERNAL,
+                false,
+                true, PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION,
+                PackageInfo.INSTALL_LOCATION_AUTO);
+    }
+
+    /*
+     * Install an app with both internal and forward-lock flags set.
+     */
+    @LargeTest
+    public void testFlagIF() {
+        sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK
+                | PackageManager.INSTALL_INTERNAL, true);
+    }
+
+    /*
+     * Install an app with both external and forward-lock flags set. should fail
+     */
+    @LargeTest
+    public void testFlagEF() {
+        installFromRawResource("install.apk", R.raw.install,
+                PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_EXTERNAL,
+                false,
+                true, PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION,
+                PackageInfo.INSTALL_LOCATION_AUTO);
+    }
+
+    /*
+     * Install an app with both internal and external flags set with forward
+     * lock. Should fail.
+     */
+    @LargeTest
+    public void testFlagIEF() {
+        installFromRawResource("install.apk", R.raw.install,
+                PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_INTERNAL |
+                PackageManager.INSTALL_EXTERNAL,
+                false,
+                true, PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION,
+                PackageInfo.INSTALL_LOCATION_AUTO);
+    }
+
    /*
     * Install an app with both internal and manifest option set.
     * should install on internal.
@@ -1706,321 +1832,402 @@
     */
    @LargeTest
    public void testFlagEManifestI() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
        installFromRawResource("install.apk", R.raw.install_loc_internal,
                PackageManager.INSTALL_EXTERNAL,
                true,
                false, -1,
                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
    }
+
    /*
     * Install an app with both external and manifest preference for
     * preferExternal. Should install externally.
     */
    @LargeTest
    public void testFlagEManifestE() {
-       installFromRawResource("install.apk", R.raw.install_loc_sdcard,
-               PackageManager.INSTALL_EXTERNAL,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   /*
-    * Install an app with both external and manifest preference for
-    * auto. should install on external media.
-    */
-   @LargeTest
-   public void testFlagEManifestA() {
-       installFromRawResource("install.apk", R.raw.install_loc_auto,
-               PackageManager.INSTALL_EXTERNAL,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   /*
-    * Install an app with fwd locked flag set and install location set to
-    * internal. should install internally.
-    */
-   @LargeTest
-   public void testFlagFManifestI() {
-       installFromRawResource("install.apk", R.raw.install_loc_internal,
-               PackageManager.INSTALL_EXTERNAL,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   /*
-    * Install an app with fwd locked flag set and install location set to
-    * preferExternal. should install internally.
-    */
-   @LargeTest
-   public void testFlagFManifestE() {
-       installFromRawResource("install.apk", R.raw.install_loc_sdcard,
-               PackageManager.INSTALL_EXTERNAL,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   /*
-    * Install an app with fwd locked flag set and install location set to
-    * auto. should install internally.
-    */
-   @LargeTest
-   public void testFlagFManifestA() {
-       installFromRawResource("install.apk", R.raw.install_loc_auto,
-               PackageManager.INSTALL_EXTERNAL,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   /* The following test functions verify install location for existing apps.
-    * ie existing app can be installed internally or externally. If install
-    * flag is explicitly set it should override current location. If manifest location
-    * is set, that should over ride current location too. if not the existing install
-    * location should be honoured.
-    * testFlagI/E/F/ExistingI/E -
-    */
-   @LargeTest
-   public void testFlagIExistingI() {
-       int iFlags = PackageManager.INSTALL_INTERNAL;
-       int rFlags = PackageManager.INSTALL_INTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install,
-               rFlags,
-               true,
-               false, -1,
-               -1);
-   }
-   @LargeTest
-   public void testFlagIExistingE() {
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       int rFlags = PackageManager.INSTALL_INTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install,
-               rFlags,
-               true,
-               false, -1,
-               -1);
-   }
-   @LargeTest
-   public void testFlagEExistingI() {
-       int iFlags = PackageManager.INSTALL_INTERNAL;
-       int rFlags = PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install,
-               rFlags,
-               true,
-               false, -1,
-               -1);
-   }
-   @LargeTest
-   public void testFlagEExistingE() {
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       int rFlags = PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install,
-               rFlags,
-               true,
-               false, -1,
-               -1);
-   }
-   @LargeTest
-   public void testFlagFExistingI() {
-       int iFlags = PackageManager.INSTALL_INTERNAL;
-       int rFlags = PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install,
-               rFlags,
-               true,
-               false, -1,
-               -1);
-   }
-   @LargeTest
-   public void testFlagFExistingE() {
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       int rFlags = PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install,
-               rFlags,
-               true,
-               false, -1,
-               -1);
-   }
-   /*
-    * The following set of tests verify the installation of apps with
-    * install location attribute set to internalOnly, preferExternal and auto.
-    * The manifest option should dictate the install location.
-    * public void testManifestI/E/A
-    * TODO out of memory fall back behaviour.
-    */
-   @LargeTest
-   public void testManifestI() {
-       installFromRawResource("install.apk", R.raw.install_loc_internal,
-               0,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
-   }
-   @LargeTest
-   public void testManifestE() {
-       installFromRawResource("install.apk", R.raw.install_loc_sdcard,
-               0,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   @LargeTest
-   public void testManifestA() {
-       installFromRawResource("install.apk", R.raw.install_loc_auto,
-               0,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
-   }
-   /*
-    * The following set of tests verify the installation of apps
-    * with install location attribute set to internalOnly, preferExternal and auto
-    * for already existing apps. The manifest option should take precedence.
-    * TODO add out of memory fall back behaviour.
-    * testManifestI/E/AExistingI/E
-    */
-   @LargeTest
-   public void testManifestIExistingI() {
-       int iFlags = PackageManager.INSTALL_INTERNAL;
-       int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install_loc_internal,
-               rFlags,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
-   }
-   @LargeTest
-   public void testManifestIExistingE() {
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install_loc_internal,
-               rFlags,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
-   }
-   @LargeTest
-   public void testManifestEExistingI() {
-       int iFlags = PackageManager.INSTALL_INTERNAL;
-       int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install_loc_sdcard,
-               rFlags,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   @LargeTest
-   public void testManifestEExistingE() {
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install_loc_sdcard,
-               rFlags,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   @LargeTest
-   public void testManifestAExistingI() {
-       int iFlags = PackageManager.INSTALL_INTERNAL;
-       int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install_loc_auto,
-               rFlags,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_AUTO);
-   }
-   @LargeTest
-   public void testManifestAExistingE() {
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
-       // First install.
-       installFromRawResource("install.apk", R.raw.install,
-               iFlags,
-               false,
-               false, -1,
-               -1);
-       // Replace now
-       installFromRawResource("install.apk", R.raw.install_loc_auto,
-               rFlags,
-               true,
-               false, -1,
-               PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        installFromRawResource("install.apk", R.raw.install_loc_sdcard,
+                PackageManager.INSTALL_EXTERNAL,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    /*
+     * Install an app with both external and manifest preference for
+     * auto. should install on external media.
+     */
+    @LargeTest
+    public void testFlagEManifestA() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        installFromRawResource("install.apk", R.raw.install_loc_auto,
+                PackageManager.INSTALL_EXTERNAL,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    /*
+     * Install an app with fwd locked flag set and install location set to
+     * internal. should install internally.
+     */
+    @LargeTest
+    public void testFlagFManifestI() {
+        installFromRawResource("install.apk", R.raw.install_loc_internal,
+                PackageManager.INSTALL_FORWARD_LOCK,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    /*
+     * Install an app with fwd locked flag set and install location set to
+     * preferExternal. should install internally.
+     */
+    @LargeTest
+    public void testFlagFManifestE() {
+        installFromRawResource("install.apk", R.raw.install_loc_sdcard,
+                PackageManager.INSTALL_FORWARD_LOCK,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    /*
+     * Install an app with fwd locked flag set and install location set to
+     * auto. should install internally.
+     */
+    @LargeTest
+    public void testFlagFManifestA() {
+        installFromRawResource("install.apk", R.raw.install_loc_auto,
+                PackageManager.INSTALL_FORWARD_LOCK,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    /* The following test functions verify install location for existing apps.
+     * ie existing app can be installed internally or externally. If install
+     * flag is explicitly set it should override current location. If manifest location
+     * is set, that should over ride current location too. if not the existing install
+     * location should be honoured.
+     * testFlagI/E/F/ExistingI/E -
+     */
+    @LargeTest
+    public void testFlagIExistingI() {
+        int iFlags = PackageManager.INSTALL_INTERNAL;
+        int rFlags = PackageManager.INSTALL_INTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install,
+                rFlags,
+                true,
+                false, -1,
+                -1);
+    }
+
+    @LargeTest
+    public void testFlagIExistingE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        int rFlags = PackageManager.INSTALL_INTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install,
+                rFlags,
+                true,
+                false, -1,
+                -1);
+    }
+
+    @LargeTest
+    public void testFlagEExistingI() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_INTERNAL;
+        int rFlags = PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install,
+                rFlags,
+                true,
+                false, -1,
+                -1);
+    }
+
+    @LargeTest
+    public void testFlagEExistingE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        int rFlags = PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install,
+                rFlags,
+                true,
+                false, -1,
+                -1);
+    }
+
+    @LargeTest
+    public void testFlagFExistingI() {
+        int iFlags = PackageManager.INSTALL_INTERNAL;
+        int rFlags = PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install,
+                rFlags,
+                true,
+                false, -1,
+                -1);
+    }
+
+    @LargeTest
+    public void testFlagFExistingE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        int rFlags = PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install,
+                rFlags,
+                true,
+                false, -1,
+                -1);
+    }
+
+    /*
+     * The following set of tests verify the installation of apps with
+     * install location attribute set to internalOnly, preferExternal and auto.
+     * The manifest option should dictate the install location.
+     * public void testManifestI/E/A
+     * TODO out of memory fall back behaviour.
+     */
+    @LargeTest
+    public void testManifestI() {
+        installFromRawResource("install.apk", R.raw.install_loc_internal,
+                0,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+    }
+
+    @LargeTest
+    public void testManifestE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        installFromRawResource("install.apk", R.raw.install_loc_sdcard,
+                0,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    @LargeTest
+    public void testManifestA() {
+        installFromRawResource("install.apk", R.raw.install_loc_auto,
+                0,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+    }
+
+    /*
+     * The following set of tests verify the installation of apps
+     * with install location attribute set to internalOnly, preferExternal and auto
+     * for already existing apps. The manifest option should take precedence.
+     * TODO add out of memory fall back behaviour.
+     * testManifestI/E/AExistingI/E
+     */
+    @LargeTest
+    public void testManifestIExistingI() {
+        int iFlags = PackageManager.INSTALL_INTERNAL;
+        int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install_loc_internal,
+                rFlags,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+    }
+
+    @LargeTest
+    public void testManifestIExistingE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install_loc_internal,
+                rFlags,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+    }
+
+    @LargeTest
+    public void testManifestEExistingI() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_INTERNAL;
+        int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install_loc_sdcard,
+                rFlags,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    @LargeTest
+    public void testManifestEExistingE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install_loc_sdcard,
+                rFlags,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    @LargeTest
+    public void testManifestAExistingI() {
+        int iFlags = PackageManager.INSTALL_INTERNAL;
+        int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install_loc_auto,
+                rFlags,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_AUTO);
+    }
+
+    @LargeTest
+    public void testManifestAExistingE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        int rFlags = PackageManager.INSTALL_REPLACE_EXISTING;
+        // First install.
+        installFromRawResource("install.apk", R.raw.install,
+                iFlags,
+                false,
+                false, -1,
+                -1);
+        // Replace now
+        installFromRawResource("install.apk", R.raw.install_loc_auto,
+                rFlags,
+                true,
+                false, -1,
+                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
    /*
     * The following set of tests check install location for existing
     * application based on user setting.
@@ -2067,36 +2274,62 @@
        int iFlags = PackageManager.INSTALL_INTERNAL;
        setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
    }
-   @LargeTest
-   public void testExistingIUserE() {
-       int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
-       int iFlags = PackageManager.INSTALL_INTERNAL;
-       setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
-   }
+
+    @LargeTest
+    public void testExistingIUserE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
+        int iFlags = PackageManager.INSTALL_INTERNAL;
+        setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+    }
+
    @LargeTest
    public void testExistingIUserA() {
        int userSetting = PackageHelper.APP_INSTALL_AUTO;
        int iFlags = PackageManager.INSTALL_INTERNAL;
        setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
    }
-   @LargeTest
-   public void testExistingEUserI() {
-       int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   @LargeTest
-   public void testExistingEUserE() {
-       int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
-   @LargeTest
-   public void testExistingEUserA() {
-       int userSetting = PackageHelper.APP_INSTALL_AUTO;
-       int iFlags = PackageManager.INSTALL_EXTERNAL;
-       setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
-   }
+
+    @LargeTest
+    public void testExistingEUserI() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int userSetting = PackageHelper.APP_INSTALL_INTERNAL;
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    @LargeTest
+    public void testExistingEUserE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
+    @LargeTest
+    public void testExistingEUserA() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int userSetting = PackageHelper.APP_INSTALL_AUTO;
+        int iFlags = PackageManager.INSTALL_EXTERNAL;
+        setExistingXUserX(userSetting, iFlags, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+    }
+
    /*
     * The following set of tests verify that the user setting defines
     * the install location.
@@ -2140,12 +2373,19 @@
        int iloc = getExpectedInstallLocation(userSetting);
        setUserX(true, userSetting, iloc);
    }
-   @LargeTest
-   public void testUserE() {
-       int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
-       int iloc = getExpectedInstallLocation(userSetting);
-       setUserX(true, userSetting, iloc);
-   }
+
+    @LargeTest
+    public void testUserE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
+        int iloc = getExpectedInstallLocation(userSetting);
+        setUserX(true, userSetting, iloc);
+    }
+
    @LargeTest
    public void testUserA() {
        int userSetting = PackageHelper.APP_INSTALL_AUTO;
@@ -2162,12 +2402,19 @@
        int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
        setUserX(false, userSetting, iloc);
    }
-   @LargeTest
-   public void testUserPrefOffUserE() {
-       int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
-       int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
-       setUserX(false, userSetting, iloc);
-   }
+
+    @LargeTest
+    public void testUserPrefOffUserE() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
+        int userSetting = PackageHelper.APP_INSTALL_EXTERNAL;
+        int iloc = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
+        setUserX(false, userSetting, iloc);
+    }
+
    @LargeTest
    public void testUserPrefOffA() {
        int userSetting = PackageHelper.APP_INSTALL_AUTO;
@@ -2379,6 +2626,11 @@
      */
     @LargeTest
     public void testInstallSdcardStaleContainer() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         boolean origMediaState = checkMediaState(Environment.MEDIA_MOUNTED);
         try {
             // Mount media first
@@ -2423,6 +2675,11 @@
      */
     @LargeTest
     public void testInstallSdcardStaleContainerReinstall() {
+        // Do not run on devices with emulated external storage.
+        if (Environment.isExternalStorageEmulated()) {
+            return;
+        }
+
         boolean origMediaState = checkMediaState(Environment.MEDIA_MOUNTED);
         try {
             // Mount media first
@@ -2458,6 +2715,7 @@
             }
         }
     }
+
     /*
      * The following series of tests are related to upgrading apps with
      * different certificates.
@@ -2846,6 +3104,7 @@
         installFromRawResource("install.apk", R.raw.install_uses_feature, 0, true, true, retCode,
                 PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
     }
+
     /*---------- Recommended install location tests ----*/
     /*
      * TODO's
diff --git a/data/fonts/AndroidClock.ttf b/data/fonts/AndroidClock.ttf
index 24a7f08..03e36cb 100644
--- a/data/fonts/AndroidClock.ttf
+++ b/data/fonts/AndroidClock.ttf
Binary files differ
diff --git a/data/fonts/AndroidClock_Highlight.ttf b/data/fonts/AndroidClock_Highlight.ttf
index 1e14a8f..8fb31ba 100644
--- a/data/fonts/AndroidClock_Highlight.ttf
+++ b/data/fonts/AndroidClock_Highlight.ttf
Binary files differ
diff --git a/graphics/java/android/graphics/BitmapRegionDecoder.java b/graphics/java/android/graphics/BitmapRegionDecoder.java
index 454eb4a..496e0c7 100644
--- a/graphics/java/android/graphics/BitmapRegionDecoder.java
+++ b/graphics/java/android/graphics/BitmapRegionDecoder.java
@@ -39,7 +39,7 @@
 
     /**
      * Create a BitmapRegionDecoder from the specified byte array.
-     * Currently only the Jpeg format is supported.
+     * Currently only the JPEG and PNG formats are supported.
      *
      * @param data byte array of compressed image data.
      * @param offset offset into data for where the decoder should begin
@@ -67,7 +67,7 @@
      * Create a BitmapRegionDecoder from the file descriptor.
      * The position within the descriptor will not be changed when
      * this returns, so the descriptor can be used again as is.
-     * Currently only the Jpeg format is supported.
+     * Currently only the JPEG and PNG formats are supported.
      *
      * @param fd The file descriptor containing the data to decode
      * @param isShareable If this is true, then the BitmapRegionDecoder may keep a
@@ -89,7 +89,7 @@
      * Create a BitmapRegionDecoder from an input stream.
      * The stream's position will be where ever it was after the encoded data
      * was read.
-     * Currently only the Jpeg format is supported.
+     * Currently only the JPEG and PNG formats are supported.
      *
      * @param is The input stream that holds the raw data to be decoded into a
      *           BitmapRegionDecoder.
@@ -126,7 +126,7 @@
 
     /**
      * Create a BitmapRegionDecoder from a file path.
-     * Currently only the Jpeg format is supported.
+     * Currently only the JPEG and PNG formats are supported.
      *
      * @param pathName complete path name for the file to be decoded.
      * @param isShareable If this is true, then the BitmapRegionDecoder may keep a
diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java
index 3acf1ea..43758e7 100644
--- a/graphics/java/android/graphics/Shader.java
+++ b/graphics/java/android/graphics/Shader.java
@@ -66,7 +66,7 @@
     public boolean getLocalMatrix(Matrix localM) {
         if (mLocalMatrix != null) {
             localM.set(mLocalMatrix);
-            return true;
+            return !mLocalMatrix.isIdentity();
         }
         return false;
     }
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 7a47c3b..0c33a5f 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-
 import android.content.res.Resources;
 import android.content.res.AssetManager;
 import android.graphics.Bitmap;
@@ -47,15 +46,62 @@
     Bitmap mBitmap;
     int mUsage;
 
+    /**
+     * The usage of the allocation.  These signal to renderscript
+     * where to place the allocation in memory.
+     *
+     * SCRIPT The allocation will be bound to and accessed by
+     * scripts.
+     */
     public static final int USAGE_SCRIPT = 0x0001;
+
+    /**
+     * GRAPHICS_TEXTURE The allcation will be used as a texture
+     * source by one or more graphcics programs.
+     *
+     */
     public static final int USAGE_GRAPHICS_TEXTURE = 0x0002;
+
+    /**
+     * GRAPHICS_VERTEX The allocation will be used as a graphics
+     * mesh.
+     *
+     */
     public static final int USAGE_GRAPHICS_VERTEX = 0x0004;
+
+
+    /**
+     * GRAPHICS_CONSTANTS The allocation will be used as the source
+     * of shader constants by one or more programs.
+     *
+     */
     public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008;
 
 
+    /**
+     * Controls mipmap behavior when using the bitmap creation and
+     * update functions.
+     */
     public enum MipmapControl {
+        /**
+         * No mipmaps will be generated and the type generated from the
+         * incoming bitmap will not contain additional LODs.
+         */
         MIPMAP_NONE(0),
+
+        /**
+         * A Full mipmap chain will be created in script memory.  The
+         * type of the allocation will contain a full mipmap chain.  On
+         * upload to graphics the full chain will be transfered.
+         */
         MIPMAP_FULL(1),
+
+        /**
+         * The type of the allocation will be the same as MIPMAP_NONE.
+         * It will not contain mipmaps.  On upload to graphics the
+         * graphics copy of the allocation data will contain a full
+         * mipmap chain generated from the top level in script memory.
+         */
         MIPMAP_ON_SYNC_TO_TEXTURE(2);
 
         int mID;
@@ -122,6 +168,49 @@
            mType.getY() != b.getHeight()) {
             throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch");
         }
+        Bitmap.Config bc = b.getConfig();
+        switch (bc) {
+        case ALPHA_8:
+            if (mType.getElement().mKind != Element.DataKind.PIXEL_A) {
+                throw new RSIllegalArgumentException("Allocation kind is " +
+                                                     mType.getElement().mKind + ", type " +
+                                                     mType.getElement().mType +
+                                                     " of " + mType.getElement().getSizeBytes() +
+                                                     " bytes, passed bitmap was " + bc);
+            }
+            break;
+        case ARGB_8888:
+            if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
+                (mType.getElement().getSizeBytes() != 4)) {
+                throw new RSIllegalArgumentException("Allocation kind is " +
+                                                     mType.getElement().mKind + ", type " +
+                                                     mType.getElement().mType +
+                                                     " of " + mType.getElement().getSizeBytes() +
+                                                     " bytes, passed bitmap was " + bc);
+            }
+            break;
+        case RGB_565:
+            if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGB) ||
+                (mType.getElement().getSizeBytes() != 2)) {
+                throw new RSIllegalArgumentException("Allocation kind is " +
+                                                     mType.getElement().mKind + ", type " +
+                                                     mType.getElement().mType +
+                                                     " of " + mType.getElement().getSizeBytes() +
+                                                     " bytes, passed bitmap was " + bc);
+            }
+            break;
+        case ARGB_4444:
+            if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
+                (mType.getElement().getSizeBytes() != 2)) {
+                throw new RSIllegalArgumentException("Allocation kind is " +
+                                                     mType.getElement().mKind + ", type " +
+                                                     mType.getElement().mType +
+                                                     " of " + mType.getElement().getSizeBytes() +
+                                                     " bytes, passed bitmap was " + bc);
+            }
+            break;
+
+        }
     }
 
     public void copyFrom(int[] d) {
@@ -214,6 +303,20 @@
         }
     }
 
+    /**
+     * Generate a mipmap chain.  Requires the type of the allocation
+     * include mipmaps.
+     *
+     * This function will generate a complete set of mipmaps from
+     * the top level lod and place them into the script memoryspace.
+     *
+     * If the allocation is also using other memory spaces a
+     * followup sync will be required.
+     */
+    public void generateMipmaps() {
+        mRS.nAllocationGenerateMipmaps(getID());
+    }
+
     public void copy1DRangeFrom(int off, int count, int[] d) {
         int dataSize = mType.mElement.getSizeBytes() * count;
         data1DChecks(off, count, d.length * 4, dataSize);
@@ -236,29 +339,49 @@
     }
 
 
-    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] d) {
+    /**
+     * Copy a rectanglular region from the array into the
+     * allocation.  The incoming array is assumed to be tightly
+     * packed.
+     *
+     * @param xoff X offset of the region to update
+     * @param yoff Y offset of the region to update
+     * @param w Width of the incoming region to update
+     * @param h Height of the incoming region to update
+     * @param data to be placed into the allocation
+     */
+    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
         mRS.validate();
-        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length);
+        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length);
     }
 
-    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] d) {
+    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
         mRS.validate();
-        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 2);
+        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 2);
     }
 
-    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] d) {
+    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
         mRS.validate();
-        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4);
+        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4);
     }
 
-    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] d) {
+    public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
         mRS.validate();
-        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4);
+        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4);
     }
 
-    public void copy2DRangeFrom(int xoff, int yoff, Bitmap b) {
+    /**
+     * Copy a bitmap into an allocation.  The height and width of
+     * the update will use the height and width of the incoming
+     * bitmap.
+     *
+     * @param xoff X offset of the region to update
+     * @param yoff Y offset of the region to update
+     * @param data the bitmap to be copied
+     */
+    public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) {
         mRS.validate();
-        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, b);
+        mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, data);
     }
 
 
@@ -287,6 +410,18 @@
         mRS.nAllocationRead(getID(), d);
     }
 
+    /**
+     * Resize a 1D allocation.  The contents of the allocation are
+     * preserved.  If new elements are allocated objects are created
+     * with null contents and the new region is otherwise undefined.
+     *
+     * If the new region is smaller the references of any objects
+     * outside the new region will be released.
+     *
+     * A new type will be created with the new dimension.
+     *
+     * @param dimX The new size of the allocation.
+     */
     public synchronized void resize(int dimX) {
         if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) {
             throw new RSInvalidStateException("Resize only support for 1D allocations at this time.");
@@ -427,7 +562,7 @@
             throw new RSIllegalArgumentException("Cubemap height must be multiple of 6");
         }
         if (width / 6 != height) {
-            throw new RSIllegalArgumentException("Only square cobe map faces supported");
+            throw new RSIllegalArgumentException("Only square cube map faces supported");
         }
         boolean isPow2 = (height & (height - 1)) == 0;
         if (!isPow2) {
@@ -449,11 +584,73 @@
         return new Allocation(id, rs, t, usage);
     }
 
-    static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b) {
+    static public Allocation createCubemapFromBitmap(RenderScript rs,
+                                                     Bitmap b) {
         return createCubemapFromBitmap(rs, b, MipmapControl.MIPMAP_NONE,
                                        USAGE_GRAPHICS_TEXTURE);
     }
 
+    static public Allocation createCubemapFromCubeFaces(RenderScript rs,
+                                                        Bitmap xpos,
+                                                        Bitmap xneg,
+                                                        Bitmap ypos,
+                                                        Bitmap yneg,
+                                                        Bitmap zpos,
+                                                        Bitmap zneg,
+                                                        MipmapControl mips,
+                                                        int usage) {
+        int height = xpos.getHeight();
+        if (xpos.getWidth() != height ||
+            xneg.getWidth() != height || xneg.getHeight() != height ||
+            ypos.getWidth() != height || ypos.getHeight() != height ||
+            yneg.getWidth() != height || yneg.getHeight() != height ||
+            zpos.getWidth() != height || zpos.getHeight() != height ||
+            zneg.getWidth() != height || zneg.getHeight() != height) {
+            throw new RSIllegalArgumentException("Only square cube map faces supported");
+        }
+        boolean isPow2 = (height & (height - 1)) == 0;
+        if (!isPow2) {
+            throw new RSIllegalArgumentException("Only power of 2 cube faces supported");
+        }
+
+        Element e = elementFromBitmap(rs, xpos);
+        Type.Builder tb = new Type.Builder(rs, e);
+        tb.setX(height);
+        tb.setY(height);
+        tb.setFaces(true);
+        tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL);
+        Type t = tb.create();
+        Allocation cubemap = Allocation.createTyped(rs, t, mips, usage);
+
+        AllocationAdapter adapter = AllocationAdapter.create2D(rs, cubemap);
+        adapter.setFace(Type.CubemapFace.POSITVE_X);
+        adapter.copyFrom(xpos);
+        adapter.setFace(Type.CubemapFace.NEGATIVE_X);
+        adapter.copyFrom(xneg);
+        adapter.setFace(Type.CubemapFace.POSITVE_Y);
+        adapter.copyFrom(ypos);
+        adapter.setFace(Type.CubemapFace.NEGATIVE_Y);
+        adapter.copyFrom(yneg);
+        adapter.setFace(Type.CubemapFace.POSITVE_Z);
+        adapter.copyFrom(zpos);
+        adapter.setFace(Type.CubemapFace.NEGATIVE_Z);
+        adapter.copyFrom(zneg);
+
+        return cubemap;
+    }
+
+    static public Allocation createCubemapFromCubeFaces(RenderScript rs,
+                                                        Bitmap xpos,
+                                                        Bitmap xneg,
+                                                        Bitmap ypos,
+                                                        Bitmap yneg,
+                                                        Bitmap zpos,
+                                                        Bitmap zneg) {
+        return createCubemapFromCubeFaces(rs, xpos, xneg, ypos, yneg,
+                                          zpos, zneg, MipmapControl.MIPMAP_NONE,
+                                          USAGE_GRAPHICS_TEXTURE);
+    }
+
     static public Allocation createFromBitmapResource(RenderScript rs,
                                                       Resources res,
                                                       int id,
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java
index e07fdfb..10dc35b 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/graphics/java/android/renderscript/Element.java
@@ -425,7 +425,13 @@
 
     Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
         super(id, rs);
-        mSize = dt.mSize * size;
+        if ((dt != DataType.UNSIGNED_5_6_5) &&
+            (dt != DataType.UNSIGNED_4_4_4_4) &&
+            (dt != DataType.UNSIGNED_5_5_5_1)) {
+            mSize = dt.mSize * size;
+        } else {
+            mSize = dt.mSize;
+        }
         mType = dt;
         mKind = dk;
         mNormalized = norm;
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 4c9ad56..28b32d5 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -223,6 +223,10 @@
     synchronized void nAllocationSyncAll(int alloc, int src) {
         rsnAllocationSyncAll(mContext, alloc, src);
     }
+    native void rsnAllocationGenerateMipmaps(int con, int alloc);
+    synchronized void nAllocationGenerateMipmaps(int alloc) {
+        rsnAllocationGenerateMipmaps(mContext, alloc);
+    }
     native void  rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp);
     synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) {
         rsnAllocationCopyFromBitmap(mContext, alloc, bmp);
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 1817a1b..a7913d7e 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -411,6 +411,13 @@
     rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits);
 }
 
+static void
+nAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, RsContext con, jint alloc)
+{
+    LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", con, (RsAllocation)alloc);
+    rsAllocationGenerateMipmaps(con, (RsAllocation)alloc);
+}
+
 static int
 nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
 {
@@ -445,10 +452,14 @@
     SkBitmap const * nativeBitmap =
             (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID);
     const SkBitmap& bitmap(*nativeBitmap);
+    int w = bitmap.width();
+    int h = bitmap.height();
 
     bitmap.lockPixels();
     const void* ptr = bitmap.getPixels();
-    rsAllocationCopyFromBitmap(con, (RsAllocation)alloc, ptr, bitmap.getSize());
+    rsAllocation2DData(con, (RsAllocation)alloc, 0, 0,
+                       0, RS_ALLOCATION_CUBMAP_FACE_POSITVE_X,
+                       w, h, ptr, bitmap.getSize());
     bitmap.unlockPixels();
 }
 
@@ -1211,6 +1222,7 @@
 {"rsnAllocationGetType",             "(II)I",                                 (void*)nAllocationGetType},
 {"rsnAllocationResize1D",            "(III)V",                                (void*)nAllocationResize1D },
 {"rsnAllocationResize2D",            "(IIII)V",                               (void*)nAllocationResize2D },
+{"rsnAllocationGenerateMipmaps",     "(II)V",                                 (void*)nAllocationGenerateMipmaps },
 
 {"rsnScriptBindAllocation",          "(IIII)V",                               (void*)nScriptBindAllocation },
 {"rsnScriptSetTimeZone",             "(II[B)V",                               (void*)nScriptSetTimeZone },
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index 29158e5..c49be93 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -13,6 +13,7 @@
 		FboCache.cpp \
 		GradientCache.cpp \
 		LayerCache.cpp \
+		LayerRenderer.cpp \
 		Matrix.cpp \
 		OpenGLDebugRenderer.cpp \
 		OpenGLRenderer.cpp \
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 40dd117..3563064 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -53,6 +53,10 @@
 
     mDebugLevel = readDebugLevel();
     LOGD("Enabling debug mode %d", mDebugLevel);
+
+#if RENDER_LAYERS_AS_REGIONS
+    LOGD("Layers will be composited as regions");
+#endif
 }
 
 Caches::~Caches() {
@@ -102,6 +106,32 @@
     textureCache.clearGarbage();
     gradientCache.clearGarbage();
     pathCache.clearGarbage();
+
+    Mutex::Autolock _l(mGarbageLock);
+
+    size_t count = mFboGarbage.size();
+    for (size_t i = 0; i < count; i++) {
+        GLuint fbo = mFboGarbage.itemAt(i);
+        if (fbo) glDeleteFramebuffers(1, &fbo);
+    }
+    mFboGarbage.clear();
+
+    count = mTextureGarbage.size();
+    for (size_t i = 0; i < count; i++) {
+        GLuint texture = mTextureGarbage.itemAt(i);
+        if (texture) glDeleteTextures(1, &texture);
+    }
+    mTextureGarbage.clear();
+}
+
+void Caches::deleteFboDeferred(GLuint fbo) {
+    Mutex::Autolock _l(mGarbageLock);
+    mFboGarbage.push(fbo);
+}
+
+void Caches::deleteTextureDeferred(GLuint texture) {
+    Mutex::Autolock _l(mGarbageLock);
+    mTextureGarbage.push(texture);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 318c120..34f48c9 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -90,6 +90,10 @@
     TextureVertex* mRegionMesh;
     GLuint mRegionMeshIndices;
 
+    mutable Mutex mGarbageLock;
+    Vector<GLuint> mFboGarbage;
+    Vector<GLuint> mTextureGarbage;
+
 public:
     /**
      * Indicates whether the renderer is in debug mode.
@@ -106,6 +110,16 @@
     void clearGarbage();
 
     /**
+     * Can be used to delete an FBO from a non EGL thread.
+     */
+    void deleteFboDeferred(GLuint fbo);
+
+    /**
+     * Can be used to delete a texture from a non EGL thread.
+     */
+    void deleteTextureDeferred(GLuint texture);
+
+    /**
      * Binds the VBO used to render simple textured quads.
      */
     void bindMeshBuffer();
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index afb82bf..fdb4e8c 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -241,6 +241,11 @@
                 renderer.drawDisplayList(getDisplayList());
             }
             break;
+            case DrawLayer: {
+                renderer.drawLayer(getInt(), getFloat(), getFloat(), getFloat(), getFloat(),
+                        getFloat(), getFloat(), getPaint());
+            }
+            break;
             case DrawBitmap: {
                 renderer.drawBitmap(getBitmap(), getFloat(), getFloat(), getPaint());
             }
@@ -483,6 +488,16 @@
     addDisplayList(displayList);
 }
 
+void DisplayListRenderer::drawLayer(int texture, float left, float top, float right, float bottom,
+        float u, float v, SkPaint* paint) {
+    addOp(DisplayList::DrawLayer);
+    addInt(texture);
+    addBounds(left, top, right, bottom);
+    addFloat(u);
+    addFloat(v);
+    addPaint(paint);
+}
+
 void DisplayListRenderer::drawBitmap(SkBitmap* bitmap, float left, float top,
         SkPaint* paint) {
     addOp(DisplayList::DrawBitmap);
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index fedb174..62cb0e8 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -93,6 +93,7 @@
         ConcatMatrix,
         ClipRect,
         DrawDisplayList,
+        DrawLayer,
         DrawBitmap,
         DrawBitmapMatrix,
         DrawBitmapRect,
@@ -245,6 +246,8 @@
     bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
 
     void drawDisplayList(DisplayList* displayList);
+    void drawLayer(int texture, float left, float top, float right, float bottom,
+            float u, float v, SkPaint* paint);
     void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
     void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
     void drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
new file mode 100644
index 0000000..d309ade
--- /dev/null
+++ b/libs/hwui/LayerRenderer.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#define LOG_TAG "OpenGLRenderer"
+
+#include "LayerRenderer.h"
+
+namespace android {
+namespace uirenderer {
+
+///////////////////////////////////////////////////////////////////////////////
+// Rendering
+///////////////////////////////////////////////////////////////////////////////
+
+void LayerRenderer::prepare(bool opaque) {
+    glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &mPreviousFbo);
+    glBindFramebuffer(GL_FRAMEBUFFER, mFbo);
+    OpenGLRenderer::prepare(opaque);
+}
+
+void LayerRenderer::finish() {
+    OpenGLRenderer::finish();
+    glBindFramebuffer(GL_FRAMEBUFFER, mPreviousFbo);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Static functions
+///////////////////////////////////////////////////////////////////////////////
+
+GLuint LayerRenderer::createLayer(uint32_t width, uint32_t height,
+        uint32_t* layerWidth, uint32_t* layerHeight, GLuint* texture) {
+    GLuint previousFbo;
+    glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo);
+
+    GLuint fbo = 0;
+    glGenFramebuffers(1, &fbo);
+    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    glActiveTexture(GL_TEXTURE0);
+    glGenTextures(1, texture);
+    glBindTexture(GL_TEXTURE_2D, *texture);
+
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
+            GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+    if (glGetError() != GL_NO_ERROR) {
+        glDeleteBuffers(1, &fbo);
+        glDeleteTextures(1, texture);
+        glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
+        return 0;
+    }
+
+    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+                *texture, 0);
+
+    if (glGetError() != GL_NO_ERROR) {
+        glDeleteBuffers(1, &fbo);
+        glDeleteTextures(1, texture);
+        glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
+        return 0;
+    }
+
+    glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
+
+    *layerWidth = width;
+    *layerHeight = height;
+
+    return fbo;
+}
+
+void LayerRenderer::resizeLayer(GLuint fbo, GLuint texture, uint32_t width, uint32_t height,
+        uint32_t* layerWidth, uint32_t* layerHeight) {
+    glActiveTexture(GL_TEXTURE0);
+    glBindTexture(GL_TEXTURE_2D, texture);
+
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
+            GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+
+    if (glGetError() != GL_NO_ERROR) {
+        glDeleteBuffers(1, &fbo);
+        glDeleteTextures(1, &texture);
+
+        *layerWidth = 0;
+        *layerHeight = 0;
+
+        return;
+    }
+
+    *layerWidth = width;
+    *layerHeight = height;
+}
+
+void LayerRenderer::destroyLayer(GLuint fbo, GLuint texture) {
+    if (fbo) glDeleteFramebuffers(1, &fbo);
+    if (texture) glDeleteTextures(1, &texture);
+}
+
+void LayerRenderer::destroyLayerDeferred(GLuint fbo, GLuint texture) {
+    Caches& caches = Caches::getInstance();
+    if (fbo) caches.deleteFboDeferred(fbo);
+    if (texture) caches.deleteTextureDeferred(texture);
+}
+
+}; // namespace uirenderer
+}; // namespace android
diff --git a/libs/hwui/LayerRenderer.h b/libs/hwui/LayerRenderer.h
new file mode 100644
index 0000000..800931a
--- /dev/null
+++ b/libs/hwui/LayerRenderer.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef ANDROID_HWUI_LAYER_RENDERER_H
+#define ANDROID_HWUI_LAYER_RENDERER_H
+
+#include "OpenGLRenderer.h"
+
+namespace android {
+namespace uirenderer {
+
+///////////////////////////////////////////////////////////////////////////////
+// Renderer
+///////////////////////////////////////////////////////////////////////////////
+
+class LayerRenderer: public OpenGLRenderer {
+public:
+    LayerRenderer(GLuint fbo): mFbo(fbo) {
+    }
+
+    ~LayerRenderer() {
+    }
+
+    void prepare(bool opaque);
+    void finish();
+
+    static GLuint createLayer(uint32_t width, uint32_t height,
+            uint32_t* layerWidth, uint32_t* layerHeight, GLuint* texture);
+    static void resizeLayer(GLuint fbo, GLuint texture, uint32_t width, uint32_t height,
+            uint32_t* layerWidth, uint32_t* layerHeight);
+    static void destroyLayer(GLuint fbo, GLuint texture);
+    static void destroyLayerDeferred(GLuint fbo, GLuint texture);
+
+private:
+    GLuint mFbo;
+    GLuint mPreviousFbo;
+
+}; // class LayerRenderer
+
+}; // namespace uirenderer
+}; // namespace android
+
+#endif // ANDROID_HWUI_LAYER_RENDERER_H
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 9613c5f..aefefe4 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -162,6 +162,11 @@
     GLenum status = GL_NO_ERROR;
     while ((status = glGetError()) != GL_NO_ERROR) {
         LOGD("GL error from OpenGLRenderer: 0x%x", status);
+        switch (status) {
+            case GL_OUT_OF_MEMORY:
+                LOGE("  OpenGLRenderer is out of memory!");
+                break;
+        }
     }
 #endif
 #if DEBUG_MEMORY_USAGE
@@ -173,7 +178,7 @@
 #endif
 }
 
-void OpenGLRenderer::acquireContext() {
+void OpenGLRenderer::interrupt() {
     if (mCaches.currentProgram) {
         if (mCaches.currentProgram->isInUse()) {
             mCaches.currentProgram->remove();
@@ -183,7 +188,11 @@
     mCaches.unbindMeshBuffer();
 }
 
-void OpenGLRenderer::releaseContext() {
+void OpenGLRenderer::acquireContext() {
+    interrupt();
+}
+
+void OpenGLRenderer::resume() {
     glViewport(0, 0, mSnapshot->viewport.getWidth(), mSnapshot->viewport.getHeight());
 
     glEnable(GL_SCISSOR_TEST);
@@ -200,6 +209,10 @@
     glBlendEquation(GL_FUNC_ADD);
 }
 
+void OpenGLRenderer::releaseContext() {
+    resume();
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // State management
 ///////////////////////////////////////////////////////////////////////////////
@@ -599,43 +612,23 @@
         size_t count;
         const android::Rect* rects = layer->region.getArray(&count);
 
-        setupDraw();
-
-        ProgramDescription description;
-        description.hasTexture = true;
-
         const float alpha = layer->alpha / 255.0f;
-        const bool setColor = description.setColor(alpha, alpha, alpha, alpha);
-        chooseBlending(layer->blend || layer->alpha < 255, layer->mode, description, false);
-
-        useProgram(mCaches.programCache.get(description));
-
-        // Texture
-        bindTexture(layer->texture);
-        glUniform1i(mCaches.currentProgram->getUniform("sampler"), 0);
-
-        // Always premultiplied
-        if (setColor) {
-            mCaches.currentProgram->setColor(alpha, alpha, alpha, alpha);
-        }
-
-        // Mesh
-        int texCoordsSlot = mCaches.currentProgram->getAttrib("texCoords");
-        glEnableVertexAttribArray(texCoordsSlot);
-
-        mModelView.loadIdentity();
-        mCaches.currentProgram->set(mOrthoMatrix, mModelView, *mSnapshot->transform);
-
         const float texX = 1.0f / float(layer->width);
         const float texY = 1.0f / float(layer->height);
 
         TextureVertex* mesh = mCaches.getRegionMesh();
         GLsizei numQuads = 0;
 
-        glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE,
-                gMeshStride, &mesh[0].position[0]);
-        glVertexAttribPointer(texCoordsSlot, 2, GL_FLOAT, GL_FALSE,
-                gMeshStride, &mesh[0].texture[0]);
+        setupDraw();
+        setupDrawWithTexture();
+        setupDrawColor(alpha, alpha, alpha, alpha);
+        setupDrawBlending(layer->blend || layer->alpha < 255, layer->mode, false);
+        setupDrawProgram();
+        setupDrawDirtyRegionsDisabled();
+        setupDrawPureColorUniforms();
+        setupDrawTexture(layer->texture);
+        setupDrawModelViewIdentity();
+        setupDrawMesh(&mesh[0].position[0], &mesh[0].texture[0]);
 
         for (size_t i = 0; i < count; i++) {
             const android::Rect* r = &rects[i];
@@ -665,7 +658,7 @@
         }
 
         glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-        glDisableVertexAttribArray(texCoordsSlot);
+        finishDrawTexture();
 
 #if DEBUG_LAYERS_AS_REGIONS
         uint32_t colors[] = {
@@ -1181,7 +1174,6 @@
 }
 
 void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
-    // TODO: Should do quickReject for each line
     if (mSnapshot->isIgnored()) return;
 
     const bool isAA = paint->isAntiAlias();
@@ -1195,6 +1187,7 @@
     getAlphaAndMode(paint, &alpha, &mode);
 
     int verticesCount = count >> 2;
+    int generatedVerticesCount = 0;
     if (!isHairLine) {
         // TODO: AA needs more vertices
         verticesCount *= 6;
@@ -1241,31 +1234,55 @@
             vec2 p3 = b + n;
             vec2 p4 = b - n;
 
-            // Draw the line as 2 triangles, could be optimized
-            // by using only 4 vertices and the correct indices
-            // Also we should probably used non textured vertices
-            // when line AA is disabled to save on bandwidth
-            TextureVertex::set(vertex++, p1.x, p1.y, 0.0f, 0.0f);
-            TextureVertex::set(vertex++, p2.x, p2.y, 0.0f, 0.0f);
-            TextureVertex::set(vertex++, p3.x, p3.y, 0.0f, 0.0f);
-            TextureVertex::set(vertex++, p1.x, p1.y, 0.0f, 0.0f);
-            TextureVertex::set(vertex++, p3.x, p3.y, 0.0f, 0.0f);
-            TextureVertex::set(vertex++, p4.x, p4.y, 0.0f, 0.0f);
+            const float left = fmin(p1.x, fmin(p2.x, fmin(p3.x, p4.x)));
+            const float right = fmax(p1.x, fmax(p2.x, fmax(p3.x, p4.x)));
+            const float top = fmin(p1.y, fmin(p2.y, fmin(p3.y, p4.y)));
+            const float bottom = fmax(p1.y, fmax(p2.y, fmax(p3.y, p4.y)));
 
-            // TODO: Mark the dirty regions when RENDER_LAYERS_AS_REGIONS is set
+            if (!quickReject(left, top, right, bottom)) {
+                // Draw the line as 2 triangles, could be optimized
+                // by using only 4 vertices and the correct indices
+                // Also we should probably used non textured vertices
+                // when line AA is disabled to save on bandwidth
+                TextureVertex::set(vertex++, p1.x, p1.y, 0.0f, 0.0f);
+                TextureVertex::set(vertex++, p2.x, p2.y, 0.0f, 0.0f);
+                TextureVertex::set(vertex++, p3.x, p3.y, 0.0f, 0.0f);
+                TextureVertex::set(vertex++, p1.x, p1.y, 0.0f, 0.0f);
+                TextureVertex::set(vertex++, p3.x, p3.y, 0.0f, 0.0f);
+                TextureVertex::set(vertex++, p4.x, p4.y, 0.0f, 0.0f);
+
+                generatedVerticesCount += 6;
+
+                dirtyLayer(left, top, right, bottom, *mSnapshot->transform);
+            }
         }
 
-        // GL_LINE does not give the result we want to match Skia
-        glDrawArrays(GL_TRIANGLES, 0, verticesCount);
+        if (generatedVerticesCount > 0) {
+            // GL_LINE does not give the result we want to match Skia
+            glDrawArrays(GL_TRIANGLES, 0, generatedVerticesCount);
+        }
     } else {
         // TODO: Handle the AA case
         for (int i = 0; i < count; i += 4) {
-            TextureVertex::set(vertex++, points[i], points[i + 1], 0.0f, 0.0f);
-            TextureVertex::set(vertex++, points[i + 2], points[i + 3], 0.0f, 0.0f);
+            const float left = fmin(points[i], points[i + 1]);
+            const float right = fmax(points[i], points[i + 1]);
+            const float top = fmin(points[i + 2], points[i + 3]);
+            const float bottom = fmax(points[i + 2], points[i + 3]);
+
+            if (!quickReject(left, top, right, bottom)) {
+                TextureVertex::set(vertex++, points[i], points[i + 1], 0.0f, 0.0f);
+                TextureVertex::set(vertex++, points[i + 2], points[i + 3], 0.0f, 0.0f);
+
+                generatedVerticesCount += 2;
+
+                dirtyLayer(left, top, right, bottom, *mSnapshot->transform);
+            }
         }
 
-        glLineWidth(1.0f);
-        glDrawArrays(GL_LINES, 0, verticesCount);
+        if (generatedVerticesCount > 0) {
+            glLineWidth(1.0f);
+            glDrawArrays(GL_LINES, 0, generatedVerticesCount);
+        }
     }
 }
 
@@ -1468,6 +1485,30 @@
     finishDrawTexture();
 }
 
+void OpenGLRenderer::drawLayer(int texture, float left, float top, float right, float bottom,
+        float u, float v, SkPaint* paint) {
+    if (quickReject(left, top, right, bottom)) {
+        return;
+    }
+
+    glActiveTexture(gTextureUnits[0]);
+    if (!texture) return;
+
+    mCaches.unbindMeshBuffer();
+    resetDrawTextureTexCoords(0.0f, v, u, 0.0f);
+
+    int alpha;
+    SkXfermode::Mode mode;
+    getAlphaAndMode(paint, &alpha, &mode);
+
+    // TODO: Should get the blend info from the caller
+    drawTextureMesh(left, top, right, bottom, texture, alpha / 255.0f, mode, true,
+            &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0],
+            GL_TRIANGLE_STRIP, gMeshCount);
+
+    resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // Shaders
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 8f93f5b..5f45915 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -64,6 +64,10 @@
     virtual void prepare(bool opaque);
     virtual void finish();
 
+    // These two calls must not be recorded in display lists
+    void interrupt();
+    void resume();
+
     virtual void acquireContext();
     virtual void releaseContext();
 
@@ -91,6 +95,8 @@
     virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
 
     virtual void drawDisplayList(DisplayList* displayList);
+    virtual void drawLayer(int texture, float left, float top, float right, float bottom,
+            float u, float v, SkPaint* paint);
     virtual void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
     virtual void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint);
     virtual void drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 8740a64..3184598 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -197,10 +197,16 @@
     bitmap.eraseColor(0);
 
     SkPaint pathPaint(*paint);
-    if (!pathPaint.getXfermode()) {
-        SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrc_Mode);
-        pathPaint.setXfermode(mode)->safeUnref();
-    }
+
+    // Make sure the paint is opaque, color, alpha, filter, etc.
+    // will be applied later when compositing the alpha8 texture
+    pathPaint.setColor(0xff000000);
+    pathPaint.setAlpha(255);
+    pathPaint.setColorFilter(NULL);
+    pathPaint.setMaskFilter(NULL);
+    pathPaint.setShader(NULL);
+    SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrc_Mode);
+    pathPaint.setXfermode(mode)->safeUnref();
 
     SkCanvas canvas(bitmap);
     canvas.translate(-bounds.fLeft + offset, -bounds.fTop + offset);
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index 33ac2f0..7e23cec 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -77,12 +77,6 @@
 	ret RsElement
 	}
 
-AllocationCopyFromBitmap {
-	param RsAllocation alloc
-	param const void * data
-	param size_t dataLen
-	}
-
 AllocationCopyToBitmap {
 	param RsAllocation alloc
 	param void * data
@@ -135,6 +129,10 @@
 	param uint32_t bytes
 	}
 
+AllocationGenerateMipmaps {
+	param RsAllocation va
+}
+
 AllocationRead {
 	param RsAllocation va
 	param void * data
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 673ade2..cf394c0 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -28,6 +28,8 @@
 
 #include "utils/StopWatch.h"
 
+static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va);
+
 using namespace android;
 using namespace android::renderscript;
 
@@ -340,26 +342,34 @@
     uint32_t lineSize = eSize * w;
     uint32_t destW = mType->getDimX();
 
-    const uint8_t *src = static_cast<const uint8_t *>(data);
-    uint8_t *dst = static_cast<uint8_t *>(mPtr);
-    dst += eSize * (xoff + yoff * destW);
+    //LOGE("data2d %p,  %i %i %i %i %i %i %p %i", this, xoff, yoff, lod, face, w, h, data, sizeBytes);
 
-    if ((lineSize * eSize * h) != sizeBytes) {
+    if ((lineSize * h) != sizeBytes) {
+        LOGE("Allocation size mismatch, expected %i, got %i", (lineSize * h), sizeBytes);
         rsAssert(!"Allocation::subData called with mismatched size");
         return;
     }
 
-    for (uint32_t line=yoff; line < (yoff+h); line++) {
-        if (mType->getElement()->getHasReferences()) {
-            incRefs(src, w);
-            decRefs(dst, w);
+    if (mPtr) {
+        const uint8_t *src = static_cast<const uint8_t *>(data);
+        uint8_t *dst = static_cast<uint8_t *>(mPtr);
+        dst += mType->getLODOffset(lod, xoff, yoff);
+
+        //LOGE("            %p  %p  %i  ", dst, src, eSize);
+        for (uint32_t line=yoff; line < (yoff+h); line++) {
+            if (mType->getElement()->getHasReferences()) {
+                incRefs(src, w);
+                decRefs(dst, w);
+            }
+            memcpy(dst, src, lineSize);
+            src += lineSize;
+            dst += destW * eSize;
         }
-        memcpy(dst, src, lineSize);
-        src += lineSize;
-        dst += destW * eSize;
+        sendDirty();
+        mUploadDefered = true;
+    } else {
+        upload2DTexture(false, data);
     }
-    sendDirty();
-    mUploadDefered = true;
 }
 
 void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face,
@@ -683,34 +693,9 @@
     a->syncAll(rsc, src);
 }
 
-void rsi_AllocationCopyFromBitmap(Context *rsc, RsAllocation va, const void *data, size_t dataLen) {
+void rsi_AllocationGenerateMipmaps(Context *rsc, RsAllocation va) {
     Allocation *texAlloc = static_cast<Allocation *>(va);
-    const Type * t = texAlloc->getType();
-
-    uint32_t w = t->getDimX();
-    uint32_t h = t->getDimY();
-    bool genMips = t->getDimLOD();
-    size_t s = w * h * t->getElementSizeBytes();
-    if (s != dataLen) {
-        rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size");
-        return;
-    }
-
-    if (texAlloc->getIsScript()) {
-        memcpy(texAlloc->getPtr(), data, s);
-        if (genMips) {
-            Adapter2D adapt(rsc, texAlloc);
-            Adapter2D adapt2(rsc, texAlloc);
-            for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
-                adapt.setLOD(lod);
-                adapt2.setLOD(lod + 1);
-                mip(adapt2, adapt);
-            }
-        }
-    } else {
-        texAlloc->upload2DTexture(false, data);
-    }
-
+    rsaAllocationGenerateScriptMips(rsc, texAlloc);
 }
 
 void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) {
@@ -770,6 +755,23 @@
 }
 }
 
+static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va) {
+    Context *rsc = static_cast<Context *>(con);
+    Allocation *texAlloc = static_cast<Allocation *>(va);
+    uint32_t numFaces = texAlloc->getType()->getDimFaces() ? 6 : 1;
+    for (uint32_t face = 0; face < numFaces; face ++) {
+        Adapter2D adapt(rsc, texAlloc);
+        Adapter2D adapt2(rsc, texAlloc);
+        adapt.setFace(face);
+        adapt2.setFace(face);
+        for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
+            adapt.setLOD(lod);
+            adapt2.setLOD(lod + 1);
+            mip(adapt2, adapt);
+        }
+    }
+}
+
 const void * rsaAllocationGetType(RsContext con, RsAllocation va) {
     Allocation *a = static_cast<Allocation *>(va);
     a->getType()->incUserRef();
@@ -802,13 +804,7 @@
 
     memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes());
     if (mips == RS_ALLOCATION_MIPMAP_FULL) {
-        Adapter2D adapt(rsc, texAlloc);
-        Adapter2D adapt2(rsc, texAlloc);
-        for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
-            adapt.setLOD(lod);
-            adapt2.setLOD(lod + 1);
-            mip(adapt2, adapt);
-        }
+        rsaAllocationGenerateScriptMips(rsc, texAlloc);
     }
 
     texAlloc->deferedUploadToTexture(rsc);
@@ -846,18 +842,10 @@
 
         // Move the data pointer to the next cube face
         sourcePtr += copySize;
+    }
 
-        if (mips == RS_ALLOCATION_MIPMAP_FULL) {
-            Adapter2D adapt(rsc, texAlloc);
-            Adapter2D adapt2(rsc, texAlloc);
-            adapt.setFace(face);
-            adapt2.setFace(face);
-            for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
-                adapt.setLOD(lod);
-                adapt2.setLOD(lod + 1);
-                mip(adapt2, adapt);
-            }
-        }
+    if (mips == RS_ALLOCATION_MIPMAP_FULL) {
+        rsaAllocationGenerateScriptMips(rsc, texAlloc);
     }
 
     texAlloc->deferedUploadToTexture(rsc);
diff --git a/libs/rs/scriptc/rs_cl.rsh b/libs/rs/scriptc/rs_cl.rsh
index 64844a4..a5092b3 100644
--- a/libs/rs/scriptc/rs_cl.rsh
+++ b/libs/rs/scriptc/rs_cl.rsh
@@ -23,8 +23,8 @@
                             CVT_FUNC_2(type, char) \
                             CVT_FUNC_2(type, ushort) \
                             CVT_FUNC_2(type, short) \
-                            CVT_FUNC_2(type, int) \
                             CVT_FUNC_2(type, uint) \
+                            CVT_FUNC_2(type, int) \
                             CVT_FUNC_2(type, float)
 
 CVT_FUNC(char)
@@ -62,6 +62,29 @@
     return r; \
 }
 
+#define DEF_FUNC_1_RI(fnc) \
+static int2 __attribute__((overloadable)) fnc(float2 v) { \
+    int2 r; \
+    r.x = fnc(v.x); \
+    r.y = fnc(v.y); \
+    return r; \
+} \
+static int3 __attribute__((overloadable)) fnc(float3 v) { \
+    int3 r; \
+    r.x = fnc(v.x); \
+    r.y = fnc(v.y); \
+    r.z = fnc(v.z); \
+    return r; \
+} \
+static int4 __attribute__((overloadable)) fnc(float4 v) { \
+    int4 r; \
+    r.x = fnc(v.x); \
+    r.y = fnc(v.y); \
+    r.z = fnc(v.z); \
+    r.w = fnc(v.w); \
+    return r; \
+}
+
 #define DEF_FUNC_2(fnc) \
 static float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2) { \
     float2 r; \
@@ -264,7 +287,7 @@
 DEF_FUNC_2(hypot)
 
 extern int __attribute__((overloadable)) ilogb(float);
-DEF_FUNC_1(ilogb)
+DEF_FUNC_1_RI(ilogb)
 
 extern float __attribute__((overloadable)) ldexp(float, int);
 extern float2 __attribute__((overloadable)) ldexp(float2, int2);
@@ -345,10 +368,10 @@
 extern float __attribute__((overloadable)) remainder(float, float);
 DEF_FUNC_2(remainder)
 
-extern float __attribute__((overloadable)) remquo(float, float, float *);
-extern float2 __attribute__((overloadable)) remquo(float2, float2, float2 *);
-extern float3 __attribute__((overloadable)) remquo(float3, float3, float3 *);
-extern float4 __attribute__((overloadable)) remquo(float4, float4, float4 *);
+extern float __attribute__((overloadable)) remquo(float, float, int *);
+extern float2 __attribute__((overloadable)) remquo(float2, float2, int2 *);
+extern float3 __attribute__((overloadable)) remquo(float3, float3, int3 *);
+extern float4 __attribute__((overloadable)) remquo(float4, float4, int4 *);
 
 extern float __attribute__((overloadable)) rint(float);
 DEF_FUNC_1(rint)
@@ -373,10 +396,10 @@
 DEF_FUNC_1(round)
 
 extern float __attribute__((overloadable)) sqrt(float);
-/*static float __attribute__((overloadable)) rsqrt(float v) {
+static float __attribute__((overloadable)) rsqrt(float v) {
     return 1.f / sqrt(v);
 }
-DEF_FUNC_1(rsqrt)*/
+DEF_FUNC_1(rsqrt)
 
 extern float __attribute__((overloadable)) sin(float);
 DEF_FUNC_1(sin)
@@ -781,5 +804,11 @@
     return v / length(v);
 }
 
+#undef CVT_FUNC
+#undef CVT_FUNC_2
+#undef DEF_FUNC_1
+#undef DEF_FUNC_1_RI
+#undef DEF_FUNC_2
+#undef DEF_FUNC_2F
 
 #endif
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 01134f2..f61ac0f 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -1300,9 +1300,9 @@
                 return;
 
             case MEDIA_INFO:
-                // For PV specific code values (msg.arg2) look in
-                // opencore/pvmi/pvmf/include/pvmf_return_codes.h
-                Log.i(TAG, "Info (" + msg.arg1 + "," + msg.arg2 + ")");
+                if (msg.arg1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) {
+                    Log.i(TAG, "Info (" + msg.arg1 + "," + msg.arg2 + ")");
+                }
                 if (mOnInfoListener != null) {
                     mOnInfoListener.onInfo(mMediaPlayer, msg.arg1, msg.arg2);
                 }
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index a098d69..87c8fe4 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -607,7 +607,9 @@
     case MEDIA_INFO:
         // ext1: Media framework error code.
         // ext2: Implementation dependant error code.
-        LOGW("info/warning (%d, %d)", ext1, ext2);
+        if (ext1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) {
+            LOGW("info/warning (%d, %d)", ext1, ext2);
+        }
         break;
     case MEDIA_SEEK_COMPLETE:
         LOGV("Received seek complete");
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 914e409..4cfe28e 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -179,6 +179,8 @@
     mStreamDoneEventPending = false;
     mBufferingEvent = new AwesomeEvent(this, &AwesomePlayer::onBufferingUpdate);
     mBufferingEventPending = false;
+    mVideoLagEvent = new AwesomeEvent(this, &AwesomePlayer::onVideoLagUpdate);
+    mVideoEventPending = false;
 
     mCheckAudioStatusEvent = new AwesomeEvent(
             this, &AwesomePlayer::onCheckAudioStatus);
@@ -205,6 +207,8 @@
     mStreamDoneEventPending = false;
     mQueue.cancelEvent(mCheckAudioStatusEvent->eventID());
     mAudioStatusEventPending = false;
+    mQueue.cancelEvent(mVideoLagEvent->eventID());
+    mVideoLagEventPending = false;
 
     if (!keepBufferingGoing) {
         mQueue.cancelEvent(mBufferingEvent->eventID());
@@ -530,6 +534,28 @@
     }
 }
 
+void AwesomePlayer::onVideoLagUpdate() {
+    Mutex::Autolock autoLock(mLock);
+    if (!mVideoLagEventPending) {
+        return;
+    }
+    mVideoLagEventPending = false;
+
+    int64_t audioTimeUs = mAudioPlayer->getMediaTimeUs();
+    int64_t videoLateByUs = audioTimeUs - mVideoTimeUs;
+
+    if (videoLateByUs > 300000ll) {
+        LOGV("video late by %lld ms.", videoLateByUs / 1000ll);
+
+        notifyListener_l(
+                MEDIA_INFO,
+                MEDIA_INFO_VIDEO_TRACK_LAGGING,
+                videoLateByUs / 1000ll);
+    }
+
+    postVideoLagEvent_l();
+}
+
 void AwesomePlayer::onBufferingUpdate() {
     Mutex::Autolock autoLock(mLock);
     if (!mBufferingEventPending) {
@@ -788,6 +814,10 @@
     if (mVideoSource != NULL) {
         // Kick off video playback
         postVideoEvent_l();
+
+        if (mAudioSource != NULL && mVideoSource != NULL) {
+            postVideoLagEvent_l();
+        }
     }
 
     if (deferredAudioSeek) {
@@ -1347,6 +1377,14 @@
     mQueue.postEventWithDelay(mBufferingEvent, 1000000ll);
 }
 
+void AwesomePlayer::postVideoLagEvent_l() {
+    if (mVideoLagEventPending) {
+        return;
+    }
+    mVideoLagEventPending = true;
+    mQueue.postEventWithDelay(mVideoLagEvent, 1000000ll);
+}
+
 void AwesomePlayer::postCheckAudioStatusEvent_l() {
     if (mAudioStatusEventPending) {
         return;
diff --git a/media/libstagefright/CameraSourceTimeLapse.cpp b/media/libstagefright/CameraSourceTimeLapse.cpp
index 9677838..31b6ec9 100644
--- a/media/libstagefright/CameraSourceTimeLapse.cpp
+++ b/media/libstagefright/CameraSourceTimeLapse.cpp
@@ -347,7 +347,8 @@
 }
 
 void CameraSourceTimeLapse::releaseRecordingFrame(const sp<IMemory>& frame) {
-    if (!mUseStillCameraForTimeLapse) {
+    if (!mUseStillCameraForTimeLapse &&
+        mCamera != NULL) {
         mCamera->releaseRecordingFrame(frame);
     }
 }
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 0bb3a86..00a4dd5e 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -228,22 +228,47 @@
 
     off64_t pos = *inout_pos;
     bool valid = false;
+
+    const size_t kMaxReadBytes = 1024;
+    const size_t kMaxBytesChecked = 128 * 1024;
+    uint8_t buf[kMaxReadBytes];
+    ssize_t bytesToRead = kMaxReadBytes;
+    ssize_t totalBytesRead = 0;
+    ssize_t remainingBytes = 0;
+    bool reachEOS = false;
+    uint8_t *tmp = buf;
+
     do {
-        if (pos >= *inout_pos + 128 * 1024) {
+        if (pos >= *inout_pos + kMaxBytesChecked) {
             // Don't scan forever.
             LOGV("giving up at offset %ld", pos);
             break;
         }
 
-        uint8_t tmp[4];
-        if (source->readAt(pos, tmp, 4) != 4) {
-            break;
+        if (remainingBytes < 4) {
+            if (reachEOS) {
+                break;
+            } else {
+                memcpy(buf, tmp, remainingBytes);
+                bytesToRead = kMaxReadBytes - remainingBytes;
+                totalBytesRead = source->readAt(pos, buf + remainingBytes, bytesToRead);
+                if (totalBytesRead <= 0) {
+                    break;
+                }
+                reachEOS = (totalBytesRead != bytesToRead);
+                totalBytesRead += remainingBytes;
+                remainingBytes = totalBytesRead;
+                tmp = buf;
+                continue;
+            }
         }
 
         uint32_t header = U32_AT(tmp);
 
         if (match_header != 0 && (header & kMask) != (match_header & kMask)) {
             ++pos;
+            ++tmp;
+            --remainingBytes;
             continue;
         }
 
@@ -253,6 +278,8 @@
                     header, &frame_size,
                     &sample_rate, &num_channels, &bitrate)) {
             ++pos;
+            ++tmp;
+            --remainingBytes;
             continue;
         }
 
@@ -303,6 +330,8 @@
         }
 
         ++pos;
+        ++tmp;
+        --remainingBytes;
     } while (!valid);
 
     return valid;
diff --git a/media/libstagefright/MediaBuffer.cpp b/media/libstagefright/MediaBuffer.cpp
index cbccd31..a8fadf2c 100644
--- a/media/libstagefright/MediaBuffer.cpp
+++ b/media/libstagefright/MediaBuffer.cpp
@@ -26,17 +26,10 @@
 #include <media/stagefright/MetaData.h>
 
 #include <ui/GraphicBuffer.h>
+#include <sys/atomics.h>
 
 namespace android {
 
-// XXX make this truly atomic.
-static int atomic_add(int *value, int delta) {
-    int prev_value = *value;
-    *value += delta;
-
-    return prev_value;
-}
-
 MediaBuffer::MediaBuffer(void *data, size_t size)
     : mObserver(NULL),
       mNextBuffer(NULL),
@@ -84,7 +77,7 @@
         return;
     }
 
-    int prevCount = atomic_add(&mRefCount, -1);
+    int prevCount = __atomic_dec(&mRefCount);
     if (prevCount == 1) {
         if (mObserver == NULL) {
             delete this;
@@ -104,7 +97,7 @@
 }
 
 void MediaBuffer::add_ref() {
-    atomic_add(&mRefCount, 1);
+    (void) __atomic_inc(&mRefCount);
 }
 
 void *MediaBuffer::data() const {
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index 110fb03..cdf4270 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -348,7 +348,7 @@
 ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) {
     Mutex::Autolock autoSerializer(mSerializer);
 
-    LOGV("readAt offset %ld, size %d", offset, size);
+    LOGV("readAt offset %lld, size %d", offset, size);
 
     Mutex::Autolock autoLock(mLock);
 
@@ -408,7 +408,7 @@
 }
 
 ssize_t NuCachedSource2::readInternal(off64_t offset, void *data, size_t size) {
-    LOGV("readInternal offset %ld size %d", offset, size);
+    LOGV("readInternal offset %lld size %d", offset, size);
 
     Mutex::Autolock autoLock(mLock);
 
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 7750a9d..e516cb4 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -3923,6 +3923,8 @@
 
             if (!mIsEncoder) {
                 OMX_CONFIG_RECTTYPE rect;
+                InitOMXParams(&rect);
+                rect.nPortIndex = kPortIndexOutput;
                 status_t err =
                         mOMX->getConfig(
                             mNode, OMX_IndexConfigCommonOutputCrop,
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 17b83c1..130ad82 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -173,6 +173,8 @@
     bool mBufferingEventPending;
     sp<TimedEventQueue::Event> mCheckAudioStatusEvent;
     bool mAudioStatusEventPending;
+    sp<TimedEventQueue::Event> mVideoLagEvent;
+    bool mVideoLagEventPending;
 
     sp<TimedEventQueue::Event> mAsyncPrepareEvent;
     Condition mPreparedCondition;
@@ -184,6 +186,7 @@
     void postBufferingEvent_l();
     void postStreamDoneEvent_l(status_t status);
     void postCheckAudioStatusEvent_l();
+    void postVideoLagEvent_l();
     status_t play_l();
 
     MediaBuffer *mVideoBuffer;
@@ -233,6 +236,7 @@
     void onPrepareAsyncEvent();
     void abortPrepare(status_t err);
     void finishAsyncPrepare_l();
+    void onVideoLagUpdate();
 
     bool getCachedDuration_l(int64_t *durationUs, bool *eos);
 
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
index 78719c1..aa320fc 100644
--- a/media/libstagefright/include/NuCachedSource2.h
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -55,8 +55,8 @@
 
     enum {
         kPageSize            = 65536,
-        kHighWaterThreshold  = 5 * 1024 * 1024,
-        kLowWaterThreshold   = 1024 * 1024,
+        kHighWaterThreshold  = 20 * 1024 * 1024,
+        kLowWaterThreshold   = 4 * 1024 * 1024,
 
         // Read data after a 15 sec timeout whether we're actively
         // fetching or not.
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp
index e0ac49f..eca9ed6 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.cpp
+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp
@@ -118,6 +118,9 @@
     virtual status_t read(
             MediaBuffer **buffer, const ReadOptions *options);
 
+protected:
+    virtual ~MatroskaSource();
+
 private:
     enum Type {
         AVC,
@@ -131,8 +134,13 @@
     BlockIterator mBlockIter;
     size_t mNALSizeLen;  // for type AVC
 
+    List<MediaBuffer *> mPendingFrames;
+
     status_t advance();
 
+    status_t readBlock();
+    void clearPendingFrames();
+
     MatroskaSource(const MatroskaSource &);
     MatroskaSource &operator=(const MatroskaSource &);
 };
@@ -168,6 +176,10 @@
     }
 }
 
+MatroskaSource::~MatroskaSource() {
+    clearPendingFrames();
+}
+
 status_t MatroskaSource::start(MetaData *params) {
     mBlockIter.reset();
 
@@ -175,6 +187,8 @@
 }
 
 status_t MatroskaSource::stop() {
+    clearPendingFrames();
+
     return OK;
 }
 
@@ -256,6 +270,214 @@
     return ptr[0] << 16 | ptr[1] << 8 | ptr[2];
 }
 
+static size_t clz(uint8_t x) {
+    size_t numLeadingZeroes = 0;
+
+    while (!(x & 0x80)) {
+        ++numLeadingZeroes;
+        x = x << 1;
+    }
+
+    return numLeadingZeroes;
+}
+
+void MatroskaSource::clearPendingFrames() {
+    while (!mPendingFrames.empty()) {
+        MediaBuffer *frame = *mPendingFrames.begin();
+        mPendingFrames.erase(mPendingFrames.begin());
+
+        frame->release();
+        frame = NULL;
+    }
+}
+
+#define BAIL(err) \
+    do {                        \
+        if (bigbuf) {           \
+            bigbuf->release();  \
+            bigbuf = NULL;      \
+        }                       \
+                                \
+        return err;             \
+    } while (0)
+
+status_t MatroskaSource::readBlock() {
+    CHECK(mPendingFrames.empty());
+
+    if (mBlockIter.eos()) {
+        return ERROR_END_OF_STREAM;
+    }
+
+    const mkvparser::Block *block = mBlockIter.block();
+
+    size_t size = block->GetSize();
+    int64_t timeUs = mBlockIter.blockTimeUs();
+    int32_t isSync = block->IsKey();
+
+    MediaBuffer *bigbuf = new MediaBuffer(size);
+
+    long res = block->Read(
+            mExtractor->mReader, (unsigned char *)bigbuf->data());
+
+    if (res != 0) {
+        bigbuf->release();
+        bigbuf = NULL;
+
+        return ERROR_END_OF_STREAM;
+    }
+
+    mBlockIter.advance();
+
+    bigbuf->meta_data()->setInt64(kKeyTime, timeUs);
+    bigbuf->meta_data()->setInt32(kKeyIsSyncFrame, isSync);
+
+    unsigned lacing = (block->Flags() >> 1) & 3;
+
+    if (lacing == 0) {
+        mPendingFrames.push_back(bigbuf);
+        return OK;
+    }
+
+    LOGV("lacing = %u, size = %d", lacing, size);
+
+    const uint8_t *data = (const uint8_t *)bigbuf->data();
+    // hexdump(data, size);
+
+    if (size == 0) {
+        BAIL(ERROR_MALFORMED);
+    }
+
+    unsigned numFrames = (unsigned)data[0] + 1;
+    ++data;
+    --size;
+
+    Vector<uint64_t> frameSizes;
+
+    switch (lacing) {
+        case 1:  // Xiph
+        {
+            for (size_t i = 0; i < numFrames - 1; ++i) {
+                size_t frameSize = 0;
+                uint8_t byte;
+                do {
+                    if (size == 0) {
+                        BAIL(ERROR_MALFORMED);
+                    }
+                    byte = data[0];
+                    ++data;
+                    --size;
+
+                    frameSize += byte;
+                } while (byte == 0xff);
+
+                frameSizes.push(frameSize);
+            }
+
+            break;
+        }
+
+        case 2:  // fixed-size
+        {
+            if ((size % numFrames) != 0) {
+                BAIL(ERROR_MALFORMED);
+            }
+
+            size_t frameSize = size / numFrames;
+            for (size_t i = 0; i < numFrames - 1; ++i) {
+                frameSizes.push(frameSize);
+            }
+
+            break;
+        }
+
+        case 3:  // EBML
+        {
+            uint64_t lastFrameSize = 0;
+            for (size_t i = 0; i < numFrames - 1; ++i) {
+                uint8_t byte;
+
+                if (size == 0) {
+                    BAIL(ERROR_MALFORMED);
+                }
+                byte = data[0];
+                ++data;
+                --size;
+
+                size_t numLeadingZeroes = clz(byte);
+
+                uint64_t frameSize = byte & ~(0x80 >> numLeadingZeroes);
+                for (size_t j = 0; j < numLeadingZeroes; ++j) {
+                    if (size == 0) {
+                        BAIL(ERROR_MALFORMED);
+                    }
+
+                    frameSize = frameSize << 8;
+                    frameSize |= data[0];
+                    ++data;
+                    --size;
+                }
+
+                if (i == 0) {
+                    frameSizes.push(frameSize);
+                } else {
+                    size_t shift =
+                        7 - numLeadingZeroes + 8 * numLeadingZeroes;
+
+                    int64_t delta =
+                        (int64_t)frameSize - (1ll << (shift - 1)) + 1;
+
+                    frameSize = lastFrameSize + delta;
+
+                    frameSizes.push(frameSize);
+                }
+
+                lastFrameSize = frameSize;
+            }
+            break;
+        }
+
+        default:
+            TRESPASS();
+    }
+
+#if 0
+    AString out;
+    for (size_t i = 0; i < frameSizes.size(); ++i) {
+        if (i > 0) {
+            out.append(", ");
+        }
+        out.append(StringPrintf("%llu", frameSizes.itemAt(i)));
+    }
+    LOGV("sizes = [%s]", out.c_str());
+#endif
+
+    for (size_t i = 0; i < frameSizes.size(); ++i) {
+        uint64_t frameSize = frameSizes.itemAt(i);
+
+        if (size < frameSize) {
+            BAIL(ERROR_MALFORMED);
+        }
+
+        MediaBuffer *mbuf = new MediaBuffer(frameSize);
+        mbuf->meta_data()->setInt64(kKeyTime, timeUs);
+        mbuf->meta_data()->setInt32(kKeyIsSyncFrame, isSync);
+        memcpy(mbuf->data(), data, frameSize);
+        mPendingFrames.push_back(mbuf);
+
+        data += frameSize;
+        size -= frameSize;
+    }
+
+    size_t offset = bigbuf->range_length() - size;
+    bigbuf->set_range(offset, size);
+
+    mPendingFrames.push_back(bigbuf);
+
+    return OK;
+}
+
+#undef BAIL
+
 status_t MatroskaSource::read(
         MediaBuffer **out, const ReadOptions *options) {
     *out = NULL;
@@ -263,17 +485,38 @@
     int64_t seekTimeUs;
     ReadOptions::SeekMode mode;
     if (options && options->getSeekTo(&seekTimeUs, &mode)) {
+        clearPendingFrames();
         mBlockIter.seek(seekTimeUs);
     }
 
 again:
-    if (mBlockIter.eos()) {
-        return ERROR_END_OF_STREAM;
+    while (mPendingFrames.empty()) {
+        status_t err = readBlock();
+
+        if (err != OK) {
+            clearPendingFrames();
+
+            return err;
+        }
     }
 
-    const mkvparser::Block *block = mBlockIter.block();
-    size_t size = block->GetSize();
-    int64_t timeUs = mBlockIter.blockTimeUs();
+    MediaBuffer *frame = *mPendingFrames.begin();
+    mPendingFrames.erase(mPendingFrames.begin());
+
+    size_t size = frame->range_length();
+
+    if (mType != AVC) {
+        *out = frame;
+
+        return OK;
+    }
+
+    if (size < mNALSizeLen) {
+        frame->release();
+        frame = NULL;
+
+        return ERROR_MALFORMED;
+    }
 
     // In the case of AVC content, each NAL unit is prefixed by
     // mNALSizeLen bytes of length. We want to prefix the data with
@@ -283,73 +526,54 @@
     static const size_t kPadding = 3;
 
     MediaBuffer *buffer = new MediaBuffer(size + kPadding);
+
+    int64_t timeUs;
+    CHECK(frame->meta_data()->findInt64(kKeyTime, &timeUs));
+    int32_t isSync;
+    CHECK(frame->meta_data()->findInt32(kKeyIsSyncFrame, &isSync));
+
     buffer->meta_data()->setInt64(kKeyTime, timeUs);
-    buffer->meta_data()->setInt32(kKeyIsSyncFrame, block->IsKey());
+    buffer->meta_data()->setInt32(kKeyIsSyncFrame, isSync);
 
-    long res = block->Read(
-            mExtractor->mReader, (unsigned char *)buffer->data() + kPadding);
-
-    if (res != 0) {
-        return ERROR_END_OF_STREAM;
-    }
+    memcpy((uint8_t *)buffer->data() + kPadding,
+           (const uint8_t *)frame->data() + frame->range_offset(),
+           size);
 
     buffer->set_range(kPadding, size);
 
-    if (mType == AVC) {
-        CHECK_GE(size, mNALSizeLen);
+    frame->release();
+    frame = NULL;
 
-        uint8_t *data = (uint8_t *)buffer->data();
+    uint8_t *data = (uint8_t *)buffer->data();
 
-        size_t NALsize;
-        switch (mNALSizeLen) {
-            case 1: NALsize = data[kPadding]; break;
-            case 2: NALsize = U16_AT(&data[kPadding]); break;
-            case 3: NALsize = U24_AT(&data[kPadding]); break;
-            case 4: NALsize = U32_AT(&data[kPadding]); break;
-            default:
-                TRESPASS();
-        }
-
-        CHECK_GE(size, NALsize + mNALSizeLen);
-        if (size > NALsize + mNALSizeLen) {
-            LOGW("discarding %d bytes of data.", size - NALsize - mNALSizeLen);
-        }
-
-        // actual data starts at &data[kPadding + mNALSizeLen]
-
-        memcpy(&data[mNALSizeLen - 1], "\x00\x00\x00\x01", 4);
-        buffer->set_range(mNALSizeLen - 1, NALsize + 4);
-    } else if (mType == AAC) {
-        // There's strange junk at the beginning...
-
-        const uint8_t *data = (const uint8_t *)buffer->data() + kPadding;
-
-        // hexdump(data, size);
-
-        size_t offset = 0;
-        while (offset < size && data[offset] != 0x21) {
-            ++offset;
-        }
-
-        if (size == offset) {
-            buffer->release();
-
-            mBlockIter.advance();
-            goto again;
-        }
-
-        buffer->set_range(kPadding + offset, size - offset);
+    size_t NALsize;
+    switch (mNALSizeLen) {
+        case 1: NALsize = data[kPadding]; break;
+        case 2: NALsize = U16_AT(&data[kPadding]); break;
+        case 3: NALsize = U24_AT(&data[kPadding]); break;
+        case 4: NALsize = U32_AT(&data[kPadding]); break;
+        default:
+            TRESPASS();
     }
 
+    if (size < NALsize + mNALSizeLen) {
+        buffer->release();
+        buffer = NULL;
+
+        return ERROR_MALFORMED;
+    }
+
+    if (size > NALsize + mNALSizeLen) {
+        LOGW("discarding %d bytes of data.", size - NALsize - mNALSizeLen);
+    }
+
+    // actual data starts at &data[kPadding + mNALSizeLen]
+
+    memcpy(&data[mNALSizeLen - 1], "\x00\x00\x00\x01", 4);
+    buffer->set_range(mNALSizeLen - 1, NALsize + 4);
+
     *out = buffer;
 
-#if 0
-    hexdump((const uint8_t *)buffer->data() + buffer->range_offset(),
-            buffer->range_length());
-#endif
-
-    mBlockIter.advance();
-
     return OK;
 }
 
diff --git a/media/libstagefright/matroska/mkvparser.cpp b/media/libstagefright/matroska/mkvparser.cpp
index 455b1d6..7448d96 100644
--- a/media/libstagefright/matroska/mkvparser.cpp
+++ b/media/libstagefright/matroska/mkvparser.cpp
@@ -4474,6 +4474,9 @@
     return ((m_flags & static_cast<unsigned char>(1 << 7)) != 0);

 }

 

+unsigned char Block::Flags() const {

+    return m_flags;

+}

 

 void Block::SetKey(bool bKey)

 {

diff --git a/media/libstagefright/matroska/mkvparser.hpp b/media/libstagefright/matroska/mkvparser.hpp
index c46d349..f7d8948 100644
--- a/media/libstagefright/matroska/mkvparser.hpp
+++ b/media/libstagefright/matroska/mkvparser.hpp
@@ -80,6 +80,8 @@
     bool IsKey() const;

     void SetKey(bool);

 

+    unsigned char Flags() const;

+

     long long GetOffset() const;

     long GetSize() const;

     long Read(IMkvReader*, unsigned char*) const;

diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 066b8e7..ec5f853 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -91,16 +91,16 @@
             0x16=0x04010100;
             <!-- Left Alt+DPAD/Trackball UP transitions from an axis to another and sends an event. -->
             <!-- Axis transitions:  2 -> 7; 1 -> 2; 0 -> 1; 3 -> 0; 4 -> 0; 5 -> 0; 6 -> 0; -->
-            0x120013=0x03020701:0x03010201:0x03000101:0x03030001:0x03040001:0x03050001:0x03060001;
+            0x200000013=0x03020701:0x03010201:0x03000101:0x03030001:0x03040001:0x03050001:0x03060001;
             <!-- Left Alt+DPAD/Trackball DOWN transitions from an axis to another and sends an event. -->
             <!-- Axis transitions: 1 -> 0; 2 -> 1; 7 -> 2; 3 -> 7; 4 -> 7; 5 -> 7; 6 -> 7; -->
-            0x120014=0x03010001:0x03020101:0x03070201:0x03030701:0x03040701:0x03050701:0x03060701;
+            0x200000014=0x03010001:0x03020101:0x03070201:0x03030701:0x03040701:0x03050701:0x03060701;
             <!-- Left Alt+DPAD/Trackball LEFT transitions from an axis to another and sends an event. -->
             <!-- Axis transitions: 4 -> 3; 5 -> 4; 6 -> 5; 0 -> 6; 1 -> 6; 2 -> 6; 7 -> 6; -->
-            0x120015=0x03040301:0x03050401:0x03060501:0x03000601:0x03010601:0x03020601:0x03070601;
+            0x200000015=0x03040301:0x03050401:0x03060501:0x03000601:0x03010601:0x03020601:0x03070601;
             <!-- Left Alt+DPAD/Trackball RIGHT transitions from an axis to another and sends an event.  -->
             <!-- Axis transitions: 5 -> 6; 4 -> 5; 3 -> 4; 2 -> 3; 7 -> 3; 1 -> 3; 0 -> 3; -->
-            0x120016=0x03050601:0x03040501:0x03030401:0x03020301:0x03070301:0x03010301:0x03000301;
+            0x200000016=0x03050601:0x03040501:0x03030401:0x03020301:0x03070301:0x03010301:0x03000301;
     </string>
 
     <!-- Default for Settings.System.USER_ROTATION -->
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 6e2bfdb..f8809d7 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -262,11 +262,8 @@
 
         // Watch for external modifications to the database file,
         // keeping our cache in sync.
-        // It's kinda lame to call mOpenHelper.getReadableDatabase()
-        // during onCreate(), but since ensureAndroidIdIsSet has
-        // already done it above and initialized/upgraded the
-        // database, might as well just use it...
-        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+        db.enableWriteAheadLogging();
         sObserverInstance = new SettingsFileObserver(db.getPath());
         sObserverInstance.startWatching();
         startAsyncCachePopulation();
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index d824f30..d3d1750 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -12,6 +12,7 @@
     <application
         android:persistent="true"
         android:allowClearUserData="false"
+        android:hardwareAccelerated="true"
         android:label="@string/app_label"
         android:icon="@drawable/ic_launcher_settings">
 
diff --git a/packages/SystemUI/res/drawable-nodpi/panel_notification.png b/packages/SystemUI/res/drawable-nodpi/panel_notification.png
index b0d9c18..437deff 100644
--- a/packages/SystemUI/res/drawable-nodpi/panel_notification.png
+++ b/packages/SystemUI/res/drawable-nodpi/panel_notification.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/panel_notification_tiled.xml b/packages/SystemUI/res/drawable/panel_notification_tiled.xml
new file mode 100644
index 0000000..9d41e28
--- /dev/null
+++ b/packages/SystemUI/res/drawable/panel_notification_tiled.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<bitmap
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:src="@drawable/panel_notification"
+    android:tileMode="repeat"
+    />
+
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml
index 0eaf08e..0533b6f 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml
@@ -25,7 +25,8 @@
     <FrameLayout
         android:id="@+id/bar_contents_holder"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_height="@*android:dimen/status_bar_height"
+        android:layout_gravity="bottom"
         >
         <RelativeLayout
             android:id="@+id/bar_contents"
@@ -93,7 +94,8 @@
     <FrameLayout
         android:id="@+id/bar_shadow_holder"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_height="@*android:dimen/status_bar_height"
+        android:layout_gravity="bottom"
         >
         <!-- lights out shade -->
         <RelativeLayout
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml b/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml
index d3fe2e7..7f84b21 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar_notification_panel.xml
@@ -20,27 +20,35 @@
     xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
     android:layout_height="match_parent"
     android:layout_width="match_parent"
-    android:orientation="vertical"
     android:gravity="right"
-    android:paddingTop="32dp"
     >
 
-    <LinearLayout
+    <View
+        android:id="@+id/scrim"
+        android:background="@drawable/notify_panel_bg_protect"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentRight="true"
+        />
+
+    <RelativeLayout
         android:id="@+id/content_parent"
         android:layout_height="wrap_content"
         android:layout_width="wrap_content"
-        android:animateLayoutChanges="true"
-        android:orientation="vertical"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentRight="true"
         >
-
-        <com.android.systemui.statusbar.tablet.NotificationTitleArea
+        <RelativeLayout
             android:id="@+id/title_area"
             android:layout_height="160dp"
             android:layout_width="384dp"
             android:layout_marginLeft="24dp"
             android:paddingTop="20dp"
             android:orientation="vertical"
-            android:animateLayoutChanges="true"
+            android:layout_alignParentTop="true"
+            android:layout_alignParentRight="true"
+            android:background="@drawable/panel_notification_tiled"
             >
 
             <com.android.systemui.statusbar.tablet.HoloClock
@@ -154,13 +162,15 @@
                 android:src="@drawable/status_bar_veto"
                 android:baseline="21dp"
                 />
-        </com.android.systemui.statusbar.tablet.NotificationTitleArea>
+        </RelativeLayout>
 
         <LinearLayout
             android:id="@+id/content_frame"
             android:layout_height="wrap_content"
             android:layout_width="408dp"
             android:orientation="vertical"
+            android:layout_below="@id/title_area"
+            android:layout_alignParentRight="true"
             >
             <ScrollView
                 android:id="@+id/notification_scroller"
@@ -191,5 +201,17 @@
                 android:src="@drawable/notify_item_glow_bottom"
                 />
         </LinearLayout>
-    </LinearLayout>
+    </RelativeLayout>
+
+    <View
+        android:id="@+id/glow"
+        android:background="@drawable/notify_glow_back"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignTop="@id/content_parent"
+        android:layout_alignLeft="@id/content_parent"
+        android:layout_marginLeft="100dip"
+        android:layout_marginTop="-100dip"
+        />
+
 </com.android.systemui.statusbar.tablet.NotificationPanel>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index df846f1..caafbdb 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -108,4 +108,6 @@
     <!-- Recent apps label. Shown as title on recent apps panel -->
     <string name="recent_tasks_app_label">Apps</string>
 
+    <!-- Network connection string for Bluetooth Reverse Tethering -->
+    <string name="bluetooth_tethered">Bluetooth tethered"</string>
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
index 472a225..8fca759 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java
@@ -52,6 +52,7 @@
     // Up-call methods
     protected abstract View makeStatusBarView();
     protected abstract int getStatusBarGravity();
+    public abstract int getStatusBarHeight();
 
     private DoNotDisturb mDoNotDisturb;
 
@@ -104,8 +105,7 @@
         }
 
         // Put up the view
-        final Resources res = mContext.getResources();
-        final int height= res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+        final int height = getStatusBarHeight();
 
         final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                 ViewGroup.LayoutParams.MATCH_PARENT,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 0d6c5f6..132433b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -287,9 +287,13 @@
         return Gravity.TOP | Gravity.FILL_HORIZONTAL;
     }
 
-    private void addIntruderView() {
+    public int getStatusBarHeight() {
         final Resources res = mContext.getResources();
-        final int height= res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+        return res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+    }
+
+    private void addIntruderView() {
+        final int height = getStatusBarHeight();
 
         WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                 ViewGroup.LayoutParams.MATCH_PARENT,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index b0b93e0..cb5e361 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -77,7 +77,7 @@
     int mDataDirectionIconId;
     int mDataSignalIconId;
     int mDataTypeIconId;
- 
+
     // wifi
     final WifiManager mWifiManager;
     boolean mWifiEnabled, mWifiConnected;
@@ -85,6 +85,11 @@
     String mWifiSsid;
     int mWifiIconId;
 
+    // bluetooth
+    private boolean mBluetoothTethered = false;
+    private int mBluetoothTetherIconId =
+        com.android.internal.R.drawable.stat_sys_tether_bluetooth;
+
     // data connectivity (regardless of state, can we access the internet?)
     // state of inet connection - 0 not connected, 100 connected
     private int mInetCondition = 0;
@@ -104,7 +109,7 @@
     int mLastCombinedSignalIconId = -1;
     int mLastDataTypeIconId = -1;
     String mLastLabel = "";
-    
+
     // yuck -- stop doing this here and put it in the framework
     IBatteryStats mBatteryStats;
 
@@ -235,7 +240,7 @@
         @Override
         public void onDataConnectionStateChanged(int state, int networkType) {
             if (DEBUG) {
-                Slog.d(TAG, "onDataConnectionStateChanged: state=" + state 
+                Slog.d(TAG, "onDataConnectionStateChanged: state=" + state
                         + " type=" + networkType);
             }
             mDataState = state;
@@ -649,13 +654,22 @@
                 mInetCondition = inetCondition;
                 updateWifiIcons();
                 break;
+            case ConnectivityManager.TYPE_BLUETOOTH:
+                mInetCondition = inetCondition;
+                if (info != null) {
+                    mBluetoothTethered = info.isConnected() ? true: false;
+                } else {
+                    mBluetoothTethered = false;
+                }
+                break;
         }
     }
 
 
     // ===== Update the views =======================================================
 
-    // figure out what to show: first wifi, then 3G, then nothing
+    // figure out what to show- there should be one connected network or nothing
+    // General order of preference is: wifi, 3G than bluetooth. This might vary by product.
     void refreshViews() {
         Context context = mContext;
 
@@ -672,12 +686,16 @@
             }
             combinedSignalIconId = mWifiIconId;
             dataTypeIconId = 0;
+        } else if (mDataConnected) {
+            label = mNetworkName;
+            combinedSignalIconId = mDataSignalIconId;
+            dataTypeIconId = mDataTypeIconId;
+        } else if (mBluetoothTethered) {
+            label = mContext.getString(R.string.bluetooth_tethered);
+            combinedSignalIconId = mBluetoothTetherIconId;
+            dataTypeIconId = 0;
         } else {
-            if (mDataConnected) {
-                label = mNetworkName;
-            } else {
-                label = context.getString(R.string.status_bar_settings_signal_meter_disconnected);
-            }
+            label = context.getString(R.string.status_bar_settings_signal_meter_disconnected);
             combinedSignalIconId = mDataSignalIconId;
             dataTypeIconId = mDataTypeIconId;
         }
@@ -689,7 +707,8 @@
                     + " mDataDirectionIconId=0x" + Integer.toHexString(mDataDirectionIconId)
                     + " mDataSignalIconId=0x" + Integer.toHexString(mDataSignalIconId)
                     + " mDataTypeIconId=0x" + Integer.toHexString(mDataTypeIconId)
-                    + " mWifiIconId=0x" + Integer.toHexString(mWifiIconId));
+                    + " mWifiIconId=0x" + Integer.toHexString(mWifiIconId)
+                    + "mBluetoothTetherIconId=0x" + Integer.toHexString(mBluetoothTetherIconId));
         }
 
         // the phone icon on phones
@@ -809,6 +828,10 @@
         pw.print("  mWifiIconId=");
         pw.println(mWifiIconId);
 
+        pw.println("  - Bluetooth ----");
+        pw.print(" mBtReverseTethered=");
+        pw.println(mBluetoothTethered);
+
         pw.println("  - connectivity ------");
         pw.print("  mInetCondition=");
         pw.println(mInetCondition);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java
new file mode 100644
index 0000000..5616159
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HeightReceiver.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2011 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 java.util.ArrayList;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Resources;
+import android.util.DisplayMetrics;
+import android.util.Slog;
+import android.view.View;
+import android.view.WindowManager;
+import android.view.WindowManagerImpl;
+import android.view.WindowManagerPolicy;
+
+public class HeightReceiver extends BroadcastReceiver {
+    private static final String TAG = "StatusBar.HeightReceiver";
+
+    public interface OnBarHeightChangedListener {
+        public void onBarHeightChanged(int height);
+    }
+
+    Context mContext;
+    ArrayList<OnBarHeightChangedListener> mListeners = new ArrayList<OnBarHeightChangedListener>();
+    WindowManager mWindowManager;
+    int mHeight;
+
+    public HeightReceiver(Context context) {
+        mContext = context;
+        mWindowManager = WindowManagerImpl.getDefault();
+    }
+
+    public void addOnBarHeightChangedListener(OnBarHeightChangedListener l) {
+        mListeners.add(l);
+        l.onBarHeightChanged(mHeight);
+    }
+
+    public void removeOnBarHeightChangedListener(OnBarHeightChangedListener l) {
+        mListeners.remove(l);
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        final boolean plugged
+                = intent.getBooleanExtra(WindowManagerPolicy.EXTRA_HDMI_PLUGGED_STATE, false);
+        setPlugged(plugged);
+    }
+
+    public void registerReceiver() {
+        final IntentFilter filter = new IntentFilter();
+        filter.addAction(WindowManagerPolicy.ACTION_HDMI_PLUGGED);
+        final Intent val = mContext.registerReceiver(this, filter);
+        onReceive(mContext, val);
+    }
+
+    private void setPlugged(boolean plugged) {
+        final Resources res = mContext.getResources();
+
+        Slog.d(TAG, "plugged=" + plugged);
+        int height = -1;
+        if (plugged) {
+            final DisplayMetrics metrics = new DisplayMetrics();
+            mWindowManager.getDefaultDisplay().getMetrics(metrics);
+            Slog.d(TAG, "metrics=" + metrics);
+            height = metrics.heightPixels - 720;
+        }
+
+        final int minHeight
+                = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+        if (height < minHeight) {
+            height = minHeight;
+        }
+        Slog.d(TAG, "using height=" + height + " old=" + mHeight);
+        mHeight = height;
+
+        final int N = mListeners.size();
+        for (int i=0; i<N; i++) {
+            mListeners.get(i).onBarHeightChanged(height);
+        }
+    }
+
+    public int getHeight() {
+        return mHeight;
+    }
+}
+
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
index 7dcf9be..ffbc0e3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
@@ -17,6 +17,7 @@
 package com.android.systemui.statusbar.tablet;
 
 import android.animation.Animator;
+import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.animation.ValueAnimator;
 import android.content.Context;
@@ -33,11 +34,13 @@
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.FrameLayout;
 import android.widget.TextView;
 
 import com.android.systemui.R;
 
-public class NotificationPanel extends LinearLayout implements StatusBarPanel,
+public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
         View.OnClickListener {
     static final String TAG = "Tablet/NotificationPanel";
     static final boolean DEBUG = false;
@@ -51,12 +54,10 @@
     ViewGroup mContentFrame;
     Rect mContentArea;
     View mSettingsView;
+    View mScrim, mGlow;
     ViewGroup mContentParent;
 
     Choreographer mChoreo = new Choreographer();
-    int mStatusBarHeight;
-    Drawable mBgDrawable;
-    Drawable mGlowDrawable;
 
     public NotificationPanel(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
@@ -64,13 +65,6 @@
 
     public NotificationPanel(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
-
-        final Resources res = context.getResources();
-
-        mStatusBarHeight = res.getDimensionPixelSize(
-                com.android.internal.R.dimen.status_bar_height);
-        mBgDrawable = res.getDrawable(R.drawable.notify_panel_bg_protect);
-        mGlowDrawable = res.getDrawable(R.drawable.notify_glow_back);
     }
 
     @Override
@@ -80,9 +74,13 @@
         setWillNotDraw(false);
 
         mContentParent = (ViewGroup)findViewById(R.id.content_parent);
+        mContentParent.bringToFront();
         mTitleArea = findViewById(R.id.title_area);
         mTitleArea.setOnClickListener(this);
 
+        mScrim = findViewById(R.id.scrim);
+        mGlow = findViewById(R.id.glow);
+
         mSettingsButton = (ImageView)findViewById(R.id.settings_button);
         mNotificationButton = (ImageView)findViewById(R.id.notification_button);
 
@@ -132,21 +130,6 @@
     @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
         super.onLayout(changed, l, t, r, b);
-        // We know that none of our children are GONE, so don't worry about skipping GONE views.
-        final int N = getChildCount();
-        if (N == 0) {
-            return;
-        }
-        final int allocatedBottom = getChildAt(N-1).getBottom();
-        final int shift = b - allocatedBottom - getPaddingBottom();
-        if (shift <= 0) {
-            return;
-        }
-        for (int i=0; i<N; i++) {
-            final View c = getChildAt(i);
-            c.layout(c.getLeft(), c.getTop() + shift, c.getRight(), c.getBottom() + shift);
-        }
-
         mChoreo.setPanelHeight(mContentParent.getHeight());
     }
 
@@ -154,26 +137,6 @@
     public void onSizeChanged(int w, int h, int oldw, int oldh) {
         super.onSizeChanged(w, h, oldw, oldh);
         mContentArea = null;
-        mBgDrawable.setBounds(0, 0, w, h-mStatusBarHeight);
-    }
-
-    @Override
-    public void onDraw(Canvas canvas) {
-        int saveCount;
-        final int w = getWidth();
-        final int h = getHeight();
-
-        super.onDraw(canvas);
-
-        // Background protection
-        mBgDrawable.draw(canvas);
-
-        // The panel glow (behind status bar)
-
-        saveCount = canvas.save();
-        canvas.clipRect(0, 0, w, h-mStatusBarHeight);
-        mGlowDrawable.draw(canvas);
-        canvas.restoreToCount(saveCount);
     }
 
     public void onClick(View v) {
@@ -227,82 +190,82 @@
 
     private class Choreographer implements Animator.AnimatorListener {
         boolean mVisible;
-        int mBgAlpha;
-        ValueAnimator mBgAnim;
         int mPanelHeight;
-        int mPanelBottom;
-        ValueAnimator mPositionAnim;
+        AnimatorSet mContentAnim;
 
         // should group this into a multi-property animation
-        final int OPEN_DURATION = 200;
+        final int OPEN_DURATION = 250;
+
+        // the panel will start to appear this many px from the end
+        final int HYPERSPACE_OFFRAMP = 120;
 
         Choreographer() {
         }
 
-        void createAnimation(boolean visible) {
-            mBgAnim = ObjectAnimator.ofInt(this, "bgAlpha", mBgAlpha, visible ? 255 : 0)
-                    .setDuration(OPEN_DURATION);
-            mBgAnim.addListener(this);
+        void createAnimation(boolean appearing) {
+            Animator bgAnim = ObjectAnimator.ofFloat(mScrim,
+                    "alpha", mScrim.getAlpha(), appearing ? 1 : 0);
 
-            mPositionAnim = ObjectAnimator.ofInt(this, "panelBottom", mPanelBottom,
-                        visible ? mPanelHeight : 0)
-                    .setDuration(OPEN_DURATION);
-        }
+            float start, end;
 
-        void startAnimation(boolean visible) {
-            if (DEBUG) Slog.d(TAG, "startAnimation(visible=" + visible + ")");
-
-            createAnimation(visible);
-            mBgAnim.start();
-            mPositionAnim.start();
-
-            mVisible = visible;
-        }
-
-        void jumpTo(boolean visible) {
-            setBgAlpha(visible ? 255 : 0);
-            setPanelBottom(visible ? mPanelHeight : 0);
-        }
-
-        public void setBgAlpha(int alpha) {
-            mBgAlpha = alpha;
-            mBgDrawable.setAlpha((int)(alpha));
-            invalidate();
-        }
-
-        // 0 is closed, the height of the panel is open
-        public void setPanelBottom(int y) {
-            mPanelBottom = y;
-            int translationY = mPanelHeight - y;
-            mContentParent.setTranslationY(translationY);
-
-            final int glowXOffset = 100;
-            final int glowYOffset = 100;
-            int glowX = mContentParent.getLeft() - glowXOffset;
-            int glowY = mContentParent.getTop() - glowYOffset + translationY;
-            mGlowDrawable.setBounds(glowX, glowY, glowX + mGlowDrawable.getIntrinsicWidth(),
-                    glowY + mGlowDrawable.getIntrinsicHeight());
-
-            float alpha;
-            if (mPanelBottom > glowYOffset) {
-                alpha = 1;
+            // 0: on-screen
+            // height: off-screen
+            float y = mContentParent.getTranslationY();
+            if (appearing) {
+                // we want to go from near-the-top to the top, unless we're half-open in the right
+                // general vicinity
+                start = (y < HYPERSPACE_OFFRAMP)
+                    ? y
+                    : HYPERSPACE_OFFRAMP;
+                end = 0;
             } else {
-                alpha = ((float)mPanelBottom) / glowYOffset;
+                start = y;
+                end = y + HYPERSPACE_OFFRAMP;
             }
-            mContentParent.setAlpha(alpha);
-            mGlowDrawable.setAlpha((int)(255 * alpha));
+            Animator posAnim = ObjectAnimator.ofFloat(mContentParent, "translationY", start, end);
+            posAnim.setInterpolator(appearing 
+                    ? new android.view.animation.DecelerateInterpolator(2.0f)
+                    : new android.view.animation.AccelerateInterpolator(2.0f));
 
-            if (false) {
-                Slog.d(TAG, "mPanelBottom=" + mPanelBottom + " translationY=" + translationY
-                        + " alpha=" + alpha + " glowY=" + glowY);
-            }
+            Animator glowAnim = ObjectAnimator.ofFloat(mGlow, "alpha",
+                    mGlow.getAlpha(), appearing ? 1.0f : 0.0f);
+            glowAnim.setInterpolator(appearing 
+                    ? new android.view.animation.AccelerateInterpolator(1.0f)
+                    : new android.view.animation.DecelerateInterpolator(1.0f));
+
+            mContentAnim = new AnimatorSet();
+            mContentAnim
+                .play(ObjectAnimator.ofFloat(mContentParent, "alpha", mContentParent.getAlpha(),
+                                                                      appearing ? 1.0f : 0.0f))
+                .with(glowAnim)
+                .with(bgAnim)
+                .with(posAnim)
+                ;
+            mContentAnim.setDuration(OPEN_DURATION);
+            mContentAnim.addListener(this);
+        }
+
+        void startAnimation(boolean appearing) {
+            if (DEBUG) Slog.d(TAG, "startAnimation(appearing=" + appearing + ")");
+
+            createAnimation(appearing);
+
+            mContentParent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+            mContentAnim.start();
+
+            mVisible = appearing;
+        }
+
+        void jumpTo(boolean appearing) {
+//            setBgAlpha(appearing ? 255 : 0);
+            mContentParent.setTranslationY(appearing ? 0 : mPanelHeight);
         }
 
         public void setPanelHeight(int h) {
+            if (DEBUG) Slog.d(TAG, "panelHeight=" + h);
             mPanelHeight = h;
-            if (mPanelBottom == 0) {
+            if (mPanelHeight == 0) {
                 // fully closed, no animation necessary
-                setPanelBottom(0);
             } else if (mVisible) {
                 if (DEBUG) {
                     Slog.d(TAG, "panelHeight not zero but trying to open; scheduling an anim to open fully");
@@ -312,17 +275,18 @@
         }
 
         public void onAnimationCancel(Animator animation) {
-            if (DEBUG) Slog.d(TAG, "onAnimationCancel mBgAlpha=" + mBgAlpha);
+            if (DEBUG) Slog.d(TAG, "onAnimationCancel");
             // force this to zero so we close the window
-            mBgAlpha = 0;
+            mVisible = false;
         }
 
         public void onAnimationEnd(Animator animation) {
-            if (DEBUG) Slog.d(TAG, "onAnimationEnd mBgAlpha=" + mBgAlpha);
-            if (mBgAlpha == 0) {
+            if (DEBUG) Slog.d(TAG, "onAnimationEnd");
+            if (! mVisible) {
                 setVisibility(View.GONE);
             }
-            mBgAnim = null;
+            mContentParent.setLayerType(View.LAYER_TYPE_NONE, null);
+            mContentAnim = null;
         }
 
         public void onAnimationRepeat(Animator animation) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationTitleArea.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationTitleArea.java
deleted file mode 100644
index d4413db..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationTitleArea.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Paint;
-import android.graphics.Canvas;
-import android.util.AttributeSet;
-import android.util.Slog;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import com.android.systemui.R;
-
-public class NotificationTitleArea extends RelativeLayout {
-    static final String TAG = "NotificationTitleArea";
-
-    View mSettingsButton;
-    View mNotificationButton;
-    View mNotificationScroller;
-    FrameLayout mSettingsFrame;
-    View mSettingsPanel;
-
-    // for drawing the background
-    Bitmap mTexture;
-    Paint mPaint;
-    int mTextureWidth;
-    int mTextureHeight;
-    
-
-    public NotificationTitleArea(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public NotificationTitleArea(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-
-        // for drawing the background
-        mTexture = BitmapFactory.decodeResource(getResources(), R.drawable.panel_notification);
-        mTextureWidth = mTexture.getWidth();
-        mTextureHeight = mTexture.getHeight();
-
-        mPaint = new Paint();
-        mPaint.setDither(false);
-    }
-
-    public void onFinishInflate() {
-        super.onFinishInflate();
-        setWillNotDraw(false);
-    }
-
-    @Override
-    public void onDraw(Canvas canvas) {
-        final Bitmap texture = mTexture;
-        final Paint paint = mPaint;
-
-        final int width = getWidth();
-        final int height = getHeight();
-
-        final int textureWidth = mTextureWidth;
-        final int textureHeight = mTextureHeight;
-
-        int x = 0;
-        int y;
-
-        while (x < width) {
-            y = 0;
-            while (y < height) {
-                canvas.drawBitmap(texture, x, y, paint);
-                y += textureHeight;
-            }
-            x += textureWidth;
-        }
-    }
-}
-
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
index 612427b..53c30fe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java
@@ -252,7 +252,11 @@
 
     private void refreshApplicationList() {
         mActivityDescriptions = getRecentTasks();
-        updateUiElements(getResources().getConfiguration(), true);
+        if (mActivityDescriptions.size() > 0) {
+            updateUiElements(getResources().getConfiguration(), true);
+        } else {
+            mBar.animateCollapse();
+        }
     }
 
     private Bitmap compositeBitmap(Bitmap background, Bitmap thumbnail) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
index b9206ea..2ebd067 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java
@@ -163,7 +163,7 @@
                         shadow = new DragShadowBuilder(mWindow.findViewById(R.id.preview));
                     }
 
-                    v.startDrag(clip, shadow, false, null);
+                    v.startDrag(clip, shadow, null, 0);
 
                     // TODO: only discard the clipping if it was accepted
                     stash(null);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 9ddb432..f858f61 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -74,7 +74,8 @@
 import com.android.systemui.statusbar.policy.NetworkController;
 import com.android.systemui.recent.RecentApplicationsActivity;
 
-public class TabletStatusBar extends StatusBar {
+public class TabletStatusBar extends StatusBar implements
+        HeightReceiver.OnBarHeightChangedListener {
     public static final boolean DEBUG = false;
     public static final String TAG = "TabletStatusBar";
 
@@ -97,7 +98,9 @@
 
     public static final int LIGHTS_ON_DELAY = 5000;
 
-    int mBarHeight = -1;
+    // The height of the bar, as definied by the build.  It may be taller if we're plugged
+    // into hdmi.
+    int mNaturalBarHeight = -1;
     int mIconSize = -1;
     int mIconHPadding = -1;
 
@@ -134,6 +137,7 @@
 
     ViewGroup mPile;
 
+    HeightReceiver mHeightReceiver;
     BatteryController mBatteryController;
     NetworkController mNetworkController;
 
@@ -183,7 +187,7 @@
         mStatusBarView.setIgnoreChildren(0, mNotificationTrigger, mNotificationPanel);
 
         WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
-                ViewGroup.LayoutParams.MATCH_PARENT,
+                720, // ViewGroup.LayoutParams.MATCH_PARENT,
                 ViewGroup.LayoutParams.MATCH_PARENT,
                 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL,
                 WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
@@ -196,6 +200,7 @@
         lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED
                 | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
         lp.windowAnimations = com.android.internal.R.style.Animation; // == no animation
+//        lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade
 
         WindowManagerImpl.getDefault().addView(mNotificationPanel, lp);
 
@@ -268,15 +273,15 @@
     }
 
     @Override
-    protected void onConfigurationChanged (Configuration newConfig) {
+    protected void onConfigurationChanged(Configuration newConfig) {
         loadDimens();
     }
 
     protected void loadDimens() {
         final Resources res = mContext.getResources();
 
-        mBarHeight = res.getDimensionPixelSize(
-            com.android.internal.R.dimen.status_bar_height);
+        mNaturalBarHeight = res.getDimensionPixelSize(
+                com.android.internal.R.dimen.status_bar_height);
 
         int newIconSize = res.getDimensionPixelSize(
             com.android.internal.R.dimen.status_bar_icon_size);
@@ -297,6 +302,10 @@
         mWindowManager = IWindowManager.Stub.asInterface(
                 ServiceManager.getService(Context.WINDOW_SERVICE));
 
+        // This guy will listen for HDMI plugged broadcasts so we can resize the
+        // status bar as appropriate.
+        mHeightReceiver = new HeightReceiver(mContext);
+        mHeightReceiver.registerReceiver();
         loadDimens();
 
         final TabletStatusBarView sb = (TabletStatusBarView)View.inflate(
@@ -407,13 +416,33 @@
         ScrollView scroller = (ScrollView)mPile.getParent();
         scroller.setFillViewport(true);
 
+        mHeightReceiver.addOnBarHeightChangedListener(this);
+
         return sb;
     }
 
+    public int getStatusBarHeight() {
+        return mHeightReceiver.getHeight();
+    }
+
     protected int getStatusBarGravity() {
         return Gravity.BOTTOM | Gravity.FILL_HORIZONTAL;
     }
 
+    public void onBarHeightChanged(int height) {
+        final WindowManager.LayoutParams lp
+                = (WindowManager.LayoutParams)mStatusBarView.getLayoutParams();
+        if (lp == null) {
+            // haven't been added yet
+            return;
+        }
+        if (lp.height != height) {
+            lp.height = height;
+            final WindowManager wm = WindowManagerImpl.getDefault();
+            wm.updateViewLayout(mStatusBarView, lp);
+        }
+    }
+
     private class H extends Handler {
         public void handleMessage(Message m) {
             switch (m.what) {
@@ -1047,7 +1076,7 @@
         if (mIconLayout == null) return;
 
         final LinearLayout.LayoutParams params
-            = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mBarHeight);
+            = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight);
 
         int N = mNotns.size();
 
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
index 82753b2..6b52454 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
@@ -18,6 +18,11 @@
 
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
 import android.media.AudioManager;
 import android.telephony.TelephonyManager;
 import android.view.KeyEvent;
@@ -37,12 +42,34 @@
  */
 public abstract class KeyguardViewBase extends FrameLayout {
 
+    private static final int BACKGROUND_COLOR = 0x70000000;
     private KeyguardViewCallback mCallback;
     private AudioManager mAudioManager;
     private TelephonyManager mTelephonyManager = null;
 
     public KeyguardViewBase(Context context) {
         super(context);
+
+        // This is a faster way to draw the background on devices without hardware acceleration
+        setBackgroundDrawable(new Drawable() {
+            @Override
+            public void draw(Canvas canvas) {
+                canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC);
+            }
+
+            @Override
+            public void setAlpha(int alpha) {
+            }
+
+            @Override
+            public void setColorFilter(ColorFilter cf) {
+            }
+
+            @Override
+            public int getOpacity() {
+                return PixelFormat.TRANSLUCENT;
+            }
+        });
     }
 
     // used to inject callback
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 38eed50..1fc2e6c 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -15,6 +15,9 @@
 
 package com.android.internal.policy.impl;
 
+import static android.view.View.MeasureSpec.AT_MOST;
+import static android.view.View.MeasureSpec.EXACTLY;
+import static android.view.View.MeasureSpec.getMode;
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
 import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
@@ -52,6 +55,7 @@
 import android.os.Parcelable;
 import android.util.AndroidRuntimeException;
 import android.util.Config;
+import android.util.DisplayMetrics;
 import android.util.EventLog;
 import android.util.Log;
 import android.util.SparseArray;
@@ -72,6 +76,7 @@
 import android.view.ViewStub;
 import android.view.Window;
 import android.view.WindowManager;
+import android.view.View.MeasureSpec;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
 import android.view.animation.Animation;
@@ -98,7 +103,10 @@
      * Simple callback used by the context menu and its submenus. The options
      * menu submenus do not use this (their behavior is more complex).
      */
-    DialogMenuCallback mContextMenuCallback = new DialogMenuCallback(FEATURE_CONTEXT_MENU);
+    final DialogMenuCallback mContextMenuCallback = new DialogMenuCallback(FEATURE_CONTEXT_MENU);
+
+    final TypedValue mMinWidthMajor = new TypedValue();
+    final TypedValue mMinWidthMinor = new TypedValue();
 
     // This is the top-level view of the window, containing the window decor.
     private DecorView mDecor;
@@ -1866,6 +1874,45 @@
         }
 
         @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
+            final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;
+
+            final int widthMode = getMode(widthMeasureSpec);
+
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+            int width = getMeasuredWidth();
+            boolean measure = false;
+
+            widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, EXACTLY);
+
+            final TypedValue tv = isPortrait ? mMinWidthMinor : mMinWidthMajor;
+
+            if (widthMode == AT_MOST && tv.type != TypedValue.TYPE_NULL) {
+                final int min;
+                if (tv.type == TypedValue.TYPE_DIMENSION) {
+                    min = (int)tv.getDimension(metrics);
+                } else if (tv.type == TypedValue.TYPE_FRACTION) {
+                    min = (int)tv.getFraction(metrics.widthPixels, metrics.widthPixels);
+                } else {
+                    min = 0;
+                }
+
+                if (width < min) {
+                    widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
+                    measure = true;
+                }
+            }
+
+            // TODO: Support height?
+
+            if (measure) {
+                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+            }
+        }
+
+        @Override
         public void draw(Canvas canvas) {
             super.draw(canvas);
 
@@ -2274,6 +2321,9 @@
             setFlags(FLAG_SPLIT_TOUCH, FLAG_SPLIT_TOUCH&(~getForcedWindowFlags()));
         }
 
+        a.getValue(com.android.internal.R.styleable.Window_windowMinWidthMajor, mMinWidthMajor);
+        a.getValue(com.android.internal.R.styleable.Window_windowMinWidthMinor, mMinWidthMinor);
+
         if (getContext().getApplicationInfo().targetSdkVersion
                 < android.os.Build.VERSION_CODES.HONEYCOMB) {
             addFlags(WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY);
@@ -2329,7 +2379,10 @@
         // System.out.println("Features: 0x" + Integer.toHexString(features));
         if ((features & ((1 << FEATURE_LEFT_ICON) | (1 << FEATURE_RIGHT_ICON))) != 0) {
             if (mIsFloating) {
-                layoutResource = com.android.internal.R.layout.dialog_title_icons;
+                TypedValue res = new TypedValue();
+                getContext().getTheme().resolveAttribute(
+                        com.android.internal.R.attr.dialogTitleIconsDecorLayout, res, true);
+                layoutResource = res.resourceId;
             } else {
                 layoutResource = com.android.internal.R.layout.screen_title_icons;
             }
@@ -2346,7 +2399,10 @@
             // Special case for a window with a custom title.
             // If the window is floating, we need a dialog layout
             if (mIsFloating) {
-                layoutResource = com.android.internal.R.layout.dialog_custom_title;
+                TypedValue res = new TypedValue();
+                getContext().getTheme().resolveAttribute(
+                        com.android.internal.R.attr.dialogCustomTitleDecorLayout, res, true);
+                layoutResource = res.resourceId;
             } else {
                 layoutResource = com.android.internal.R.layout.screen_custom_title;
             }
@@ -2356,7 +2412,10 @@
             // If no other features and not embedded, only need a title.
             // If the window is floating, we need a dialog layout
             if (mIsFloating) {
-                layoutResource = com.android.internal.R.layout.dialog_title;
+                TypedValue res = new TypedValue();
+                getContext().getTheme().resolveAttribute(
+                        com.android.internal.R.attr.dialogTitleDecorLayout, res, true);
+                layoutResource = res.resourceId;
             } else if ((features & (1 << FEATURE_ACTION_BAR)) != 0) {
                 if ((features & (1 << FEATURE_ACTION_BAR_OVERLAY)) != 0) {
                     layoutResource = com.android.internal.R.layout.screen_action_bar_overlay;
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 3e8318e..243fa07 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -122,6 +122,8 @@
 import android.media.AudioManager;
 
 import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
 import java.util.ArrayList;
 
 /**
@@ -712,6 +714,8 @@
         if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) {
             mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi");
         }
+        mHdmiPlugged = !readHdmiState();
+        setHdmiPlugged(!mHdmiPlugged);
 
         // Note: the Configuration is not stable here, so we cannot load mStatusBarCanHide from
         // config_statusBarCanHide because the latter depends on the screen size
@@ -2000,11 +2004,40 @@
             mHdmiPlugged = plugged;
             updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
             Intent intent = new Intent(ACTION_HDMI_PLUGGED);
+            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
             intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged);
             mContext.sendStickyBroadcast(intent);
         }
     }
 
+    boolean readHdmiState() {
+        final String filename = "/sys/class/switch/hdmi/state";
+        FileReader reader = null;
+        try {
+            reader = new FileReader(filename);
+            char[] buf = new char[15];
+            int n = reader.read(buf);
+            if (n > 1) {
+                return 0 != Integer.parseInt(new String(buf, 0, n-1));
+            } else {
+                return false;
+            }
+        } catch (IOException ex) {
+            Slog.d(TAG, "couldn't read hdmi state from " + filename + ": " + ex);
+            return false;
+        } catch (NumberFormatException ex) {
+            Slog.d(TAG, "couldn't read hdmi state from " + filename + ": " + ex);
+            return false;
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException ex) {
+                }
+            }
+        }
+    }
+
     /**
      * @return Whether music is being played right now.
      */
diff --git a/services/input/Android.mk b/services/input/Android.mk
index 37804ff..d7b61fc 100644
--- a/services/input/Android.mk
+++ b/services/input/Android.mk
@@ -21,6 +21,7 @@
     InputDispatcher.cpp \
     InputManager.cpp \
     InputReader.cpp \
+    InputWindow.cpp \
     PointerController.cpp
 
 LOCAL_SHARED_LIBRARIES := \
diff --git a/services/input/InputApplication.h b/services/input/InputApplication.h
new file mode 100644
index 0000000..cc80062
--- /dev/null
+++ b/services/input/InputApplication.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef _UI_INPUT_APPLICATION_H
+#define _UI_INPUT_APPLICATION_H
+
+#include <ui/Input.h>
+
+#include <utils/RefBase.h>
+#include <utils/Timers.h>
+#include <utils/String8.h>
+
+namespace android {
+
+/*
+ * A handle to an application that can receive input.
+ * Used by the native input dispatcher to indirectly refer to the window manager objects
+ * that describe an application.
+ */
+class InputApplicationHandle : public RefBase {
+protected:
+    InputApplicationHandle() { }
+    virtual ~InputApplicationHandle() { }
+};
+
+
+/*
+ * An input application describes properties of an application that can receive input.
+ */
+struct InputApplication {
+    sp<InputApplicationHandle> inputApplicationHandle;
+    String8 name;
+    nsecs_t dispatchingTimeout;
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_APPLICATION_H
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index 89a7751..b5a4bd2 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -72,6 +72,10 @@
 // when an application takes too long to respond and the user has pressed an app switch key.
 const nsecs_t APP_SWITCH_TIMEOUT = 500 * 1000000LL; // 0.5sec
 
+// Amount of time to allow for an event to be dispatched (measured since its eventTime)
+// before considering it stale and dropping it.
+const nsecs_t STALE_EVENT_TIMEOUT = 10000 * 1000000LL; // 10sec
+
 
 static inline nsecs_t now() {
     return systemTime(SYSTEM_TIME_MONOTONIC);
@@ -151,34 +155,12 @@
 }
 
 
-// --- InputWindow ---
-
-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
-            || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY;
-}
-
-bool InputWindow::supportsSplitTouch() const {
-    return layoutParamsFlags & InputWindow::FLAG_SPLIT_TOUCH;
-}
-
-
 // --- InputDispatcher ---
 
 InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& policy) :
     mPolicy(policy),
-    mPendingEvent(NULL), mAppSwitchDueTime(LONG_LONG_MAX),
+    mPendingEvent(NULL), mAppSwitchSawKeyDown(false), mAppSwitchDueTime(LONG_LONG_MAX),
+    mNextUnblockedEvent(NULL),
     mDispatchEnabled(true), mDispatchFrozen(false),
     mFocusedWindow(NULL),
     mFocusedApplication(NULL),
@@ -368,6 +350,7 @@
     }
 
     // Now we have an event to dispatch.
+    // All events are eventually dequeued and processed this way, even if we intend to drop them.
     assert(mPendingEvent != NULL);
     bool done = false;
     DropReason dropReason = DROP_REASON_NOT_DROPPED;
@@ -376,6 +359,11 @@
     } else if (!mDispatchEnabled) {
         dropReason = DROP_REASON_DISABLED;
     }
+
+    if (mNextUnblockedEvent == mPendingEvent) {
+        mNextUnblockedEvent = NULL;
+    }
+
     switch (mPendingEvent->type) {
     case EventEntry::TYPE_CONFIGURATION_CHANGED: {
         ConfigurationChangedEntry* typedEntry =
@@ -395,6 +383,13 @@
                 dropReason = DROP_REASON_APP_SWITCH;
             }
         }
+        if (dropReason == DROP_REASON_NOT_DROPPED
+                && isStaleEventLocked(currentTime, typedEntry)) {
+            dropReason = DROP_REASON_STALE;
+        }
+        if (dropReason == DROP_REASON_NOT_DROPPED && mNextUnblockedEvent) {
+            dropReason = DROP_REASON_BLOCKED;
+        }
         done = dispatchKeyLocked(currentTime, typedEntry, keyRepeatTimeout,
                 &dropReason, nextWakeupTime);
         break;
@@ -405,6 +400,13 @@
         if (dropReason == DROP_REASON_NOT_DROPPED && isAppSwitchDue) {
             dropReason = DROP_REASON_APP_SWITCH;
         }
+        if (dropReason == DROP_REASON_NOT_DROPPED
+                && isStaleEventLocked(currentTime, typedEntry)) {
+            dropReason = DROP_REASON_STALE;
+        }
+        if (dropReason == DROP_REASON_NOT_DROPPED && mNextUnblockedEvent) {
+            dropReason = DROP_REASON_BLOCKED;
+        }
         done = dispatchMotionLocked(currentTime, typedEntry,
                 &dropReason, nextWakeupTime);
         break;
@@ -431,6 +433,9 @@
 
     switch (entry->type) {
     case EventEntry::TYPE_KEY: {
+        // Optimize app switch latency.
+        // If the application takes too long to catch up then we drop all events preceding
+        // the app switch key.
         KeyEntry* keyEntry = static_cast<KeyEntry*>(entry);
         if (isAppSwitchKeyEventLocked(keyEntry)) {
             if (keyEntry->action == AKEY_EVENT_ACTION_DOWN) {
@@ -448,11 +453,63 @@
         }
         break;
     }
+
+    case EventEntry::TYPE_MOTION: {
+        // Optimize case where the current application is unresponsive and the user
+        // decides to touch a window in a different application.
+        // If the application takes too long to catch up then we drop all events preceding
+        // the touch into the other window.
+        MotionEntry* motionEntry = static_cast<MotionEntry*>(entry);
+        if (motionEntry->action == AMOTION_EVENT_ACTION_DOWN
+                && (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER)
+                && mInputTargetWaitCause == INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY
+                && mInputTargetWaitApplication != NULL) {
+            int32_t x = int32_t(motionEntry->firstSample.pointerCoords[0].x);
+            int32_t y = int32_t(motionEntry->firstSample.pointerCoords[0].y);
+            const InputWindow* touchedWindow = findTouchedWindowAtLocked(x, y);
+            if (touchedWindow
+                    && touchedWindow->inputWindowHandle != NULL
+                    && touchedWindow->inputWindowHandle->getInputApplicationHandle()
+                            != mInputTargetWaitApplication) {
+                // User touched a different application than the one we are waiting on.
+                // Flag the event, and start pruning the input queue.
+                mNextUnblockedEvent = motionEntry;
+                needWake = true;
+            }
+        }
+        break;
+    }
     }
 
     return needWake;
 }
 
+const InputWindow* InputDispatcher::findTouchedWindowAtLocked(int32_t x, int32_t y) {
+    // Traverse windows from front to back to find touched window.
+    size_t numWindows = mWindows.size();
+    for (size_t i = 0; i < numWindows; i++) {
+        const InputWindow* window = & mWindows.editItemAt(i);
+        int32_t flags = window->layoutParamsFlags;
+
+        if (window->visible) {
+            if (!(flags & InputWindow::FLAG_NOT_TOUCHABLE)) {
+                bool isTouchModal = (flags & (InputWindow::FLAG_NOT_FOCUSABLE
+                        | InputWindow::FLAG_NOT_TOUCH_MODAL)) == 0;
+                if (isTouchModal || window->touchableAreaContainsPoint(x, y)) {
+                    // Found window.
+                    return window;
+                }
+            }
+        }
+
+        if (flags & InputWindow::FLAG_SYSTEM_ERROR) {
+            // Error window is on top but not visible, so touch is dropped.
+            return NULL;
+        }
+    }
+    return NULL;
+}
+
 void InputDispatcher::dropInboundEventLocked(EventEntry* entry, DropReason dropReason) {
     const char* reason;
     switch (dropReason) {
@@ -470,6 +527,16 @@
         LOGI("Dropped event because of pending overdue app switch.");
         reason = "inbound event was dropped because of pending overdue app switch";
         break;
+    case DROP_REASON_BLOCKED:
+        LOGI("Dropped event because the current application is not responding and the user "
+                "has started interating with a different application.");
+        reason = "inbound event was dropped because the current application is not responding "
+                "and the user has started interating with a different application";
+        break;
+    case DROP_REASON_STALE:
+        LOGI("Dropped event because it is stale.");
+        reason = "inbound event was dropped because it is stale";
+        break;
     default:
         assert(false);
         return;
@@ -521,6 +588,10 @@
 #endif
 }
 
+bool InputDispatcher::isStaleEventLocked(nsecs_t currentTime, EventEntry* entry) {
+    return currentTime - entry->eventTime >= STALE_EVENT_TIMEOUT;
+}
+
 bool InputDispatcher::runCommandsLockedInterruptible() {
     if (mCommandQueue.isEmpty()) {
         return false;
@@ -670,7 +741,7 @@
             CommandEntry* commandEntry = postCommandLocked(
                     & InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible);
             if (mFocusedWindow) {
-                commandEntry->inputChannel = mFocusedWindow->inputChannel;
+                commandEntry->inputWindowHandle = mFocusedWindow->inputWindowHandle;
             }
             commandEntry->keyEntry = entry;
             entry->refCount += 1;
@@ -848,6 +919,7 @@
     mCurrentInputTargetsValid = false;
     mCurrentInputTargets.clear();
     mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_NONE;
+    mInputTargetWaitApplication.clear();
 }
 
 void InputDispatcher::commitTargetsLocked() {
@@ -866,6 +938,7 @@
             mInputTargetWaitStartTime = currentTime;
             mInputTargetWaitTimeoutTime = LONG_LONG_MAX;
             mInputTargetWaitTimeoutExpired = false;
+            mInputTargetWaitApplication.clear();
         }
     } else {
         if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY) {
@@ -880,6 +953,15 @@
             mInputTargetWaitStartTime = currentTime;
             mInputTargetWaitTimeoutTime = currentTime + timeout;
             mInputTargetWaitTimeoutExpired = false;
+            mInputTargetWaitApplication.clear();
+
+            if (window && window->inputWindowHandle != NULL) {
+                mInputTargetWaitApplication =
+                        window->inputWindowHandle->getInputApplicationHandle();
+            }
+            if (mInputTargetWaitApplication == NULL && application) {
+                mInputTargetWaitApplication = application->inputApplicationHandle;
+            }
         }
     }
 
@@ -2624,7 +2706,7 @@
 void InputDispatcher::releaseFocusedApplicationLocked() {
     if (mFocusedApplication) {
         mFocusedApplication = NULL;
-        mFocusedApplicationStorage.handle.clear();
+        mFocusedApplicationStorage.inputApplicationHandle.clear();
     }
 }
 
@@ -2860,7 +2942,8 @@
     }
 }
 
-status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChannel, bool monitor) {
+status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChannel,
+        const sp<InputWindowHandle>& inputWindowHandle, bool monitor) {
 #if DEBUG_REGISTRATION
     LOGD("channel '%s' ~ registerInputChannel - monitor=%s", inputChannel->getName().string(),
             toString(monitor));
@@ -2875,7 +2958,7 @@
             return BAD_VALUE;
         }
 
-        sp<Connection> connection = new Connection(inputChannel);
+        sp<Connection> connection = new Connection(inputChannel, inputWindowHandle);
         status_t status = connection->initialize();
         if (status) {
             LOGE("Failed to initialize input publisher for input channel '%s', status=%d",
@@ -3002,9 +3085,10 @@
     CommandEntry* commandEntry = postCommandLocked(
             & InputDispatcher::doNotifyANRLockedInterruptible);
     if (application) {
-        commandEntry->inputApplicationHandle = application->handle;
+        commandEntry->inputApplicationHandle = application->inputApplicationHandle;
     }
     if (window) {
+        commandEntry->inputWindowHandle = window->inputWindowHandle;
         commandEntry->inputChannel = window->inputChannel;
     }
 }
@@ -3025,7 +3109,7 @@
     if (connection->status != Connection::STATUS_ZOMBIE) {
         mLock.unlock();
 
-        mPolicy->notifyInputChannelBroken(connection->inputChannel);
+        mPolicy->notifyInputChannelBroken(connection->inputWindowHandle);
 
         mLock.lock();
     }
@@ -3036,7 +3120,7 @@
     mLock.unlock();
 
     nsecs_t newTimeout = mPolicy->notifyANR(
-            commandEntry->inputApplicationHandle, commandEntry->inputChannel);
+            commandEntry->inputApplicationHandle, commandEntry->inputWindowHandle);
 
     mLock.lock();
 
@@ -3052,7 +3136,7 @@
 
     mLock.unlock();
 
-    bool consumed = mPolicy->interceptKeyBeforeDispatching(commandEntry->inputChannel,
+    bool consumed = mPolicy->interceptKeyBeforeDispatching(commandEntry->inputWindowHandle,
             &event, entry->policyFlags);
 
     mLock.lock();
@@ -3095,7 +3179,7 @@
 
                     mLock.unlock();
 
-                    bool fallback = mPolicy->dispatchUnhandledKey(connection->inputChannel,
+                    bool fallback = mPolicy->dispatchUnhandledKey(connection->inputWindowHandle,
                             &event, keyEntry->policyFlags, &event);
 
                     mLock.lock();
@@ -3604,8 +3688,10 @@
 
 // --- InputDispatcher::Connection ---
 
-InputDispatcher::Connection::Connection(const sp<InputChannel>& inputChannel) :
-        status(STATUS_NORMAL), inputChannel(inputChannel), inputPublisher(inputChannel),
+InputDispatcher::Connection::Connection(const sp<InputChannel>& inputChannel,
+        const sp<InputWindowHandle>& inputWindowHandle) :
+        status(STATUS_NORMAL), inputChannel(inputChannel), inputWindowHandle(inputWindowHandle),
+        inputPublisher(inputChannel),
         lastEventTime(LONG_LONG_MAX), lastDispatchTime(LONG_LONG_MAX) {
 }
 
diff --git a/services/input/InputDispatcher.h b/services/input/InputDispatcher.h
index c8beab2..11e5117 100644
--- a/services/input/InputDispatcher.h
+++ b/services/input/InputDispatcher.h
@@ -33,6 +33,9 @@
 #include <unistd.h>
 #include <limits.h>
 
+#include "InputWindow.h"
+#include "InputApplication.h"
+
 
 namespace android {
 
@@ -116,137 +119,6 @@
 
 
 /*
- * An input window describes the bounds of a window that can receive input.
- */
-struct InputWindow {
-    // Window flags from WindowManager.LayoutParams
-    enum {
-        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001,
-        FLAG_DIM_BEHIND        = 0x00000002,
-        FLAG_BLUR_BEHIND        = 0x00000004,
-        FLAG_NOT_FOCUSABLE      = 0x00000008,
-        FLAG_NOT_TOUCHABLE      = 0x00000010,
-        FLAG_NOT_TOUCH_MODAL    = 0x00000020,
-        FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
-        FLAG_KEEP_SCREEN_ON     = 0x00000080,
-        FLAG_LAYOUT_IN_SCREEN   = 0x00000100,
-        FLAG_LAYOUT_NO_LIMITS   = 0x00000200,
-        FLAG_FULLSCREEN      = 0x00000400,
-        FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800,
-        FLAG_DITHER             = 0x00001000,
-        FLAG_SECURE             = 0x00002000,
-        FLAG_SCALED             = 0x00004000,
-        FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000,
-        FLAG_LAYOUT_INSET_DECOR = 0x00010000,
-        FLAG_ALT_FOCUSABLE_IM = 0x00020000,
-        FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
-        FLAG_SHOW_WHEN_LOCKED = 0x00080000,
-        FLAG_SHOW_WALLPAPER = 0x00100000,
-        FLAG_TURN_SCREEN_ON = 0x00200000,
-        FLAG_DISMISS_KEYGUARD = 0x00400000,
-        FLAG_SPLIT_TOUCH = 0x00800000,
-        FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000,
-        FLAG_COMPATIBLE_WINDOW = 0x20000000,
-        FLAG_SYSTEM_ERROR = 0x40000000,
-    };
-
-    // Window types from WindowManager.LayoutParams
-    enum {
-        FIRST_APPLICATION_WINDOW = 1,
-        TYPE_BASE_APPLICATION   = 1,
-        TYPE_APPLICATION        = 2,
-        TYPE_APPLICATION_STARTING = 3,
-        LAST_APPLICATION_WINDOW = 99,
-        FIRST_SUB_WINDOW        = 1000,
-        TYPE_APPLICATION_PANEL  = FIRST_SUB_WINDOW,
-        TYPE_APPLICATION_MEDIA  = FIRST_SUB_WINDOW+1,
-        TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2,
-        TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3,
-        TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW+4,
-        LAST_SUB_WINDOW         = 1999,
-        FIRST_SYSTEM_WINDOW     = 2000,
-        TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW,
-        TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1,
-        TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2,
-        TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3,
-        TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4,
-        TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5,
-        TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6,
-        TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7,
-        TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8,
-        TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9,
-        TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10,
-        TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11,
-        TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12,
-        TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13,
-        TYPE_STATUS_BAR_SUB_PANEL  = FIRST_SYSTEM_WINDOW+14,
-        TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
-        TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16,
-        TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+17,
-        LAST_SYSTEM_WINDOW      = 2999,
-    };
-
-    sp<InputChannel> inputChannel;
-    String8 name;
-    int32_t layoutParamsFlags;
-    int32_t layoutParamsType;
-    nsecs_t dispatchingTimeout;
-    int32_t frameLeft;
-    int32_t frameTop;
-    int32_t frameRight;
-    int32_t frameBottom;
-    int32_t visibleFrameLeft;
-    int32_t visibleFrameTop;
-    int32_t visibleFrameRight;
-    int32_t visibleFrameBottom;
-    int32_t touchableAreaLeft;
-    int32_t touchableAreaTop;
-    int32_t touchableAreaRight;
-    int32_t touchableAreaBottom;
-    bool visible;
-    bool canReceiveKeys;
-    bool hasFocus;
-    bool hasWallpaper;
-    bool paused;
-    int32_t layer;
-    int32_t ownerPid;
-    int32_t ownerUid;
-
-    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;
-
-    bool supportsSplitTouch() const;
-};
-
-
-/*
- * A private handle type used by the input manager to track the window.
- */
-class InputApplicationHandle : public RefBase {
-protected:
-    InputApplicationHandle() { }
-    virtual ~InputApplicationHandle() { }
-};
-
-
-/*
- * An input application describes properties of an application that can receive input.
- */
-struct InputApplication {
-    String8 name;
-    nsecs_t dispatchingTimeout;
-    sp<InputApplicationHandle> handle;
-};
-
-
-/*
  * Input dispatcher policy interface.
  *
  * The input reader policy is used by the input reader to interact with the Window Manager
@@ -267,10 +139,10 @@
     /* Notifies the system that an application is not responding.
      * Returns a new timeout to continue waiting, or 0 to abort dispatch. */
     virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
-            const sp<InputChannel>& inputChannel) = 0;
+            const sp<InputWindowHandle>& inputWindowHandle) = 0;
 
     /* Notifies the system that an input channel is unrecoverably broken. */
-    virtual void notifyInputChannelBroken(const sp<InputChannel>& inputChannel) = 0;
+    virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) = 0;
 
     /* Gets the key repeat initial timeout or -1 if automatic key repeating is disabled. */
     virtual nsecs_t getKeyRepeatTimeout() = 0;
@@ -303,12 +175,12 @@
     virtual void interceptGenericBeforeQueueing(nsecs_t when, uint32_t& policyFlags) = 0;
 
     /* Allows the policy a chance to intercept a key before dispatching. */
-    virtual bool interceptKeyBeforeDispatching(const sp<InputChannel>& inputChannel,
+    virtual bool interceptKeyBeforeDispatching(const sp<InputWindowHandle>& inputWindowHandle,
             const KeyEvent* keyEvent, uint32_t policyFlags) = 0;
 
     /* Allows the policy a chance to perform default processing for an unhandled key.
      * Returns an alternate keycode to redispatch as a fallback, or 0 to give up. */
-    virtual bool dispatchUnhandledKey(const sp<InputChannel>& inputChannel,
+    virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle,
             const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) = 0;
 
     /* Notifies the policy about switch events.
@@ -407,7 +279,8 @@
      *
      * These methods may be called on any thread (usually by the input manager).
      */
-    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel, bool monitor) = 0;
+    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel,
+            const sp<InputWindowHandle>& inputWindowHandle, bool monitor) = 0;
     virtual status_t unregisterInputChannel(const sp<InputChannel>& inputChannel) = 0;
 };
 
@@ -461,7 +334,8 @@
     virtual bool transferTouchFocus(const sp<InputChannel>& fromChannel,
             const sp<InputChannel>& toChannel);
 
-    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel, bool monitor);
+    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel,
+            const sp<InputWindowHandle>& inputWindowHandle, bool monitor);
     virtual status_t unregisterInputChannel(const sp<InputChannel>& inputChannel);
 
 private:
@@ -615,6 +489,7 @@
         KeyEntry* keyEntry;
         sp<InputChannel> inputChannel;
         sp<InputApplicationHandle> inputApplicationHandle;
+        sp<InputWindowHandle> inputWindowHandle;
         int32_t userActivityEventType;
         bool handled;
     };
@@ -815,7 +690,8 @@
         };
 
         Status status;
-        sp<InputChannel> inputChannel;
+        sp<InputChannel> inputChannel; // never null
+        sp<InputWindowHandle> inputWindowHandle; // may be null
         InputPublisher inputPublisher;
         InputState inputState;
         Queue<DispatchEntry> outboundQueue;
@@ -823,7 +699,8 @@
         nsecs_t lastEventTime; // the time when the event was originally captured
         nsecs_t lastDispatchTime; // the time when the last event was dispatched
 
-        explicit Connection(const sp<InputChannel>& inputChannel);
+        explicit Connection(const sp<InputChannel>& inputChannel,
+                const sp<InputWindowHandle>& inputWindowHandle);
 
         inline const char* getInputChannelName() const { return inputChannel->getName().string(); }
 
@@ -851,6 +728,8 @@
         DROP_REASON_POLICY = 1,
         DROP_REASON_APP_SWITCH = 2,
         DROP_REASON_DISABLED = 3,
+        DROP_REASON_BLOCKED = 4,
+        DROP_REASON_STALE = 5,
     };
 
     sp<InputDispatcherPolicyInterface> mPolicy;
@@ -884,6 +763,15 @@
     bool isAppSwitchPendingLocked();
     void resetPendingAppSwitchLocked(bool handled);
 
+    // Stale event latency optimization.
+    static bool isStaleEventLocked(nsecs_t currentTime, EventEntry* entry);
+
+    // Blocked event latency optimization.  Drops old events when the user intends
+    // to transfer focus to a new application.
+    EventEntry* mNextUnblockedEvent;
+
+    const InputWindow* findTouchedWindowAtLocked(int32_t x, int32_t y);
+
     // All registered connections mapped by receive pipe file descriptor.
     KeyedVector<int, sp<Connection> > mConnectionsByReceiveFd;
 
@@ -1006,6 +894,7 @@
     nsecs_t mInputTargetWaitStartTime;
     nsecs_t mInputTargetWaitTimeoutTime;
     bool mInputTargetWaitTimeoutExpired;
+    sp<InputApplicationHandle> mInputTargetWaitApplication;
 
     // Finding targets for input events.
     void resetTargetsLocked();
diff --git a/services/input/InputWindow.cpp b/services/input/InputWindow.cpp
new file mode 100644
index 0000000..9ce45f5
--- /dev/null
+++ b/services/input/InputWindow.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#define LOG_TAG "InputWindow"
+
+#include "InputWindow.h"
+
+#include <cutils/log.h>
+
+namespace android {
+
+// --- InputWindow ---
+
+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
+            || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY;
+}
+
+bool InputWindow::supportsSplitTouch() const {
+    return layoutParamsFlags & InputWindow::FLAG_SPLIT_TOUCH;
+}
+
+} // namespace android
diff --git a/services/input/InputWindow.h b/services/input/InputWindow.h
new file mode 100644
index 0000000..b3d5a65
--- /dev/null
+++ b/services/input/InputWindow.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef _UI_INPUT_WINDOW_H
+#define _UI_INPUT_WINDOW_H
+
+#include <ui/Input.h>
+#include <ui/InputTransport.h>
+#include <utils/RefBase.h>
+#include <utils/Timers.h>
+#include <utils/String8.h>
+
+#include "InputApplication.h"
+
+namespace android {
+
+/*
+ * A handle to a window that can receive input.
+ * Used by the native input dispatcher to indirectly refer to the window manager objects
+ * that describe a window.
+ */
+class InputWindowHandle : public RefBase {
+protected:
+    InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
+            mInputApplicationHandle(inputApplicationHandle) { }
+    virtual ~InputWindowHandle() { }
+
+public:
+    inline sp<InputApplicationHandle> getInputApplicationHandle() {
+        return mInputApplicationHandle;
+    }
+
+private:
+    sp<InputApplicationHandle> mInputApplicationHandle;
+};
+
+
+/*
+ * An input window describes the bounds of a window that can receive input.
+ */
+struct InputWindow {
+    // Window flags from WindowManager.LayoutParams
+    enum {
+        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001,
+        FLAG_DIM_BEHIND        = 0x00000002,
+        FLAG_BLUR_BEHIND        = 0x00000004,
+        FLAG_NOT_FOCUSABLE      = 0x00000008,
+        FLAG_NOT_TOUCHABLE      = 0x00000010,
+        FLAG_NOT_TOUCH_MODAL    = 0x00000020,
+        FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
+        FLAG_KEEP_SCREEN_ON     = 0x00000080,
+        FLAG_LAYOUT_IN_SCREEN   = 0x00000100,
+        FLAG_LAYOUT_NO_LIMITS   = 0x00000200,
+        FLAG_FULLSCREEN      = 0x00000400,
+        FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800,
+        FLAG_DITHER             = 0x00001000,
+        FLAG_SECURE             = 0x00002000,
+        FLAG_SCALED             = 0x00004000,
+        FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000,
+        FLAG_LAYOUT_INSET_DECOR = 0x00010000,
+        FLAG_ALT_FOCUSABLE_IM = 0x00020000,
+        FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
+        FLAG_SHOW_WHEN_LOCKED = 0x00080000,
+        FLAG_SHOW_WALLPAPER = 0x00100000,
+        FLAG_TURN_SCREEN_ON = 0x00200000,
+        FLAG_DISMISS_KEYGUARD = 0x00400000,
+        FLAG_SPLIT_TOUCH = 0x00800000,
+        FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000,
+        FLAG_COMPATIBLE_WINDOW = 0x20000000,
+        FLAG_SYSTEM_ERROR = 0x40000000,
+    };
+
+    // Window types from WindowManager.LayoutParams
+    enum {
+        FIRST_APPLICATION_WINDOW = 1,
+        TYPE_BASE_APPLICATION   = 1,
+        TYPE_APPLICATION        = 2,
+        TYPE_APPLICATION_STARTING = 3,
+        LAST_APPLICATION_WINDOW = 99,
+        FIRST_SUB_WINDOW        = 1000,
+        TYPE_APPLICATION_PANEL  = FIRST_SUB_WINDOW,
+        TYPE_APPLICATION_MEDIA  = FIRST_SUB_WINDOW+1,
+        TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2,
+        TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3,
+        TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW+4,
+        LAST_SUB_WINDOW         = 1999,
+        FIRST_SYSTEM_WINDOW     = 2000,
+        TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW,
+        TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1,
+        TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2,
+        TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3,
+        TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4,
+        TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5,
+        TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6,
+        TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7,
+        TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8,
+        TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9,
+        TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10,
+        TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11,
+        TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12,
+        TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13,
+        TYPE_STATUS_BAR_SUB_PANEL  = FIRST_SYSTEM_WINDOW+14,
+        TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
+        TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16,
+        TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+17,
+        LAST_SYSTEM_WINDOW      = 2999,
+    };
+
+    sp<InputWindowHandle> inputWindowHandle;
+    sp<InputChannel> inputChannel;
+    String8 name;
+    int32_t layoutParamsFlags;
+    int32_t layoutParamsType;
+    nsecs_t dispatchingTimeout;
+    int32_t frameLeft;
+    int32_t frameTop;
+    int32_t frameRight;
+    int32_t frameBottom;
+    int32_t visibleFrameLeft;
+    int32_t visibleFrameTop;
+    int32_t visibleFrameRight;
+    int32_t visibleFrameBottom;
+    int32_t touchableAreaLeft;
+    int32_t touchableAreaTop;
+    int32_t touchableAreaRight;
+    int32_t touchableAreaBottom;
+    bool visible;
+    bool canReceiveKeys;
+    bool hasFocus;
+    bool hasWallpaper;
+    bool paused;
+    int32_t layer;
+    int32_t ownerPid;
+    int32_t ownerUid;
+
+    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;
+
+    bool supportsSplitTouch() const;
+};
+
+} // namespace android
+
+#endif // _UI_INPUT_WINDOW_H
diff --git a/services/input/tests/InputDispatcher_test.cpp b/services/input/tests/InputDispatcher_test.cpp
index b79633a..5ba1867 100644
--- a/services/input/tests/InputDispatcher_test.cpp
+++ b/services/input/tests/InputDispatcher_test.cpp
@@ -36,11 +36,11 @@
     }
 
     virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
-            const sp<InputChannel>& inputChannel) {
+            const sp<InputWindowHandle>& inputWindowHandle) {
         return 0;
     }
 
-    virtual void notifyInputChannelBroken(const sp<InputChannel>& inputChannel) {
+    virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) {
     }
 
     virtual nsecs_t getKeyRepeatTimeout() {
@@ -61,12 +61,12 @@
     virtual void interceptGenericBeforeQueueing(nsecs_t when, uint32_t& policyFlags) {
     }
 
-    virtual bool interceptKeyBeforeDispatching(const sp<InputChannel>& inputChannel,
+    virtual bool interceptKeyBeforeDispatching(const sp<InputWindowHandle>& inputWindowHandle,
             const KeyEvent* keyEvent, uint32_t policyFlags) {
         return false;
     }
 
-    virtual bool dispatchUnhandledKey(const sp<InputChannel>& inputChannel,
+    virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle,
             const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) {
         return false;
     }
diff --git a/services/input/tests/InputReader_test.cpp b/services/input/tests/InputReader_test.cpp
index 9d2c52f..8ec6f53 100644
--- a/services/input/tests/InputReader_test.cpp
+++ b/services/input/tests/InputReader_test.cpp
@@ -368,7 +368,8 @@
         return 0;
     }
 
-    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel, bool monitor) {
+    virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel,
+            const sp<InputWindowHandle>& inputWindowHandle, bool monitor) {
         ADD_FAILURE() << "Should never be called by input reader.";
         return 0;
     }
diff --git a/services/java/com/android/server/AccessibilityManagerService.java b/services/java/com/android/server/AccessibilityManagerService.java
index 393beda..04ae490 100644
--- a/services/java/com/android/server/AccessibilityManagerService.java
+++ b/services/java/com/android/server/AccessibilityManagerService.java
@@ -532,7 +532,10 @@
 
         for (int i = 0, count = services.size(); i < count; i++) {
             Service service = services.get(i);
-            service.unbind();
+            if (service.unbind()) {
+                i--;
+                count--;
+            }
         }
     }
 
@@ -575,7 +578,6 @@
             Set<ComponentName> enabledServices) {
 
         Map<ComponentName, Service> componentNameToServiceMap = mComponentNameToServiceMap;
-        List<Service> services = mServices;
         boolean isEnabled = mIsEnabled;
 
         for (int i = 0, count = installedServices.size(); i < count; i++) {
@@ -665,23 +667,31 @@
 
         /**
          * Binds to the accessibility service.
+         *
+         * @return True if binding is successful.
          */
-        public void bind() {
+        public boolean bind() {
             if (mService == null) {
-                mContext.bindService(mIntent, this, Context.BIND_AUTO_CREATE);
+                return mContext.bindService(mIntent, this, Context.BIND_AUTO_CREATE);
             }
+            return false;
         }
 
         /**
          * Unbinds form the accessibility service and removes it from the data
          * structures for service management.
+         *
+         * @return True if unbinding is successful.
          */
-        public void unbind() {
+        public boolean unbind() {
             if (mService != null) {
+                mService = null;
                 mContext.unbindService(this);
                 mComponentNameToServiceMap.remove(mComponentName);
                 mServices.remove(this);
+                return true;
             }
+            return false;
         }
 
         /**
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index b1eead2..a3d8ac9 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1100,18 +1100,10 @@
                     info.getExtraInfo());
         }
 
-        NetworkStateTracker newNet = null;
         if (mNetAttributes[prevNetType].isDefault()) {
-            newNet = tryFailover(prevNetType);
-            if (newNet != null) {
-                NetworkInfo switchTo = newNet.getNetworkInfo();
-                if (!switchTo.isConnected()) {
-                    // if the other net is connected they've already reset this and perhaps even
-                    // gotten a positive report we don't want to overwrite, but if not we need to
-                    // clear this now to turn our cellular sig strength white
-                    mDefaultInetConditionPublished = 0;
-                    intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true);
-                }
+            tryFailover(prevNetType);
+            if (mActiveDefaultNetwork != -1) {
+                NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
                 intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
             } else {
                 mDefaultInetConditionPublished = 0; // we're not connected anymore
@@ -1127,55 +1119,45 @@
          * If the failover network is already connected, then immediately send
          * out a followup broadcast indicating successful failover
          */
-        if (newNet != null && newNet.getNetworkInfo().isConnected()) {
-            sendConnectedBroadcast(newNet.getNetworkInfo());
+        if (mActiveDefaultNetwork != -1) {
+            sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
         }
     }
 
-    // returns null if no failover available, otherwise returns the highest
-    // priority network we're trying
-    private NetworkStateTracker tryFailover(int prevNetType) {
+    private void tryFailover(int prevNetType) {
         /*
          * If this is a default network, check if other defaults are available.
          * Try to reconnect on all available and let them hash it out when
          * more than one connects.
          */
-        NetworkStateTracker newNet = null;
         if (mNetAttributes[prevNetType].isDefault()) {
             if (mActiveDefaultNetwork == prevNetType) {
                 mActiveDefaultNetwork = -1;
             }
 
-            int newType = -1;
-            int newPriority = -1;
+            // don't signal a reconnect for anything lower or equal priority than our
+            // current connected default
+            // TODO - don't filter by priority now - nice optimization but risky
+//            int currentPriority = -1;
+//            if (mActiveDefaultNetwork != -1) {
+//                currentPriority = mNetAttributes[mActiveDefaultNetwork].mPriority;
+//            }
             for (int checkType=0; checkType <= ConnectivityManager.MAX_NETWORK_TYPE; checkType++) {
                 if (checkType == prevNetType) continue;
                 if (mNetAttributes[checkType] == null) continue;
                 if (!mNetAttributes[checkType].isDefault()) continue;
                 if (!mNetTrackers[checkType].isAvailable()) continue;
+//                if (currentPriority >= mNetAttributes[checkType].mPriority) continue;
 
-                NetworkStateTracker tracker = mNetTrackers[checkType];
-                NetworkInfo info = tracker.getNetworkInfo();
-                if (!info.isConnectedOrConnecting() ||
-                        tracker.isTeardownRequested()) {
-                    info.setFailover(true);
-                    tracker.reconnect();
+                NetworkStateTracker checkTracker = mNetTrackers[checkType];
+                NetworkInfo checkInfo = checkTracker.getNetworkInfo();
+                if (!checkInfo.isConnectedOrConnecting() || checkTracker.isTeardownRequested()) {
+                    checkInfo.setFailover(true);
+                    checkTracker.reconnect();
                 }
-                if (DBG) log("Attempting to switch to " + info.getTypeName());
-
-                // figure out if this is the highest priority network
-                // so we send an appropriate return value
-                if (checkType == mNetworkPreference) {
-                    newType = checkType;
-                }
-                if (mNetAttributes[checkType].mPriority > newPriority &&
-                        newType != mNetworkPreference) {
-                    newType = checkType;
-                    newPriority = mNetAttributes[newType].mPriority;
-                }
+                if (DBG) log("Attempting to switch to " + checkInfo.getTypeName());
             }
         }
-        return newNet;
     }
 
     private void sendConnectedBroadcast(NetworkInfo info) {
@@ -1238,17 +1220,10 @@
             info.setFailover(false);
         }
 
-        NetworkStateTracker newNet = null;
         if (mNetAttributes[info.getType()].isDefault()) {
-            newNet = tryFailover(info.getType());
-            if (newNet != null) {
-                NetworkInfo switchTo = newNet.getNetworkInfo();
-                if (!switchTo.isConnected()) {
-                    // if the other net is connected they've already reset this and perhaps
-                    // even gotten a positive report we don't want to overwrite, but if not
-                    // we need to clear this now to turn our cellular sig strength white
-                    mDefaultInetConditionPublished = 0;
-                }
+            tryFailover(info.getType());
+            if (mActiveDefaultNetwork != -1) {
+                NetworkInfo switchTo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo();
                 intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO, switchTo);
             } else {
                 mDefaultInetConditionPublished = 0;
@@ -1262,8 +1237,8 @@
          * If the failover network is already connected, then immediately send
          * out a followup broadcast indicating successful failover
          */
-        if (newNet != null && newNet.getNetworkInfo().isConnected()) {
-            sendConnectedBroadcast(newNet.getNetworkInfo());
+        if (mActiveDefaultNetwork != -1) {
+            sendConnectedBroadcast(mNetTrackers[mActiveDefaultNetwork].getNetworkInfo());
         }
     }
 
diff --git a/services/java/com/android/server/InputApplication.java b/services/java/com/android/server/InputApplication.java
index 38420d4..ae09484 100644
--- a/services/java/com/android/server/InputApplication.java
+++ b/services/java/com/android/server/InputApplication.java
@@ -18,16 +18,19 @@
 
 /**
  * Describes input-related application properties for use by the input dispatcher.
- * 
  * @hide
  */
 public final class InputApplication {
+    // Application handle.
+    public InputApplicationHandle inputApplicationHandle;
+
     // Application name.
     public String name;
-    
+
     // Dispatching timeout.
     public long dispatchingTimeoutNanos;
-    
-    // The application window token.
-    public Object token;
+
+    public void recycle() {
+        inputApplicationHandle = null;
+    }
 }
diff --git a/services/java/com/android/server/InputApplicationHandle.java b/services/java/com/android/server/InputApplicationHandle.java
new file mode 100644
index 0000000..d396d11
--- /dev/null
+++ b/services/java/com/android/server/InputApplicationHandle.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 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.server;
+
+/**
+ * Functions as a handle for an application that can receive input.
+ * Enables the native input dispatcher to refer indirectly to the window manager's
+ * application window token.
+ * @hide
+ */
+public final class InputApplicationHandle {
+    // Pointer to the native input application handle.
+    // This field is lazily initialized via JNI.
+    @SuppressWarnings("unused")
+    private int ptr;
+
+    // The window manager's application window token.
+    public final WindowManagerService.AppWindowToken appWindowToken;
+
+    private native void nativeDispose();
+
+    public InputApplicationHandle(WindowManagerService.AppWindowToken appWindowToken) {
+        this.appWindowToken = appWindowToken;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        nativeDispose();
+        super.finalize();
+    }
+}
diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/InputManager.java
index 410b8c2..5c2048b 100644
--- a/services/java/com/android/server/InputManager.java
+++ b/services/java/com/android/server/InputManager.java
@@ -77,7 +77,7 @@
     private static native boolean nativeHasKeys(int deviceId, int sourceMask,
             int[] keyCodes, boolean[] keyExists);
     private static native void nativeRegisterInputChannel(InputChannel inputChannel,
-            boolean monitor);
+            InputWindowHandle inputWindowHandle, boolean monitor);
     private static native void nativeUnregisterInputChannel(InputChannel inputChannel);
     private static native int nativeInjectInputEvent(InputEvent event,
             int injectorPid, int injectorUid, int syncMode, int timeoutMillis);
@@ -240,7 +240,7 @@
         }
         
         InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName);
-        nativeRegisterInputChannel(inputChannels[0], true);
+        nativeRegisterInputChannel(inputChannels[0], null, true);
         inputChannels[0].dispose(); // don't need to retain the Java object reference
         return inputChannels[1];
     }
@@ -248,13 +248,16 @@
     /**
      * Registers an input channel so that it can be used as an input event target.
      * @param inputChannel The input channel to register.
+     * @param inputWindowHandle The handle of the input window associated with the
+     * input channel, or null if none.
      */
-    public void registerInputChannel(InputChannel inputChannel) {
+    public void registerInputChannel(InputChannel inputChannel,
+            InputWindowHandle inputWindowHandle) {
         if (inputChannel == null) {
             throw new IllegalArgumentException("inputChannel must not be null.");
         }
         
-        nativeRegisterInputChannel(inputChannel, false);
+        nativeRegisterInputChannel(inputChannel, inputWindowHandle, false);
     }
     
     /**
@@ -429,13 +432,15 @@
         }
         
         @SuppressWarnings("unused")
-        public void notifyInputChannelBroken(InputChannel inputChannel) {
-            mWindowManagerService.mInputMonitor.notifyInputChannelBroken(inputChannel);
+        public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) {
+            mWindowManagerService.mInputMonitor.notifyInputChannelBroken(inputWindowHandle);
         }
         
         @SuppressWarnings("unused")
-        public long notifyANR(Object token, InputChannel inputChannel) {
-            return mWindowManagerService.mInputMonitor.notifyANR(token, inputChannel);
+        public long notifyANR(InputApplicationHandle inputApplicationHandle,
+                InputWindowHandle inputWindowHandle) {
+            return mWindowManagerService.mInputMonitor.notifyANR(
+                    inputApplicationHandle, inputWindowHandle);
         }
         
         @SuppressWarnings("unused")
@@ -445,14 +450,14 @@
         }
         
         @SuppressWarnings("unused")
-        public boolean interceptKeyBeforeDispatching(InputChannel focus,
+        public boolean interceptKeyBeforeDispatching(InputWindowHandle focus,
                 KeyEvent event, int policyFlags) {
             return mWindowManagerService.mInputMonitor.interceptKeyBeforeDispatching(
                     focus, event, policyFlags);
         }
         
         @SuppressWarnings("unused")
-        public KeyEvent dispatchUnhandledKey(InputChannel focus,
+        public KeyEvent dispatchUnhandledKey(InputWindowHandle focus,
                 KeyEvent event, int policyFlags) {
             return mWindowManagerService.mInputMonitor.dispatchUnhandledKey(
                     focus, event, policyFlags);
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 7ed9187..a2684fb 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1981,21 +1981,38 @@
 
     private ArrayList<InputMethodSubtype> getApplicableSubtypesLocked(
             List<InputMethodSubtype> subtypes) {
-        ArrayList<InputMethodSubtype> applicableSubtypes = new ArrayList<InputMethodSubtype>();
         final String systemLocale = mRes.getConfiguration().locale.toString();
-        if (TextUtils.isEmpty(systemLocale)) return applicableSubtypes;
+        if (TextUtils.isEmpty(systemLocale)) return new ArrayList<InputMethodSubtype>();
+        HashMap<String, InputMethodSubtype> applicableModeAndSubtypesMap =
+                new HashMap<String, InputMethodSubtype>();
         final int N = subtypes.size();
         boolean containsKeyboardSubtype = false;
         for (int i = 0; i < N; ++i) {
             InputMethodSubtype subtype = subtypes.get(i);
-            if (subtype.getLocale().equals(systemLocale)) {
-                applicableSubtypes.add(subtype);
+            final String locale = subtype.getLocale();
+            final String mode = subtype.getMode();
+            // When system locale starts with subtype's locale, that subtype will be applicable
+            // for system locale
+            // For instance, it's clearly applicable for cases like system locale = en_US and
+            // subtype = en, but it is not necessarily considered applicable for cases like system
+            // locale = en and subtype = en_US.
+            // We just call systemLocale.startsWith(locale) in this function because there is no
+            // need to find applicable subtypes aggressively unlike
+            // findLastResortApplicableSubtypeLocked.
+            if (systemLocale.startsWith(locale)) {
+                InputMethodSubtype applicableSubtype = applicableModeAndSubtypesMap.get(mode);
+                // If more applicable subtypes are contained, skip.
+                if (applicableSubtype != null
+                        && systemLocale.equals(applicableSubtype.getLocale())) continue;
+                applicableModeAndSubtypesMap.put(mode, subtype);
                 if (!containsKeyboardSubtype
                         && SUBTYPE_MODE_KEYBOARD.equalsIgnoreCase(subtype.getMode())) {
                     containsKeyboardSubtype = true;
                 }
             }
         }
+        ArrayList<InputMethodSubtype> applicableSubtypes = new ArrayList<InputMethodSubtype>(
+                applicableModeAndSubtypesMap.values());
         if (!containsKeyboardSubtype) {
             InputMethodSubtype lastResortKeyboardSubtype = findLastResortApplicableSubtypeLocked(
                     subtypes, SUBTYPE_MODE_KEYBOARD, systemLocale, true);
@@ -2188,6 +2205,7 @@
     // TODO: We should change the return type from List to List<Parcelable>
     public List getShortcutInputMethodsAndSubtypes() {
         synchronized (mMethodMap) {
+            ArrayList<Object> ret = new ArrayList<Object>();
             if (mShortcutInputMethodsAndSubtypes.size() == 0) {
                 // If there are no selected shortcut subtypes, the framework will try to find
                 // the most applicable subtype from all subtypes whose mode is
@@ -2196,10 +2214,11 @@
                     findLastResortApplicableShortcutInputMethodAndSubtypeLocked(
                             SUBTYPE_MODE_VOICE);
                 if (info != null) {
-                    addShortcutInputMethodAndSubtypes(info.first, info.second);
+                    ret.add(info.first);
+                    ret.add(info.second);
                 }
+                return ret;
             }
-            ArrayList<Object> ret = new ArrayList<Object>();
             for (InputMethodInfo imi: mShortcutInputMethodsAndSubtypes.keySet()) {
                 ret.add(imi);
                 for (InputMethodSubtype subtype: mShortcutInputMethodsAndSubtypes.get(imi)) {
diff --git a/services/java/com/android/server/InputWindow.java b/services/java/com/android/server/InputWindow.java
index befc770..1515290 100644
--- a/services/java/com/android/server/InputWindow.java
+++ b/services/java/com/android/server/InputWindow.java
@@ -20,64 +20,67 @@
 
 /**
  * Describes input-related window properties for use by the input dispatcher.
- * 
  * @hide
  */
 public final class InputWindow {
+    // The window handle.
+    public InputWindowHandle inputWindowHandle;
+
     // The input channel associated with the window.
     public InputChannel inputChannel;
-    
+
     // The window name.
     public String name;
-    
+
     // Window layout params attributes.  (WindowManager.LayoutParams)
     public int layoutParamsFlags;
     public int layoutParamsType;
-    
+
     // Dispatching timeout.
     public long dispatchingTimeoutNanos;
-    
+
     // Window frame area.
     public int frameLeft;
     public int frameTop;
     public int frameRight;
     public int frameBottom;
-    
+
     // Window visible frame area.
     public int visibleFrameLeft;
     public int visibleFrameTop;
     public int visibleFrameRight;
     public int visibleFrameBottom;
-    
+
     // Window touchable area.
     public int touchableAreaLeft;
     public int touchableAreaTop;
     public int touchableAreaRight;
     public int touchableAreaBottom;
-    
+
     // Window is visible.
     public boolean visible;
-    
+
     // Window can receive keys.
     public boolean canReceiveKeys;
-    
+
     // Window has focus.
     public boolean hasFocus;
-    
+
     // Window has wallpaper.  (window is the current wallpaper target)
     public boolean hasWallpaper;
-    
+
     // Input event dispatching is paused.
     public boolean paused;
-    
+
     // Window layer.
     public int layer;
-    
+
     // Id of process and user that owns the window.
     public int ownerPid;
     public int ownerUid;
-    
+
     public void recycle() {
+        inputWindowHandle = null;
         inputChannel = null;
     }
 }
diff --git a/services/java/com/android/server/InputWindowHandle.java b/services/java/com/android/server/InputWindowHandle.java
new file mode 100644
index 0000000..4b92939
--- /dev/null
+++ b/services/java/com/android/server/InputWindowHandle.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 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.server;
+
+import android.view.WindowManagerPolicy;
+
+/**
+ * Functions as a handle for a window that can receive input.
+ * Enables the native input dispatcher to refer indirectly to the window manager's window state.
+ * @hide
+ */
+public final class InputWindowHandle {
+    // Pointer to the native input window handle.
+    // This field is lazily initialized via JNI.
+    @SuppressWarnings("unused")
+    private int ptr;
+
+    // The input application handle.
+    public final InputApplicationHandle inputApplicationHandle;
+
+    // The window manager's window state.
+    public final WindowManagerPolicy.WindowState windowState;
+
+    private native void nativeDispose();
+
+    public InputWindowHandle(InputApplicationHandle inputApplicationHandle,
+            WindowManagerPolicy.WindowState windowState) {
+        this.inputApplicationHandle = inputApplicationHandle;
+        this.windowState = windowState;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        nativeDispose();
+        super.finalize();
+    }
+}
diff --git a/services/java/com/android/server/IntentResolver.java b/services/java/com/android/server/IntentResolver.java
index e47de13..a8b2840 100644
--- a/services/java/com/android/server/IntentResolver.java
+++ b/services/java/com/android/server/IntentResolver.java
@@ -346,7 +346,7 @@
 
         int num = 0;
         while (i.hasNext()) {
-            String name = (String)i.next();
+            String name = i.next();
             num++;
             if (localLOGV) Slog.v(TAG, prefix + name);
             String baseName = name;
@@ -395,7 +395,7 @@
 
         int num = 0;
         while (i.hasNext()) {
-            String name = (String)i.next();
+            String name = i.next();
             num++;
             if (localLOGV) Slog.v(TAG, prefix + name);
             String baseName = name;
@@ -534,8 +534,8 @@
     // Sorts a List of IntentFilter objects into descending priority order.
     private static final Comparator mResolvePrioritySorter = new Comparator() {
         public int compare(Object o1, Object o2) {
-            float q1 = ((IntentFilter)o1).getPriority();
-            float q2 = ((IntentFilter)o2).getPriority();
+            final int q1 = ((IntentFilter) o1).getPriority();
+            final int q2 = ((IntentFilter) o2).getPriority();
             return (q1 > q2) ? -1 : ((q1 < q2) ? 1 : 0);
         }
     };
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 435a2a5..b196f74 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -2882,13 +2882,13 @@
         SharedUserSetting suid = null;
         PackageSetting pkgSetting = null;
 
-        if ((pkg.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
+        if (!isSystemApp(pkg)) {
             // Only system apps can use these features.
             pkg.mOriginalPackages = null;
             pkg.mRealPackage = null;
             pkg.mAdoptPermissions = null;
         }
-        
+
         synchronized (mPackages) {
             // Check all shared libraries and map to their actual file path.
             if (pkg.usesLibraries != null || pkg.usesOptionalLibraries != null) {
@@ -4080,6 +4080,7 @@
         }
 
         public final void addActivity(PackageParser.Activity a, String type) {
+            final boolean systemApp = isSystemApp(a.info.applicationInfo);
             mActivities.put(a.getComponentName(), a);
             if (SHOW_INFO || Config.LOGV) Log.v(
                 TAG, "  " + type + " " +
@@ -4088,6 +4089,11 @@
             int NI = a.intents.size();
             for (int j=0; j<NI; j++) {
                 PackageParser.ActivityIntentInfo intent = a.intents.get(j);
+                if (!systemApp && intent.getPriority() > 0 && "activity".equals(type)) {
+                    intent.setPriority(0);
+                    Log.w(TAG, "Package " + a.info.applicationInfo.packageName + " has activity "
+                            + a.className + " with priority > 0, forcing to 0");
+                }
                 if (SHOW_INFO || Config.LOGV) {
                     Log.v(TAG, "    IntentFilter:");
                     intent.dump(new LogPrinter(Log.VERBOSE, TAG), "      ");
@@ -6026,6 +6032,10 @@
         return (pkg.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
     }
 
+    private static boolean isSystemApp(ApplicationInfo info) {
+        return (info.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
+    }
+
     private static boolean isUpdatedSystemApp(PackageParser.Package pkg) {
         return (pkg.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
     }
@@ -7926,6 +7936,14 @@
             copyFrom(orig);
         }
 
+        public void copyFrom(PackageSetting base) {
+            super.copyFrom((PackageSettingBase) base);
+
+            userId = base.userId;
+            sharedUser = base.sharedUser;
+            pkg = base.pkg;
+        }
+
         @Override
         public String toString() {
             return "PackageSetting{"
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index cff9892..1b590ba 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -954,8 +954,10 @@
          * @see #shouldDeviceStayAwake(int, int)
          */
         private boolean shouldWifiStayAwake(int stayAwakeConditions, int pluggedType) {
+            //Never sleep when plugged in as long as the user has not changed the settings
             int wifiSleepPolicy = Settings.System.getInt(mContext.getContentResolver(),
-                    Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_DEFAULT);
+                    Settings.System.WIFI_SLEEP_POLICY,
+                    Settings.System.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED);
 
             if (wifiSleepPolicy == Settings.System.WIFI_SLEEP_POLICY_NEVER) {
                 // Never sleep
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index c33d19d..7011f9a 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -493,7 +493,7 @@
     class DragState {
         IBinder mToken;
         Surface mSurface;
-        boolean mLocalOnly;
+        int mFlags;
         IBinder mLocalWin;
         ClipData mData;
         ClipDescription mDataDescription;
@@ -507,10 +507,10 @@
 
         private final Rect tmpRect = new Rect();
 
-        DragState(IBinder token, Surface surface, boolean localOnly, IBinder localWin) {
+        DragState(IBinder token, Surface surface, int flags, IBinder localWin) {
             mToken = token;
             mSurface = surface;
-            mLocalOnly = localOnly;
+            mFlags = flags;
             mLocalWin = localWin;
             mNotifiedWindows = new ArrayList<WindowState>();
         }
@@ -520,7 +520,7 @@
                 mSurface.destroy();
             }
             mSurface = null;
-            mLocalOnly = false;
+            mFlags = 0;
             mLocalWin = null;
             mToken = null;
             mData = null;
@@ -536,7 +536,7 @@
                 InputChannel[] channels = InputChannel.openInputChannelPair("drag");
                 mServerChannel = channels[0];
                 mClientChannel = channels[1];
-                mInputManager.registerInputChannel(mServerChannel);
+                mInputManager.registerInputChannel(mServerChannel, null);
                 InputQueue.registerInputChannel(mClientChannel, mDragInputHandler,
                         mH.getLooper().getQueue());
             }
@@ -593,7 +593,7 @@
                 ClipDescription desc) {
             // Don't actually send the event if the drag is supposed to be pinned
             // to the originating window but 'newWin' is not that window.
-            if (mLocalOnly) {
+            if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0) {
                 final IBinder winBinder = newWin.mClient.asBinder();
                 if (winBinder != mLocalWin) {
                     if (DEBUG_DRAG) {
@@ -681,7 +681,7 @@
 
             // Tell the affected window
             WindowState touchedWin = getTouchedWinAtPointLw(x, y);
-            if (mLocalOnly) {
+            if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0) {
                 final IBinder touchedBinder = touchedWin.mClient.asBinder();
                 if (touchedBinder != mLocalWin) {
                     // This drag is pinned only to the originating window, but the drag
@@ -2311,7 +2311,7 @@
                 win.mInputChannel = inputChannels[0];
                 inputChannels[1].transferToBinderOutParameter(outInputChannel);
                 
-                mInputManager.registerInputChannel(win.mInputChannel);
+                mInputManager.registerInputChannel(win.mInputChannel, win.mInputWindowHandle);
             }
 
             // From now on, no exceptions or errors allowed!
@@ -5633,10 +5633,10 @@
     // -------------------------------------------------------------
 
     IBinder prepareDragSurface(IWindow window, SurfaceSession session,
-            boolean localOnly, int width, int height, Surface outSurface) {
+            int flags, int width, int height, Surface outSurface) {
         if (DEBUG_DRAG) {
             Slog.d(TAG, "prepare drag surface: w=" + width + " h=" + height
-                    + " local=" + localOnly + " win=" + window
+                    + " flags=" + Integer.toHexString(flags) + " win=" + window
                     + " asbinder=" + window.asBinder());
         }
 
@@ -5647,17 +5647,15 @@
         try {
             synchronized (mWindowMap) {
                 try {
-                    // !!! TODO: fail if the given window does not currently have touch focus?
-
                     if (mDragState == null) {
                         Surface surface = new Surface(session, callerPid, "drag surface", 0,
                                 width, height, PixelFormat.TRANSLUCENT, Surface.HIDDEN);
                         outSurface.copyFrom(surface);
                         final IBinder winBinder = window.asBinder();
                         token = new Binder();
-                        mDragState = new DragState(token, surface, localOnly, winBinder);
+                        // TODO: preserve flags param in DragState
+                        mDragState = new DragState(token, surface, 0, winBinder);
                         mDragState.mSurface = surface;
-                        mDragState.mLocalOnly = localOnly;
                         token = mDragState.mToken = new Binder();
 
                         // 5 second timeout for this window to actually begin the drag
@@ -5711,13 +5709,13 @@
          * 
          * Called by the InputManager.
          */
-        public void notifyInputChannelBroken(InputChannel inputChannel) {
+        public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) {
+            if (inputWindowHandle == null) {
+                return;
+            }
+
             synchronized (mWindowMap) {
-                WindowState windowState = getWindowStateForInputChannelLocked(inputChannel);
-                if (windowState == null) {
-                    return; // irrelevant
-                }
-                
+                WindowState windowState = (WindowState) inputWindowHandle.windowState;
                 Slog.i(TAG, "WINDOW DIED " + windowState);
                 removeWindowLocked(windowState.mSession, windowState);
             }
@@ -5728,11 +5726,12 @@
          * 
          * Called by the InputManager.
          */
-        public long notifyANR(Object token, InputChannel inputChannel) {
+        public long notifyANR(InputApplicationHandle inputApplicationHandle,
+                InputWindowHandle inputWindowHandle) {
             AppWindowToken appWindowToken = null;
-            if (inputChannel != null) {
+            if (inputWindowHandle != null) {
                 synchronized (mWindowMap) {
-                    WindowState windowState = getWindowStateForInputChannelLocked(inputChannel);
+                    WindowState windowState = (WindowState) inputWindowHandle.windowState;
                     if (windowState != null) {
                         Slog.i(TAG, "Input event dispatching timed out sending to "
                                 + windowState.mAttrs.getTitle());
@@ -5741,8 +5740,8 @@
                 }
             }
             
-            if (appWindowToken == null && token != null) {
-                appWindowToken = (AppWindowToken) token;
+            if (appWindowToken == null && inputApplicationHandle != null) {
+                appWindowToken = inputApplicationHandle.appWindowToken;
                 Slog.i(TAG, "Input event dispatching timed out sending to application "
                         + appWindowToken.stringName);
             }
@@ -5762,24 +5761,6 @@
             }
             return 0; // abort dispatching
         }
-        
-        private WindowState getWindowStateForInputChannel(InputChannel inputChannel) {
-            synchronized (mWindowMap) {
-                return getWindowStateForInputChannelLocked(inputChannel);
-            }
-        }
-        
-        private WindowState getWindowStateForInputChannelLocked(InputChannel inputChannel) {
-            int windowCount = mWindows.size();
-            for (int i = 0; i < windowCount; i++) {
-                WindowState windowState = mWindows.get(i);
-                if (windowState.mInputChannel == inputChannel) {
-                    return windowState;
-                }
-            }
-            
-            return null;
-        }
 
         private void addDragInputWindowLw(InputWindowList windowList) {
             final InputWindow inputWindow = windowList.add();
@@ -5856,6 +5837,7 @@
 
                 // Add a window to our list of input windows.
                 final InputWindow inputWindow = mTempInputWindows.add();
+                inputWindow.inputWindowHandle = child.mInputWindowHandle;
                 inputWindow.inputChannel = child.mInputChannel;
                 inputWindow.name = child.toString();
                 inputWindow.layoutParamsFlags = flags;
@@ -5934,16 +5916,16 @@
         /* Provides an opportunity for the window manager policy to process a key before
          * ordinary dispatch. */
         public boolean interceptKeyBeforeDispatching(
-                InputChannel focus, KeyEvent event, int policyFlags) {
-            WindowState windowState = getWindowStateForInputChannel(focus);
+                InputWindowHandle focus, KeyEvent event, int policyFlags) {
+            WindowState windowState = (WindowState) focus.windowState;
             return mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags);
         }
         
         /* Provides an opportunity for the window manager policy to process a key that
          * the application did not handle. */
         public KeyEvent dispatchUnhandledKey(
-                InputChannel focus, KeyEvent event, int policyFlags) {
-            WindowState windowState = getWindowStateForInputChannel(focus);
+                InputWindowHandle focus, KeyEvent event, int policyFlags) {
+            WindowState windowState = (WindowState) focus.windowState;
             return mPolicy.dispatchUnhandledKey(windowState, event, policyFlags);
         }
         
@@ -5973,12 +5955,14 @@
             if (newApp == null) {
                 mInputManager.setFocusedApplication(null);
             } else {
+                mTempInputApplication.inputApplicationHandle = newApp.mInputApplicationHandle;
                 mTempInputApplication.name = newApp.toString();
                 mTempInputApplication.dispatchingTimeoutNanos =
                         newApp.inputDispatchingTimeoutNanos;
-                mTempInputApplication.token = newApp;
-                
+
                 mInputManager.setFocusedApplication(mTempInputApplication);
+
+                mTempInputApplication.recycle();
             }
         }
         
@@ -6426,9 +6410,9 @@
         }
 
         /* Drag/drop */
-        public IBinder prepareDrag(IWindow window, boolean localOnly,
+        public IBinder prepareDrag(IWindow window, int flags,
                 int width, int height, Surface outSurface) {
-            return prepareDragSurface(window, mSurfaceSession, localOnly,
+            return prepareDragSurface(window, mSurfaceSession, flags,
                     width, height, outSurface);
         }
 
@@ -6823,7 +6807,8 @@
         int mSurfaceLayer;
         float mSurfaceAlpha;
         
-        // Input channel
+        // Input channel and input window handle used by the input dispatcher.
+        InputWindowHandle mInputWindowHandle;
         InputChannel mInputChannel;
         
         // Used to improve performance of toString()
@@ -6915,6 +6900,8 @@
             mLayer = 0;
             mAnimLayer = 0;
             mLastLayer = 0;
+            mInputWindowHandle = new InputWindowHandle(
+                    mAppToken != null ? mAppToken.mInputApplicationHandle : null, this);
         }
 
         void attach() {
@@ -8304,11 +8291,15 @@
         boolean startingMoved;
         boolean firstWindowDrawn;
 
+        // Input application handle used by the input dispatcher.
+        InputApplicationHandle mInputApplicationHandle;
+
         AppWindowToken(IApplicationToken _token) {
             super(_token.asBinder(),
                     WindowManager.LayoutParams.TYPE_APPLICATION, true);
             appWindowToken = this;
             appToken = _token;
+            mInputApplicationHandle = new InputApplicationHandle(this);
         }
 
         public void setAnimation(Animation anim) {
diff --git a/services/jni/Android.mk b/services/jni/Android.mk
index ec85e54..f5a5b4d 100644
--- a/services/jni/Android.mk
+++ b/services/jni/Android.mk
@@ -4,7 +4,11 @@
 LOCAL_SRC_FILES:= \
     com_android_server_AlarmManagerService.cpp \
     com_android_server_BatteryService.cpp \
+    com_android_server_InputApplication.cpp \
+    com_android_server_InputApplicationHandle.cpp \
     com_android_server_InputManager.cpp \
+    com_android_server_InputWindow.cpp \
+    com_android_server_InputWindowHandle.cpp \
     com_android_server_LightsService.cpp \
     com_android_server_PowerManagerService.cpp \
     com_android_server_SystemServer.cpp \
diff --git a/services/jni/com_android_server_InputApplication.cpp b/services/jni/com_android_server_InputApplication.cpp
new file mode 100644
index 0000000..a46a162
--- /dev/null
+++ b/services/jni/com_android_server_InputApplication.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#define LOG_TAG "InputApplication"
+
+#include "JNIHelp.h"
+#include "jni.h"
+#include <android_runtime/AndroidRuntime.h>
+
+#include "com_android_server_InputApplication.h"
+#include "com_android_server_InputApplicationHandle.h"
+
+namespace android {
+
+static struct {
+    jclass clazz;
+
+    jfieldID inputApplicationHandle;
+    jfieldID name;
+    jfieldID dispatchingTimeoutNanos;
+} gInputApplicationClassInfo;
+
+
+// --- Global functions ---
+
+void android_server_InputApplication_toNative(
+        JNIEnv* env, jobject inputApplicationObj, InputApplication* outInputApplication) {
+    jobject inputApplicationHandleObj = env->GetObjectField(inputApplicationObj,
+            gInputApplicationClassInfo.inputApplicationHandle);
+    if (inputApplicationHandleObj) {
+        outInputApplication->inputApplicationHandle =
+                android_server_InputApplicationHandle_getHandle(env, inputApplicationHandleObj);
+        env->DeleteLocalRef(inputApplicationHandleObj);
+    } else {
+        outInputApplication->inputApplicationHandle = NULL;
+    }
+
+    jstring nameObj = jstring(env->GetObjectField(inputApplicationObj,
+            gInputApplicationClassInfo.name));
+    if (nameObj) {
+        const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
+        outInputApplication->name.setTo(nameStr);
+        env->ReleaseStringUTFChars(nameObj, nameStr);
+        env->DeleteLocalRef(nameObj);
+    } else {
+        LOGE("InputApplication.name should not be null.");
+        outInputApplication->name.setTo("unknown");
+    }
+
+    outInputApplication->dispatchingTimeout = env->GetLongField(inputApplicationObj,
+            gInputApplicationClassInfo.dispatchingTimeoutNanos);
+}
+
+
+// --- JNI ---
+
+#define FIND_CLASS(var, className) \
+        var = env->FindClass(className); \
+        LOG_FATAL_IF(! var, "Unable to find class " className); \
+        var = jclass(env->NewGlobalRef(var));
+
+#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
+        var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
+        LOG_FATAL_IF(! var, "Unable to find field " fieldName);
+
+int register_android_server_InputApplication(JNIEnv* env) {
+    FIND_CLASS(gInputApplicationClassInfo.clazz, "com/android/server/InputApplication");
+
+    GET_FIELD_ID(gInputApplicationClassInfo.inputApplicationHandle,
+            gInputApplicationClassInfo.clazz,
+            "inputApplicationHandle", "Lcom/android/server/InputApplicationHandle;");
+
+    GET_FIELD_ID(gInputApplicationClassInfo.name, gInputApplicationClassInfo.clazz,
+            "name", "Ljava/lang/String;");
+
+    GET_FIELD_ID(gInputApplicationClassInfo.dispatchingTimeoutNanos,
+            gInputApplicationClassInfo.clazz,
+            "dispatchingTimeoutNanos", "J");
+    return 0;
+}
+
+} /* namespace android */
diff --git a/services/jni/com_android_server_InputApplication.h b/services/jni/com_android_server_InputApplication.h
new file mode 100644
index 0000000..85fb891
--- /dev/null
+++ b/services/jni/com_android_server_InputApplication.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef _ANDROID_SERVER_INPUT_APPLICATION_H
+#define _ANDROID_SERVER_INPUT_APPLICATION_H
+
+#include <input/InputApplication.h>
+
+#include "JNIHelp.h"
+#include "jni.h"
+
+namespace android {
+
+extern void android_server_InputApplication_toNative(
+        JNIEnv* env, jobject inputApplicationObj, InputApplication* outInputApplication);
+
+} // namespace android
+
+#endif // _ANDROID_SERVER_INPUT_APPLICATION_H
diff --git a/services/jni/com_android_server_InputApplicationHandle.cpp b/services/jni/com_android_server_InputApplicationHandle.cpp
new file mode 100644
index 0000000..ab82635
--- /dev/null
+++ b/services/jni/com_android_server_InputApplicationHandle.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#define LOG_TAG "InputApplicationHandle"
+
+#include "JNIHelp.h"
+#include "jni.h"
+#include <android_runtime/AndroidRuntime.h>
+#include <utils/threads.h>
+
+#include "com_android_server_InputApplicationHandle.h"
+
+namespace android {
+
+static struct {
+    jclass clazz;
+
+    jfieldID ptr;
+} gInputApplicationHandleClassInfo;
+
+static Mutex gHandleMutex;
+
+
+// --- NativeInputApplicationHandle ---
+
+NativeInputApplicationHandle::NativeInputApplicationHandle(jweak objWeak) :
+        mObjWeak(objWeak) {
+}
+
+NativeInputApplicationHandle::~NativeInputApplicationHandle() {
+    JNIEnv* env = AndroidRuntime::getJNIEnv();
+    env->DeleteWeakGlobalRef(mObjWeak);
+}
+
+jobject NativeInputApplicationHandle::getInputApplicationHandleObjLocalRef(JNIEnv* env) {
+    return env->NewLocalRef(mObjWeak);
+}
+
+
+// --- Global functions ---
+
+sp<InputApplicationHandle> android_server_InputApplicationHandle_getHandle(
+        JNIEnv* env, jobject inputApplicationHandleObj) {
+    if (!inputApplicationHandleObj) {
+        return NULL;
+    }
+
+    AutoMutex _l(gHandleMutex);
+
+    int ptr = env->GetIntField(inputApplicationHandleObj, gInputApplicationHandleClassInfo.ptr);
+    NativeInputApplicationHandle* handle;
+    if (ptr) {
+        handle = reinterpret_cast<NativeInputApplicationHandle*>(ptr);
+    } else {
+        jweak objWeak = env->NewWeakGlobalRef(inputApplicationHandleObj);
+        handle = new NativeInputApplicationHandle(objWeak);
+        handle->incStrong(inputApplicationHandleObj);
+        env->SetIntField(inputApplicationHandleObj, gInputApplicationHandleClassInfo.ptr,
+                reinterpret_cast<int>(handle));
+    }
+    return handle;
+}
+
+
+// --- JNI ---
+
+static void android_server_InputApplicationHandle_nativeDispose(JNIEnv* env, jobject obj) {
+    AutoMutex _l(gHandleMutex);
+
+    int ptr = env->GetIntField(obj, gInputApplicationHandleClassInfo.ptr);
+    if (ptr) {
+        env->SetIntField(obj, gInputApplicationHandleClassInfo.ptr, 0);
+
+        NativeInputApplicationHandle* handle = reinterpret_cast<NativeInputApplicationHandle*>(ptr);
+        handle->decStrong(obj);
+    }
+}
+
+
+static JNINativeMethod gInputApplicationHandleMethods[] = {
+    /* name, signature, funcPtr */
+    { "nativeDispose", "()V",
+            (void*) android_server_InputApplicationHandle_nativeDispose },
+};
+
+#define FIND_CLASS(var, className) \
+        var = env->FindClass(className); \
+        LOG_FATAL_IF(! var, "Unable to find class " className); \
+        var = jclass(env->NewGlobalRef(var));
+
+#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
+        var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
+        LOG_FATAL_IF(! var, "Unable to find field " fieldName);
+
+int register_android_server_InputApplicationHandle(JNIEnv* env) {
+    int res = jniRegisterNativeMethods(env, "com/android/server/InputApplicationHandle",
+            gInputApplicationHandleMethods, NELEM(gInputApplicationHandleMethods));
+    LOG_FATAL_IF(res < 0, "Unable to register native methods.");
+
+    FIND_CLASS(gInputApplicationHandleClassInfo.clazz, "com/android/server/InputApplicationHandle");
+
+    GET_FIELD_ID(gInputApplicationHandleClassInfo.ptr, gInputApplicationHandleClassInfo.clazz,
+            "ptr", "I");
+
+    return 0;
+}
+
+} /* namespace android */
diff --git a/services/jni/com_android_server_InputApplicationHandle.h b/services/jni/com_android_server_InputApplicationHandle.h
new file mode 100644
index 0000000..9d18721
--- /dev/null
+++ b/services/jni/com_android_server_InputApplicationHandle.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef _ANDROID_SERVER_INPUT_APPLICATION_HANDLE_H
+#define _ANDROID_SERVER_INPUT_APPLICATION_HANDLE_H
+
+#include <input/InputApplication.h>
+
+#include "JNIHelp.h"
+#include "jni.h"
+
+namespace android {
+
+class NativeInputApplicationHandle : public InputApplicationHandle {
+public:
+    NativeInputApplicationHandle(jweak objWeak);
+    virtual ~NativeInputApplicationHandle();
+
+    jobject getInputApplicationHandleObjLocalRef(JNIEnv* env);
+
+private:
+    jweak mObjWeak;
+};
+
+
+extern sp<InputApplicationHandle> android_server_InputApplicationHandle_getHandle(
+        JNIEnv* env, jobject inputApplicationHandleObj);
+
+} // namespace android
+
+#endif // _ANDROID_SERVER_INPUT_APPLICATION_HANDLE_H
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 5ed63f0..e04e4c3 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -42,11 +42,13 @@
 #include <android/graphics/GraphicsJNI.h>
 
 #include "com_android_server_PowerManagerService.h"
+#include "com_android_server_InputApplication.h"
+#include "com_android_server_InputApplicationHandle.h"
+#include "com_android_server_InputWindow.h"
+#include "com_android_server_InputWindowHandle.h"
 
 namespace android {
 
-// ----------------------------------------------------------------------------
-
 static struct {
     jclass clazz;
 
@@ -68,44 +70,6 @@
 
 static struct {
     jclass clazz;
-
-    jfieldID inputChannel;
-    jfieldID name;
-    jfieldID layoutParamsFlags;
-    jfieldID layoutParamsType;
-    jfieldID dispatchingTimeoutNanos;
-    jfieldID frameLeft;
-    jfieldID frameTop;
-    jfieldID frameRight;
-    jfieldID frameBottom;
-    jfieldID visibleFrameLeft;
-    jfieldID visibleFrameTop;
-    jfieldID visibleFrameRight;
-    jfieldID visibleFrameBottom;
-    jfieldID touchableAreaLeft;
-    jfieldID touchableAreaTop;
-    jfieldID touchableAreaRight;
-    jfieldID touchableAreaBottom;
-    jfieldID visible;
-    jfieldID canReceiveKeys;
-    jfieldID hasFocus;
-    jfieldID hasWallpaper;
-    jfieldID paused;
-    jfieldID layer;
-    jfieldID ownerPid;
-    jfieldID ownerUid;
-} gInputWindowClassInfo;
-
-static struct {
-    jclass clazz;
-
-    jfieldID name;
-    jfieldID dispatchingTimeoutNanos;
-    jfieldID token;
-} gInputApplicationClassInfo;
-
-static struct {
-    jclass clazz;
 } gKeyEventClassInfo;
 
 static struct {
@@ -141,7 +105,29 @@
     jfieldID hotSpotY;
 } gPointerIconClassInfo;
 
-// ----------------------------------------------------------------------------
+
+// --- Global functions ---
+
+static jobject getInputApplicationHandleObjLocalRef(JNIEnv* env,
+        const sp<InputApplicationHandle>& inputApplicationHandle) {
+    if (inputApplicationHandle == NULL) {
+        return NULL;
+    }
+    return static_cast<NativeInputApplicationHandle*>(inputApplicationHandle.get())->
+            getInputApplicationHandleObjLocalRef(env);
+}
+
+static jobject getInputWindowHandleObjLocalRef(JNIEnv* env,
+        const sp<InputWindowHandle>& inputWindowHandle) {
+    if (inputWindowHandle == NULL) {
+        return NULL;
+    }
+    return static_cast<NativeInputWindowHandle*>(inputWindowHandle.get())->
+            getInputWindowHandleObjLocalRef(env);
+}
+
+
+// --- NativeInputManager ---
 
 class NativeInputManager : public virtual RefBase,
     public virtual InputReaderPolicyInterface,
@@ -160,7 +146,7 @@
     void setDisplayOrientation(int32_t displayId, int32_t orientation);
 
     status_t registerInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel,
-            jweak inputChannelObjWeak, bool monitor);
+            const sp<InputWindowHandle>& inputWindowHandle, bool monitor);
     status_t unregisterInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel);
 
     void setInputWindows(JNIEnv* env, jobjectArray windowObjArray);
@@ -182,37 +168,22 @@
             uint32_t policyFlags);
     virtual void notifyConfigurationChanged(nsecs_t when);
     virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
-            const sp<InputChannel>& inputChannel);
-    virtual void notifyInputChannelBroken(const sp<InputChannel>& inputChannel);
+            const sp<InputWindowHandle>& inputWindowHandle);
+    virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle);
     virtual nsecs_t getKeyRepeatTimeout();
     virtual nsecs_t getKeyRepeatDelay();
     virtual int32_t getMaxEventsPerSecond();
     virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags);
     virtual void interceptGenericBeforeQueueing(nsecs_t when, uint32_t& policyFlags);
-    virtual bool interceptKeyBeforeDispatching(const sp<InputChannel>& inputChannel,
+    virtual bool interceptKeyBeforeDispatching(const sp<InputWindowHandle>& inputWindowHandle,
             const KeyEvent* keyEvent, uint32_t policyFlags);
-    virtual bool dispatchUnhandledKey(const sp<InputChannel>& inputChannel,
+    virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle,
             const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent);
     virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType);
     virtual bool checkInjectEventsPermissionNonReentrant(
             int32_t injectorPid, int32_t injectorUid);
 
 private:
-    class ApplicationToken : public InputApplicationHandle {
-        jweak mTokenObjWeak;
-
-    public:
-        ApplicationToken(jweak tokenObjWeak) :
-            mTokenObjWeak(tokenObjWeak) { }
-
-        virtual ~ApplicationToken() {
-            JNIEnv* env = NativeInputManager::jniEnv();
-            env->DeleteWeakGlobalRef(mTokenObjWeak);
-        }
-
-        inline jweak getTokenObj() { return mTokenObjWeak; }
-    };
-
     sp<InputManager> mInputManager;
 
     jobject mCallbacksObj;
@@ -232,19 +203,12 @@
 
         // Pointer controller singleton, created and destroyed as needed.
         wp<PointerController> pointerController;
-
-        // Weak references to all currently registered input channels by connection pointer.
-        KeyedVector<InputChannel*, jweak> inputChannelObjWeakTable;
     } mLocked;
 
     // Power manager interactions.
     bool isScreenOn();
     bool isScreenBright();
 
-    jobject getInputChannelObjLocal(JNIEnv* env, const sp<InputChannel>& inputChannel);
-
-    static bool populateWindow(JNIEnv* env, jobject windowObj, InputWindow& outWindow);
-
     static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName);
 
     static inline JNIEnv* jniEnv() {
@@ -252,7 +216,7 @@
     }
 };
 
-// ----------------------------------------------------------------------------
+
 
 NativeInputManager::NativeInputManager(jobject callbacksObj) :
     mFilterTouchEvents(-1), mFilterJumpyTouchEvents(-1),
@@ -328,88 +292,17 @@
 }
 
 status_t NativeInputManager::registerInputChannel(JNIEnv* env,
-        const sp<InputChannel>& inputChannel, jobject inputChannelObj, bool monitor) {
-    jweak inputChannelObjWeak = env->NewWeakGlobalRef(inputChannelObj);
-    if (! inputChannelObjWeak) {
-        LOGE("Could not create weak reference for input channel.");
-        LOGE_EX(env);
-        return NO_MEMORY;
-    }
-
-    status_t status;
-    {
-        AutoMutex _l(mLock);
-
-        ssize_t index = mLocked.inputChannelObjWeakTable.indexOfKey(inputChannel.get());
-        if (index >= 0) {
-            LOGE("Input channel object '%s' has already been registered",
-                    inputChannel->getName().string());
-            status = INVALID_OPERATION;
-            goto DeleteWeakRef;
-        }
-
-        mLocked.inputChannelObjWeakTable.add(inputChannel.get(), inputChannelObjWeak);
-    }
-
-    status = mInputManager->getDispatcher()->registerInputChannel(inputChannel, monitor);
-    if (! status) {
-        // Success.
-        return OK;
-    }
-
-    // Failed!
-    {
-        AutoMutex _l(mLock);
-        mLocked.inputChannelObjWeakTable.removeItem(inputChannel.get());
-    }
-
-DeleteWeakRef:
-    env->DeleteWeakGlobalRef(inputChannelObjWeak);
-    return status;
+        const sp<InputChannel>& inputChannel,
+        const sp<InputWindowHandle>& inputWindowHandle, bool monitor) {
+    return mInputManager->getDispatcher()->registerInputChannel(
+            inputChannel, inputWindowHandle, monitor);
 }
 
 status_t NativeInputManager::unregisterInputChannel(JNIEnv* env,
         const sp<InputChannel>& inputChannel) {
-    jweak inputChannelObjWeak;
-    {
-        AutoMutex _l(mLock);
-
-        ssize_t index = mLocked.inputChannelObjWeakTable.indexOfKey(inputChannel.get());
-        if (index < 0) {
-            LOGE("Input channel object '%s' is not currently registered",
-                    inputChannel->getName().string());
-            return INVALID_OPERATION;
-        }
-
-        inputChannelObjWeak = mLocked.inputChannelObjWeakTable.valueAt(index);
-        mLocked.inputChannelObjWeakTable.removeItemsAt(index);
-    }
-
-    env->DeleteWeakGlobalRef(inputChannelObjWeak);
-
     return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel);
 }
 
-jobject NativeInputManager::getInputChannelObjLocal(JNIEnv* env,
-        const sp<InputChannel>& inputChannel) {
-    InputChannel* inputChannelPtr = inputChannel.get();
-    if (! inputChannelPtr) {
-        return NULL;
-    }
-
-    {
-        AutoMutex _l(mLock);
-
-        ssize_t index = mLocked.inputChannelObjWeakTable.indexOfKey(inputChannelPtr);
-        if (index < 0) {
-            return NULL;
-        }
-
-        jweak inputChannelObjWeak = mLocked.inputChannelObjWeakTable.valueAt(index);
-        return env->NewLocalRef(inputChannelObjWeak);
-    }
-}
-
 bool NativeInputManager::getDisplayInfo(int32_t displayId,
         int32_t* width, int32_t* height, int32_t* orientation) {
     bool result = false;
@@ -549,50 +442,46 @@
 }
 
 nsecs_t NativeInputManager::notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
-        const sp<InputChannel>& inputChannel) {
+        const sp<InputWindowHandle>& inputWindowHandle) {
 #if DEBUG_INPUT_DISPATCHER_POLICY
     LOGD("notifyANR");
 #endif
 
     JNIEnv* env = jniEnv();
 
-    jobject tokenObjLocal;
-    if (inputApplicationHandle.get()) {
-        ApplicationToken* token = static_cast<ApplicationToken*>(inputApplicationHandle.get());
-        jweak tokenObjWeak = token->getTokenObj();
-        tokenObjLocal = env->NewLocalRef(tokenObjWeak);
-    } else {
-        tokenObjLocal = NULL;
-    }
+    jobject inputApplicationHandleObj =
+            getInputApplicationHandleObjLocalRef(env, inputApplicationHandle);
+    jobject inputWindowHandleObj =
+            getInputWindowHandleObjLocalRef(env, inputWindowHandle);
 
-    jobject inputChannelObjLocal = getInputChannelObjLocal(env, inputChannel);
     jlong newTimeout = env->CallLongMethod(mCallbacksObj,
-                gCallbacksClassInfo.notifyANR, tokenObjLocal, inputChannelObjLocal);
+                gCallbacksClassInfo.notifyANR, inputApplicationHandleObj, inputWindowHandleObj);
     if (checkAndClearExceptionFromCallback(env, "notifyANR")) {
         newTimeout = 0; // abort dispatch
     } else {
         assert(newTimeout >= 0);
     }
 
-    env->DeleteLocalRef(tokenObjLocal);
-    env->DeleteLocalRef(inputChannelObjLocal);
+    env->DeleteLocalRef(inputWindowHandleObj);
+    env->DeleteLocalRef(inputApplicationHandleObj);
     return newTimeout;
 }
 
-void NativeInputManager::notifyInputChannelBroken(const sp<InputChannel>& inputChannel) {
+void NativeInputManager::notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) {
 #if DEBUG_INPUT_DISPATCHER_POLICY
-    LOGD("notifyInputChannelBroken - inputChannel='%s'", inputChannel->getName().string());
+    LOGD("notifyInputChannelBroken");
 #endif
 
     JNIEnv* env = jniEnv();
 
-    jobject inputChannelObjLocal = getInputChannelObjLocal(env, inputChannel);
-    if (inputChannelObjLocal) {
+    jobject inputWindowHandleObj =
+            getInputWindowHandleObjLocalRef(env, inputWindowHandle);
+    if (inputWindowHandleObj) {
         env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyInputChannelBroken,
-                inputChannelObjLocal);
+                inputWindowHandleObj);
         checkAndClearExceptionFromCallback(env, "notifyInputChannelBroken");
 
-        env->DeleteLocalRef(inputChannelObjLocal);
+        env->DeleteLocalRef(inputWindowHandleObj);
     }
 }
 
@@ -630,160 +519,32 @@
 
     jsize length = env->GetArrayLength(windowObjArray);
     for (jsize i = 0; i < length; i++) {
-        jobject inputTargetObj = env->GetObjectArrayElement(windowObjArray, i);
-        if (! inputTargetObj) {
+        jobject windowObj = env->GetObjectArrayElement(windowObjArray, i);
+        if (! windowObj) {
             break; // found null element indicating end of used portion of the array
         }
 
         windows.push();
         InputWindow& window = windows.editTop();
-        bool valid = populateWindow(env, inputTargetObj, window);
-        if (! valid) {
+        android_server_InputWindow_toNative(env, windowObj, &window);
+        if (window.inputChannel == NULL) {
             windows.pop();
         }
-
-        env->DeleteLocalRef(inputTargetObj);
+        env->DeleteLocalRef(windowObj);
     }
 
     mInputManager->getDispatcher()->setInputWindows(windows);
 }
 
-bool NativeInputManager::populateWindow(JNIEnv* env, jobject windowObj,
-        InputWindow& outWindow) {
-    bool valid = false;
-
-    jobject inputChannelObj = env->GetObjectField(windowObj,
-            gInputWindowClassInfo.inputChannel);
-    if (inputChannelObj) {
-        sp<InputChannel> inputChannel =
-                android_view_InputChannel_getInputChannel(env, inputChannelObj);
-        if (inputChannel != NULL) {
-            jstring name = jstring(env->GetObjectField(windowObj,
-                    gInputWindowClassInfo.name));
-            jint layoutParamsFlags = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.layoutParamsFlags);
-            jint layoutParamsType = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.layoutParamsType);
-            jlong dispatchingTimeoutNanos = env->GetLongField(windowObj,
-                    gInputWindowClassInfo.dispatchingTimeoutNanos);
-            jint frameLeft = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.frameLeft);
-            jint frameTop = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.frameTop);
-            jint frameRight = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.frameRight);
-            jint frameBottom = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.frameBottom);
-            jint visibleFrameLeft = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.visibleFrameLeft);
-            jint visibleFrameTop = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.visibleFrameTop);
-            jint visibleFrameRight = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.visibleFrameRight);
-            jint visibleFrameBottom = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.visibleFrameBottom);
-            jint touchableAreaLeft = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.touchableAreaLeft);
-            jint touchableAreaTop = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.touchableAreaTop);
-            jint touchableAreaRight = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.touchableAreaRight);
-            jint touchableAreaBottom = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.touchableAreaBottom);
-            jboolean visible = env->GetBooleanField(windowObj,
-                    gInputWindowClassInfo.visible);
-            jboolean canReceiveKeys = env->GetBooleanField(windowObj,
-                    gInputWindowClassInfo.canReceiveKeys);
-            jboolean hasFocus = env->GetBooleanField(windowObj,
-                    gInputWindowClassInfo.hasFocus);
-            jboolean hasWallpaper = env->GetBooleanField(windowObj,
-                    gInputWindowClassInfo.hasWallpaper);
-            jboolean paused = env->GetBooleanField(windowObj,
-                    gInputWindowClassInfo.paused);
-            jint layer = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.layer);
-            jint ownerPid = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.ownerPid);
-            jint ownerUid = env->GetIntField(windowObj,
-                    gInputWindowClassInfo.ownerUid);
-
-            const char* nameStr = env->GetStringUTFChars(name, NULL);
-
-            outWindow.inputChannel = inputChannel;
-            outWindow.name.setTo(nameStr);
-            outWindow.layoutParamsFlags = layoutParamsFlags;
-            outWindow.layoutParamsType = layoutParamsType;
-            outWindow.dispatchingTimeout = dispatchingTimeoutNanos;
-            outWindow.frameLeft = frameLeft;
-            outWindow.frameTop = frameTop;
-            outWindow.frameRight = frameRight;
-            outWindow.frameBottom = frameBottom;
-            outWindow.visibleFrameLeft = visibleFrameLeft;
-            outWindow.visibleFrameTop = visibleFrameTop;
-            outWindow.visibleFrameRight = visibleFrameRight;
-            outWindow.visibleFrameBottom = visibleFrameBottom;
-            outWindow.touchableAreaLeft = touchableAreaLeft;
-            outWindow.touchableAreaTop = touchableAreaTop;
-            outWindow.touchableAreaRight = touchableAreaRight;
-            outWindow.touchableAreaBottom = touchableAreaBottom;
-            outWindow.visible = visible;
-            outWindow.canReceiveKeys = canReceiveKeys;
-            outWindow.hasFocus = hasFocus;
-            outWindow.hasWallpaper = hasWallpaper;
-            outWindow.paused = paused;
-            outWindow.layer = layer;
-            outWindow.ownerPid = ownerPid;
-            outWindow.ownerUid = ownerUid;
-
-            env->ReleaseStringUTFChars(name, nameStr);
-            env->DeleteLocalRef(name);
-            valid = true;
-        } else {
-            LOGW("Dropping input target because its input channel is not initialized.");
-        }
-
-        env->DeleteLocalRef(inputChannelObj);
-    } else {
-        LOGW("Dropping input target because the input channel object was null.");
-    }
-    return valid;
-}
-
 void NativeInputManager::setFocusedApplication(JNIEnv* env, jobject applicationObj) {
     if (applicationObj) {
-        jstring nameObj = jstring(env->GetObjectField(applicationObj,
-                gInputApplicationClassInfo.name));
-        jlong dispatchingTimeoutNanos = env->GetLongField(applicationObj,
-                gInputApplicationClassInfo.dispatchingTimeoutNanos);
-        jobject tokenObj = env->GetObjectField(applicationObj,
-                gInputApplicationClassInfo.token);
-        jweak tokenObjWeak = env->NewWeakGlobalRef(tokenObj);
-        if (! tokenObjWeak) {
-            LOGE("Could not create weak reference for application token.");
-            LOGE_EX(env);
-            env->ExceptionClear();
-        }
-        env->DeleteLocalRef(tokenObj);
-
-        String8 name;
-        if (nameObj) {
-            const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
-            name.setTo(nameStr);
-            env->ReleaseStringUTFChars(nameObj, nameStr);
-            env->DeleteLocalRef(nameObj);
-        } else {
-            LOGE("InputApplication.name should not be null.");
-            name.setTo("unknown");
-        }
-
         InputApplication application;
-        application.name = name;
-        application.dispatchingTimeout = dispatchingTimeoutNanos;
-        application.handle = new ApplicationToken(tokenObjWeak);
-        mInputManager->getDispatcher()->setFocusedApplication(& application);
-    } else {
-        mInputManager->getDispatcher()->setFocusedApplication(NULL);
+        android_server_InputApplication_toNative(env, applicationObj, &application);
+        if (application.inputApplicationHandle != NULL) {
+            mInputManager->getDispatcher()->setFocusedApplication(&application);
+        }
     }
+    mInputManager->getDispatcher()->setFocusedApplication(NULL);
 }
 
 void NativeInputManager::setInputDispatchMode(bool enabled, bool frozen) {
@@ -875,7 +636,8 @@
     }
 }
 
-bool NativeInputManager::interceptKeyBeforeDispatching(const sp<InputChannel>& inputChannel,
+bool NativeInputManager::interceptKeyBeforeDispatching(
+        const sp<InputWindowHandle>& inputWindowHandle,
         const KeyEvent* keyEvent, uint32_t policyFlags) {
     // Policy:
     // - Ignore untrusted events and pass them along.
@@ -885,13 +647,13 @@
     if (policyFlags & POLICY_FLAG_TRUSTED) {
         JNIEnv* env = jniEnv();
 
-        // Note: inputChannel may be null.
-        jobject inputChannelObj = getInputChannelObjLocal(env, inputChannel);
+        // Note: inputWindowHandle may be null.
+        jobject inputWindowHandleObj = getInputWindowHandleObjLocalRef(env, inputWindowHandle);
         jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
         if (keyEventObj) {
             jboolean consumed = env->CallBooleanMethod(mCallbacksObj,
                     gCallbacksClassInfo.interceptKeyBeforeDispatching,
-                    inputChannelObj, keyEventObj, policyFlags);
+                    inputWindowHandleObj, keyEventObj, policyFlags);
             bool error = checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching");
             android_view_KeyEvent_recycle(env, keyEventObj);
             env->DeleteLocalRef(keyEventObj);
@@ -899,12 +661,12 @@
         } else {
             LOGE("Failed to obtain key event object for interceptKeyBeforeDispatching.");
         }
-        env->DeleteLocalRef(inputChannelObj);
+        env->DeleteLocalRef(inputWindowHandleObj);
     }
     return result;
 }
 
-bool NativeInputManager::dispatchUnhandledKey(const sp<InputChannel>& inputChannel,
+bool NativeInputManager::dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle,
         const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) {
     // Policy:
     // - Ignore untrusted events and do not perform default handling.
@@ -912,13 +674,13 @@
     if (policyFlags & POLICY_FLAG_TRUSTED) {
         JNIEnv* env = jniEnv();
 
-        // Note: inputChannel may be null.
-        jobject inputChannelObj = getInputChannelObjLocal(env, inputChannel);
+        // Note: inputWindowHandle may be null.
+        jobject inputWindowHandleObj = getInputWindowHandleObjLocalRef(env, inputWindowHandle);
         jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
         if (keyEventObj) {
             jobject fallbackKeyEventObj = env->CallObjectMethod(mCallbacksObj,
                     gCallbacksClassInfo.dispatchUnhandledKey,
-                    inputChannelObj, keyEventObj, policyFlags);
+                    inputWindowHandleObj, keyEventObj, policyFlags);
             checkAndClearExceptionFromCallback(env, "dispatchUnhandledKey");
             android_view_KeyEvent_recycle(env, keyEventObj);
             env->DeleteLocalRef(keyEventObj);
@@ -935,7 +697,7 @@
         } else {
             LOGE("Failed to obtain key event object for dispatchUnhandledKey.");
         }
-        env->DeleteLocalRef(inputChannelObj);
+        env->DeleteLocalRef(inputWindowHandleObj);
     }
     return result;
 }
@@ -1079,7 +841,7 @@
 }
 
 static void android_server_InputManager_nativeRegisterInputChannel(JNIEnv* env, jclass clazz,
-        jobject inputChannelObj, jboolean monitor) {
+        jobject inputChannelObj, jobject inputWindowHandleObj, jboolean monitor) {
     if (checkInputManagerUnitialized(env)) {
         return;
     }
@@ -1091,9 +853,11 @@
         return;
     }
 
+    sp<InputWindowHandle> inputWindowHandle =
+            android_server_InputWindowHandle_getHandle(env, inputWindowHandleObj);
 
     status_t status = gNativeInputManager->registerInputChannel(
-            env, inputChannel, inputChannelObj, monitor);
+            env, inputChannel, inputWindowHandle, monitor);
     if (status) {
         jniThrowRuntimeException(env, "Failed to register input channel.  "
                 "Check logs for details.");
@@ -1311,7 +1075,8 @@
             (void*) android_server_InputManager_nativeGetSwitchState },
     { "nativeHasKeys", "(II[I[Z)Z",
             (void*) android_server_InputManager_nativeHasKeys },
-    { "nativeRegisterInputChannel", "(Landroid/view/InputChannel;Z)V",
+    { "nativeRegisterInputChannel",
+            "(Landroid/view/InputChannel;Lcom/android/server/InputWindowHandle;Z)V",
             (void*) android_server_InputManager_nativeRegisterInputChannel },
     { "nativeUnregisterInputChannel", "(Landroid/view/InputChannel;)V",
             (void*) android_server_InputManager_nativeUnregisterInputChannel },
@@ -1364,21 +1129,22 @@
             "notifyLidSwitchChanged", "(JZ)V");
 
     GET_METHOD_ID(gCallbacksClassInfo.notifyInputChannelBroken, gCallbacksClassInfo.clazz,
-            "notifyInputChannelBroken", "(Landroid/view/InputChannel;)V");
+            "notifyInputChannelBroken", "(Lcom/android/server/InputWindowHandle;)V");
 
     GET_METHOD_ID(gCallbacksClassInfo.notifyANR, gCallbacksClassInfo.clazz,
-            "notifyANR", "(Ljava/lang/Object;Landroid/view/InputChannel;)J");
+            "notifyANR",
+            "(Lcom/android/server/InputApplicationHandle;Lcom/android/server/InputWindowHandle;)J");
 
     GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeQueueing, gCallbacksClassInfo.clazz,
             "interceptKeyBeforeQueueing", "(Landroid/view/KeyEvent;IZ)I");
 
     GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeDispatching, gCallbacksClassInfo.clazz,
             "interceptKeyBeforeDispatching",
-            "(Landroid/view/InputChannel;Landroid/view/KeyEvent;I)Z");
+            "(Lcom/android/server/InputWindowHandle;Landroid/view/KeyEvent;I)Z");
 
     GET_METHOD_ID(gCallbacksClassInfo.dispatchUnhandledKey, gCallbacksClassInfo.clazz,
             "dispatchUnhandledKey",
-            "(Landroid/view/InputChannel;Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;");
+            "(Lcom/android/server/InputWindowHandle;Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;");
 
     GET_METHOD_ID(gCallbacksClassInfo.checkInjectEventsPermission, gCallbacksClassInfo.clazz,
             "checkInjectEventsPermission", "(II)Z");
@@ -1401,99 +1167,6 @@
     GET_METHOD_ID(gCallbacksClassInfo.getPointerIcon, gCallbacksClassInfo.clazz,
             "getPointerIcon", "()Lcom/android/server/InputManager$PointerIcon;");
 
-    // InputWindow
-
-    FIND_CLASS(gInputWindowClassInfo.clazz, "com/android/server/InputWindow");
-
-    GET_FIELD_ID(gInputWindowClassInfo.inputChannel, gInputWindowClassInfo.clazz,
-            "inputChannel", "Landroid/view/InputChannel;");
-
-    GET_FIELD_ID(gInputWindowClassInfo.name, gInputWindowClassInfo.clazz,
-            "name", "Ljava/lang/String;");
-
-    GET_FIELD_ID(gInputWindowClassInfo.layoutParamsFlags, gInputWindowClassInfo.clazz,
-            "layoutParamsFlags", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.layoutParamsType, gInputWindowClassInfo.clazz,
-            "layoutParamsType", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.dispatchingTimeoutNanos, gInputWindowClassInfo.clazz,
-            "dispatchingTimeoutNanos", "J");
-
-    GET_FIELD_ID(gInputWindowClassInfo.frameLeft, gInputWindowClassInfo.clazz,
-            "frameLeft", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.frameTop, gInputWindowClassInfo.clazz,
-            "frameTop", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.frameRight, gInputWindowClassInfo.clazz,
-            "frameRight", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.frameBottom, gInputWindowClassInfo.clazz,
-            "frameBottom", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameLeft, gInputWindowClassInfo.clazz,
-            "visibleFrameLeft", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameTop, gInputWindowClassInfo.clazz,
-            "visibleFrameTop", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameRight, gInputWindowClassInfo.clazz,
-            "visibleFrameRight", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameBottom, gInputWindowClassInfo.clazz,
-            "visibleFrameBottom", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaLeft, gInputWindowClassInfo.clazz,
-            "touchableAreaLeft", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaTop, gInputWindowClassInfo.clazz,
-            "touchableAreaTop", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaRight, gInputWindowClassInfo.clazz,
-            "touchableAreaRight", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaBottom, gInputWindowClassInfo.clazz,
-            "touchableAreaBottom", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.visible, gInputWindowClassInfo.clazz,
-            "visible", "Z");
-
-    GET_FIELD_ID(gInputWindowClassInfo.canReceiveKeys, gInputWindowClassInfo.clazz,
-            "canReceiveKeys", "Z");
-
-    GET_FIELD_ID(gInputWindowClassInfo.hasFocus, gInputWindowClassInfo.clazz,
-            "hasFocus", "Z");
-
-    GET_FIELD_ID(gInputWindowClassInfo.hasWallpaper, gInputWindowClassInfo.clazz,
-            "hasWallpaper", "Z");
-
-    GET_FIELD_ID(gInputWindowClassInfo.paused, gInputWindowClassInfo.clazz,
-            "paused", "Z");
-
-    GET_FIELD_ID(gInputWindowClassInfo.layer, gInputWindowClassInfo.clazz,
-            "layer", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.ownerPid, gInputWindowClassInfo.clazz,
-            "ownerPid", "I");
-
-    GET_FIELD_ID(gInputWindowClassInfo.ownerUid, gInputWindowClassInfo.clazz,
-            "ownerUid", "I");
-
-    // InputApplication
-
-    FIND_CLASS(gInputApplicationClassInfo.clazz, "com/android/server/InputApplication");
-
-    GET_FIELD_ID(gInputApplicationClassInfo.name, gInputApplicationClassInfo.clazz,
-            "name", "Ljava/lang/String;");
-
-    GET_FIELD_ID(gInputApplicationClassInfo.dispatchingTimeoutNanos,
-            gInputApplicationClassInfo.clazz,
-            "dispatchingTimeoutNanos", "J");
-
-    GET_FIELD_ID(gInputApplicationClassInfo.token, gInputApplicationClassInfo.clazz,
-            "token", "Ljava/lang/Object;");
-
     // KeyEvent
 
     FIND_CLASS(gKeyEventClassInfo.clazz, "android/view/KeyEvent");
diff --git a/services/jni/com_android_server_InputWindow.cpp b/services/jni/com_android_server_InputWindow.cpp
new file mode 100644
index 0000000..a4609a0
--- /dev/null
+++ b/services/jni/com_android_server_InputWindow.cpp
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#define LOG_TAG "InputWindow"
+
+#include "JNIHelp.h"
+#include "jni.h"
+#include <android_runtime/AndroidRuntime.h>
+
+#include <android_view_InputChannel.h>
+#include "com_android_server_InputWindow.h"
+#include "com_android_server_InputWindowHandle.h"
+
+namespace android {
+
+static struct {
+    jclass clazz;
+
+    jfieldID inputWindowHandle;
+    jfieldID inputChannel;
+    jfieldID name;
+    jfieldID layoutParamsFlags;
+    jfieldID layoutParamsType;
+    jfieldID dispatchingTimeoutNanos;
+    jfieldID frameLeft;
+    jfieldID frameTop;
+    jfieldID frameRight;
+    jfieldID frameBottom;
+    jfieldID visibleFrameLeft;
+    jfieldID visibleFrameTop;
+    jfieldID visibleFrameRight;
+    jfieldID visibleFrameBottom;
+    jfieldID touchableAreaLeft;
+    jfieldID touchableAreaTop;
+    jfieldID touchableAreaRight;
+    jfieldID touchableAreaBottom;
+    jfieldID visible;
+    jfieldID canReceiveKeys;
+    jfieldID hasFocus;
+    jfieldID hasWallpaper;
+    jfieldID paused;
+    jfieldID layer;
+    jfieldID ownerPid;
+    jfieldID ownerUid;
+} gInputWindowClassInfo;
+
+
+// --- Global functions ---
+
+void android_server_InputWindow_toNative(
+        JNIEnv* env, jobject inputWindowObj, InputWindow* outInputWindow) {
+    jobject inputWindowHandleObj = env->GetObjectField(inputWindowObj,
+            gInputWindowClassInfo.inputWindowHandle);
+    if (inputWindowHandleObj) {
+        outInputWindow->inputWindowHandle =
+                android_server_InputWindowHandle_getHandle(env, inputWindowHandleObj);
+        env->DeleteLocalRef(inputWindowHandleObj);
+    } else {
+        outInputWindow->inputWindowHandle = NULL;
+    }
+
+    jobject inputChannelObj = env->GetObjectField(inputWindowObj,
+            gInputWindowClassInfo.inputChannel);
+    if (inputChannelObj) {
+        outInputWindow->inputChannel =
+                android_view_InputChannel_getInputChannel(env, inputChannelObj);
+        env->DeleteLocalRef(inputChannelObj);
+    } else {
+        outInputWindow->inputChannel = NULL;
+    }
+
+    jstring nameObj = jstring(env->GetObjectField(inputWindowObj,
+            gInputWindowClassInfo.name));
+    if (nameObj) {
+        const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
+        outInputWindow->name.setTo(nameStr);
+        env->ReleaseStringUTFChars(nameObj, nameStr);
+        env->DeleteLocalRef(nameObj);
+    } else {
+        LOGE("InputWindow.name should not be null.");
+        outInputWindow->name.setTo("unknown");
+    }
+
+    outInputWindow->layoutParamsFlags = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.layoutParamsFlags);
+    outInputWindow->layoutParamsType = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.layoutParamsType);
+    outInputWindow->dispatchingTimeout = env->GetLongField(inputWindowObj,
+            gInputWindowClassInfo.dispatchingTimeoutNanos);
+    outInputWindow->frameLeft = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.frameLeft);
+    outInputWindow->frameTop = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.frameTop);
+    outInputWindow->frameRight = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.frameRight);
+    outInputWindow->frameBottom = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.frameBottom);
+    outInputWindow->visibleFrameLeft = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.visibleFrameLeft);
+    outInputWindow->visibleFrameTop = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.visibleFrameTop);
+    outInputWindow->visibleFrameRight = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.visibleFrameRight);
+    outInputWindow->visibleFrameBottom = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.visibleFrameBottom);
+    outInputWindow->touchableAreaLeft = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.touchableAreaLeft);
+    outInputWindow->touchableAreaTop = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.touchableAreaTop);
+    outInputWindow->touchableAreaRight = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.touchableAreaRight);
+    outInputWindow->touchableAreaBottom = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.touchableAreaBottom);
+    outInputWindow->visible = env->GetBooleanField(inputWindowObj,
+            gInputWindowClassInfo.visible);
+    outInputWindow->canReceiveKeys = env->GetBooleanField(inputWindowObj,
+            gInputWindowClassInfo.canReceiveKeys);
+    outInputWindow->hasFocus = env->GetBooleanField(inputWindowObj,
+            gInputWindowClassInfo.hasFocus);
+    outInputWindow->hasWallpaper = env->GetBooleanField(inputWindowObj,
+            gInputWindowClassInfo.hasWallpaper);
+    outInputWindow->paused = env->GetBooleanField(inputWindowObj,
+            gInputWindowClassInfo.paused);
+    outInputWindow->layer = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.layer);
+    outInputWindow->ownerPid = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.ownerPid);
+    outInputWindow->ownerUid = env->GetIntField(inputWindowObj,
+            gInputWindowClassInfo.ownerUid);
+}
+
+
+// --- JNI ---
+
+#define FIND_CLASS(var, className) \
+        var = env->FindClass(className); \
+        LOG_FATAL_IF(! var, "Unable to find class " className); \
+        var = jclass(env->NewGlobalRef(var));
+
+#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
+        var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
+        LOG_FATAL_IF(! var, "Unable to find field " fieldName);
+
+int register_android_server_InputWindow(JNIEnv* env) {
+    FIND_CLASS(gInputWindowClassInfo.clazz, "com/android/server/InputWindow");
+
+    GET_FIELD_ID(gInputWindowClassInfo.inputWindowHandle, gInputWindowClassInfo.clazz,
+            "inputWindowHandle", "Lcom/android/server/InputWindowHandle;");
+
+    GET_FIELD_ID(gInputWindowClassInfo.inputChannel, gInputWindowClassInfo.clazz,
+            "inputChannel", "Landroid/view/InputChannel;");
+
+    GET_FIELD_ID(gInputWindowClassInfo.name, gInputWindowClassInfo.clazz,
+            "name", "Ljava/lang/String;");
+
+    GET_FIELD_ID(gInputWindowClassInfo.layoutParamsFlags, gInputWindowClassInfo.clazz,
+            "layoutParamsFlags", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.layoutParamsType, gInputWindowClassInfo.clazz,
+            "layoutParamsType", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.dispatchingTimeoutNanos, gInputWindowClassInfo.clazz,
+            "dispatchingTimeoutNanos", "J");
+
+    GET_FIELD_ID(gInputWindowClassInfo.frameLeft, gInputWindowClassInfo.clazz,
+            "frameLeft", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.frameTop, gInputWindowClassInfo.clazz,
+            "frameTop", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.frameRight, gInputWindowClassInfo.clazz,
+            "frameRight", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.frameBottom, gInputWindowClassInfo.clazz,
+            "frameBottom", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameLeft, gInputWindowClassInfo.clazz,
+            "visibleFrameLeft", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameTop, gInputWindowClassInfo.clazz,
+            "visibleFrameTop", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameRight, gInputWindowClassInfo.clazz,
+            "visibleFrameRight", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.visibleFrameBottom, gInputWindowClassInfo.clazz,
+            "visibleFrameBottom", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaLeft, gInputWindowClassInfo.clazz,
+            "touchableAreaLeft", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaTop, gInputWindowClassInfo.clazz,
+            "touchableAreaTop", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaRight, gInputWindowClassInfo.clazz,
+            "touchableAreaRight", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.touchableAreaBottom, gInputWindowClassInfo.clazz,
+            "touchableAreaBottom", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.visible, gInputWindowClassInfo.clazz,
+            "visible", "Z");
+
+    GET_FIELD_ID(gInputWindowClassInfo.canReceiveKeys, gInputWindowClassInfo.clazz,
+            "canReceiveKeys", "Z");
+
+    GET_FIELD_ID(gInputWindowClassInfo.hasFocus, gInputWindowClassInfo.clazz,
+            "hasFocus", "Z");
+
+    GET_FIELD_ID(gInputWindowClassInfo.hasWallpaper, gInputWindowClassInfo.clazz,
+            "hasWallpaper", "Z");
+
+    GET_FIELD_ID(gInputWindowClassInfo.paused, gInputWindowClassInfo.clazz,
+            "paused", "Z");
+
+    GET_FIELD_ID(gInputWindowClassInfo.layer, gInputWindowClassInfo.clazz,
+            "layer", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.ownerPid, gInputWindowClassInfo.clazz,
+            "ownerPid", "I");
+
+    GET_FIELD_ID(gInputWindowClassInfo.ownerUid, gInputWindowClassInfo.clazz,
+            "ownerUid", "I");
+    return 0;
+}
+
+} /* namespace android */
diff --git a/services/jni/com_android_server_InputWindow.h b/services/jni/com_android_server_InputWindow.h
new file mode 100644
index 0000000..eaf7bde
--- /dev/null
+++ b/services/jni/com_android_server_InputWindow.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef _ANDROID_SERVER_INPUT_WINDOW_H
+#define _ANDROID_SERVER_INPUT_WINDOW_H
+
+#include <input/InputWindow.h>
+
+#include "JNIHelp.h"
+#include "jni.h"
+
+namespace android {
+
+extern void android_server_InputWindow_toNative(
+        JNIEnv* env, jobject inputWindowObj, InputWindow* outInputWindow);
+
+} // namespace android
+
+#endif // _ANDROID_SERVER_INPUT_WINDOW_H
diff --git a/services/jni/com_android_server_InputWindowHandle.cpp b/services/jni/com_android_server_InputWindowHandle.cpp
new file mode 100644
index 0000000..4d66212
--- /dev/null
+++ b/services/jni/com_android_server_InputWindowHandle.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#define LOG_TAG "InputWindowHandle"
+
+#include "JNIHelp.h"
+#include "jni.h"
+#include <android_runtime/AndroidRuntime.h>
+#include <utils/threads.h>
+
+#include "com_android_server_InputWindowHandle.h"
+#include "com_android_server_InputApplicationHandle.h"
+
+namespace android {
+
+static struct {
+    jclass clazz;
+
+    jfieldID ptr;
+    jfieldID inputApplicationHandle;
+} gInputWindowHandleClassInfo;
+
+static Mutex gHandleMutex;
+
+
+// --- NativeInputWindowHandle ---
+
+NativeInputWindowHandle::NativeInputWindowHandle(
+        const sp<InputApplicationHandle>& inputApplicationHandle, jweak objWeak) :
+        InputWindowHandle(inputApplicationHandle),
+        mObjWeak(objWeak) {
+}
+
+NativeInputWindowHandle::~NativeInputWindowHandle() {
+    JNIEnv* env = AndroidRuntime::getJNIEnv();
+    env->DeleteWeakGlobalRef(mObjWeak);
+}
+
+jobject NativeInputWindowHandle::getInputWindowHandleObjLocalRef(JNIEnv* env) {
+    return env->NewLocalRef(mObjWeak);
+}
+
+
+// --- Global functions ---
+
+sp<NativeInputWindowHandle> android_server_InputWindowHandle_getHandle(
+        JNIEnv* env, jobject inputWindowHandleObj) {
+    if (!inputWindowHandleObj) {
+        return NULL;
+    }
+
+    AutoMutex _l(gHandleMutex);
+
+    int ptr = env->GetIntField(inputWindowHandleObj, gInputWindowHandleClassInfo.ptr);
+    NativeInputWindowHandle* handle;
+    if (ptr) {
+        handle = reinterpret_cast<NativeInputWindowHandle*>(ptr);
+    } else {
+        jobject inputApplicationHandleObj = env->GetObjectField(inputWindowHandleObj,
+                gInputWindowHandleClassInfo.inputApplicationHandle);
+        sp<InputApplicationHandle> inputApplicationHandle =
+                android_server_InputApplicationHandle_getHandle(env, inputApplicationHandleObj);
+        env->DeleteLocalRef(inputApplicationHandleObj);
+
+        jweak objWeak = env->NewWeakGlobalRef(inputWindowHandleObj);
+        handle = new NativeInputWindowHandle(inputApplicationHandle, objWeak);
+        handle->incStrong(inputWindowHandleObj);
+        env->SetIntField(inputWindowHandleObj, gInputWindowHandleClassInfo.ptr,
+                reinterpret_cast<int>(handle));
+    }
+    return handle;
+}
+
+
+// --- JNI ---
+
+static void android_server_InputWindowHandle_nativeDispose(JNIEnv* env, jobject obj) {
+    AutoMutex _l(gHandleMutex);
+
+    int ptr = env->GetIntField(obj, gInputWindowHandleClassInfo.ptr);
+    if (ptr) {
+        env->SetIntField(obj, gInputWindowHandleClassInfo.ptr, 0);
+
+        NativeInputWindowHandle* handle = reinterpret_cast<NativeInputWindowHandle*>(ptr);
+        handle->decStrong(obj);
+    }
+}
+
+
+static JNINativeMethod gInputWindowHandleMethods[] = {
+    /* name, signature, funcPtr */
+    { "nativeDispose", "()V",
+            (void*) android_server_InputWindowHandle_nativeDispose },
+};
+
+#define FIND_CLASS(var, className) \
+        var = env->FindClass(className); \
+        LOG_FATAL_IF(! var, "Unable to find class " className); \
+        var = jclass(env->NewGlobalRef(var));
+
+#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
+        var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
+        LOG_FATAL_IF(! var, "Unable to find field " fieldName);
+
+int register_android_server_InputWindowHandle(JNIEnv* env) {
+    int res = jniRegisterNativeMethods(env, "com/android/server/InputWindowHandle",
+            gInputWindowHandleMethods, NELEM(gInputWindowHandleMethods));
+    LOG_FATAL_IF(res < 0, "Unable to register native methods.");
+
+    FIND_CLASS(gInputWindowHandleClassInfo.clazz, "com/android/server/InputWindowHandle");
+
+    GET_FIELD_ID(gInputWindowHandleClassInfo.ptr, gInputWindowHandleClassInfo.clazz,
+            "ptr", "I");
+
+    GET_FIELD_ID(gInputWindowHandleClassInfo.inputApplicationHandle,
+            gInputWindowHandleClassInfo.clazz,
+            "inputApplicationHandle", "Lcom/android/server/InputApplicationHandle;");
+
+    return 0;
+}
+
+} /* namespace android */
diff --git a/services/jni/com_android_server_InputWindowHandle.h b/services/jni/com_android_server_InputWindowHandle.h
new file mode 100644
index 0000000..43f2a6b
--- /dev/null
+++ b/services/jni/com_android_server_InputWindowHandle.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef _ANDROID_SERVER_INPUT_WINDOW_HANDLE_H
+#define _ANDROID_SERVER_INPUT_WINDOW_HANDLE_H
+
+#include <input/InputWindow.h>
+
+#include "JNIHelp.h"
+#include "jni.h"
+
+namespace android {
+
+class NativeInputWindowHandle : public InputWindowHandle {
+public:
+    NativeInputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle,
+            jweak objWeak);
+    virtual ~NativeInputWindowHandle();
+
+    jobject getInputWindowHandleObjLocalRef(JNIEnv* env);
+
+private:
+    jweak mObjWeak;
+};
+
+
+extern sp<NativeInputWindowHandle> android_server_InputWindowHandle_getHandle(
+        JNIEnv* env, jobject inputWindowHandleObj);
+
+} // namespace android
+
+#endif // _ANDROID_SERVER_INPUT_WINDOW_HANDLE_H
diff --git a/services/jni/onload.cpp b/services/jni/onload.cpp
index cd4f0a4..bdd6d80 100644
--- a/services/jni/onload.cpp
+++ b/services/jni/onload.cpp
@@ -6,6 +6,10 @@
 namespace android {
 int register_android_server_AlarmManagerService(JNIEnv* env);
 int register_android_server_BatteryService(JNIEnv* env);
+int register_android_server_InputApplication(JNIEnv* env);
+int register_android_server_InputApplicationHandle(JNIEnv* env);
+int register_android_server_InputWindow(JNIEnv* env);
+int register_android_server_InputWindowHandle(JNIEnv* env);
 int register_android_server_InputManager(JNIEnv* env);
 int register_android_server_LightsService(JNIEnv* env);
 int register_android_server_PowerManagerService(JNIEnv* env);
@@ -28,6 +32,10 @@
     LOG_ASSERT(env, "Could not retrieve the env!");
 
     register_android_server_PowerManagerService(env);
+    register_android_server_InputApplication(env);
+    register_android_server_InputApplicationHandle(env);
+    register_android_server_InputWindow(env);
+    register_android_server_InputWindowHandle(env);
     register_android_server_InputManager(env);
     register_android_server_LightsService(env);
     register_android_server_AlarmManagerService(env);
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 0fdc030..e73afa0 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -34,6 +34,15 @@
         </activity>
         
         <activity
+                android:name="ViewLayersActivity2"
+                android:label="_ViewLayers2">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        
+        <activity
                 android:name="AlphaLayersActivity"
                 android:label="_αLayers">
             <intent-filter>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java
index 91e3b84..8ca842e 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/LinesActivity.java
@@ -23,6 +23,7 @@
 import android.graphics.BitmapShader;
 import android.graphics.Canvas;
 import android.graphics.Paint;
+import android.graphics.drawable.ColorDrawable;
 import android.os.Bundle;
 import android.view.View;
 
@@ -31,7 +32,9 @@
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        getWindow().setBackgroundDrawable(new ColorDrawable(0xffffffff));
         final LinesView view = new LinesView(this);
+        //view.setAlpha(0.80f);
         setContentView(view);
     }
 
@@ -91,8 +94,6 @@
         protected void onDraw(Canvas canvas) {
             super.onDraw(canvas);
 
-            canvas.drawARGB(255, 255, 255, 255);
-
             canvas.save();
             canvas.translate(100.0f, 20.0f);
 
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/PathsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/PathsActivity.java
index aa1eb59..5ddcd20 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/PathsActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/PathsActivity.java
@@ -69,7 +69,7 @@
 
             mMediumPaint = new Paint();
             mMediumPaint.setAntiAlias(true);
-            mMediumPaint.setColor(0xff0000ff);
+            mMediumPaint.setColor(0xe00000ff);
             mMediumPaint.setStrokeWidth(10.0f);
             mMediumPaint.setStyle(Paint.Style.STROKE);
 
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity2.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity2.java
new file mode 100644
index 0000000..a0b1d78
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity2.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2011 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.test.hwui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.util.DisplayMetrics;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class ViewLayersActivity2 extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        
+        setContentView(R.layout.view_layers);
+
+        setupList(R.id.list1);
+        setupList(R.id.list2);
+        setupList(R.id.list3);
+    }
+
+    private void setupList(int listId) {
+        final ListView list = (ListView) findViewById(listId);
+        list.setAdapter(new SimpleListAdapter(this));
+        list.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+    }
+
+    private static class SimpleListAdapter extends ArrayAdapter<String> {
+        public SimpleListAdapter(Context context) {
+            super(context, android.R.layout.simple_list_item_1, DATA_LIST);
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            TextView v = (TextView) super.getView(position, convertView, parent);
+            final Resources r = getContext().getResources();
+            final DisplayMetrics metrics = r.getDisplayMetrics();
+            v.setCompoundDrawablePadding((int) (6 * metrics.density + 0.5f));
+            v.setCompoundDrawablesWithIntrinsicBounds(r.getDrawable(R.drawable.icon),
+                    null, null, null);
+            return v;
+        }
+    }
+
+    private static final String[] DATA_LIST = {
+            "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
+            "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
+            "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
+            "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
+            "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
+            "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil",
+            "British Indian Ocean Territory", "British Virgin Islands", "Brunei", "Bulgaria",
+            "Burkina Faso", "Burundi", "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
+            "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
+            "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
+            "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic",
+            "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic",
+            "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
+            "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland",
+            "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia",
+            "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar",
+            "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau",
+            "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary",
+            "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica",
+            "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos",
+            "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
+            "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands",
+            "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova",
+            "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia",
+            "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand",
+            "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas",
+            "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru",
+            "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar",
+            "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena",
+            "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon",
+            "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal",
+            "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands",
+            "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea",
+            "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden",
+            "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas",
+            "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey",
+            "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda",
+            "Ukraine", "United Arab Emirates", "United Kingdom",
+            "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan",
+            "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara",
+            "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"
+    };
+}
diff --git a/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java b/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java
index bb0fa60..2c8c5ba 100644
--- a/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java
+++ b/tests/appwidgets/AppWidgetHostTest/src/com/android/tests/appwidgethost/AppWidgetHostActivity.java
@@ -46,14 +46,22 @@
     AppWidgetContainerView mAppWidgetContainer;
 
     public AppWidgetHostActivity() {
-        mAppWidgetManager = AppWidgetManager.getInstance(this);
     }
 
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
+        mAppWidgetManager = AppWidgetManager.getInstance(this);
+
         setContentView(R.layout.appwidget_host);
 
+        mHost = new AppWidgetHost(this, HOST_ID) {
+                protected AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) {
+                    return new MyAppWidgetView(appWidgetId);
+                }
+            };
+
+
         findViewById(R.id.add_appwidget).setOnClickListener(mOnClickListener);
         mAppWidgetContainer = (AppWidgetContainerView)findViewById(R.id.appwidget_container);
 
@@ -188,11 +196,7 @@
         }
     }
 
-    AppWidgetHost mHost = new AppWidgetHost(this, HOST_ID) {
-        protected AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) {
-            return new MyAppWidgetView(appWidgetId);
-        }
-    };
+    AppWidgetHost mHost;
 }
 
 
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
index c57aef6..096498b 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory.java
@@ -351,7 +351,8 @@
                 If the exception happened on open, bm will be null.
                 If it happened on close, bm is still valid.
             */
-            Bridge.getLog().error(null, e);
+            Bridge.getLog().error(null,
+                    String.format("Error decoding bitmap of id 0x%x", id), e);
         } finally {
             try {
                 if (is != null) is.close();
diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
index e9fb30a..5524f4f 100644
--- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -73,7 +73,7 @@
             oos = new ObjectOutputStream(baos);
             oos.writeObject(chunk);
         } catch (IOException e) {
-            Bridge.getLog().error("Failed to serialize NinePatchChunk.", e);
+            Bridge.getLog().error(null, "Failed to serialize NinePatchChunk.", e);
             return null;
         } finally {
             if (oos != null) {
@@ -196,10 +196,10 @@
                     sChunkCache.put(array, new SoftReference<NinePatchChunk>(chunk));
                 }
             } catch (IOException e) {
-                Bridge.getLog().error("Failed to deserialize NinePatchChunk content.", e);
+                Bridge.getLog().error(null, "Failed to deserialize NinePatchChunk content.", e);
                 return null;
             } catch (ClassNotFoundException e) {
-                Bridge.getLog().error("Failed to deserialize NinePatchChunk class.", e);
+                Bridge.getLog().error(null, "Failed to deserialize NinePatchChunk class.", e);
                 return null;
             } finally {
                 if (ois != null) {
diff --git a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
index bc13b52..33c2aed 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
@@ -135,6 +135,123 @@
 
     // ---- native methods ----
 
+    /*package*/ static boolean isEmpty(Region thisRegion) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return true;
+        }
+
+        return regionDelegate.mArea.isEmpty();
+    }
+
+    /*package*/ static boolean isRect(Region thisRegion) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return true;
+        }
+
+        return regionDelegate.mArea.isRectangular();
+    }
+
+    /*package*/ static boolean isComplex(Region thisRegion) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return true;
+        }
+
+        return regionDelegate.mArea.isSingular() == false;
+    }
+
+    /*package*/ static boolean contains(Region thisRegion, int x, int y) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return false;
+        }
+
+        return regionDelegate.mArea.contains(x, y);
+    }
+
+    /*package*/ static boolean quickContains(Region thisRegion,
+            int left, int top, int right, int bottom) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return false;
+        }
+
+        return regionDelegate.mArea.isRectangular() &&
+                regionDelegate.mArea.contains(left, top, right - left, bottom - top);
+    }
+
+    /*package*/ static boolean quickReject(Region thisRegion,
+            int left, int top, int right, int bottom) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return false;
+        }
+
+        return regionDelegate.mArea.isEmpty() ||
+                regionDelegate.mArea.intersects(left, top, right - left, bottom - top) == false;
+    }
+
+    /*package*/ static boolean quickReject(Region thisRegion, Region rgn) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return false;
+        }
+
+        Region_Delegate targetRegionDelegate = sManager.getDelegate(rgn.mNativeRegion);
+        if (targetRegionDelegate == null) {
+            return false;
+        }
+
+        return regionDelegate.mArea.isEmpty() ||
+                regionDelegate.mArea.getBounds().intersects(
+                        targetRegionDelegate.mArea.getBounds()) == false;
+
+    }
+
+    /*package*/ static void translate(Region thisRegion, int dx, int dy, Region dst) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return;
+        }
+
+        Region_Delegate targetRegionDelegate = sManager.getDelegate(dst.mNativeRegion);
+        if (targetRegionDelegate == null) {
+            return;
+        }
+
+        if (regionDelegate.mArea.isEmpty()) {
+            targetRegionDelegate.mArea = new Area();
+        } else {
+            targetRegionDelegate.mArea = new Area(regionDelegate.mArea);
+            AffineTransform mtx = new AffineTransform();
+            mtx.translate(dx, dy);
+            targetRegionDelegate.mArea.transform(mtx);
+        }
+    }
+
+    /*package*/ static void scale(Region thisRegion, float scale, Region dst) {
+        Region_Delegate regionDelegate = sManager.getDelegate(thisRegion.mNativeRegion);
+        if (regionDelegate == null) {
+            return;
+        }
+
+        Region_Delegate targetRegionDelegate = sManager.getDelegate(dst.mNativeRegion);
+        if (targetRegionDelegate == null) {
+            return;
+        }
+
+        if (regionDelegate.mArea.isEmpty()) {
+            targetRegionDelegate.mArea = new Area();
+        } else {
+            targetRegionDelegate.mArea = new Area(regionDelegate.mArea);
+            AffineTransform mtx = new AffineTransform();
+            mtx.scale(scale, scale);
+            targetRegionDelegate.mArea.transform(mtx);
+        }
+    }
+
     /*package*/ static int nativeConstructor() {
         Region_Delegate newDelegate = new Region_Delegate();
         return sManager.addDelegate(newDelegate);
diff --git a/tools/layoutlib/bridge/src/com/android/internal/util/XmlUtils_Delegate.java b/tools/layoutlib/bridge/src/com/android/internal/util/XmlUtils_Delegate.java
new file mode 100644
index 0000000..7fa1679
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/internal/util/XmlUtils_Delegate.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 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.util;
+
+
+/**
+ * Delegate used to provide new implementation of a select few methods of {@link XmlUtils}
+ *
+ * Through the layoutlib_create tool, the original  methods of XmlUtils have been replaced
+ * by calls to methods of the same name in this delegate class.
+ *
+ */
+public class XmlUtils_Delegate {
+    /*package*/ static final int convertValueToInt(CharSequence charSeq, int defaultValue) {
+        if (null == charSeq)
+            return defaultValue;
+
+        String nm = charSeq.toString();
+
+        // This code is copied from the original implementation. The issue is that
+        // The Dalvik libraries are able to handle Integer.parse("XXXXXXXX", 16) where XXXXXXX
+        // is > 80000000 but the Java VM cannot.
+
+        int sign = 1;
+        int index = 0;
+        int len = nm.length();
+        int base = 10;
+
+        if ('-' == nm.charAt(0)) {
+            sign = -1;
+            index++;
+        }
+
+        if ('0' == nm.charAt(index)) {
+            //  Quick check for a zero by itself
+            if (index == (len - 1))
+                return 0;
+
+            char c = nm.charAt(index + 1);
+
+            if ('x' == c || 'X' == c) {
+                index += 2;
+                base = 16;
+            } else {
+                index++;
+                base = 8;
+            }
+        }
+        else if ('#' == nm.charAt(index)) {
+            index++;
+            base = 16;
+        }
+
+        return ((int)Long.parseLong(nm.substring(index), base)) * sign;
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index c042327..7713f4b 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -142,16 +142,6 @@
         }
 
         @Override
-        public void error(String tag, Throwable t) {
-            String message = t.getMessage();
-            if (message == null) {
-                message = t.getClass().getName();
-            }
-
-            System.err.println(message);
-        }
-
-        @Override
         public void error(String tag, String message, Throwable throwable) {
             System.err.println(message);
         }
@@ -328,7 +318,7 @@
                 t2 = t.getCause();
             }
             return new BridgeRenderSession(null,
-                    ERROR_UNKNOWN.createResult(t2.getMessage(), t2));
+                    ERROR_UNKNOWN.createResult(t2.getMessage(), t));
         }
     }
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java
index 791e53b..194687e 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java
@@ -48,6 +48,7 @@
 
     public final static String PREFIX_ANDROID = "android:";
 
+    public final static String RES_ANIMATOR = "animator";
     public final static String RES_STYLE = "style";
     public final static String RES_ATTR = "attr";
     public final static String RES_DIMEN = "dimen";
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
index 6ebc56c..4c4eedb 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
@@ -170,7 +170,9 @@
 
     /*package*/ BridgeRenderSession(RenderSessionImpl scene, Result lastResult) {
         mSession = scene;
-        mSession.setScene(this);
+        if (scene != null) {
+            mSession.setScene(this);
+        }
         mLastResult = lastResult;
     }
 }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index b0eea4c..28a690b0 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -382,8 +382,9 @@
                         defStyleValues = (StyleResourceValue)item;
                     }
                 } else {
-                    // TODO: log the error properly
-                    System.out.println("Failed to find defStyle: " + defStyleName);
+                    Bridge.getLog().error(null,
+                            String.format(
+                                    "Failed to find style '%s' in current theme", defStyleName));
                 }
             }
         }
@@ -493,12 +494,12 @@
     /**
      * Resolves the value of a resource, if the value references a theme or resource value.
      * <p/>
-     * This method ensures that it returns a {@link IResourceValue} object that does not
+     * This method ensures that it returns a {@link ResourceValue} object that does not
      * reference another resource.
      * If the resource cannot be resolved, it returns <code>null</code>.
      * <p/>
      * If a value that does not need to be resolved is given, the method will return a new
-     * instance of IResourceValue that contains the input value.
+     * instance of {@link ResourceValue} that contains the input value.
      *
      * @param type the type of the resource
      * @param name the name of the attribute containing this value.
@@ -510,11 +511,11 @@
             return null;
         }
 
-        // get the IResourceValue referenced by this value
+        // get the ResourceValue referenced by this value
         ResourceValue resValue = findResValue(value, false /*forceFrameworkOnly*/);
 
         // if resValue is null, but value is not null, this means it was not a reference.
-        // we return the name/value wrapper in a IResourceValue. the isFramework flag doesn't
+        // we return the name/value wrapper in a ResourceValue. the isFramework flag doesn't
         // matter.
         if (resValue == null) {
             return new ResourceValue(type, name, value, false /*isFramework*/);
@@ -525,9 +526,9 @@
     }
 
     /**
-     * Returns the {@link IResourceValue} referenced by the value of <var>value</var>.
+     * Returns the {@link ResourceValue} referenced by the value of <var>value</var>.
      * <p/>
-     * This method ensures that it returns a {@link IResourceValue} object that does not
+     * This method ensures that it returns a {@link ResourceValue} object that does not
      * reference another resource.
      * If the resource cannot be resolved, it returns <code>null</code>.
      * <p/>
@@ -535,7 +536,7 @@
      * value.
      *
      * @param value the value containing the reference to resolve.
-     * @return a {@link IResourceValue} object or <code>null</code>
+     * @return a {@link ResourceValue} object or <code>null</code>
      */
     public ResourceValue resolveResValue(ResourceValue value) {
         if (value == null) {
@@ -547,7 +548,7 @@
             return value;
         }
 
-        // else attempt to find another IResourceValue referenced by this one.
+        // else attempt to find another ResourceValue referenced by this one.
         ResourceValue resolvedValue = findResValue(value.getValue(), value.isFramework());
 
         // if the value did not reference anything, then we simply return the input value
@@ -560,7 +561,7 @@
     }
 
     /**
-     * Searches for, and returns a {@link IResourceValue} by its reference.
+     * Searches for, and returns a {@link ResourceValue} by its reference.
      * <p/>
      * The reference format can be:
      * <pre>@resType/resName</pre>
@@ -577,7 +578,7 @@
      * @param reference the resource reference to search for.
      * @param forceFrameworkOnly if true all references are considered to be toward framework
      *      resource even if the reference does not include the android: prefix.
-     * @return a {@link IResourceValue} or <code>null</code>.
+     * @return a {@link ResourceValue} or <code>null</code>.
      */
     ResourceValue findResValue(String reference, boolean forceFrameworkOnly) {
         if (reference == null) {
@@ -670,7 +671,7 @@
     }
 
     /**
-     * Searches for, and returns a {@link IResourceValue} by its name, and type.
+     * Searches for, and returns a {@link ResourceValue} by its name, and type.
      * @param resType the type of the resource
      * @param resName  the name of the resource
      * @param frameworkOnly if <code>true</code>, the method does not search in the
@@ -746,11 +747,11 @@
     }
 
     /**
-     * Returns the {@link IResourceValue} matching a given name in a given style. If the
+     * Returns the {@link ResourceValue} matching a given name in a given style. If the
      * item is not directly available in the style, the method looks in its parent style.
      * @param style the style to search in
      * @param itemName the name of the item to search for.
-     * @return the {@link IResourceValue} object or <code>null</code>
+     * @return the {@link ResourceValue} object or <code>null</code>
      */
     public ResourceValue findItemInStyle(StyleResourceValue style, String itemName) {
         ResourceValue item = style.findValue(itemName);
@@ -878,8 +879,8 @@
         return null;
     }
 
-    int getFrameworkIdValue(String idName, int defValue) {
-        Integer value = Bridge.getResourceValue(BridgeConstants.RES_ID, idName);
+    int getFrameworkResourceValue(String resType, String resName, int defValue) {
+        Integer value = Bridge.getResourceValue(resType, resName);
         if (value != null) {
             return value.intValue();
         }
@@ -887,9 +888,9 @@
         return defValue;
     }
 
-    int getProjectIdValue(String idName, int defValue) {
+    int getProjectResourceValue(String resType, String resName, int defValue) {
         if (mProjectCallback != null) {
-            Integer value = mProjectCallback.getResourceValue(BridgeConstants.RES_ID, idName);
+            Integer value = mProjectCallback.getResourceValue(resType, resName);
             if (value != null) {
                 return value.intValue();
             }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
index 1b59621..36aa335 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
@@ -178,8 +178,10 @@
 
                         return inflate(bridgeParser, root);
                     } catch (Exception e) {
-                        Bridge.getLog().error(null, e);
-                        // return null below.
+                        Bridge.getLog().error(null,
+                                "Failed to parse file " + f.getAbsolutePath(), e);
+
+                        return null;
                     }
                 }
             }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
index 2ea5281..a56800c 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
@@ -43,7 +43,6 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
-import java.io.IOException;
 import java.io.InputStream;
 
 /**
@@ -173,14 +172,13 @@
 
                         return ColorStateList.createFromXml(this,
                                 new BridgeXmlBlockParser(parser, mContext, resValue.isFramework()));
-                    } catch (XmlPullParserException e) {
-                        Bridge.getLog().error(null, e);
-                    } catch (FileNotFoundException e) {
-                        // will not happen, since we pre-check
-                    } catch (IOException e) {
-                        Bridge.getLog().error(null, e);
-                    }
+                    } catch (Exception e) {
+                        // this is an error and not warning since the file existence is checked before
+                        // attempting to parse it.
+                        Bridge.getLog().error(null, "Failed to parse file " + value, e);
 
+                        return null;
+                    }
                 } else {
                     // try to load the color state list from an int
                     try {
@@ -245,7 +243,8 @@
                     return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
                 }
             } catch (XmlPullParserException e) {
-                Bridge.getLog().error(null, e);
+                Bridge.getLog().error(null,
+                        "Failed to configure parser for " + value.getValue(), e);
                 // we'll return null below.
             } catch (FileNotFoundException e) {
                 // this shouldn't happen since we check above.
@@ -279,7 +278,8 @@
                     return new BridgeXmlBlockParser(parser, mContext, mPlatformResourceFlag[0]);
                 }
             } catch (XmlPullParserException e) {
-                Bridge.getLog().error(null, e);
+                Bridge.getLog().error(null,
+                        "Failed to configure parser for " + value.getValue(), e);
                 // we'll return null below.
             } catch (FileNotFoundException e) {
                 // this shouldn't happen since we check above.
@@ -294,7 +294,6 @@
         return null;
     }
 
-
     @Override
     public TypedArray obtainAttributes(AttributeSet set, int[] attrs) {
         return mContext.obtainStyledAttributes(set, attrs);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
index 4fb280d..7f11897 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
@@ -322,9 +322,9 @@
         } catch (Exception e) {
             // this is an error and not warning since the file existence is checked before
             // attempting to parse it.
-            Bridge.getLog().error(null, e);
+            Bridge.getLog().error(null, "Failed to parse file " + value, e);
 
-            // return null below.
+            return null;
         }
 
         // looks like were unable to resolve the color value.
@@ -577,19 +577,21 @@
             return mContext.getDynamicIdByStyle((StyleResourceValue)resValue);
         }
 
-        // if the attribute was a reference to an id, and not a declaration of an id (@+id), then
-        // the xml attribute value was "resolved" which leads us to a ResourceValue with
-        // getType() returning "id" and getName() returning the id name
+        // if the attribute was a reference to a resource, and not a declaration of an id (@+id),
+        // then the xml attribute value was "resolved" which leads us to a ResourceValue with a
+        // valid getType() and getName() returning a resource name.
         // (and getValue() returning null!). We need to handle this!
-        if (resValue.getType() != null && resValue.getType().equals(BridgeConstants.RES_ID)) {
+        if (resValue.getType() != null && resValue.getType().startsWith("@+") == false) {
             // if this is a framework id
             if (mPlatformFile || resValue.isFramework()) {
                 // look for idName in the android R classes
-                return mContext.getFrameworkIdValue(resValue.getName(), defValue);
+                return mContext.getFrameworkResourceValue(
+                        resValue.getType(), resValue.getName(), defValue);
             }
 
             // look for idName in the project R class.
-            return mContext.getProjectIdValue(resValue.getName(), defValue);
+            return mContext.getProjectResourceValue(
+                    resValue.getType(), resValue.getName(), defValue);
         }
 
         // else, try to get the value, and resolve it somehow.
@@ -626,11 +628,11 @@
             // if this is a framework id
             if (mPlatformFile || value.startsWith("@android") || value.startsWith("@+android")) {
                 // look for idName in the android R classes
-                return mContext.getFrameworkIdValue(idName, defValue);
+                return mContext.getFrameworkResourceValue(BridgeConstants.RES_ID, idName, defValue);
             }
 
             // look for idName in the project R class.
-            return mContext.getProjectIdValue(idName, defValue);
+            return mContext.getProjectResourceValue(BridgeConstants.RES_ID, idName, defValue);
         }
 
         // not a direct id valid reference? resolve it
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
index 74e5a65..ff46e7c 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
@@ -106,7 +106,7 @@
         // pass for now.
     }
 
-    public IBinder prepareDrag(IWindow window, boolean localOnly,
+    public IBinder prepareDrag(IWindow window, int flags,
             int thumbnailWidth, int thumbnailHeight, Surface outSurface)
             throws RemoteException {
         // pass for now
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index 55a5bc0..5d5f2a1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -365,7 +365,7 @@
             }
 
             // log it
-            mParams.getLog().error("Scene inflate failed", t);
+            mParams.getLog().error(null, "Scene inflate failed", t);
 
             return ERROR_INFLATION.createResult(t.getMessage(), t);
         }
@@ -481,7 +481,7 @@
             }
 
             // log it
-            mParams.getLog().error("Scene Render failed", t);
+            mParams.getLog().error(null, "Scene Render failed", t);
 
             return ERROR_UNKNOWN.createResult(t.getMessage(), t);
         }
@@ -505,14 +505,18 @@
         ResourceValue animationResource = null;
         int animationId = 0;
         if (isFrameworkAnimation) {
-            animationResource = mContext.getFrameworkResource("anim", animationName);
+            animationResource = mContext.getFrameworkResource(BridgeConstants.RES_ANIMATOR,
+                    animationName);
             if (animationResource != null) {
-                animationId = Bridge.getResourceValue("anim", animationName);
+                animationId = Bridge.getResourceValue(BridgeConstants.RES_ANIMATOR,
+                        animationName);
             }
         } else {
-            animationResource = mContext.getProjectResource("anim", animationName);
+            animationResource = mContext.getProjectResource(BridgeConstants.RES_ANIMATOR,
+                    animationName);
             if (animationResource != null) {
-                animationId = mContext.getProjectCallback().getResourceValue("anim", animationName);
+                animationId = mContext.getProjectCallback().getResourceValue(
+                        BridgeConstants.RES_ANIMATOR, animationName);
             }
         }
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 5427f142..fb52c86 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -27,7 +27,6 @@
 
 import org.kxml2.io.KXmlParser;
 import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
 
 import android.graphics.Bitmap;
 import android.graphics.Bitmap_Delegate;
@@ -40,7 +39,6 @@
 import android.util.TypedValue;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -162,7 +160,7 @@
                         // URL is wrong, we'll return null below
                     } catch (IOException e) {
                         // failed to read the file, we'll return null below.
-                        Bridge.getLog().error(null, e);
+                        Bridge.getLog().error(null, "Failed lot load " + file.getAbsolutePath(), e);
                     }
                 }
 
@@ -190,13 +188,14 @@
                     d = Drawable.createFromXml(context.getResources(),
                             new BridgeXmlBlockParser(parser, context, isFramework));
                     return d;
-                } catch (XmlPullParserException e) {
-                    Bridge.getLog().error(null, e);
-                } catch (FileNotFoundException e) {
-                    // will not happen, since we pre-check
-                } catch (IOException e) {
-                    Bridge.getLog().error(null, e);
+                } catch (Exception e) {
+                    // this is an error and not warning since the file existence is checked before
+                    // attempting to parse it.
+                    Bridge.getLog().error(null, "Failed to parse file " + value, e);
                 }
+            } else {
+                Bridge.getLog().error(null,
+                        String.format("File %s does not exist (or is not a file)", stringValue));
             }
 
             return null;
@@ -222,7 +221,7 @@
                     return new BitmapDrawable(context.getResources(), bitmap);
                 } catch (IOException e) {
                     // we'll return null below
-                    Bridge.getLog().error(null, e);
+                    Bridge.getLog().error(null, "Failed lot load " + bmpFile.getAbsolutePath(), e);
                 }
             } else {
                 // attempt to get a color from the value
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 6b589d7..4198006 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -97,6 +97,7 @@
         "android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
         "android.os.Handler#sendMessageAtTime",
         "android.view.View#isInEditMode",
+        "com.android.internal.util.XmlUtils#convertValueToInt"
         // TODO: comment out once DelegateClass is working
         // "android.content.res.Resources$Theme#obtainStyledAttributes",
     };
diff --git a/voip/java/android/net/sip/SipProfile.java b/voip/java/android/net/sip/SipProfile.java
index f8fd2b7..c7e18df 100644
--- a/voip/java/android/net/sip/SipProfile.java
+++ b/voip/java/android/net/sip/SipProfile.java
@@ -49,6 +49,7 @@
     private String mDomain;
     private String mProtocol = UDP;
     private String mProfileName;
+    private String mAuthUserName;
     private int mPort = DEFAULT_PORT;
     private boolean mSendKeepAlive = false;
     private boolean mAutoRegistration = true;
@@ -147,6 +148,18 @@
         }
 
         /**
+         * Sets the username used for authentication.
+         *
+         * @param name auth. name of the profile
+         * @return this builder object
+         * @hide // TODO: remove when we make it public
+         */
+        public Builder setAuthUserName(String name) {
+            mProfile.mAuthUserName = name;
+            return this;
+        }
+
+        /**
          * Sets the name of the profile. This name is given by user.
          *
          * @param name name of the profile
@@ -300,6 +313,7 @@
         mAutoRegistration = (in.readInt() == 0) ? false : true;
         mCallingUid = in.readInt();
         mPort = in.readInt();
+        mAuthUserName = in.readString();
     }
 
     @Override
@@ -314,6 +328,7 @@
         out.writeInt(mAutoRegistration ? 1 : 0);
         out.writeInt(mCallingUid);
         out.writeInt(mPort);
+        out.writeString(mAuthUserName);
     }
 
     @Override
@@ -375,6 +390,17 @@
     }
 
     /**
+     * Gets the username for authentication. If it is null, then the username
+     * should be used in authentication instead.
+     *
+     * @return the auth. username
+     * @hide // TODO: remove when we make it public
+     */
+    public String getAuthUserName() {
+        return mAuthUserName;
+    }
+
+    /**
      * Gets the password.
      *
      * @return the password
diff --git a/voip/java/com/android/server/sip/SipSessionGroup.java b/voip/java/com/android/server/sip/SipSessionGroup.java
index 3275317..aa616a9 100644
--- a/voip/java/com/android/server/sip/SipSessionGroup.java
+++ b/voip/java/com/android/server/sip/SipSessionGroup.java
@@ -895,7 +895,9 @@
                         challengedTransaction, String realm) {
                     return new UserCredentials() {
                         public String getUserName() {
-                            return mLocalProfile.getUserName();
+                            String username = mLocalProfile.getAuthUserName();
+                            return (!TextUtils.isEmpty(username) ? username :
+                                    mLocalProfile.getUserName());
                         }
 
                         public String getPassword() {
diff --git a/wifi/java/android/net/wifi/SupplicantStateTracker.java b/wifi/java/android/net/wifi/SupplicantStateTracker.java
index 1a00507..f96a5ae 100644
--- a/wifi/java/android/net/wifi/SupplicantStateTracker.java
+++ b/wifi/java/android/net/wifi/SupplicantStateTracker.java
@@ -192,27 +192,16 @@
         @Override
          public void enter() {
              if (DBG) Log.d(TAG, getName() + "\n");
-             mWifiStateMachine.setNetworkAvailable(false);
          }
-        @Override
-        public void exit() {
-            mWifiStateMachine.setNetworkAvailable(true);
-        }
     }
 
     class InactiveState extends HierarchicalState {
         @Override
          public void enter() {
              if (DBG) Log.d(TAG, getName() + "\n");
-             mWifiStateMachine.setNetworkAvailable(false);
          }
-        @Override
-        public void exit() {
-            mWifiStateMachine.setNetworkAvailable(true);
-        }
     }
 
-
     class DisconnectedState extends HierarchicalState {
         @Override
          public void enter() {
@@ -336,4 +325,4 @@
             if (DBG) Log.d(TAG, getName() + "\n");
         }
     }
-}
\ No newline at end of file
+}
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 10faeda..8718117 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -299,10 +299,8 @@
     static final int CMD_SET_FREQUENCY_BAND               = 90;
 
     /* Commands from/to the SupplicantStateTracker */
-    /* Indicates whether a wifi network is available for connection */
-    static final int CMD_SET_NETWORK_AVAILABLE            = 111;
     /* Reset the supplicant state tracker */
-    static final int CMD_RESET_SUPPLICANT_STATE           = 112;
+    static final int CMD_RESET_SUPPLICANT_STATE           = 111;
 
 
     /* Commands/events reported by WpsStateMachine */
@@ -1451,10 +1449,6 @@
         setWifiEnabled(true);
     }
 
-    void setNetworkAvailable(boolean available) {
-        sendMessage(obtainMessage(CMD_SET_NETWORK_AVAILABLE, available ? 1 : 0, 0));
-    }
-
     /********************************************************
      * HSM states
      *******************************************************/
@@ -1480,9 +1474,6 @@
                 case CMD_ENABLE_RSSI_POLL:
                     mEnableRssiPolling = (message.arg1 == 1);
                     break;
-                case CMD_SET_NETWORK_AVAILABLE:
-                    mNetworkInfo.setIsAvailable(message.arg1 == 1);
-                    break;
                     /* Discard */
                 case CMD_LOAD_DRIVER:
                 case CMD_UNLOAD_DRIVER:
@@ -1873,6 +1864,8 @@
             EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
             /* Initialize for connect mode operation at start */
             mIsScanMode = false;
+            /* Wifi is available as long as we have a connection to supplicant */
+            mNetworkInfo.setIsAvailable(true);
         }
         @Override
         public boolean processMessage(Message message) {
@@ -1886,6 +1879,7 @@
                         Log.e(TAG, "Failed to stop supplicant, issue kill");
                         WifiNative.killSupplicant();
                     }
+                    mNetworkInfo.setIsAvailable(false);
                     handleNetworkDisconnect();
                     setWifiState(WIFI_STATE_DISABLING);
                     sendSupplicantConnectionChangedBroadcast(false);
@@ -1896,6 +1890,7 @@
                     Log.e(TAG, "Connection lost, restart supplicant");
                     WifiNative.killSupplicant();
                     WifiNative.closeSupplicantConnection();
+                    mNetworkInfo.setIsAvailable(false);
                     handleNetworkDisconnect();
                     sendSupplicantConnectionChangedBroadcast(false);
                     mSupplicantStateTracker.sendMessage(CMD_RESET_SUPPLICANT_STATE);
@@ -1975,6 +1970,11 @@
             }
             return HANDLED;
         }
+
+        @Override
+        public void exit() {
+            mNetworkInfo.setIsAvailable(false);
+        }
     }
 
     class SupplicantStoppingState extends HierarchicalState {