Merge "Doc change: escape angle brackets in javadoc comment." into gingerbread
diff --git a/Android.mk b/Android.mk
index ab30c6e..941cf85 100644
--- a/Android.mk
+++ b/Android.mk
@@ -373,6 +373,7 @@
     -since ./frameworks/base/api/6.xml 6 \
     -since ./frameworks/base/api/7.xml 7 \
     -since ./frameworks/base/api/8.xml 8 \
+    -since ./frameworks/base/api/9.xml 9 \
     -werror -hide 13 \
     -overview $(LOCAL_PATH)/core/java/overview.html
 
@@ -525,7 +526,7 @@
 		-proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
 		-todo $(OUT_DOCS)/$(LOCAL_MODULE)-docs-todo.html \
 		-sdkvalues $(OUT_DOCS) \
-		-hdf android.whichdoc offline 
+		-hdf android.whichdoc offline
 
 ifeq ($(framework_docs_SDK_PREVIEW),true)
   LOCAL_DROIDDOC_OPTIONS += -hdf sdk.preview true
diff --git a/CleanSpec.mk b/CleanSpec.mk
index da1d46f..d19f3f8 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -70,6 +70,8 @@
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/os/storage/*)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/trustedlogic)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/com/trustedlogic)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/trustedlogic)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/com/trustedlogic)
 
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/api/current.xml b/api/current.xml
index bdc7f2e..d99d3ca 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -705,6 +705,17 @@
  visibility="public"
 >
 </field>
+<field name="NFC"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.permission.NFC&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="PERSISTENT_ACTIVITY"
  type="java.lang.String"
  transient="false"
@@ -1559,226 +1570,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17432608"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17432599"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17432598"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="17432597"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="17432596"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="17432595"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad15"
- type="int"
- transient="false"
- volatile="false"
- value="17432594"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad16"
- type="int"
- transient="false"
- volatile="false"
- value="17432593"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad17"
- type="int"
- transient="false"
- volatile="false"
- value="17432592"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad18"
- type="int"
- transient="false"
- volatile="false"
- value="17432591"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad19"
- type="int"
- transient="false"
- volatile="false"
- value="17432590"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17432607"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad20"
- type="int"
- transient="false"
- volatile="false"
- value="17432589"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17432606"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17432605"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17432604"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17432603"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17432602"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17432601"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17432600"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="linear_interpolator"
  type="int"
  transient="false"
@@ -1862,138 +1653,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17235984"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17235975"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17235974"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="17235973"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17235983"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17235982"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17235981"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17235980"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17235979"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17235978"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17235977"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17235976"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="organizationTypes"
  type="int"
  transient="false"
@@ -5256,611 +4915,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="16843520"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="16843511"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="16843510"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="16843509"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="16843508"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="16843507"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad15"
- type="int"
- transient="false"
- volatile="false"
- value="16843506"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad16"
- type="int"
- transient="false"
- volatile="false"
- value="16843505"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad17"
- type="int"
- transient="false"
- volatile="false"
- value="16843504"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad18"
- type="int"
- transient="false"
- volatile="false"
- value="16843503"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad19"
- type="int"
- transient="false"
- volatile="false"
- value="16843502"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="16843519"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad20"
- type="int"
- transient="false"
- volatile="false"
- value="16843501"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad21"
- type="int"
- transient="false"
- volatile="false"
- value="16843500"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad22"
- type="int"
- transient="false"
- volatile="false"
- value="16843499"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad23"
- type="int"
- transient="false"
- volatile="false"
- value="16843498"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad24"
- type="int"
- transient="false"
- volatile="false"
- value="16843497"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad25"
- type="int"
- transient="false"
- volatile="false"
- value="16843496"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad26"
- type="int"
- transient="false"
- volatile="false"
- value="16843495"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad27"
- type="int"
- transient="false"
- volatile="false"
- value="16843494"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad28"
- type="int"
- transient="false"
- volatile="false"
- value="16843493"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad29"
- type="int"
- transient="false"
- volatile="false"
- value="16843492"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="16843518"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad30"
- type="int"
- transient="false"
- volatile="false"
- value="16843491"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad31"
- type="int"
- transient="false"
- volatile="false"
- value="16843490"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad32"
- type="int"
- transient="false"
- volatile="false"
- value="16843489"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad33"
- type="int"
- transient="false"
- volatile="false"
- value="16843488"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad34"
- type="int"
- transient="false"
- volatile="false"
- value="16843487"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad35"
- type="int"
- transient="false"
- volatile="false"
- value="16843486"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad36"
- type="int"
- transient="false"
- volatile="false"
- value="16843485"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad37"
- type="int"
- transient="false"
- volatile="false"
- value="16843484"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad38"
- type="int"
- transient="false"
- volatile="false"
- value="16843483"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad39"
- type="int"
- transient="false"
- volatile="false"
- value="16843482"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="16843517"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad40"
- type="int"
- transient="false"
- volatile="false"
- value="16843481"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad41"
- type="int"
- transient="false"
- volatile="false"
- value="16843480"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad42"
- type="int"
- transient="false"
- volatile="false"
- value="16843479"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad43"
- type="int"
- transient="false"
- volatile="false"
- value="16843478"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad44"
- type="int"
- transient="false"
- volatile="false"
- value="16843477"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad45"
- type="int"
- transient="false"
- volatile="false"
- value="16843476"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad46"
- type="int"
- transient="false"
- volatile="false"
- value="16843475"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad47"
- type="int"
- transient="false"
- volatile="false"
- value="16843474"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad48"
- type="int"
- transient="false"
- volatile="false"
- value="16843473"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad49"
- type="int"
- transient="false"
- volatile="false"
- value="16843472"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="16843516"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad50"
- type="int"
- transient="false"
- volatile="false"
- value="16843471"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad51"
- type="int"
- transient="false"
- volatile="false"
- value="16843470"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad52"
- type="int"
- transient="false"
- volatile="false"
- value="16843469"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad53"
- type="int"
- transient="false"
- volatile="false"
- value="16843468"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad54"
- type="int"
- transient="false"
- volatile="false"
- value="16843467"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad55"
- type="int"
- transient="false"
- volatile="false"
- value="16843466"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="16843515"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="16843514"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="16843513"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="16843512"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="label"
  type="int"
  transient="false"
@@ -10548,171 +9602,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17170464"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17170455"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17170454"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="17170453"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="17170452"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="17170451"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad15"
- type="int"
- transient="false"
- volatile="false"
- value="17170450"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17170463"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17170462"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17170461"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17170460"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17170459"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17170458"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17170457"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17170456"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="primary_text_dark"
  type="int"
  transient="false"
@@ -10895,160 +9784,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17104912"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17104903"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17104902"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="17104901"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="17104900"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="17104899"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17104911"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17104910"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17104909"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17104908"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17104907"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17104906"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17104905"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17104904"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="thumbnail_height"
  type="int"
  transient="false"
@@ -12232,875 +10967,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17301760"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17301751"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17301750"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="17301749"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="17301748"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="17301747"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad15"
- type="int"
- transient="false"
- volatile="false"
- value="17301746"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad16"
- type="int"
- transient="false"
- volatile="false"
- value="17301745"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad17"
- type="int"
- transient="false"
- volatile="false"
- value="17301744"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad18"
- type="int"
- transient="false"
- volatile="false"
- value="17301743"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad19"
- type="int"
- transient="false"
- volatile="false"
- value="17301742"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17301759"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad20"
- type="int"
- transient="false"
- volatile="false"
- value="17301741"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad21"
- type="int"
- transient="false"
- volatile="false"
- value="17301740"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad22"
- type="int"
- transient="false"
- volatile="false"
- value="17301739"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad23"
- type="int"
- transient="false"
- volatile="false"
- value="17301738"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad24"
- type="int"
- transient="false"
- volatile="false"
- value="17301737"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad25"
- type="int"
- transient="false"
- volatile="false"
- value="17301736"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad26"
- type="int"
- transient="false"
- volatile="false"
- value="17301735"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad27"
- type="int"
- transient="false"
- volatile="false"
- value="17301734"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad28"
- type="int"
- transient="false"
- volatile="false"
- value="17301733"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad29"
- type="int"
- transient="false"
- volatile="false"
- value="17301732"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17301758"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad30"
- type="int"
- transient="false"
- volatile="false"
- value="17301731"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad31"
- type="int"
- transient="false"
- volatile="false"
- value="17301730"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad32"
- type="int"
- transient="false"
- volatile="false"
- value="17301729"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad33"
- type="int"
- transient="false"
- volatile="false"
- value="17301728"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad34"
- type="int"
- transient="false"
- volatile="false"
- value="17301727"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad35"
- type="int"
- transient="false"
- volatile="false"
- value="17301726"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad36"
- type="int"
- transient="false"
- volatile="false"
- value="17301725"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad37"
- type="int"
- transient="false"
- volatile="false"
- value="17301724"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad38"
- type="int"
- transient="false"
- volatile="false"
- value="17301723"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad39"
- type="int"
- transient="false"
- volatile="false"
- value="17301722"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17301757"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad40"
- type="int"
- transient="false"
- volatile="false"
- value="17301721"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad41"
- type="int"
- transient="false"
- volatile="false"
- value="17301720"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad42"
- type="int"
- transient="false"
- volatile="false"
- value="17301719"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad43"
- type="int"
- transient="false"
- volatile="false"
- value="17301718"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad44"
- type="int"
- transient="false"
- volatile="false"
- value="17301717"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad45"
- type="int"
- transient="false"
- volatile="false"
- value="17301716"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad46"
- type="int"
- transient="false"
- volatile="false"
- value="17301715"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad47"
- type="int"
- transient="false"
- volatile="false"
- value="17301714"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad48"
- type="int"
- transient="false"
- volatile="false"
- value="17301713"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad49"
- type="int"
- transient="false"
- volatile="false"
- value="17301712"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17301756"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad50"
- type="int"
- transient="false"
- volatile="false"
- value="17301711"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad51"
- type="int"
- transient="false"
- volatile="false"
- value="17301710"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad52"
- type="int"
- transient="false"
- volatile="false"
- value="17301709"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad53"
- type="int"
- transient="false"
- volatile="false"
- value="17301708"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad54"
- type="int"
- transient="false"
- volatile="false"
- value="17301707"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad55"
- type="int"
- transient="false"
- volatile="false"
- value="17301706"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad56"
- type="int"
- transient="false"
- volatile="false"
- value="17301705"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad57"
- type="int"
- transient="false"
- volatile="false"
- value="17301704"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad58"
- type="int"
- transient="false"
- volatile="false"
- value="17301703"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad59"
- type="int"
- transient="false"
- volatile="false"
- value="17301702"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17301755"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad60"
- type="int"
- transient="false"
- volatile="false"
- value="17301701"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad61"
- type="int"
- transient="false"
- volatile="false"
- value="17301700"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad62"
- type="int"
- transient="false"
- volatile="false"
- value="17301699"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad63"
- type="int"
- transient="false"
- volatile="false"
- value="17301698"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad64"
- type="int"
- transient="false"
- volatile="false"
- value="17301697"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad65"
- type="int"
- transient="false"
- volatile="false"
- value="17301696"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad66"
- type="int"
- transient="false"
- volatile="false"
- value="17301695"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad67"
- type="int"
- transient="false"
- volatile="false"
- value="17301694"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad68"
- type="int"
- transient="false"
- volatile="false"
- value="17301693"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad69"
- type="int"
- transient="false"
- volatile="false"
- value="17301692"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17301754"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad70"
- type="int"
- transient="false"
- volatile="false"
- value="17301691"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad71"
- type="int"
- transient="false"
- volatile="false"
- value="17301690"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad72"
- type="int"
- transient="false"
- volatile="false"
- value="17301689"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad73"
- type="int"
- transient="false"
- volatile="false"
- value="17301688"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad74"
- type="int"
- transient="false"
- volatile="false"
- value="17301687"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad75"
- type="int"
- transient="false"
- volatile="false"
- value="17301686"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad76"
- type="int"
- transient="false"
- volatile="false"
- value="17301685"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad77"
- type="int"
- transient="false"
- volatile="false"
- value="17301684"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad78"
- type="int"
- transient="false"
- volatile="false"
- value="17301683"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad79"
- type="int"
- transient="false"
- volatile="false"
- value="17301682"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17301753"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17301752"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="list_selector_background"
  type="int"
  transient="false"
@@ -14130,237 +11996,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="16908352"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="16908343"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="16908342"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="16908341"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="16908340"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="16908339"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad15"
- type="int"
- transient="false"
- volatile="false"
- value="16908338"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad16"
- type="int"
- transient="false"
- volatile="false"
- value="16908337"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad17"
- type="int"
- transient="false"
- volatile="false"
- value="16908336"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad18"
- type="int"
- transient="false"
- volatile="false"
- value="16908335"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad19"
- type="int"
- transient="false"
- volatile="false"
- value="16908334"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="16908351"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad20"
- type="int"
- transient="false"
- volatile="false"
- value="16908333"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad21"
- type="int"
- transient="false"
- volatile="false"
- value="16908332"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="16908350"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="16908349"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="16908348"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="16908347"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="16908346"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="16908345"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="16908344"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="list"
  type="int"
  transient="false"
@@ -14631,160 +12266,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17694736"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17694727"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17694726"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="17694725"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="17694724"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="17694723"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17694735"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17694734"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17694733"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17694732"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17694731"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17694730"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17694729"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17694728"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="R.layout"
  extends="java.lang.Object"
@@ -14835,149 +12316,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17367072"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17367063"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17367062"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="17367061"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="17367060"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17367071"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17367070"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17367069"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17367068"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17367067"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17367066"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17367065"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17367064"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="preference_category"
  type="int"
  transient="false"
@@ -15370,127 +12708,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="17039392"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="17039383"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="17039382"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="17039391"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="17039390"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="17039389"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="17039388"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="17039387"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="17039386"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="17039385"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="17039384"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="no"
  type="int"
  transient="false"
@@ -16718,446 +13935,6 @@
  visibility="public"
 >
 </field>
-<field name="kraken_resource_pad1"
- type="int"
- transient="false"
- volatile="false"
- value="16973968"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad10"
- type="int"
- transient="false"
- volatile="false"
- value="16973959"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad11"
- type="int"
- transient="false"
- volatile="false"
- value="16973958"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad12"
- type="int"
- transient="false"
- volatile="false"
- value="16973957"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad13"
- type="int"
- transient="false"
- volatile="false"
- value="16973956"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad14"
- type="int"
- transient="false"
- volatile="false"
- value="16973955"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad15"
- type="int"
- transient="false"
- volatile="false"
- value="16973954"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad16"
- type="int"
- transient="false"
- volatile="false"
- value="16973953"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad17"
- type="int"
- transient="false"
- volatile="false"
- value="16973952"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad18"
- type="int"
- transient="false"
- volatile="false"
- value="16973951"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad19"
- type="int"
- transient="false"
- volatile="false"
- value="16973950"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad2"
- type="int"
- transient="false"
- volatile="false"
- value="16973967"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad20"
- type="int"
- transient="false"
- volatile="false"
- value="16973949"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad21"
- type="int"
- transient="false"
- volatile="false"
- value="16973948"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad22"
- type="int"
- transient="false"
- volatile="false"
- value="16973947"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad23"
- type="int"
- transient="false"
- volatile="false"
- value="16973946"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad24"
- type="int"
- transient="false"
- volatile="false"
- value="16973945"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad25"
- type="int"
- transient="false"
- volatile="false"
- value="16973944"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad26"
- type="int"
- transient="false"
- volatile="false"
- value="16973943"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad27"
- type="int"
- transient="false"
- volatile="false"
- value="16973942"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad28"
- type="int"
- transient="false"
- volatile="false"
- value="16973941"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad29"
- type="int"
- transient="false"
- volatile="false"
- value="16973940"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad3"
- type="int"
- transient="false"
- volatile="false"
- value="16973966"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad30"
- type="int"
- transient="false"
- volatile="false"
- value="16973939"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad31"
- type="int"
- transient="false"
- volatile="false"
- value="16973938"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad32"
- type="int"
- transient="false"
- volatile="false"
- value="16973937"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad33"
- type="int"
- transient="false"
- volatile="false"
- value="16973936"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad34"
- type="int"
- transient="false"
- volatile="false"
- value="16973935"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad35"
- type="int"
- transient="false"
- volatile="false"
- value="16973934"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad36"
- type="int"
- transient="false"
- volatile="false"
- value="16973933"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad37"
- type="int"
- transient="false"
- volatile="false"
- value="16973932"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad38"
- type="int"
- transient="false"
- volatile="false"
- value="16973931"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad39"
- type="int"
- transient="false"
- volatile="false"
- value="16973930"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad4"
- type="int"
- transient="false"
- volatile="false"
- value="16973965"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad40"
- type="int"
- transient="false"
- volatile="false"
- value="16973929"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad5"
- type="int"
- transient="false"
- volatile="false"
- value="16973964"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad6"
- type="int"
- transient="false"
- volatile="false"
- value="16973963"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad7"
- type="int"
- transient="false"
- volatile="false"
- value="16973962"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad8"
- type="int"
- transient="false"
- volatile="false"
- value="16973961"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="kraken_resource_pad9"
- type="int"
- transient="false"
- volatile="false"
- value="16973960"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 </class>
 <class name="R.xml"
  extends="java.lang.Object"
@@ -103136,6 +99913,8 @@
 >
 <parameter name="data" type="byte[]">
 </parameter>
+<exception name="FormatException" type="android.nfc.FormatException">
+</exception>
 </constructor>
 <method name="describeContents"
  return="int"
@@ -124007,7 +120786,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="10000"
+ value="9"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -131656,6 +128435,17 @@
  visibility="public"
 >
 </method>
+<method name="enableDefaults"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getThreadPolicy"
  return="android.os.StrictMode.ThreadPolicy"
  abstract="false"
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index a27ba84..6ff5a40 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -175,13 +175,18 @@
          * camera image needs to be rotated clockwise so it shows correctly on
          * the display in its natural orientation. It should be 0, 90, 180, or 270.
          *
-         * For example, suppose a device has a naturally tall screen, but the camera
-         * sensor is mounted in landscape. If the top side of the camera sensor is
-         * aligned with the right edge of the display in natural orientation, the
-         * value should be 90.
+         * For example, suppose a device has a naturally tall screen. The
+         * back-facing camera sensor is mounted in landscape. You are looking at
+         * the screen. If the top side of the camera sensor is aligned with the
+         * right edge of the screen in natural orientation, the value should be
+         * 90. If the top side of a front-facing camera sensor is aligned with
+         * the right of the screen, the value should be 270.
          *
          * @see #setDisplayOrientation(int)
          * @see #setRotation(int)
+         * @see #setPreviewSize(int, int)
+         * @see #setPictureSize(int, int)
+         * @see #setJpegThumbnailSize(int, int)
          */
         public int orientation;
     };
@@ -771,13 +776,16 @@
     public native final void stopSmoothZoom();
 
     /**
-     * Set the display orientation. This affects the preview frames and the
-     * picture displayed after snapshot. This method is useful for portrait
-     * mode applications.
+     * Set the clockwise rotation of preview display in degrees. This affects
+     * the preview frames and the picture displayed after snapshot. This method
+     * is useful for portrait mode applications. Note that preview display of
+     * front-facing cameras is flipped horizontally, that is, the image is
+     * reflected along the central vertical axis of the camera sensor. So the
+     * users can see themselves as looking into a mirror.
      *
-     * This does not affect the order of byte array passed in
-     * {@link PreviewCallback#onPreviewFrame}. This method is not allowed to
-     * be called during preview.
+     * This does not affect the order of byte array passed in {@link
+     * PreviewCallback#onPreviewFrame}, JPEG pictures, or recorded videos. This
+     * method is not allowed to be called during preview.
      *
      * If you want to make the camera image show in the same orientation as
      * the display, you can use the following code.<p>
@@ -797,13 +805,20 @@
      *         case Surface.ROTATION_270: degrees = 270; break;
      *     }
      *
-     *     int result = (info.orientation - degrees + 360) % 360;
+     *     int result;
+     *     if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
+     *         result = (info.orientation + degrees) % 360;
+     *         result = (360 - result) % 360;  // compensate the mirror
+     *     } else {  // back-facing
+     *         result = (info.orientation - degrees + 360) % 360;
+     *     }
      *     camera.setDisplayOrientation(result);
      * }
      * </pre>
      * @param degrees the angle that the picture will be rotated clockwise.
      *                Valid values are 0, 90, 180, and 270. The starting
      *                position is 0 (landscape).
+     * @see #setPreviewDisplay(SurfaceHolder)
      */
     public native final void setDisplayOrientation(int degrees);
 
@@ -1749,20 +1764,23 @@
          * the orientation in the EXIF header will be missing or 1 (row #0 is
          * top and column #0 is left side).
          *
-         * If appplications want to rotate the picture to match the
-         * orientation of what users see, apps should use {@link
+         * If applications want to rotate the picture to match the orientation
+         * of what users see, apps should use {@link
          * android.view.OrientationEventListener} and {@link CameraInfo}.
          * The value from OrientationEventListener is relative to the natural
-         * orientation of the device. CameraInfo.mOrientation is the angle
-         * between camera orientation and natural device orientation. The sum
-         * of the two is the angle for rotation.
+         * orientation of the device. CameraInfo.orientation is the angle
+         * between camera orientation and natural device orientation. The sum or
+         * of the two is the rotation angle for back-facing camera. The
+         * difference of the two is the rotation angle for front-facing camera.
+         * Note that the JPEG pictures of front-facing cameras are not mirrored
+         * as in preview display.
          *
          * For example, suppose the natural orientation of the device is
          * portrait. The device is rotated 270 degrees clockwise, so the device
-         * orientation is 270. Suppose the camera sensor is mounted in landscape
-         * and the top side of the camera sensor is aligned with the right edge
-         * of the display in natural orientation. So the camera orientation is
-         * 90. The rotation should be set to 0 (270 + 90).
+         * orientation is 270. Suppose a back-facing camera sensor is mounted in
+         * landscape and the top side of the camera sensor is aligned with the
+         * right edge of the display in natural orientation. So the camera
+         * orientation is 90. The rotation should be set to 0 (270 + 90).
          *
          * The reference code is as follows.
          *
@@ -1772,7 +1790,13 @@
          *            new android.hardware.Camera.CameraInfo();
          *     android.hardware.Camera.getCameraInfo(cameraId, info);
          *     orientation = (orientation + 45) / 90 * 90;
-         *     mParameters.setRotation((orientation + info.mOrientation) % 360);
+         *     int rotation = 0;
+         *     if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
+         *         rotation = (info.orientation - orientation + 360) % 360;
+         *     } else {  // back-facing camera
+         *         rotation = (info.orientation + orientation) % 360;
+         *     }
+         *     mParameters.setRotation(rotation);
          * }
          *
          * @param rotation The rotation angle in degrees relative to the
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index 23fd2ca..edc5ab9 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -200,8 +200,17 @@
      *
      * @throws FormatException if the data is not a valid NDEF record
      */
-    public NdefRecord(byte[] data) {
-        throw new UnsupportedOperationException();
+    public NdefRecord(byte[] data) throws FormatException {
+        /* Prevent compiler to complain about unassigned final fields */
+        mFlags = 0;
+        mTnf = 0;
+        mType = null;
+        mId = null;
+        mPayload = null;
+        /* Perform actual parsing */
+        if (parseNdefRecord(data) == -1) {
+            throw new FormatException("Error while parsing NDEF record");
+        }
     }
 
     /**
@@ -280,5 +289,6 @@
         }
     };
 
+    private native int parseNdefRecord(byte[] data);
     private native byte[] generate(short flags, short tnf, byte[] type, byte[] id, byte[] data);
 }
\ No newline at end of file
diff --git a/core/java/android/nfc/NdefTag.java b/core/java/android/nfc/NdefTag.java
index 6d44e6e..45cdc31 100644
--- a/core/java/android/nfc/NdefTag.java
+++ b/core/java/android/nfc/NdefTag.java
@@ -16,6 +16,8 @@
 
 package android.nfc;
 
+import java.util.HashMap;
+
 import android.os.Parcel;
 import android.os.Parcelable;
 
@@ -41,8 +43,8 @@
      * tag is discovered and by Parcelable methods.
      * @hide
      */
-    public NdefTag(int type, byte[] uid, int nativeHandle, NdefMessage[] messages) {
-        super(type, true, uid, nativeHandle);
+    public NdefTag(String typeName, byte[] uid, int nativeHandle, NdefMessage[] messages) {
+        super(typeName, true, uid, nativeHandle);
         mMessages = messages.clone();
     }
 
@@ -62,10 +64,22 @@
 
     /**
      * Get only the NDEF Messages from a single NDEF target on a tag.
+     * <p>
+     * This retrieves the NDEF Messages that were found on the Tag at discovery
+     * time. It does not cause any further RF activity, and does not block.
+     * <p>
+     * Most tags only contain a single NDEF message.
+     *
+     * @param target One of targets strings provided by getNdefTargets()
+     * @return NDEF Messages found at Tag discovery
      */
     public NdefMessage[] getNdefMessages(String target) {
-        //TODO(nxp): new api method
-        throw new UnsupportedOperationException();
+        // TODO: handle multiprotocol
+        String[] localTypes = convertToNdefType(mTypeName);
+        if (!target.equals(localTypes[0])) {
+            throw new IllegalArgumentException();
+        }
+        return getNdefMessages();
     }
 
     /** TODO(npelly):
@@ -79,13 +93,35 @@
     public static final String TARGET_MIFARE_CLASSIC = "type_mifare_classic";
     public static final String TARGET_OTHER = "other";
 
+    private static final HashMap<String, String[]> NDEF_TYPES_CONVERTION_TABLE = new HashMap<String, String[]>() {
+        {
+            // TODO: handle multiprotocol
+            // TODO: move INTERNAL_TARGET_Type to TARGET_TYPE mapping to NFC service
+            put(Tag.INTERNAL_TARGET_TYPE_JEWEL, new String[] { NdefTag.TARGET_TYPE_1 });
+            put(Tag.INTERNAL_TARGET_TYPE_MIFARE_UL, new String[] { NdefTag.TARGET_TYPE_2 });
+            put(Tag.INTERNAL_TARGET_TYPE_MIFARE_1K, new String[] { NdefTag.TARGET_MIFARE_CLASSIC });
+            put(Tag.INTERNAL_TARGET_TYPE_MIFARE_4K, new String[] { NdefTag.TARGET_MIFARE_CLASSIC });
+            put(Tag.INTERNAL_TARGET_TYPE_FELICA, new String[] { NdefTag.TARGET_TYPE_3 });
+            put(Tag.INTERNAL_TARGET_TYPE_ISO14443_4, new String[] { NdefTag.TARGET_TYPE_4 });
+            put(Tag.INTERNAL_TARGET_TYPE_MIFARE_DESFIRE, new String[] { NdefTag.TARGET_TYPE_4 });
+        }
+    };
+
+    private String[] convertToNdefType(String internalTypeName) {
+        String[] result =  NDEF_TYPES_CONVERTION_TABLE.get(internalTypeName);
+        if (result == null) {
+            return new String[] { NdefTag.TARGET_OTHER };
+        }
+        return result;
+    }
+
     /**
      * Return the
      *
      * @return
      */
     public String[] getNdefTargets() {
-        throw new UnsupportedOperationException();
+        return convertToNdefType(mTypeName);
     }
 
     @Override
@@ -107,7 +143,7 @@
             int messagesLength = in.readInt();
             NdefMessage[] messages = new NdefMessage[messagesLength];
             in.readTypedArray(messages, NdefMessage.CREATOR);
-            return new NdefTag(tag.mType, tag.mUid, tag.mNativeHandle, messages);
+            return new NdefTag(tag.mTypeName, tag.mUid, tag.mNativeHandle, messages);
         }
         public NdefTag[] newArray(int size) {
             return new NdefTag[size];
diff --git a/core/java/android/nfc/NdefTagConnection.java b/core/java/android/nfc/NdefTagConnection.java
index 8038d1a..4795fa7 100644
--- a/core/java/android/nfc/NdefTagConnection.java
+++ b/core/java/android/nfc/NdefTagConnection.java
@@ -25,6 +25,9 @@
  * A connection to an NDEF target on an {@link NdefTag}.
  * <p>You can acquire this kind of connection with {@link NfcAdapter#createNdefTagConnection
  * createNdefTagConnection()}. Use the connection to read or write {@link NdefMessage}s.
+ * <p class="note"><strong>Note:</strong>
+ * Use of this class requires the {@link android.Manifest.permission#NFC}
+ * permission.
  */
 public class NdefTagConnection extends RawTagConnection {
     public static final int NDEF_MODE_READ_ONCE = 1;
@@ -39,8 +42,29 @@
      * Internal constructor, to be used by NfcAdapter
      * @hide
      */
-    NdefTagConnection(INfcAdapter service, NdefTag tag) throws RemoteException {
+    /* package private */ NdefTagConnection(INfcAdapter service, NdefTag tag, String target) throws RemoteException {
         super(service, tag);
+        String[] targets = tag.getNdefTargets();
+        int i;
+
+        // Check target validity
+        for (i=0; i<targets.length; i++) {
+            if (target.equals(targets[i])) {
+                break;
+            }
+        }
+        if (i >= targets.length) {
+            // Target not found
+            throw new IllegalArgumentException();
+        }
+    }
+
+    /**
+     * Internal constructor, to be used by NfcAdapter
+     * @hide
+     */
+    /* package private */ NdefTagConnection(INfcAdapter service, NdefTag tag) throws RemoteException {
+        this(service, tag, tag.getNdefTargets()[0]);
     }
 
     /**
@@ -48,7 +72,7 @@
      * This will always return the most up to date payload, and can block.
      * It can be canceled with {@link RawTagConnection#close}.
      * Most NDEF tags will contain just one NDEF message.
-     * <p>
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      * @throws FormatException if the tag is not NDEF formatted
      * @throws IOException if the target is lost or connection closed
      * @throws FormatException
@@ -88,8 +112,9 @@
      * message. Use {@link NdefRecord} to write several records to a single tag.
      * For write-many tags, use {@link #makeReadOnly} after this method to attempt
      * to prevent further modification. For write-once tags this is not
-     * neccesary.
-     * Requires NFC_WRITE permission.
+     * necessary.
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
+     *
      * @throws FormatException if the tag is not suitable for NDEF messages
      * @throws IOException if the target is lost or connection closed or the
      *                     write failed
@@ -117,7 +142,7 @@
      * Attempts to make the NDEF data in this tag read-only.
      * This method will block until the action is complete. It can be canceled
      * with {@link RawTagConnection#close}.
-     * Requires NFC_WRITE permission.
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      * @return true if the tag is now read-only
      * @throws IOException if the target is lost, or connection closed
      */
@@ -143,7 +168,8 @@
 
     /**
      * Read/Write mode hint.
-     * Provides a hint if further reads or writes are likely to suceed.
+     * Provides a hint if further reads or writes are likely to succeed.
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      * @return one of NDEF_MODE
      * @throws IOException if the target is lost or connection closed
      */
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index 37243f7..bc3c6d9 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -15,14 +15,16 @@
 
 import android.annotation.SdkConstant;
 import android.annotation.SdkConstant.SdkConstantType;
+import android.app.ActivityThread;
 import android.content.Context;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageManager;
 import android.nfc.INfcAdapter;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.util.Log;
 
-//TODO(npelly) permission {@link android.Manifest.permission#NFC_MODIFY}
 /**
  * Represents the device's local NFC adapter.
  * <p>
@@ -35,7 +37,7 @@
  * to NFC Tags.
  * <p class="note">
  * <strong>Note:</strong> Some methods require the
- * TODO permission.
+ * {@link android.Manifest.permission#NFC} permission.
  */
 public final class NfcAdapter {
     /**
@@ -73,6 +75,25 @@
             "android.nfc.action.TRANSACTION_DETECTED";
 
     /**
+     * Broadcast Action: an adapter's state changed between enabled and disabled.
+     *
+     * The new value is stored in the extra EXTRA_NEW_BOOLEAN_STATE and just contains
+     * whether it's enabled or disabled, not including any information about whether it's
+     * actively enabling or disabling.
+     *
+     * @hide
+     */
+    public static final String ACTION_ADAPTER_STATE_CHANGE =
+            "android.nfc.action.ADAPTER_STATE_CHANGE";
+
+    /**
+     * The Intent extra for ACTION_ADAPTER_STATE_CHANGE, saying what the new state is.
+     *
+     * @hide
+     */
+    public static final String EXTRA_NEW_BOOLEAN_STATE = "android.nfc.isEnabled";
+
+    /**
      * Mandatory byte array extra field in
      * {@link android.nfc.NfcAdapter#ACTION_TRANSACTION_DETECTED}.
      * <p>
@@ -143,6 +164,7 @@
 
     private static final String TAG = "NFC";
 
+    // Both guarded by NfcAdapter.class:
     private static boolean sIsInitialized = false;
     private static NfcAdapter sAdapter;
 
@@ -153,6 +175,26 @@
     }
 
     /**
+     * Helper to check if this device has FEATURE_NFC, but without using
+     * a context.
+     * Equivalent to
+     * context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)
+     */
+    private static boolean hasNfcFeature() {
+        IPackageManager pm = ActivityThread.getPackageManager();
+        if (pm == null) {
+            Log.e(TAG, "Cannot get package manager, assuming no NFC feature");
+            return false;
+        }
+        try {
+            return pm.hasSystemFeature(PackageManager.FEATURE_NFC);
+        } catch (RemoteException e) {
+            Log.e(TAG, "Package manager query failed, assuming no NFC feature", e);
+            return false;
+        }
+    }
+
+    /**
      * Get a handle to the default NFC Adapter on this Android device.
      * <p>
      * Most Android devices will only have one NFC Adapter (NFC Controller).
@@ -166,9 +208,16 @@
             }
             sIsInitialized = true;
 
+            /* is this device meant to have NFC */
+            if (!hasNfcFeature()) {
+                Log.v(TAG, "this device does not have NFC support");
+                return null;
+            }
+
+            /* get a handle to NFC service */
             IBinder b = ServiceManager.getService("nfc");
             if (b == null) {
-                Log.d(TAG, "NFC Service not available");
+                Log.e(TAG, "could not retrieve NFC service");
                 return null;
             }
 
@@ -195,6 +244,9 @@
     }
 
     /**
+     * NOTE: may block for ~second or more.  Poor API.  Avoid
+     * calling from the UI thread.
+     *
      * @hide
      */
     public boolean enableTagDiscovery() {
@@ -207,6 +259,9 @@
     }
 
     /**
+     * NOTE: may block for ~second or more.  Poor API.  Avoid
+     * calling from the UI thread.
+     *
      * @hide
      */
     public boolean disableTagDiscovery() {
@@ -231,8 +286,7 @@
      * <li>provide the NDEF message on over LLCP to peer NFC adapters
      * </ul>
      * The NDEF message is preserved across reboot.
-     * <p>
-     * Requires NFC_WRITE permission
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      *
      * @param message NDEF message to make public
      */
@@ -246,8 +300,7 @@
 
     /**
      * Get the NDEF Message that this adapter appears as to Tag readers.
-     * <p>
-     * Requires NFC_WRITE permission
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      *
      * @return NDEF Message that is publicly readable
      */
@@ -262,6 +315,7 @@
 
     /**
      * Create a raw tag connection to the default Target
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      */
     public RawTagConnection createRawTagConnection(Tag tag) {
         try {
@@ -274,14 +328,20 @@
 
     /**
      * Create a raw tag connection to the specified Target
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      */
     public RawTagConnection createRawTagConnection(Tag tag, String target) {
-        //TODO
-        throw new UnsupportedOperationException();
+        try {
+            return new RawTagConnection(mService, tag, target);
+        } catch (RemoteException e) {
+            Log.e(TAG, "NFC service died", e);
+            return null;
+        }
     }
 
     /**
      * Create an NDEF tag connection to the default Target
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      */
     public NdefTagConnection createNdefTagConnection(NdefTag tag) {
         try {
@@ -294,9 +354,14 @@
 
     /**
      * Create an NDEF tag connection to the specified Target
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      */
     public NdefTagConnection createNdefTagConnection(NdefTag tag, String target) {
-        //TODO
-        throw new UnsupportedOperationException();
+        try {
+            return new NdefTagConnection(mService, tag, target);
+        } catch (RemoteException e) {
+            Log.e(TAG, "NFC service died", e);
+            return null;
+        }
     }
 }
diff --git a/core/java/android/nfc/RawTagConnection.java b/core/java/android/nfc/RawTagConnection.java
index 50e2a5d..265eb1b 100644
--- a/core/java/android/nfc/RawTagConnection.java
+++ b/core/java/android/nfc/RawTagConnection.java
@@ -30,7 +30,7 @@
  * Applications must implement their own protocol stack on top of {@link #transceive transceive()}.
  *
  * <p class="note"><strong>Note:</strong>
- * Most methods require the TODO
+ * Use of this class requires the {@link android.Manifest.permission#NFC}
  * permission.
  */
 public class RawTagConnection {
@@ -39,33 +39,56 @@
     /*package*/ final INfcTag mTagService;
     /*package*/ final Tag mTag;
     /*package*/ boolean mIsConnected;
+    /*package*/ String mSelectedTarget;
 
     private static final String TAG = "NFC";
 
-    /* package private */ RawTagConnection(INfcAdapter service, Tag tag) throws RemoteException {
+    /* package private */ RawTagConnection(INfcAdapter service, Tag tag, String target) throws RemoteException {
+        String[] targets = tag.getRawTargets();
+        int i;
+
+        // Check target validity
+        for (i=0;i<targets.length;i++) {
+            if (target.equals(targets[i])) {
+                break;
+            }
+        }
+        if (i >= targets.length) {
+            // Target not found
+            throw new IllegalArgumentException();
+        }
+
         mService = service;
         mTagService = service.getNfcTagInterface();
         mService.openTagConnection(tag);  // TODO(nxp): don't connect until connect()
         mTag = tag;
+        mSelectedTarget = target;
+    }
+
+    /* package private */ RawTagConnection(INfcAdapter service, Tag tag) throws RemoteException {
+        this(service, tag, tag.getRawTargets()[0]);
     }
 
     /**
      * Get the {@link Tag} this connection is associated with.
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      */
     public Tag getTag() {
         return mTag;
     }
 
+    /**
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
+     */
     public String getTagTarget() {
-        //TODO
-        throw new UnsupportedOperationException();
+        return mSelectedTarget;
     }
 
     /**
      * Helper to indicate if {@link #transceive transceive()} calls might succeed.
      * <p>
      * Does not cause RF activity, and does not block.
-     * <p>
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      * @return true if {@link #connect} has completed successfully and the {@link Tag} is believed
      * to be within range. Applications must still handle {@link java.io.IOException}
      * while using {@link #transceive transceive()}, in case connection is lost after this method
@@ -85,7 +108,7 @@
      * <p>
      * {@link #close} can be called from another thread to cancel this connection
      * attempt.
-     *
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      * @throws IOException if the target is lost, or connect canceled
      */
     public void connect() throws IOException {
@@ -101,6 +124,7 @@
      * <p>
      * Once this method is called, this object cannot be re-used and should be discarded. Further
      * calls to {@link #transceive transceive()} or {@link #connect} will fail.
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      */
     public void close() {
         mIsConnected = false;
@@ -116,8 +140,7 @@
      * <p>
      * This method will block until the response is received. It can be canceled
      * with {@link #close}.
-     * <p>
-     * Requires NFC_WRITE permission.
+     * <p>Requires {@link android.Manifest.permission#NFC} permission.
      *
      * @param data bytes to send
      * @return bytes received in response
diff --git a/core/java/android/nfc/Tag.java b/core/java/android/nfc/Tag.java
index ea21790..abf02b5 100644
--- a/core/java/android/nfc/Tag.java
+++ b/core/java/android/nfc/Tag.java
@@ -16,6 +16,8 @@
 
 package android.nfc;
 
+import java.util.HashMap;
+
 import android.os.Parcel;
 import android.os.Parcelable;
 
@@ -113,17 +115,73 @@
 
     public static final String TARGET_OTHER = "other";
 
-    /*package*/ final int mType;
+    /*package*/ final String mTypeName;
     /*package*/ final boolean mIsNdef;
     /*package*/ final byte[] mUid;
     /*package*/ final int mNativeHandle;
 
+    /*package*/ static final String INTERNAL_TARGET_TYPE_ISO14443_3A = "Iso14443-3A";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_ISO14443_3B = "Iso14443-3B";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_ISO14443_4 = "Iso14443-4";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_MIFARE_UL = "MifareUL";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_MIFARE_1K = "Mifare1K";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_MIFARE_4K = "Mifare4K";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_MIFARE_DESFIRE = "MifareDESFIRE";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_MIFARE_UNKNOWN = "Unknown Mifare";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_FELICA = "Felica";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_JEWEL = "Jewel";
+    /*package*/ static final String INTERNAL_TARGET_TYPE_UNKNOWN = "Unknown Type";
+
+	private static final HashMap<String, Integer> INT_TYPES_CONVERTION_TABLE = new HashMap<String, Integer>() {
+		{
+			put(Tag.INTERNAL_TARGET_TYPE_ISO14443_3A, Tag.NFC_TAG_ISO14443_A );
+			put(Tag.INTERNAL_TARGET_TYPE_ISO14443_3B, Tag.NFC_TAG_ISO14443_B );
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_UL, Tag.NFC_TAG_MIFARE );
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_1K, Tag.NFC_TAG_MIFARE );
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_4K, Tag.NFC_TAG_MIFARE );
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_DESFIRE, Tag.NFC_TAG_MIFARE );
+			put(Tag.INTERNAL_TARGET_TYPE_FELICA, Tag.NFC_TAG_FELICA );
+			put(Tag.INTERNAL_TARGET_TYPE_JEWEL, Tag.NFC_TAG_JEWEL );
+		}
+	};
+
+	private int convertToInt(String internalTypeName) {
+		Integer result = INT_TYPES_CONVERTION_TABLE.get(internalTypeName);
+		if (result == null) {
+		    return Tag.NFC_TAG_OTHER;
+		}
+		return result;
+    }
+
+	private static final HashMap<String, String[]> RAW_TYPES_CONVERTION_TABLE = new HashMap<String, String[]>() {
+		{
+			/* TODO: handle multiprotocol */
+			put(Tag.INTERNAL_TARGET_TYPE_ISO14443_3A, new String[] { Tag.TARGET_ISO_14443_3A });
+			put(Tag.INTERNAL_TARGET_TYPE_ISO14443_3B, new String[] { Tag.TARGET_ISO_14443_3B });
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_UL, new String[] { Tag.TARGET_ISO_14443_3A });
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_1K, new String[] { Tag.TARGET_ISO_14443_3A });
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_4K, new String[] { Tag.TARGET_ISO_14443_3A });
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_DESFIRE, new String[] { Tag.TARGET_ISO_14443_3A });
+			put(Tag.INTERNAL_TARGET_TYPE_MIFARE_UNKNOWN, new String[] { Tag.TARGET_ISO_14443_3A });
+			put(Tag.INTERNAL_TARGET_TYPE_FELICA, new String[] { Tag.TARGET_JIS_X_6319_4 });
+			put(Tag.INTERNAL_TARGET_TYPE_JEWEL, new String[] { Tag.TARGET_TOPAZ });
+		}
+	};
+
+	private String[] convertToRaw(String internalTypeName) {
+	    String[] result =  RAW_TYPES_CONVERTION_TABLE.get(internalTypeName);
+	    if (result == null) {
+	        return new String[] { Tag.TARGET_OTHER };
+	    }
+	    return result;
+	}
+
     /**
      * Hidden constructor to be used by NFC service only.
      * @hide
      */
-    public Tag(int type, boolean isNdef, byte[] uid, int nativeHandle) {
-        mType = type;
+    public Tag(String typeName, boolean isNdef, byte[] uid, int nativeHandle) {
+        mTypeName = typeName;
         mIsNdef = isNdef;
         mUid = uid.clone();
         mNativeHandle = nativeHandle;
@@ -144,8 +202,7 @@
      * @return
      */
     public String[] getRawTargets() {
-        //TODO
-        throw new UnsupportedOperationException();
+        return convertToRaw(mTypeName);
     }
 
     /**
@@ -159,7 +216,7 @@
      * @hide
      */
     public int getType() {
-        return mType;
+        return convertToInt(mTypeName);
     }
 
     /**
@@ -188,7 +245,7 @@
     @Override
     public void writeToParcel(Parcel dest, int flags) {
         boolean[] booleans = new boolean[] {mIsNdef};
-        dest.writeInt(mType);
+        dest.writeString(mTypeName);
         dest.writeBooleanArray(booleans);
         dest.writeInt(mUid.length);
         dest.writeByteArray(mUid);
@@ -199,7 +256,7 @@
             new Parcelable.Creator<Tag>() {
         public Tag createFromParcel(Parcel in) {
             boolean[] booleans = new boolean[1];
-            int type = in.readInt();
+            String type = in.readString();
             in.readBooleanArray(booleans);
             boolean isNdef = booleans[0];
             int uidLength = in.readInt();
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 8925bd0..08c1402 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -198,7 +198,7 @@
          * graphics to ensure they look okay on a dark background.
          * </ul>
          */
-        public static final int GINGERBREAD = CUR_DEVELOPMENT;
+        public static final int GINGERBREAD = 9;
     }
     
     /** The type of build, like "user" or "eng". */
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index de5b7b9..e912089 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -66,7 +66,7 @@
  *                 .penaltyLog()
  *                 .build());
  *         StrictMode.setVmPolicy(new {@link VmPolicy.Builder StrictMode.VmPolicy.Builder}()
- *                 .detectLeakedSqlLiteCursors()
+ *                 .detectLeakedSqlLiteObjects()
  *                 .penaltyLog()
  *                 .penaltyDeath()
  *                 .build());
@@ -962,6 +962,24 @@
     }
 
     /**
+     * Enable the recommended StrictMode defaults, with violations just being logged.
+     *
+     * <p>This catches disk and network access on the main thread, as
+     * well as leaked SQLite cursors.  This is simply a wrapper around
+     * {@link #setVmPolicy} and {@link #setThreadPolicy}.
+     */
+    public static void enableDefaults() {
+        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
+                                   .detectAll()
+                                   .penaltyLog()
+                                   .build());
+        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+                               .detectLeakedSqlLiteObjects()
+                               .penaltyLog()
+                               .build());
+    }
+
+    /**
      * @hide
      */
     public static boolean vmSqliteObjectLeaksEnabled() {
diff --git a/core/java/android/os/Vibrator.java b/core/java/android/os/Vibrator.java
index 58ed986..be818da 100644
--- a/core/java/android/os/Vibrator.java
+++ b/core/java/android/os/Vibrator.java
@@ -50,7 +50,7 @@
         }
         try {
             mService.vibrate(milliseconds, mToken);
-        } catch (Exception e) {
+        } catch (RemoteException e) {
             Log.w(TAG, "Failed to vibrate.", e);
         }
     }
@@ -80,7 +80,7 @@
         if (repeat < pattern.length) {
             try {
                 mService.vibratePattern(pattern, repeat, mToken);
-            } catch (Exception e) {
+            } catch (RemoteException e) {
                 Log.w(TAG, "Failed to vibrate.", e);
             }
         } else {
diff --git a/core/java/android/webkit/HTML5Audio.java b/core/java/android/webkit/HTML5Audio.java
new file mode 100644
index 0000000..d292881
--- /dev/null
+++ b/core/java/android/webkit/HTML5Audio.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.webkit;
+
+import android.media.MediaPlayer;
+import android.media.MediaPlayer.OnBufferingUpdateListener;
+import android.media.MediaPlayer.OnCompletionListener;
+import android.media.MediaPlayer.OnErrorListener;
+import android.media.MediaPlayer.OnPreparedListener;
+import android.media.MediaPlayer.OnSeekCompleteListener;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+
+import java.io.IOException;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * <p>HTML5 support class for Audio.
+ */
+class HTML5Audio extends Handler
+                 implements MediaPlayer.OnBufferingUpdateListener,
+                            MediaPlayer.OnCompletionListener,
+                            MediaPlayer.OnErrorListener,
+                            MediaPlayer.OnPreparedListener,
+                            MediaPlayer.OnSeekCompleteListener {
+    // Logging tag.
+    private static final String LOGTAG = "HTML5Audio";
+
+    private MediaPlayer mMediaPlayer;
+
+    // The C++ MediaPlayerPrivateAndroid object.
+    private int mNativePointer;
+
+    private static int IDLE        =  0;
+    private static int INITIALIZED =  1;
+    private static int PREPARED    =  2;
+    private static int STARTED     =  4;
+    private static int COMPLETE    =  5;
+    private static int PAUSED      =  6;
+    private static int STOPPED     = -2;
+    private static int ERROR       = -1;
+
+    private int mState = IDLE;
+
+    private String mUrl;
+    private boolean mAskToPlay = false;
+
+    // Timer thread -> UI thread
+    private static final int TIMEUPDATE = 100;
+
+    // The spec says the timer should fire every 250 ms or less.
+    private static final int TIMEUPDATE_PERIOD = 250;  // ms
+    // The timer for timeupate events.
+    // See http://www.whatwg.org/specs/web-apps/current-work/#event-media-timeupdate
+    private Timer mTimer;
+    private final class TimeupdateTask extends TimerTask {
+        public void run() {
+            HTML5Audio.this.obtainMessage(TIMEUPDATE).sendToTarget();
+        }
+    }
+
+    @Override
+    public void handleMessage(Message msg) {
+        switch (msg.what) {
+            case TIMEUPDATE: {
+                try {
+                    if (mState != ERROR && mMediaPlayer.isPlaying()) {
+                        int position = mMediaPlayer.getCurrentPosition();
+                        nativeOnTimeupdate(position, mNativePointer);
+                    }
+                } catch (IllegalStateException e) {
+                    mState = ERROR;
+                }
+            }
+        }
+    }
+
+    // event listeners for MediaPlayer
+    // Those are called from the same thread we created the MediaPlayer
+    // (i.e. the webviewcore thread here)
+
+    // MediaPlayer.OnBufferingUpdateListener
+    public void onBufferingUpdate(MediaPlayer mp, int percent) {
+        nativeOnBuffering(percent, mNativePointer);
+    }
+
+    // MediaPlayer.OnCompletionListener;
+    public void onCompletion(MediaPlayer mp) {
+        resetMediaPlayer();
+        mState = IDLE;
+        nativeOnEnded(mNativePointer);
+    }
+
+    // MediaPlayer.OnErrorListener
+    public boolean onError(MediaPlayer mp, int what, int extra) {
+        mState = ERROR;
+        resetMediaPlayer();
+        mState = IDLE;
+        return false;
+    }
+
+    // MediaPlayer.OnPreparedListener
+    public void onPrepared(MediaPlayer mp) {
+        mState = PREPARED;
+        if (mTimer != null) {
+            mTimer.schedule(new TimeupdateTask(),
+                            TIMEUPDATE_PERIOD, TIMEUPDATE_PERIOD);
+        }
+        nativeOnPrepared(mp.getDuration(), 0, 0, mNativePointer);
+        if (mAskToPlay) {
+            mAskToPlay = false;
+            play();
+        }
+    }
+
+    // MediaPlayer.OnSeekCompleteListener
+    public void onSeekComplete(MediaPlayer mp) {
+        nativeOnTimeupdate(mp.getCurrentPosition(), mNativePointer);
+    }
+
+
+    /**
+     * @param nativePtr is the C++ pointer to the MediaPlayerPrivate object.
+     */
+    public HTML5Audio(int nativePtr) {
+        // Save the native ptr
+        mNativePointer = nativePtr;
+        resetMediaPlayer();
+    }
+
+    private void resetMediaPlayer() {
+        if (mMediaPlayer == null) {
+            mMediaPlayer = new MediaPlayer();
+        } else {
+            mMediaPlayer.reset();
+        }
+        mMediaPlayer.setOnBufferingUpdateListener(this);
+        mMediaPlayer.setOnCompletionListener(this);
+        mMediaPlayer.setOnErrorListener(this);
+        mMediaPlayer.setOnPreparedListener(this);
+        mMediaPlayer.setOnSeekCompleteListener(this);
+
+        if (mTimer != null) {
+            mTimer.cancel();
+        }
+        mTimer = new Timer();
+        mState = IDLE;
+    }
+
+    private void setDataSource(String url) {
+        mUrl = url;
+        try {
+            if (mState != IDLE) {
+                resetMediaPlayer();
+            }
+            mMediaPlayer.setDataSource(url);
+            mState = INITIALIZED;
+            mMediaPlayer.prepareAsync();
+        } catch (IOException e) {
+            Log.e(LOGTAG, "couldn't load the resource: " + url + " exc: " + e);
+            resetMediaPlayer();
+        }
+    }
+
+    private void play() {
+        if ((mState == ERROR || mState == IDLE) && mUrl != null) {
+            resetMediaPlayer();
+            setDataSource(mUrl);
+            mAskToPlay = true;
+        }
+
+        if (mState >= PREPARED) {
+            mMediaPlayer.start();
+            mState = STARTED;
+        }
+    }
+
+    private void pause() {
+        if (mState == STARTED) {
+            if (mTimer != null) {
+                mTimer.purge();
+            }
+            mMediaPlayer.pause();
+            mState = PAUSED;
+        }
+    }
+
+    private void seek(int msec) {
+        if (mState >= PREPARED) {
+            mMediaPlayer.seekTo(msec);
+        }
+    }
+
+    private void teardown() {
+        mMediaPlayer.release();
+        mState = ERROR;
+        mNativePointer = 0;
+    }
+
+    private float getMaxTimeSeekable() {
+        return mMediaPlayer.getDuration() / 1000.0f;
+    }
+
+    private native void nativeOnBuffering(int percent, int nativePointer);
+    private native void nativeOnEnded(int nativePointer);
+    private native void nativeOnPrepared(int duration, int width, int height, int nativePointer);
+    private native void nativeOnTimeupdate(int position, int nativePointer);
+}
diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java
index eda2e72..6769563 100644
--- a/core/java/android/webkit/HTML5VideoViewProxy.java
+++ b/core/java/android/webkit/HTML5VideoViewProxy.java
@@ -72,6 +72,7 @@
     private static final int PREPARED          = 200;
     private static final int ENDED             = 201;
     private static final int POSTER_FETCHED    = 202;
+    private static final int PAUSED            = 203;
 
     private static final String COOKIE = "Cookie";
 
@@ -118,6 +119,7 @@
         }
         // The spec says the timer should fire every 250 ms or less.
         private static final int TIMEUPDATE_PERIOD = 250;  // ms
+        static boolean isVideoSelfEnded = false;
 
         private static final WebChromeClient.CustomViewCallback mCallback =
             new WebChromeClient.CustomViewCallback() {
@@ -132,7 +134,11 @@
                     if (mVideoView.isPlaying()) {
                         mVideoView.stopPlayback();
                     }
-                    mCurrentProxy.dispatchOnEnded();
+                    if (isVideoSelfEnded)
+                        mCurrentProxy.dispatchOnEnded();
+                    else
+                        mCurrentProxy.dispatchOnPaused();
+                    isVideoSelfEnded = false;
                     mCurrentProxy = null;
                     mLayout.removeView(mVideoView);
                     mVideoView = null;
@@ -249,7 +255,8 @@
         // The video ended by itself, so we need to
         // send a message to the UI thread to dismiss
         // the video view and to return to the WebView.
-        sendMessage(obtainMessage(ENDED));
+        // arg1 == 1 means the video ends by itself.
+        sendMessage(obtainMessage(ENDED, 1, 0));
     }
 
     // MediaPlayer.OnErrorListener
@@ -263,6 +270,11 @@
         mWebCoreHandler.sendMessage(msg);
     }
 
+    public void dispatchOnPaused() {
+      Message msg = Message.obtain(mWebCoreHandler, PAUSED);
+      mWebCoreHandler.sendMessage(msg);
+    }
+
     public void onTimeupdate() {
         sendMessage(obtainMessage(TIMEUPDATE));
     }
@@ -291,6 +303,8 @@
                 break;
             }
             case ENDED:
+                if (msg.arg1 == 1)
+                    VideoPlayer.isVideoSelfEnded = true;
             case ERROR: {
                 WebChromeClient client = mWebView.getWebChromeClient();
                 if (client != null) {
@@ -476,6 +490,9 @@
                     case ENDED:
                         nativeOnEnded(mNativePointer);
                         break;
+                    case PAUSED:
+                        nativeOnPaused(mNativePointer);
+                        break;
                     case POSTER_FETCHED:
                         Bitmap poster = (Bitmap) msg.obj;
                         nativeOnPosterFetched(poster, mNativePointer);
@@ -584,6 +601,7 @@
 
     private native void nativeOnPrepared(int duration, int width, int height, int nativePointer);
     private native void nativeOnEnded(int nativePointer);
+    private native void nativeOnPaused(int nativePointer);
     private native void nativeOnPosterFetched(Bitmap poster, int nativePointer);
     private native void nativeOnTimeupdate(int position, int nativePointer);
 }
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index f7afdb9..4f192b3 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -28,6 +28,7 @@
 import android.graphics.drawable.Drawable;
 import android.text.Editable;
 import android.text.InputFilter;
+import android.text.Layout;
 import android.text.Selection;
 import android.text.Spannable;
 import android.text.TextPaint;
@@ -292,8 +293,9 @@
      * Ensure that the underlying textfield is lined up with the WebTextView.
      */
     private void lineUpScroll() {
-        if (mWebView != null) {
-            float maxScrollX = Touch.getMaxScrollX(this, getLayout(), mScrollY);
+        Layout layout = getLayout();
+        if (mWebView != null && layout != null) {
+            float maxScrollX = Touch.getMaxScrollX(this, layout, mScrollY);
             if (DebugFlags.WEB_TEXT_VIEW) {
                 Log.v(LOGTAG, "onTouchEvent x=" + mScrollX + " y="
                         + mScrollY + " maxX=" + maxScrollX);
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 040bf15..9098639 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -5619,6 +5619,11 @@
             overScrollBy(deltaX, deltaY, oldX, oldY,
                     rangeX, rangeY,
                     mOverscrollDistance, mOverscrollDistance, true);
+            if (mEdgeGlowTop != null &&
+                    (!mEdgeGlowTop.isFinished() || !mEdgeGlowBottom.isFinished() ||
+                            !mEdgeGlowLeft.isFinished() || !mEdgeGlowRight.isFinished())) {
+                invalidate();
+            }
         }
         if (!getSettings().getBuiltInZoomControls()) {
             boolean showPlusMinus = mMinZoomScale < mMaxZoomScale;
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
index d38eef3..fee3455 100644
--- a/core/java/android/widget/HorizontalScrollView.java
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -551,6 +551,10 @@
                                 mEdgeGlowLeft.onRelease();
                             }
                         }
+                        if (mEdgeGlowLeft != null
+                                && (!mEdgeGlowLeft.isFinished() || !mEdgeGlowRight.isFinished())) {
+                            invalidate();
+                        }
                     }
                 }
                 break;
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index 1daf2ab..2ad67ba 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -546,6 +546,10 @@
                                 mEdgeGlowTop.onRelease();
                             }
                         }
+                        if (mEdgeGlowTop != null
+                                && (!mEdgeGlowTop.isFinished() || !mEdgeGlowBottom.isFinished())) {
+                            invalidate();
+                        }
                     }
                 }
                 break;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 9080f96..d719783 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -2956,6 +2956,25 @@
         if (imm != null) imm.restartInput(this);
     }
 
+    /**
+     * It would be better to rely on the input type for everything. A password inputType should have
+     * a password transformation. We should hence use isPasswordInputType instead of this method.
+     *
+     * We should:
+     * - Call setInputType in setKeyListener instead of changing the input type directly (which
+     * would install the correct transformation).
+     * - Refuse the installation of a non-password transformation in setTransformation if the input
+     * type is password.
+     *
+     * However, this is like this for legacy reasons and we cannot break existing apps. This method
+     * is useful since it matches what the user can see (obfuscated text or not).
+     *
+     * @return true if the current transformation method is of the password type.
+     */
+    private boolean hasPasswordTransformationMethod() {
+        return mTransformation instanceof PasswordTransformationMethod;
+    }
+
     private boolean isPasswordInputType(int inputType) {
         final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS
                 | EditorInfo.TYPE_MASK_VARIATION);
@@ -7135,7 +7154,7 @@
     }
 
     private boolean canCut() {
-        if (mTransformation instanceof PasswordTransformationMethod) {
+        if (hasPasswordTransformationMethod()) {
             return false;
         }
 
@@ -7149,7 +7168,7 @@
     }
 
     private boolean canCopy() {
-        if (mTransformation instanceof PasswordTransformationMethod) {
+        if (hasPasswordTransformationMethod()) {
             return false;
         }
 
@@ -7398,8 +7417,13 @@
             MenuHandler handler = new MenuHandler();
 
             if (canSelectText()) {
-                menu.add(0, ID_START_SELECTING_TEXT, 0, com.android.internal.R.string.selectText).
-                     setOnMenuItemClickListener(handler);
+                if (!hasPasswordTransformationMethod()) {
+                    // selectCurrentWord is not available on a password field and would return an
+                    // arbitrary 10-charater selection around pressed position. Discard it.
+                    // SelectAll is still useful to be able to clear the field using the delete key.
+                    menu.add(0, ID_START_SELECTING_TEXT, 0, com.android.internal.R.string.selectText).
+                    setOnMenuItemClickListener(handler);
+                }
                 menu.add(0, ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll).
                      setOnMenuItemClickListener(handler).
                      setAlphabeticShortcut('a');
diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java
index 1fcd654..b7255bb 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -360,7 +360,13 @@
         } else if (SHUTDOWN_VIBRATE_MS > 0) {
             // vibrate before shutting down
             Vibrator vibrator = new Vibrator();
-            vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
+            try {
+                vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
+            } catch (Exception e) {
+                // Failure to vibrate shouldn't interrupt shutdown.  Just log it.
+                Log.w(TAG, "Failed to vibrate during shutdown.", e);
+            }
+
             // vibrator is asynchronous so we need to wait to avoid shutting down too soon.
             try {
                 Thread.sleep(SHUTDOWN_VIBRATE_MS);
diff --git a/core/java/com/trustedlogic/trustednfc/android/LlcpConnectionlessSocket.java b/core/java/com/android/internal/nfc/LlcpConnectionlessSocket.java
similarity index 87%
rename from core/java/com/trustedlogic/trustednfc/android/LlcpConnectionlessSocket.java
rename to core/java/com/android/internal/nfc/LlcpConnectionlessSocket.java
index eccdeb13..a9cf6b8 100644
--- a/core/java/com/trustedlogic/trustednfc/android/LlcpConnectionlessSocket.java
+++ b/core/java/com/android/internal/nfc/LlcpConnectionlessSocket.java
@@ -14,48 +14,28 @@
  * limitations under the License.
  */
 
-/**
- * File            : LlcpConnectionLessSocket.java
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created         : 18-02-2010
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 import java.io.IOException;
 
 import android.nfc.ErrorCodes;
 import android.nfc.ILlcpConnectionlessSocket;
 import android.nfc.LlcpPacket;
-
 import android.os.RemoteException;
 import android.util.Log;
 
-/**
- * LlcpConnectionlessSocket represents a LLCP Connectionless object to be used
- * in a connectionless communication
- *
- * @since AA02.01
- * @hide
- */
 public class LlcpConnectionlessSocket {
-
-
     private static final String TAG = "LlcpConnectionlessSocket";
 
     /**
      * The handle returned by the NFC service and used to identify the LLCP connectionless socket in
      * every call of this class.
-     *
-     * @hide
      */
     protected int mHandle;
 
 
     /**
      * The entry point for LLCP Connectionless socket operations.
-     *
-     * @hide
      */
     protected ILlcpConnectionlessSocket mService;
 
@@ -66,7 +46,6 @@
      * @param service The entry point to the Nfc Service for  LLCP Connectionless socket  class.
      * @param handle The handle returned by the NFC service and used to identify
      *            the socket in subsequent calls.
-     * @hide
      */
 	LlcpConnectionlessSocket(ILlcpConnectionlessSocket service, int handle) {
         this.mService = service;
@@ -79,7 +58,6 @@
      * @param packet Service Access Point number related to a LLCP
      *            Connectionless client and a data buffer to send
      * @throws IOException if the LLCP link has been lost or deactivated.
-     * @since AA02.01
      */
     public void sendTo(LlcpPacket packet) throws IOException {
 		try {
@@ -99,7 +77,6 @@
      * @return data data received from a specific LLCP Connectionless client
      * @throws IOException if the LLCP link has been lost or deactivated.
      * @see LlcpPacket
-     * @since AA02.01
      */
     public LlcpPacket receiveFrom() throws IOException {
 		try {
@@ -118,8 +95,6 @@
 
     /**
      * Close the created Connectionless socket.
-     *
-     * @since AA02.01
      */
     public void close() {
 		try {
@@ -133,7 +108,6 @@
      * Returns the local Service Access Point number of the socket
      *
      * @return sap
-     * @since AA02.01
      */
     public int getSap() {
     	int sap = 0;
diff --git a/core/java/com/trustedlogic/trustednfc/android/LlcpException.java b/core/java/com/android/internal/nfc/LlcpException.java
similarity index 82%
rename from core/java/com/trustedlogic/trustednfc/android/LlcpException.java
rename to core/java/com/android/internal/nfc/LlcpException.java
index 1e2e2da..da4e91e 100644
--- a/core/java/com/trustedlogic/trustednfc/android/LlcpException.java
+++ b/core/java/com/android/internal/nfc/LlcpException.java
@@ -14,20 +14,11 @@
  * limitations under the License.
  */
 
-/**
- * File            : LLCPException.java
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created         : 24-02-2010
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 /**
  * Generic exception thrown in case something unexpected happened during a 
  * LLCP communication.
- *
- * @since AA02.01
- * @hide
  */
 public class LlcpException extends Exception {
    /**
diff --git a/core/java/com/trustedlogic/trustednfc/android/LlcpServiceSocket.java b/core/java/com/android/internal/nfc/LlcpServiceSocket.java
similarity index 92%
rename from core/java/com/trustedlogic/trustednfc/android/LlcpServiceSocket.java
rename to core/java/com/android/internal/nfc/LlcpServiceSocket.java
index 1bdf72f..4607527 100644
--- a/core/java/com/trustedlogic/trustednfc/android/LlcpServiceSocket.java
+++ b/core/java/com/android/internal/nfc/LlcpServiceSocket.java
@@ -14,29 +14,19 @@
  * limitations under the License.
  */
 
-/**
- * File            : LLCPServerSocket.java
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created         : 18-02-2010
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 import java.io.IOException;
 
 import android.nfc.ErrorCodes;
 import android.nfc.ILlcpSocket;
 import android.nfc.ILlcpServiceSocket;
-
 import android.os.RemoteException;
 import android.util.Log;
 
 /**
  * LlcpServiceSocket represents a LLCP Service to be used in a
  * Connection-oriented communication
- *
- * @since AA02.01
- * @hide
  */
 public class LlcpServiceSocket {
 
@@ -45,15 +35,11 @@
 	/**
 	 * The handle returned by the NFC service and used to identify the LLCP
 	 * Service socket in every call of this class.
-	 *
-	 * @hide
 	 */
 	protected int mHandle;
 
 	/**
 	 * The entry point for LLCP Service socket operations.
-	 *
-	 * @hide
 	 */
 	protected ILlcpServiceSocket mService;
 
@@ -92,7 +78,6 @@
 	 * @param handle
 	 *            The handle returned by the NFC service and used to identify
 	 *            the socket in subsequent calls.
-	 * @hide
 	 */
 	LlcpServiceSocket(ILlcpServiceSocket service, ILlcpSocket socketService, int handle) {
 		this.mService = service;
@@ -112,7 +97,6 @@
 	 *             if not enough ressources are available
 	 *
 	 * @see LlcpSocket
-	 * @since AA02.01
 	 */
 	public LlcpSocket accept() throws IOException, LlcpException {
 
@@ -141,7 +125,6 @@
 	 *
 	 * @param timeout
 	 *            value of the timeout for the accept request
-	 * @since AA02.01
 	 */
 	public void setAcceptTimeout(int timeout) {
 		try {
@@ -155,7 +138,6 @@
 	 * Get the timeout value of the accept request
 	 *
 	 * @return mTimeout
-	 * @since AA02.01
 	 */
 	public int getAcceptTimeout() {
 		try {
@@ -168,8 +150,6 @@
 
 	/**
 	 * Close the created Llcp Service socket
-	 *
-	 * @since AA02.01
 	 */
 	public void close() {
 		try {
@@ -178,5 +158,4 @@
 			Log.e(TAG, "RemoteException in close(): ", e);
 		}
 	}
-
 }
diff --git a/core/java/com/trustedlogic/trustednfc/android/LlcpSocket.java b/core/java/com/android/internal/nfc/LlcpSocket.java
similarity index 94%
rename from core/java/com/trustedlogic/trustednfc/android/LlcpSocket.java
rename to core/java/com/android/internal/nfc/LlcpSocket.java
index ebde3e1..ae74002 100644
--- a/core/java/com/trustedlogic/trustednfc/android/LlcpSocket.java
+++ b/core/java/com/android/internal/nfc/LlcpSocket.java
@@ -14,28 +14,18 @@
  * limitations under the License.
  */
 
-/**
- * File            : LlcpClientSocket.java
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created         : 18-02-2010
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 import java.io.IOException;
 
 import android.nfc.ErrorCodes;
 import android.nfc.ILlcpSocket;
-
 import android.os.RemoteException;
 import android.util.Log;
 
 /**
  * LlcpClientSocket represents a LLCP Connection-Oriented client to be used in a
  * connection-oriented communication
- *
- * @since AA02.01
- * @hide
  */
 public class LlcpSocket {
 
@@ -44,15 +34,11 @@
 	/**
 	 * The handle returned by the NFC service and used to identify the LLCP
 	 * socket in every call of this class.
-	 *
-	 * @hide
 	 */
 	protected int mHandle;
 
 	/**
 	 * The entry point for LLCP socket operations.
-	 *
-	 * @hide
 	 */
 	protected ILlcpSocket mService;
 
@@ -92,7 +78,6 @@
 	 * @param handle
 	 *            The handle returned by the NFC service and used to identify
 	 *            the socket in subsequent calls.
-	 * @hide
 	 */
 	LlcpSocket(ILlcpSocket service, int handle) {
 		this.mService = service;
@@ -109,7 +94,6 @@
 	 * @throws LlcpException
 	 *             if the connection request is rejected by the remote LLCP
 	 *             Service
-	 * @since AA02.01
 	 */
 	public void connect(int sap) throws IOException, LlcpException {
 		try {
@@ -137,7 +121,6 @@
 	 * @throws LlcpException
 	 *             if the connection request is rejected by the remote LLCP
 	 *             Service
-	 * @since AA02.01
 	 */
 	public void connect(String sn) throws IOException, LlcpException {
 		try {
@@ -160,7 +143,6 @@
 	 *
 	 * @param timeout
 	 *            timeout value for the connect request
-	 * @since AA02.01
 	 */
 	public void setConnectTimeout(int timeout) {
 		try {
@@ -174,7 +156,6 @@
 	 * Get the timeout value of the connect request
 	 *
 	 * @return mTimeout
-	 * @since AA02.01
 	 */
 	public int getConnectTimeout() {
 		try {
@@ -191,7 +172,6 @@
 	 *
 	 * @throws IOException
 	 *             if the LLCP has been lost or deactivated.
-	 * @since AA02.01
 	 */
 	public void close() throws IOException {
 		try {
@@ -210,7 +190,6 @@
 	 *
 	 * @throws IOException
 	 *             if the LLCP has been lost or deactivated.
-	 * @since AA02.01
 	 */
 	public void send(byte[] data) throws IOException {
 		try {
@@ -232,7 +211,6 @@
 	 * @return length length of the data received
 	 * @throws IOException
 	 *             if the LLCP has been lost or deactivated.
-	 * @since AA02.01
 	 */
 	public int receive(byte[] receiveBuffer) throws IOException {
 		int receivedLength = 0;
@@ -252,7 +230,6 @@
 	 * Returns the local Service Access Point number of the socket
 	 *
 	 * @return localSap
-	 * @since AA02.01
 	 */
 	public int getLocalSap() {
 		try {
@@ -267,7 +244,6 @@
 	 * Returns the local Maximum Information Unit(MIU) of the socket
 	 *
 	 * @return miu
-	 * @since AA02.01
 	 */
 	public int getLocalSocketMiu() {
 		try {
@@ -282,7 +258,6 @@
 	 * Returns the local Receive Window(RW) of the socket
 	 *
 	 * @return rw
-	 * @since AA02.01
 	 */
 	public int getLocalSocketRw() {
 		try {
@@ -301,7 +276,6 @@
 	 * @return remoteMiu
 	 * @throws LlcpException
 	 *             if the LlcpClientSocket is not in a CONNECTED_STATE
-	 * @since AA02.01
 	 */
 	public int getRemoteSocketMiu() throws LlcpException {
 		try {
@@ -325,7 +299,6 @@
 	 * @return rw
 	 * @throws LlcpException
 	 *             if the LlcpClientSocket is not in a CONNECTED_STATE
-	 * @since AA02.01
 	 */
 	public int getRemoteSocketRw() throws LlcpException {
 		try {
@@ -340,6 +313,4 @@
 			return 0;
 		}
 	}
-
-
 }
diff --git a/core/java/com/trustedlogic/trustednfc/android/NfcException.java b/core/java/com/android/internal/nfc/NfcException.java
similarity index 82%
rename from core/java/com/trustedlogic/trustednfc/android/NfcException.java
rename to core/java/com/android/internal/nfc/NfcException.java
index 2497c15..29a99c6 100644
--- a/core/java/com/trustedlogic/trustednfc/android/NfcException.java
+++ b/core/java/com/android/internal/nfc/NfcException.java
@@ -14,20 +14,11 @@
  * limitations under the License.
  */
 
-/**
- * File            : NFCException.java
- * Original-Author : Trusted Logic S.A. (Jeremie Corbier)
- * Created         : 26-08-2009
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 /**
  * Generic exception thrown in case something unexpected happened during the
  * NFCManager operations.
- *
- * @since AA01.04
- * @hide
  */
 public class NfcException extends Exception {
    /**
diff --git a/core/java/com/trustedlogic/trustednfc/android/P2pDevice.java b/core/java/com/android/internal/nfc/P2pDevice.java
similarity index 89%
rename from core/java/com/trustedlogic/trustednfc/android/P2pDevice.java
rename to core/java/com/android/internal/nfc/P2pDevice.java
index 65800f2..8ab9aad 100644
--- a/core/java/com/trustedlogic/trustednfc/android/P2pDevice.java
+++ b/core/java/com/android/internal/nfc/P2pDevice.java
@@ -14,20 +14,13 @@
  * limitations under the License.
  */
 
-/**
- * File            : P2PDevice.java
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- * Created         : 26-02-2010
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 import java.io.IOException;
 
 /**
  * P2pDevice is the abstract base class for all supported P2P targets the
  * NfcManager can handle.
- * @hide
  */
 public abstract class P2pDevice {
 
@@ -48,19 +41,16 @@
 
     /**
      * Target handle, used by native calls.
-     * @hide
      */
     protected int mHandle;
 	
     /**
      * Flag set when the object is closed and thus not usable any more.
-     * @hide
      */
 	protected boolean isClosed = false;
 
     /**
      * Prevent default constructor to be public.
-     * @hide
      */
 	protected P2pDevice() {
 	}
diff --git a/core/java/com/trustedlogic/trustednfc/android/P2pInitiator.java b/core/java/com/android/internal/nfc/P2pInitiator.java
similarity index 92%
rename from core/java/com/trustedlogic/trustednfc/android/P2pInitiator.java
rename to core/java/com/android/internal/nfc/P2pInitiator.java
index 6b93bce..46ae9ab 100644
--- a/core/java/com/trustedlogic/trustednfc/android/P2pInitiator.java
+++ b/core/java/com/android/internal/nfc/P2pInitiator.java
@@ -14,12 +14,7 @@
  * limitations under the License.
  */
 
-/**
- * File            : P2PInitiator.java
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 import java.io.IOException;
 
@@ -32,8 +27,6 @@
  * communication.
  *
  * @see P2pTarget
- * @since AA02.01
- * @hide
  */
 public class P2pInitiator extends P2pDevice {
 
@@ -41,7 +34,6 @@
 
 	/**
      * The entry point for P2P tag operations.
-     * @hide
      */
 	private final IP2pInitiator mService;
 
@@ -50,8 +42,6 @@
      *
      * @param handle The handle returned by the NFC service and used to identify
      * 				 the tag in subsequent calls.
-     *
-     * @hide
      */
     P2pInitiator(IP2pInitiator service, int handle) {
         this.mService = service;
diff --git a/core/java/com/trustedlogic/trustednfc/android/P2pTarget.java b/core/java/com/android/internal/nfc/P2pTarget.java
similarity index 94%
rename from core/java/com/trustedlogic/trustednfc/android/P2pTarget.java
rename to core/java/com/android/internal/nfc/P2pTarget.java
index aa9e94f..7b59da3 100644
--- a/core/java/com/trustedlogic/trustednfc/android/P2pTarget.java
+++ b/core/java/com/android/internal/nfc/P2pTarget.java
@@ -14,12 +14,7 @@
  * limitations under the License.
  */
 
-/**
- * File            : P2PTarget.java
- * Original-Author : Trusted Logic S.A. (Daniel Tomas)
- */
-
-package com.trustedlogic.trustednfc.android;
+package com.android.internal.nfc;
 
 import java.io.IOException;
 
@@ -32,8 +27,6 @@
  * P2pTarget represents the target in an NFC-IP1 peer-to-peer communication.
  *
  * @see P2pInitiator
- * @since AA02.01
- * @hide
  */
 public class P2pTarget extends P2pDevice {
 
@@ -41,19 +34,16 @@
 
 	/**
      * The entry point for P2P tag operations.
-     * @hide
      */
 	private final IP2pTarget mService;
 
     /**
      * Flag set when the object is closed and thus not usable any more.
-     * @hide
      */
 	private final boolean isClosed = false;
 
     /**
      * Flag set when the tag is connected.
-     * @hide
      */
 	private boolean isConnected = false;
 
@@ -62,8 +52,6 @@
      *
      * @return data sent by the P2pInitiator.
      * @throws NfcException if accessing a closed target.
-     *
-     * @hide
      */
     public void checkState() throws NfcException {
     	if(isClosed) {
@@ -76,8 +64,6 @@
      *
      * @param handle The handle returned by the NFC service and used to identify
      * 				 the tag in subsequent calls.
-     *
-     * @hide
      */
     P2pTarget(IP2pTarget service, int handle) {
         this.mService = service;
@@ -181,5 +167,4 @@
     public int getMode() {
         return P2pDevice.MODE_P2P_TARGET;
     }
-
 }
diff --git a/core/java/com/android/internal/util/HierarchicalStateMachine.java b/core/java/com/android/internal/util/HierarchicalStateMachine.java
index f789301..fc1e866 100644
--- a/core/java/com/android/internal/util/HierarchicalStateMachine.java
+++ b/core/java/com/android/internal/util/HierarchicalStateMachine.java
@@ -1094,7 +1094,9 @@
      * @param msg that couldn't be handled.
      */
     protected void unhandledMessage(Message msg) {
-        Log.e(TAG, mName + " - unhandledMessage: msg.what=" + msg.what);
+        if (false) {
+            Log.e(TAG, mName + " - unhandledMessage: msg.what=" + msg.what);
+        }
     }
 
     /**
diff --git a/core/java/com/trustedlogic/trustednfc/android/package.html b/core/java/com/trustedlogic/trustednfc/android/package.html
deleted file mode 100644
index 0c0b605..0000000
--- a/core/java/com/trustedlogic/trustednfc/android/package.html
+++ /dev/null
@@ -1,473 +0,0 @@
-<html>
-<body>
-
-<p>Provides classes that manage the NFC functionality.</p>
-
-<p>The NFC functionality is related to Near Field Communication.</p>
-
-<p>The NFC APIs let applications:</p>
-<ul>
-  <li>Scan for remote NFC targets (NFC Tag or NFC Peer)</li>
-  <li>Transfer raw data to and from remote NFC targets (NFC Tags or NFC Peer)</li>
-  <li>Read/Write NDEF data from/to remote NFC targets (NFC Tags)</li>
-  <li>Establish LLCP connection with a remote NFC target (NFC Peer with LLCP support)</li>
-  <li>Exchange data with a remote NFC target through LLCP services (NFC Peer with LLCP support)</li>
-  <li>Be notified of transactions on the local Secure Element by an external NFC reader</li>
-</ul>
-
-
-<h1>Setting Up NFC</h1>
-
-<p>
-Before an application can use the NFC feature, it needs to check if NFC is
-supported on the device by getting an instance of the
-{@link com.trustedlogic.trustednfc.android.NfcManager} class.
-</p>
-
-<pre>
-	NfcManager mNfcManager = (NfcManager) getSystemService(Context.NFC_SERVICE);
-	if (mNfcManager == null) {
-		// Device does not support NFC
-	}
-</pre>
-
-<p>
-An application can ensure that NFC is enabled.
-If not, an application with the needed permission can request that NFC be
-enabled.
-</p>
-
-<pre>
-	if (!mNfcManager.isEnabled) {
-		// NFC is currently disabled.
-		// Enable NFC.
-		mNfcManager.enable();
-	}
-</pre>
-
-<p>
-Before using the card emulation mode, an application can ensure that a secure
-element is selected ({@link com.trustedlogic.trustednfc.android.NfcManager#getSelectedSecureElement}).
-If not, an application with the needed permission can recover the list of
-available secure elements on the device
-({@link com.trustedlogic.trustednfc.android.NfcManager#getSecureElementList}) and select one
-({@link com.trustedlogic.trustednfc.android.NfcManager#selectSecureElement}).
-</p>
-
-<p>
-Before using the NFC feature, an application can configure the NFC device by
-calling {@link com.trustedlogic.trustednfc.android.NfcManager#setProperties}. This function allows:
-</p>
-<ul>
-  <li>Enabling/disabling the NFC device capabilities (RF types, baudrates,
-  NFCIP-1 mode and role...)</li>
-  <li>Settings the NFCIP-1 general bytes and the LLCP link parameters</li>
-</ul>
-<p>
-The setting properties can be customized according to the Device capabilities.
-The next table give the minimal set of properties supported by the Device.
-Depending on the implementation, the table may be completed.
-</p>
-<table>
-  <TR><TH> Property Name </TH><TH> Property Values </TH></TR>
-  <TR><TD> discovery.felica    </TD><TD> <b>true</b>|false </TD></TR>
-  <TR><TD> discovery.iso14443A </TD><TD> <b>true</b>|false </TD></TR>
-  <TR><TD> discovery.iso14443B </TD><TD> <b>true</b>|false </TD></TR>
-  <TR><TD> discovery.iso15693  </TD><TD> <b>true</b>|false </TD></TR>
-  <TR><TD> discovery.nfcip     </TD><TD> <b>true</b>|false </TD></TR>
-  <TR><TD> nfcip.baudrate     </TD><TD> 106|212|424 </TD></TR>
-  <TR><TD> nfcip.generalbytes </TD><TD>  </TD></TR>
-  <TR><TD> nfcip.mode         </TD><TD> active|passive|<b>all</b> </TD></TR>
-  <TR><TD> nfcip.role         </TD><TD> initiator|target|<b>both</b> </TD></TR>
-  <TR><TD> llcp.lto </TD><TD> <b>150</b> (0 to 255) </TD></TR>
-  <TR><TD> llcp.opt </TD><TD>   <b>0</b> (0 to 3) </TD></TR>
-  <TR><TD> llcp.miu </TD><TD> <b>128</b> (128 to 2176) </TD></TR>
-  <TR><TD> llcp.wks </TD><TD>   <b>1</b> (0 to 15) </TD></TR>
-</table> 
-<p>(default values in bold)</p>
-
-
-<h1>NFC Permissions</h1>
-
-<p>
-To change the NFC service settings such as enabling the NFC targets
-discovery or activating the secure element, an application must declare the
-NFC_ADMIN permission.
-</p>
-<p>
-To perform NFC raw communication with a remote NFC target in
-Reader/Write Mode or Peer-to-Peer Mode, an application must declare the NFC_RAW
-permission.
-</p>
-<p>
-To receive NDEF message or Secure Element intents, an application must declare
-the NFC_NOTIFY permission.
-</p>
-<p>
-To receive the LLCP link intent and perform an LLCP communication with a remote NFC target, an application must
-declare the NFC_LLCP permission.
-</p>
-
-
-<h1>NFC Usage</h1>
-
-<p>
-The following code samples illustrate the APIs usage regarding the NFC service
-use cases.
-</p>
-
-<h2>Reader/Writer Mode NDEF message notification</h2>
-
-<p>
-This code sample illustrates the NDEF message notification through an Intent declared in the manifest and a receiver implemented in the application.
-</p>
-<p>Main involved classes/methods:</p>
-
-<p>Manifest Example:</p>
-<pre>
-	&lt;receiver android:name=".NfcReaderDemoReceiver">
-            &lt;intent-filter>
-               &lt;action android:name= "com.trustedlogic.trustednfc.android.action.NDEF_TAG_DISCOVERED"/>
-            &lt;/intent-filter>
-        &lt;/receiver>
-</pre>
-
-<p>Receiver Example:</p>
-<ul>
-  <li>{@link com.trustedlogic.trustednfc.android.NdefMessage}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#NDEF_TAG_DISCOVERED_ACTION}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#NDEF_MESSAGE_EXTRA}</li>
-</ul>
-<pre>
-public class NdefMessageReceiverSample extends BroadcastReceiver {
-	public void onReceive(Context context, Intent intent) {
-		if (intent.getAction().equals(NfcManager.NDEF_TAG_DISCOVERERD_ACTION)) {
-			NdefMessage msg = intent.getParcelableExtra(NfcManager.NDEF_MESSAGE_EXTRA);
-		
-		/* Manage the NdefMessage received */
-	}
-</pre>
-
-<h2>Reader/Writer Mode raw exchange</h2>
-
-<p>
-This code sample illustrates raw exchanges with a NFC target in Reader/Writer
-mode.
-</p>
-<p>Main involved classes/methods:</p>
-<ul>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#openTagConnection}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcTag}</li>
-</ul>
-
-<pre>
-public class TagReaderSample {
-
-	/** The NFC manager to access NFC features */
-	private NfcManager manager = (NfcManager) getSystemService(Context.NFC_SERVICE);
-
-	private void runTagReader() {
-		NfcTag tag = null;
-		String type;
-		byte[] cmd = { 0x01, 0x02, 0x03 };
-		byte[] res;
-
-		while (true) {
-			try {
-				Log.i("NFC example", "Please wave in front of the tag");
-				// Open a connection on next available tag
-				try {
-					tag = manager.openTagConnection();
-				} catch (NfcException e) {
-					// TODO: Handle open failure
-				}
-
-				// Look for a mifare 4k
-				type = tag.getType();
-				if (type.equals("Mifare4K")) {
-					Log.i("NFC example", "Tag detected");
-					tag.connect();
-					// Ready to communicate, we can send transceive !
-					res = tag.transceive(cmd);
-				} else {
-					Log.i("NFC example", "Unknown tag");
-				}
-			} catch (IOException e) {
-				// TODO: Handle broken connection
-			} finally {
-				if (tag != null) {
-					tag.close();
-				}
-			}
-		}
-	}
-}
-</pre>
-
-<h2>Peer-to-Peer Mode raw exchange</h2>
-
-<p>
-This code sample illustrates raw exchanges with a NFC target in Peer-to-Peer
-mode.
-</p>
-<p>Main involved classes/methods:</p>
-<ul>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#openP2pConnection}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.P2pDevice}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.P2pInitiator}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.P2pTarget}</li>
-</ul>
-
-<pre>
-public class P2pSample {
-
-	/** The NFC manager to access NFC features */
-	private NfcManager manager = (NfcManager) getSystemService(Context.NFC_SERVICE);
-
-	private void runP2p() {
-		P2pDevice deviceP2p;
-		P2pInitiator initiator;
-		P2pTarget target;
-		byte[] data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-		byte[] echo = new byte[data.length * 10];
-
-		try {
-			deviceP2p = manager.openP2pConnection();
-
-			if (deviceP2p.getMode() == P2pDevice.MODE_P2P_INITIATOR) {
-				target = new P2pTarget(deviceP2p);
-				// Connect to the detected P2P target
-				target.connect();
-				// send data to the target
-				target.transceive(data);
-				// disconnect the connected target
-				target.disconnect();
-			} else if (deviceP2p.getMode() == P2pDevice.MODE_P2P_TARGET) {
-				initiator = new P2pInitiator(deviceP2p);
-				//target in receive state 
-				echo = initiator.receive();	
-				// send back the data received
-				initiator.send(echo);
-			}
-		} catch (IOException e0) {
-
-		} catch (NfcException e1) {
-
-		}
-	}
-}
-</pre>
-
-<h2>Peer-to-Peer Mode LLCP exchange</h2>
-
-<p>
-This code sample illustrates how to get LLCP link state notification with the declaration of a Receiver in the manifest of the application  and the implementation 
-of the receiver in the application.
-</p>
-<p>Manifest Example:</p>
-<pre>
-	&lt;receiver android:name=".LlcpModeReceiverSample">
-            &lt;intent-filter>
-		&lt;action android:name= "com.trustedlogic.trustednfc.android.action.LLCP_LINK_STATE_CHANGED"/>
-            &lt;/intent-filter>
-        &lt;/receiver>
-</pre>
-
-<p>Receiver Example:</p>
-<ul>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#LLCP_LINK_STATE_CHANGED_ACTION}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#LLCP_LINK_STATE_CHANGED_EXTRA}</li> 
-</ul> 
-<pre>
-public class LlcpModeReceiverSample extends BroadcastReceiver {
-	public void onReceive(Context context, Intent intent) {
-
-		if (intent.getAction().equals(NfcManager.LLCP_LINK_STATE_CHANGED_ACTION)){
-			byte[] aid = intent.getByteArrayExtra(NfcManager.LLCP_LINK_STATE_CHANGED_EXTRA);
-			/* Create an LLCP service or client and start an LLCP communication */
-		} 
-	}
-</pre>
-
-
-<p>
-This code samples illustrate LLCP exchanges with a NFC Peer.
-</p>
-<p>Main involved classes/methods:</p>
-<ul>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#createLlcpSocket}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#createLlcpConnectionlessSocket}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#createLlcpServiceSocket}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.LlcpSocket}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.LlcpConnectionlessSocket}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.LlcpPacket}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.LlcpServiceSocket}</li>
-</ul>
-
-<pre>
-public class LlcpServerSample {
-
-	/** The NFC manager to access NFC features */
-	private NfcManager manager = (NfcManager) getSystemService(Context.NFC_SERVICE);
-
-	private void runLlcpClient() {
-		LlcpSocket sock;
-		byte[] data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-		byte[] echo = new byte[data.length * 10];
-		int length = 0;
-
-		sock = manager.createLlcpSocket((short) 128, (byte) 2, 1024);
-		
-		// set a timeout in ms for connect request
-		sock.setConnectTimeout(10);
-		
-		try {
-			// Connect to remote service
-			// NOTE: could be sock.connect("com.trusted-logic.tnfc.testapp");
-			sock.connect((byte) 0x10);
-
-			// Send data
-			for (int i = 0; i < 10; i++) {
-				sock.send(data);
-			}
-
-			// Receive echo
-			while (length < 10 * data.length) {
-				length += sock.receive(echo);
-			}
-
-		} catch (IOException e) {
-			// TODO: Handle broken connection broken (link down, remote closure
-			// or connect rejected) or Timeout expired
-		}
-	}
-}
-</pre>
-
-<pre>
-public class LlcpClientSample {
-
-	/** The NFC manager to access NFC features */
-	private NfcManager manager = (NfcManager) getSystemService(Context.NFC_SERVICE);
-
-	private void runLlcpClient() {
-		LlcpSocket sock;
-		byte[] data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-		byte[] echo = new byte[data.length * 10];
-		int length = 0;
-
-		sock = manager.createLlcpSocket((short) 128, (byte) 2, 1024);
-		try {
-			// Connect to remote service
-			// NOTE: could be sock.connect("com.trusted-logic.tnfc.testapp");
-			sock.connect((byte) 0x10);
-
-			// Send data
-			for (int i = 0; i < 10; i++) {
-				sock.send(data);
-			}
-
-			// Receive echo
-			while (length < 10 * data.length) {
-				length += sock.receive(echo);
-			}
-
-		} catch (IOException e) {
-			// TODO: Handle broken connection broken (link down, remote closure
-			// or connect rejected)
-		}
-	}
-}
-</pre>
-
-<h2>Card Emulation Mode transaction notification</h2>
-
-<p>
-This code sample illustrates how to get the card emulation notification with the declaration of a Receiver in the manifest of the application  and the implementation 
-of the receiver in the application.
-</p>
-<p>Manifest Example:</p>
-<pre>
-	&lt;receiver android:name=".NfcReaderDemoReceiver">
-            &lt;intent-filter>
-		&lt;action android:name= "com.trustedlogic.trustednfc.android.action.TRANSACTION_DETECTED"/>
-            &lt;/intent-filter>
-        &lt;/receiver>
-</pre>
-
-<p>Receiver Example:</p>
-<ul>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#TRANSACTION_DETECTED_ACTION}</li>
-  <li>{@link com.trustedlogic.trustednfc.android.NfcManager#AID_EXTRA}</li> 
-</ul> 
-<pre>
-public class CardEmulationReceiverSample extends BroadcastReceiver {
-	public void onReceive(Context context, Intent intent) {
-
-		if (intent.getAction().equals(NfcManager.TRANSACTION_DETECTED_ACTION)){
-			byte[] aid = intent.getByteArrayExtra(NfcManager.AID_EXTRA);
-			/* Manage the AID: */
-			/* For example start an activity related to this AID value or display a popup with the AID */
-		} 
-	}
-</pre>
-
-
-
-<h1>Multiple Applications rules</h1>
-
-<p>
-Several LLCP sockets can be created by a single application or by multiple
-applications by calling {@link com.trustedlogic.trustednfc.android.NfcManager#createLlcpSocket}, 
-{@link com.trustedlogic.trustednfc.android.NfcManager#createLlcpConnectionlessSocket} or 
-{@link com.trustedlogic.trustednfc.android.NfcManager#createLlcpServiceSocket}, provided the local SAP
-numbers are differents.
-</p>
-
-<p>
-Only one application can open a raw connection by calling 
-{@link com.trustedlogic.trustednfc.android.NfcManager#openTagConnection} or
-{@link com.trustedlogic.trustednfc.android.NfcManager#openP2pConnection}.
-While this application has not closed or cancelled its connection, any other
-application that attempts to open another raw connection will raise an
-exception.
-During an open connnection, the card emulation mode is always enabled and 
-applications are able to receive card emulation intents.
-</p>
-
-<p>
-When an application opens a tag connection by calling 
-{@link com.trustedlogic.trustednfc.android.NfcManager#openTagConnection}, this operation is exclusive, no NDEF message intent are
-broadcast while the connection is not closed or canceled.
-</p>
-
-<p>
-When an application opens a peer-to-peer connection by calling
-{@link com.trustedlogic.trustednfc.android.NfcManager#openP2pConnection}, this operation is exclusive, no LLCP intent are broadcast and LLCP sockets are
-disabled while the connection is not closed or canceled. 
-</p>
-
-
-<h1>NFC Tag types</h1>
-
-<p>
-The {@link com.trustedlogic.trustednfc.android.NfcTag} type returned by
-{@link com.trustedlogic.trustednfc.android.NfcTag#getType} indicates the set of
-commands supported by the tag. These commands can be used in
-{@link com.trustedlogic.trustednfc.android.NfcTag#transceive}.
-</p>
-
-<TABLE BORDER="1">
-  <TR><TH> Tag Type </TH><TH> Returned string </TH></TR>
-  <TR><TD> Jewel/Topaz </TD><TD> Jewel </TD></TR>
-  <TR><TD> Mifare UltraLight </TD><TD> MifareUL </TD></TR>
-  <TR><TD> Mifare Standard 1K </TD><TD> Mifare1K </TD></TR>
-  <TR><TD> Mifare Standard 4K </TD><TD> Mifare4K </TD></TR>
-  <TR><TD> Mifare DESFIRE </TD><TD> MifareDESFIRE </TD></TR>
-  <TR><TD> Felica </TD><TD> Felica </TD></TR>
-  <TR><TD> ISO14443-4 A or B </TD><TD> Iso14443 </TD></TR>
-  <TR><TD> ISO15693 </TD><TD> Iso15693 </TD></TR>
-</TABLE> 
-
-</body>
-</html>
diff --git a/core/jni/android_nfc_NdefRecord.cpp b/core/jni/android_nfc_NdefRecord.cpp
index 8ce1837..9d20d6d 100644
--- a/core/jni/android_nfc_NdefRecord.cpp
+++ b/core/jni/android_nfc_NdefRecord.cpp
@@ -80,8 +80,92 @@
     return result;
 }
 
+static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o,
+        jbyteArray array)
+{
+    uint16_t status;
+    jbyte *raw_record;
+    jsize raw_record_size;
+    jint ret = -1;
+    phFriNfc_NdefRecord_t record;
+
+    jfieldID mType, mId, mPayload, mTnf;
+    jbyteArray type = NULL;
+    jbyteArray id = NULL;
+    jbyteArray payload = NULL;
+
+    jclass record_cls = e->GetObjectClass(o);
+
+    raw_record_size = e->GetArrayLength(array);
+    raw_record = e->GetByteArrayElements(array, NULL);
+    if (raw_record == NULL) {
+        goto clean_and_return;
+    }
+
+    LOGD("phFriNfc_NdefRecord_Parse()");
+    status = phFriNfc_NdefRecord_Parse(&record, (uint8_t *)raw_record);
+    if (status) {
+        LOGE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status);
+        goto clean_and_return;
+    }
+    LOGD("phFriNfc_NdefRecord_Parse() returned 0x%04x", status);
+
+    /* Set TNF field */
+    mTnf = e->GetFieldID(record_cls, "mTnf", "S");
+    e->SetShortField(o, mTnf, record.Tnf);
+
+    /* Set type field */
+    mType = e->GetFieldID(record_cls, "mType", "[B");
+    type = e->NewByteArray(record.TypeLength);
+    if (type == NULL) {
+        goto clean_and_return;
+    }
+    e->SetByteArrayRegion(type, 0, record.TypeLength,
+            (jbyte *)record.Type);
+    e->SetObjectField(o, mType, type);
+
+    /* Set id field */
+    mId = e->GetFieldID(record_cls, "mId", "[B");
+    id = e->NewByteArray(record.IdLength);
+    if (id == NULL) {
+        goto clean_and_return;
+    }
+    e->SetByteArrayRegion(id, 0, record.IdLength,
+            (jbyte *)record.Id);
+    e->SetObjectField(o, mId, id);
+
+    /* Set payload field */
+    mPayload = e->GetFieldID(record_cls, "mPayload", "[B");
+    payload = e->NewByteArray(record.PayloadLength);
+    if (payload == NULL) {
+        goto clean_and_return;
+    }
+    e->SetByteArrayRegion(payload, 0, record.PayloadLength,
+            (jbyte *)record.PayloadData);
+    e->SetObjectField(o, mPayload, payload);
+
+    ret = 0;
+
+clean_and_return:
+    if (type != NULL) {
+        e->DeleteLocalRef(type);
+    }
+    if (id != NULL) {
+        e->DeleteLocalRef(id);
+    }
+    if (payload != NULL) {
+        e->DeleteLocalRef(payload);
+    }
+    if (raw_record != NULL) {
+        e->ReleaseByteArrayElements(array, raw_record, JNI_ABORT);
+    }
+
+    return ret;
+}
+
 static JNINativeMethod gMethods[] = {
     {"generate", "(SS[B[B[B)[B", (void *)android_nfc_NdefRecord_generate},
+    {"parseNdefRecord", "([B)I", (void *)android_nfc_NdefRecord_parseNdefRecord},
 };
 
 int register_android_nfc_NdefRecord(JNIEnv *e)
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index ef4ee11..a22c827 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -341,29 +341,12 @@
         android:description="@string/permdesc_bluetooth"
         android:label="@string/permlab_bluetooth" />
 
-    <!-- Allows applications to access remote NFC devices
-         @hide -->
-    <permission android:name="com.trustedlogic.trustednfc.permission.NFC_RAW"
+    <!-- Allows applications to directly communicate over NFC -->
+    <permission android:name="android.permission.NFC"
         android:permissionGroup="android.permission-group.NETWORK"
         android:protectionLevel="dangerous"
-        android:description="@string/permdesc_nfcRaw"
-        android:label="@string/permlab_nfcRaw" />
-
-    <!-- Allows applications to be notified of remote NFC devices
-         @hide -->
-    <permission android:name="com.trustedlogic.trustednfc.permission.NFC_NOTIFY"
-        android:permissionGroup="android.permission-group.NETWORK"
-        android:protectionLevel="dangerous"
-        android:description="@string/permdesc_nfcNotify"
-        android:label="@string/permlab_nfcNotify" />
-
-    <!-- Allows applications to be notified of remote NFC LLCP devices
-         @hide -->
-    <permission android:name="com.trustedlogic.trustednfc.permission.NFC_LLCP"
-        android:permissionGroup="android.permission-group.NETWORK"
-        android:protectionLevel="dangerous"
-        android:description="@string/permdesc_nfcLlcp"
-        android:label="@string/permlab_nfcLlcp" />
+        android:description="@string/permdesc_nfc"
+        android:label="@string/permlab_nfc" />
 
     <!-- Allows an application to use SIP service -->
     <permission android:name="android.permission.USE_SIP"
@@ -875,14 +858,6 @@
         android:description="@string/permdesc_bluetoothAdmin"
         android:label="@string/permlab_bluetoothAdmin" />
 
-    <!-- Allows applications to change NFC connectivity settings 
-         @hide -->
-    <permission android:name="com.trustedlogic.trustednfc.permission.NFC_ADMIN"
-        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
-        android:protectionLevel="dangerous"
-        android:description="@string/permdesc_nfcAdmin"
-        android:label="@string/permlab_nfcAdmin" />
-
     <!-- Allows an application to clear the caches of all installed
          applications on the device.  -->
     <permission android:name="android.permission.CLEAR_APP_CACHE"
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index cc91fb7..5531d47 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1261,11 +1261,6 @@
   <public type="attr" name="textSelectHandleWindowStyle" id="0x010102c8" />
   <public type="attr" name="popupAnimationStyle" id="0x010102c9" />
 
-  <public-padding type="attr" name="kraken_resource_pad" end="0x01010300" />
-  
-  <public-padding type="id" name="kraken_resource_pad" end="0x01020040" />
-  <public-padding type="anim" name="kraken_resource_pad" end="0x010a0020" />
-
   <!-- presence drawables for videochat or audiochat capable contacts -->
   <public type="drawable" name="presence_video_away" id="0x010800ac" />
   <public type="drawable" name="presence_video_busy" id="0x010800ad" />
@@ -1274,19 +1269,9 @@
   <public type="drawable" name="presence_audio_busy" id="0x010800b0" />
   <public type="drawable" name="presence_audio_online" id="0x010800b1" />
 
-  <public-padding type="drawable" name="kraken_resource_pad" end="0x01080100" />
-  
   <public type="style" name="TextAppearance.StatusBar.Title" id="0x01030065" />
   <public type="style" name="TextAppearance.StatusBar.Icon" id="0x01030066" />
   <public type="style" name="TextAppearance.StatusBar.EventContent" id="0x01030067" />
   <public type="style" name="TextAppearance.StatusBar.EventContent.Title" id="0x01030068" />
-
-  <public-padding type="style" name="kraken_resource_pad" end="0x01030090" />
-
-  <public-padding type="string" name="kraken_resource_pad" end="0x01040020" />
-  <public-padding type="integer" name="kraken_resource_pad" end="0x010e0010" />
-  <public-padding type="layout" name="kraken_resource_pad" end="0x01090020" />
-  <public-padding type="dimen" name="kraken_resource_pad" end="0x01050010" />
-  <public-padding type="color" name="kraken_resource_pad" end="0x01060020" />
-  <public-padding type="array" name="kraken_resource_pad" end="0x01070010" />
+  
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index e1b5d93..075cc66 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1153,28 +1153,10 @@
       connections with paired devices.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_nfcAdmin">NFC administration</string>
+    <string name="permlab_nfc">control Near Field Communication</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_nfcAdmin">Allows an application to configure
-      the local NFC phone.</string>
-
-    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_nfcRaw">NFC full access to remote device</string>
-    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_nfcRaw">Allows an application to access
-      remote NFC devices.</string>
-
-    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_nfcNotify">NFC notification from remote device</string>
-    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_nfcNotify">Allows an application to be notified
-      of operations related to remote NFC devices.</string>
-
-    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_nfcLlcp">NFC notification from remote LLCP device</string>
-    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_nfcLlcp">Allows an application to be notified
-      of LLCP operations related to remote NFC devices.</string>
+    <string name="permdesc_nfc">Allows an application to communicate
+      with Near Field Communication (NFC) tags, cards, and readers.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_disableKeyguard">disable keylock</string>
diff --git a/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java b/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java
index 149685c..892dc8a 100644
--- a/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java
+++ b/core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java
@@ -80,12 +80,17 @@
     }
 
     public void testPair() {
+        int iterations = BluetoothTestRunner.sPairIterations;
         BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
-        BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sHeadsetAddress);
-
+        BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPairAddress);
         mTestUtils.enable(adapter);
-        mTestUtils.pair(adapter, device);
-        mTestUtils.unpair(adapter, device);
+
+        for (int i = 0; i < iterations; i++) {
+            mTestUtils.writeOutput("pair iteration " + (i + 1) + " of " + iterations);
+            mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey,
+                    BluetoothTestRunner.sPairPin);
+            mTestUtils.unpair(adapter, device);
+        }
         mTestUtils.disable(adapter);
     }
 
@@ -95,7 +100,8 @@
         BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sA2dpAddress);
 
         mTestUtils.enable(adapter);
-        mTestUtils.pair(adapter, device);
+        mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey,
+                BluetoothTestRunner.sPairPin);
 
         for (int i = 0; i < iterations; i++) {
             mTestUtils.writeOutput("connectA2dp iteration " + (i + 1) + " of " + iterations);
@@ -113,7 +119,8 @@
         BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sHeadsetAddress);
 
         mTestUtils.enable(adapter);
-        mTestUtils.pair(adapter, device);
+        mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey,
+                BluetoothTestRunner.sPairPin);
 
         for (int i = 0; i < iterations; i++) {
             mTestUtils.writeOutput("connectHeadset iteration " + (i + 1) + " of " + iterations);
diff --git a/core/tests/coretests/src/android/bluetooth/BluetoothTestRunner.java b/core/tests/coretests/src/android/bluetooth/BluetoothTestRunner.java
index 2e6daa3..050dc30 100644
--- a/core/tests/coretests/src/android/bluetooth/BluetoothTestRunner.java
+++ b/core/tests/coretests/src/android/bluetooth/BluetoothTestRunner.java
@@ -26,12 +26,17 @@
     public static int sEnableIterations = 100;
     public static int sDiscoverableIterations = 1000;
     public static int sScanIterations = 1000;
+    public static int sPairIterations = 100;
     public static int sConnectHeadsetIterations = 100;
     public static int sConnectA2dpIterations = 100;
 
+    public static String sPairAddress = "";
     public static String sHeadsetAddress = "";
     public static String sA2dpAddress = "";
 
+    public static byte[] sPairPin = {'1', '2', '3', '4'};
+    public static int sPairPasskey = 123456;
+
     @Override
     public TestSuite getAllTests() {
         TestSuite suite = new InstrumentationTestSuite(this);
@@ -75,6 +80,15 @@
             }
         }
 
+        val = arguments.getString("pair_iterations");
+        if (val != null) {
+            try {
+                sPairIterations = Integer.parseInt(val);
+            } catch (NumberFormatException e) {
+                // Invalid argument, fall back to default value
+            }
+        }
+
         val = arguments.getString("connect_a2dp_iterations");
         if (val != null) {
             try {
@@ -93,6 +107,11 @@
             }
         }
 
+        val = arguments.getString("pair_address");
+        if (val != null) {
+            sPairAddress = val;
+        }
+
         val = arguments.getString("headset_address");
         if (val != null) {
             sHeadsetAddress = val;
@@ -102,5 +121,19 @@
         if (val != null) {
             sA2dpAddress = val;
         }
+
+        val = arguments.getString("pair_pin");
+        if (val != null) {
+            sPairPin = BluetoothDevice.convertPinToBytes(val);
+        }
+
+        val = arguments.getString("pair_passkey");
+        if (val != null) {
+            try {
+                sPairPasskey = Integer.parseInt(val);
+            } catch (NumberFormatException e) {
+                // Invalid argument, fall back to default value
+            }
+        }
     }
 }
diff --git a/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java b/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java
index 2d0424d..f7bb1f9 100644
--- a/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java
+++ b/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java
@@ -30,6 +30,8 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 public class BluetoothTestUtils extends Assert {
 
@@ -88,33 +90,6 @@
      */
     private static final int DISCONNECT_HEADSET_TIMEOUT = 20000;
 
-    private static final int DISCOVERY_STARTED_FLAG = 1;
-    private static final int DISCOVERY_FINISHED_FLAG = 1 << 1;
-    private static final int SCAN_MODE_NONE_FLAG = 1 << 2;
-    private static final int SCAN_MODE_CONNECTABLE_FLAG = 1 << 3;
-    private static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE_FLAG = 1 << 4;
-    private static final int STATE_OFF_FLAG = 1 << 5;
-    private static final int STATE_TURNING_ON_FLAG = 1 << 6;
-    private static final int STATE_ON_FLAG = 1 << 7;
-    private static final int STATE_TURNING_OFF_FLAG = 1 << 8;
-    private static final int PAIR_STATE_FLAG = 1 << 9;
-    private static final int PROFILE_A2DP_FLAG = 1 << 10;
-    private static final int PROFILE_HEADSET_FLAG = 1 << 11;
-
-    private static final int PAIR_STATE_BONDED = 1;
-    private static final int PAIR_STATE_BONDING = 1 << 1;
-    private static final int PAIR_STATE_NONE = 1 << 2;
-
-    private static final int A2DP_STATE_DISCONNECTED = 1;
-    private static final int A2DP_STATE_CONNECTING = 1 << 1;
-    private static final int A2DP_STATE_CONNECTED = 1 << 2;
-    private static final int A2DP_STATE_DISCONNECTING = 1 << 3;
-    private static final int A2DP_STATE_PLAYING = 1 << 4;
-
-    private static final int HEADSET_STATE_DISCONNECTED = 1;
-    private static final int HEADSET_STATE_CONNECTING = 1 << 1;
-    private static final int HEADSET_STATE_CONNECTED = 1 << 2;
-
     /**
      * Time between polls in ms.
      */
@@ -155,8 +130,29 @@
     private HeadsetServiceListener mHeadsetServiceListener = new HeadsetServiceListener();
 
     private class BluetoothReceiver extends BroadcastReceiver {
+        private static final int DISCOVERY_STARTED_FLAG = 1;
+        private static final int DISCOVERY_FINISHED_FLAG = 1 << 1;
+        private static final int SCAN_MODE_NONE_FLAG = 1 << 2;
+        private static final int SCAN_MODE_CONNECTABLE_FLAG = 1 << 3;
+        private static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE_FLAG = 1 << 4;
+        private static final int STATE_OFF_FLAG = 1 << 5;
+        private static final int STATE_TURNING_ON_FLAG = 1 << 6;
+        private static final int STATE_ON_FLAG = 1 << 7;
+        private static final int STATE_TURNING_OFF_FLAG = 1 << 8;
+        private static final int PROFILE_A2DP_FLAG = 1 << 9;
+        private static final int PROFILE_HEADSET_FLAG = 1 << 10;
+
+        private static final int A2DP_STATE_DISCONNECTED = 1;
+        private static final int A2DP_STATE_CONNECTING = 1 << 1;
+        private static final int A2DP_STATE_CONNECTED = 1 << 2;
+        private static final int A2DP_STATE_DISCONNECTING = 1 << 3;
+        private static final int A2DP_STATE_PLAYING = 1 << 4;
+
+        private static final int HEADSET_STATE_DISCONNECTED = 1;
+        private static final int HEADSET_STATE_CONNECTING = 1 << 1;
+        private static final int HEADSET_STATE_CONNECTED = 1 << 2;
+
         private int mFiredFlags = 0;
-        private int mPairFiredFlags = 0;
         private int mA2dpFiredFlags = 0;
         private int mHeadsetFiredFlags = 0;
 
@@ -200,21 +196,6 @@
                             mFiredFlags |= STATE_TURNING_OFF_FLAG;
                             break;
                     }
-                } else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(intent.getAction())) {
-                    mFiredFlags |= PAIR_STATE_FLAG;
-                    int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);
-                    assertNotSame(state, -1);
-                    switch (state) {
-                        case BluetoothDevice.BOND_BONDED:
-                            mPairFiredFlags |= PAIR_STATE_BONDED;
-                            break;
-                        case BluetoothDevice.BOND_BONDING:
-                            mPairFiredFlags |= PAIR_STATE_BONDING;
-                            break;
-                        case BluetoothDevice.BOND_NONE:
-                            mPairFiredFlags |= PAIR_STATE_NONE;
-                            break;
-                    }
                 } else if (BluetoothA2dp.ACTION_SINK_STATE_CHANGED.equals(intent.getAction())) {
                     mFiredFlags |= PROFILE_A2DP_FLAG;
                     int state = intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE, -1);
@@ -262,12 +243,6 @@
             }
         }
 
-        public int getPairFiredFlags() {
-            synchronized (this) {
-                return mPairFiredFlags;
-            }
-        }
-
         public int getA2dpFiredFlags() {
             synchronized (this) {
                 return mA2dpFiredFlags;
@@ -283,14 +258,101 @@
         public void resetFiredFlags() {
             synchronized (this) {
                 mFiredFlags = 0;
-                mPairFiredFlags = 0;
                 mA2dpFiredFlags = 0;
                 mHeadsetFiredFlags = 0;
             }
         }
     }
 
-    private BluetoothReceiver mReceiver = new BluetoothReceiver();
+    private BluetoothReceiver mBluetoothReceiver = new BluetoothReceiver();
+
+    private class PairReceiver extends BroadcastReceiver {
+        private final static int PAIR_FLAG = 1;
+        private static final int PAIR_STATE_BONDED = 1;
+        private static final int PAIR_STATE_BONDING = 1 << 1;
+        private static final int PAIR_STATE_NONE = 1 << 2;
+
+        private int mFiredFlags = 0;
+        private int mPairFiredFlags = 0;
+
+        private BluetoothDevice mDevice;
+        private int mPasskey;
+        private byte[] mPin;
+
+        public PairReceiver(BluetoothDevice device, int passkey, byte[] pin) {
+            super();
+            mDevice = device;
+            mPasskey = passkey;
+            mPin = pin;
+        }
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            synchronized (this) {
+                if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(intent.getAction())
+                        && mDevice.equals(intent.getParcelableExtra(
+                                BluetoothDevice.EXTRA_DEVICE))) {
+                    int type = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
+                            BluetoothDevice.ERROR);
+                    assertNotSame(type, BluetoothDevice.ERROR);
+                    switch (type) {
+                        case BluetoothDevice.PAIRING_VARIANT_PIN:
+                            mDevice.setPin(mPin);
+                            break;
+                        case BluetoothDevice.PAIRING_VARIANT_PASSKEY:
+                            mDevice.setPasskey(mPasskey);
+                            break;
+                        case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION:
+                        case BluetoothDevice.PAIRING_VARIANT_CONSENT:
+                            mDevice.setPairingConfirmation(true);
+                            break;
+                        case BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT:
+                            mDevice.setRemoteOutOfBandData();
+                            break;
+                    }
+                } else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(intent.getAction())
+                        && mDevice.equals(intent.getParcelableExtra(
+                                BluetoothDevice.EXTRA_DEVICE))) {
+                    mFiredFlags |= PAIR_FLAG;
+                    int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE,
+                            BluetoothDevice.ERROR);
+                    assertNotSame(state, BluetoothDevice.ERROR);
+                    switch (state) {
+                        case BluetoothDevice.BOND_BONDED:
+                            mPairFiredFlags |= PAIR_STATE_BONDED;
+                            break;
+                        case BluetoothDevice.BOND_BONDING:
+                            mPairFiredFlags |= PAIR_STATE_BONDING;
+                            break;
+                        case BluetoothDevice.BOND_NONE:
+                            mPairFiredFlags |= PAIR_STATE_NONE;
+                            break;
+                    }
+                }
+            }
+        }
+
+        public int getFiredFlags() {
+            synchronized (this) {
+                return mFiredFlags;
+            }
+        }
+
+        public int getPairFiredFlags() {
+            synchronized (this) {
+                return mPairFiredFlags;
+            }
+        }
+
+        public void resetFiredFlags() {
+            synchronized (this) {
+                mFiredFlags = 0;
+                mPairFiredFlags = 0;
+            }
+        }
+    }
+
+    private List<BroadcastReceiver> mReceivers = new ArrayList<BroadcastReceiver>();
 
     public BluetoothTestUtils(Context context, String tag) {
         this(context, tag, null);
@@ -313,19 +375,16 @@
             }
         }
 
-        IntentFilter filter = new IntentFilter();
-        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
-        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
-        filter.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
-        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
-        mContext.registerReceiver(mReceiver, filter);
-
         mA2dp = new BluetoothA2dp(mContext);
         mHeadset = new BluetoothHeadset(mContext, mHeadsetServiceListener);
+        mBluetoothReceiver = getBluetoothReceiver(mContext);
+        mReceivers.add(mBluetoothReceiver);
     }
 
     public void close() {
-        mContext.unregisterReceiver(mReceiver);
+        while (!mReceivers.isEmpty()) {
+            mContext.unregisterReceiver(mReceivers.remove(0));
+        }
 
         if (mOutputWriter != null) {
             try {
@@ -337,8 +396,9 @@
     }
 
     public void enable(BluetoothAdapter adapter) {
-        int mask = STATE_TURNING_ON_FLAG | STATE_ON_FLAG | SCAN_MODE_CONNECTABLE_FLAG;
-        mReceiver.resetFiredFlags();
+        int mask = (BluetoothReceiver.STATE_TURNING_ON_FLAG | BluetoothReceiver.STATE_ON_FLAG
+                | BluetoothReceiver.SCAN_MODE_CONNECTABLE_FLAG);
+        mBluetoothReceiver.resetFiredFlags();
 
         int state = adapter.getState();
         switch (state) {
@@ -363,8 +423,8 @@
             state = adapter.getState();
             if (state == BluetoothAdapter.STATE_ON) {
                 assertTrue(adapter.isEnabled());
-                if ((mReceiver.getFiredFlags() & mask) == mask) {
-                    mReceiver.resetFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask) {
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("enable() completed in %d ms",
                             (System.currentTimeMillis() - s)));
                     return;
@@ -376,15 +436,16 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("enable() timeout: state=%d (expected %d), flags=0x%x (expected 0x%x)",
                 state, BluetoothAdapter.STATE_ON, firedFlags, mask));
     }
 
     public void disable(BluetoothAdapter adapter) {
-        int mask = STATE_TURNING_OFF_FLAG | STATE_OFF_FLAG | SCAN_MODE_NONE_FLAG;
-        mReceiver.resetFiredFlags();
+        int mask = (BluetoothReceiver.STATE_TURNING_OFF_FLAG | BluetoothReceiver.STATE_OFF_FLAG
+                | BluetoothReceiver.SCAN_MODE_NONE_FLAG);
+        mBluetoothReceiver.resetFiredFlags();
 
         int state = adapter.getState();
         switch (state) {
@@ -412,8 +473,8 @@
             state = adapter.getState();
             if (state == BluetoothAdapter.STATE_OFF) {
                 assertFalse(adapter.isEnabled());
-                if ((mReceiver.getFiredFlags() & mask) == mask) {
-                    mReceiver.resetFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask) {
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("disable() completed in %d ms",
                             (System.currentTimeMillis() - s)));
                     return;
@@ -425,15 +486,15 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("disable() timeout: state=%d (expected %d), flags=0x%x (expected 0x%x)",
                 state, BluetoothAdapter.STATE_OFF, firedFlags, mask));
     }
 
     public void discoverable(BluetoothAdapter adapter) {
-        int mask = SCAN_MODE_CONNECTABLE_DISCOVERABLE_FLAG;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.SCAN_MODE_CONNECTABLE_DISCOVERABLE_FLAG;
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("discoverable() bluetooth not enabled");
@@ -451,8 +512,8 @@
         while (System.currentTimeMillis() - s < SET_SCAN_MODE_TIMEOUT) {
             scanMode = adapter.getScanMode();
             if (scanMode == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
-                if ((mReceiver.getFiredFlags() & mask) == mask) {
-                    mReceiver.resetFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask) {
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("discoverable() completed in %d ms",
                             (System.currentTimeMillis() - s)));
                     return;
@@ -463,16 +524,16 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("discoverable() timeout: scanMode=%d (expected %d), flags=0x%x "
                 + "(expected 0x%x)", scanMode, BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE,
                 firedFlags, mask));
     }
 
     public void undiscoverable(BluetoothAdapter adapter) {
-        int mask = SCAN_MODE_CONNECTABLE_FLAG;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.SCAN_MODE_CONNECTABLE_FLAG;
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("undiscoverable() bluetooth not enabled");
@@ -490,8 +551,8 @@
         while (System.currentTimeMillis() - s < SET_SCAN_MODE_TIMEOUT) {
             scanMode = adapter.getScanMode();
             if (scanMode == BluetoothAdapter.SCAN_MODE_CONNECTABLE) {
-                if ((mReceiver.getFiredFlags() & mask) == mask) {
-                    mReceiver.resetFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask) {
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("undiscoverable() completed in %d ms",
                             (System.currentTimeMillis() - s)));
                     return;
@@ -502,16 +563,16 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("undiscoverable() timeout: scanMode=%d (expected %d), flags=0x%x "
                 + "(expected 0x%x)", scanMode, BluetoothAdapter.SCAN_MODE_CONNECTABLE, firedFlags,
                 mask));
     }
 
     public void startScan(BluetoothAdapter adapter) {
-        int mask = DISCOVERY_STARTED_FLAG;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.DISCOVERY_STARTED_FLAG;
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("startScan() bluetooth not enabled");
@@ -525,8 +586,8 @@
 
         long s = System.currentTimeMillis();
         while (System.currentTimeMillis() - s < START_DISCOVERY_TIMEOUT) {
-            if (adapter.isDiscovering() && ((mReceiver.getFiredFlags() & mask) == mask)) {
-                mReceiver.resetFiredFlags();
+            if (adapter.isDiscovering() && ((mBluetoothReceiver.getFiredFlags() & mask) == mask)) {
+                mBluetoothReceiver.resetFiredFlags();
                 writeOutput(String.format("startScan() completed in %d ms",
                         (System.currentTimeMillis() - s)));
                 return;
@@ -534,15 +595,15 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("startScan() timeout: isDiscovering=%b, flags=0x%x (expected 0x%x)",
                 adapter.isDiscovering(), firedFlags, mask));
     }
 
     public void stopScan(BluetoothAdapter adapter) {
-        int mask = DISCOVERY_FINISHED_FLAG;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.DISCOVERY_FINISHED_FLAG;
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("stopScan() bluetooth not enabled");
@@ -557,8 +618,8 @@
 
         long s = System.currentTimeMillis();
         while (System.currentTimeMillis() - s < CANCEL_DISCOVERY_TIMEOUT) {
-            if (!adapter.isDiscovering() && ((mReceiver.getFiredFlags() & mask) == mask)) {
-                mReceiver.resetFiredFlags();
+            if (!adapter.isDiscovering() && ((mBluetoothReceiver.getFiredFlags() & mask) == mask)) {
+                mBluetoothReceiver.resetFiredFlags();
                 writeOutput(String.format("stopScan() completed in %d ms",
                         (System.currentTimeMillis() - s)));
                 return;
@@ -566,17 +627,19 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("stopScan() timeout: isDiscovering=%b, flags=0x%x (expected 0x%x)",
                 adapter.isDiscovering(), firedFlags, mask));
 
     }
 
-    public void pair(BluetoothAdapter adapter, BluetoothDevice device) {
-        int mask = PAIR_STATE_FLAG;
-        int pairMask = PAIR_STATE_BONDING | PAIR_STATE_BONDED;
-        mReceiver.resetFiredFlags();
+    public void pair(BluetoothAdapter adapter, BluetoothDevice device, int passkey, byte[] pin) {
+        int mask = PairReceiver.PAIR_FLAG;
+        int pairMask = PairReceiver.PAIR_STATE_BONDING | PairReceiver.PAIR_STATE_BONDED;
+
+        PairReceiver pairReceiver = getPairReceiver(mContext, device, passkey, pin);
+        mReceivers.add(pairReceiver);
 
         if (!adapter.isEnabled()) {
             fail("pair() bluetooth not enabled");
@@ -604,28 +667,32 @@
             state = device.getBondState();
             if (state == BluetoothDevice.BOND_BONDED) {
                 assertTrue(adapter.getBondedDevices().contains(device));
-                if ((mReceiver.getFiredFlags() & mask) == mask
-                        && (mReceiver.getPairFiredFlags() & pairMask) == pairMask) {
+                if ((pairReceiver.getFiredFlags() & mask) == mask
+                        && (pairReceiver.getPairFiredFlags() & pairMask) == pairMask) {
                     writeOutput(String.format("pair() completed in %d ms: device=%s",
                             (System.currentTimeMillis() - s), device));
+                    mReceivers.remove(pairReceiver);
+                    mContext.unregisterReceiver(pairReceiver);
                     return;
                 }
             }
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        int pairFiredFlags = mReceiver.getPairFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = pairReceiver.getFiredFlags();
+        int pairFiredFlags = pairReceiver.getPairFiredFlags();
+        pairReceiver.resetFiredFlags();
         fail(String.format("pair() timeout: state=%d (expected %d), flags=0x%x (expected 0x%x), "
                 + "pairFlags=0x%x (expected 0x%x)", state, BluetoothDevice.BOND_BONDED, firedFlags,
                 mask, pairFiredFlags, pairMask));
     }
 
     public void unpair(BluetoothAdapter adapter, BluetoothDevice device) {
-        int mask = PAIR_STATE_FLAG;
-        int pairMask = PAIR_STATE_NONE;
-        mReceiver.resetFiredFlags();
+        int mask = PairReceiver.PAIR_FLAG;
+        int pairMask = PairReceiver.PAIR_STATE_NONE;
+
+        PairReceiver pairReceiver = getPairReceiver(mContext, device, 0, null);
+        mReceivers.add(pairReceiver);
 
         if (!adapter.isEnabled()) {
             fail("unpair() bluetooth not enabled");
@@ -653,29 +720,32 @@
         while (System.currentTimeMillis() - s < UNPAIR_TIMEOUT) {
             if (device.getBondState() == BluetoothDevice.BOND_NONE) {
                 assertFalse(adapter.getBondedDevices().contains(device));
-                if ((mReceiver.getFiredFlags() & mask) == mask
-                        && (mReceiver.getPairFiredFlags() & pairMask) == pairMask) {
+                if ((pairReceiver.getFiredFlags() & mask) == mask
+                       && (pairReceiver.getPairFiredFlags() & pairMask) == pairMask) {
                     writeOutput(String.format("unpair() completed in %d ms: device=%s",
                             (System.currentTimeMillis() - s), device));
+                    mReceivers.remove(pairReceiver);
+                    mContext.unregisterReceiver(pairReceiver);
                     return;
                 }
             }
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        int pairFiredFlags = mReceiver.getPairFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = pairReceiver.getFiredFlags();
+        int pairFiredFlags = pairReceiver.getPairFiredFlags();
+        pairReceiver.resetFiredFlags();
         fail(String.format("unpair() timeout: state=%d (expected %d), flags=0x%x (expected 0x%x), "
                 + "pairFlags=0x%x (expected 0x%x)", state, BluetoothDevice.BOND_BONDED, firedFlags,
                 mask, pairFiredFlags, pairMask));
     }
 
     public void connectA2dp(BluetoothAdapter adapter, BluetoothDevice device) {
-        int mask = PROFILE_A2DP_FLAG;
-        int a2dpMask1 = A2DP_STATE_CONNECTING | A2DP_STATE_CONNECTED | A2DP_STATE_PLAYING;
-        int a2dpMask2 = a2dpMask1 ^ A2DP_STATE_CONNECTED;
-        int a2dpMask3 = a2dpMask1 ^ A2DP_STATE_PLAYING;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.PROFILE_A2DP_FLAG;
+        int a2dpMask1 = (BluetoothReceiver.A2DP_STATE_CONNECTING
+                | BluetoothReceiver.A2DP_STATE_CONNECTED | BluetoothReceiver.A2DP_STATE_PLAYING);
+        int a2dpMask2 = a2dpMask1 ^ BluetoothReceiver.A2DP_STATE_CONNECTED;
+        int a2dpMask3 = a2dpMask1 ^ BluetoothReceiver.A2DP_STATE_PLAYING;
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("connectA2dp() bluetooth not enabled");
@@ -712,13 +782,13 @@
                 assertTrue(mA2dp.isSinkConnected(device));
                 // Check whether STATE_CONNECTING and (STATE_CONNECTED or STATE_PLAYING) intents
                 // have fired if we are checking if intents should be fired.
-                int firedFlags = mReceiver.getFiredFlags();
-                int a2dpFiredFlags = mReceiver.getA2dpFiredFlags();
-                if ((mReceiver.getFiredFlags() & mask) == mask
+                int firedFlags = mBluetoothReceiver.getFiredFlags();
+                int a2dpFiredFlags = mBluetoothReceiver.getA2dpFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask
                         && ((a2dpFiredFlags & a2dpMask1) == a2dpMask1
                                 || (a2dpFiredFlags & a2dpMask2) == a2dpMask2
                                 || (a2dpFiredFlags & a2dpMask3) == a2dpMask3)) {
-                    mReceiver.resetFiredFlags();
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("connectA2dp() completed in %d ms: device=%s",
                             (System.currentTimeMillis() - s), device));
                     return;
@@ -727,9 +797,9 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        int a2dpFiredFlags = mReceiver.getA2dpFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        int a2dpFiredFlags = mBluetoothReceiver.getA2dpFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("connectA2dp() timeout: state=%d (expected %d or %d), "
                 + "flags=0x%x (expected 0x%x), a2dpFlags=0x%x (expected 0x%x or 0x%x or 0x%x)",
                 state, BluetoothHeadset.STATE_CONNECTED, BluetoothA2dp.STATE_PLAYING, firedFlags,
@@ -737,9 +807,10 @@
     }
 
     public void disconnectA2dp(BluetoothAdapter adapter, BluetoothDevice device) {
-        int mask = PROFILE_A2DP_FLAG;
-        int a2dpMask = A2DP_STATE_DISCONNECTING | A2DP_STATE_DISCONNECTED;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.PROFILE_A2DP_FLAG;
+        int a2dpMask = (BluetoothReceiver.A2DP_STATE_DISCONNECTING
+                | BluetoothReceiver.A2DP_STATE_DISCONNECTED);
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("disconnectA2dp() bluetooth not enabled");
@@ -777,9 +848,9 @@
             state = mA2dp.getSinkState(device);
             if (state == BluetoothA2dp.STATE_DISCONNECTED) {
                 assertFalse(mA2dp.isSinkConnected(device));
-                if ((mReceiver.getFiredFlags() & mask) == mask
-                        && (mReceiver.getA2dpFiredFlags() & a2dpMask) == a2dpMask) {
-                    mReceiver.resetFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask
+                        && (mBluetoothReceiver.getA2dpFiredFlags() & a2dpMask) == a2dpMask) {
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("disconnectA2dp() completed in %d ms: device=%s",
                             (System.currentTimeMillis() - s), device));
                     return;
@@ -788,18 +859,19 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        int a2dpFiredFlags = mReceiver.getA2dpFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        int a2dpFiredFlags = mBluetoothReceiver.getA2dpFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("disconnectA2dp() timeout: state=%d (expected %d), "
                 + "flags=0x%x (expected 0x%x), a2dpFlags=0x%x (expected 0x%x)", state,
                 BluetoothA2dp.STATE_DISCONNECTED, firedFlags, mask, a2dpFiredFlags, a2dpMask));
     }
 
     public void connectHeadset(BluetoothAdapter adapter, BluetoothDevice device) {
-        int mask = PROFILE_HEADSET_FLAG;
-        int headsetMask = HEADSET_STATE_CONNECTING | HEADSET_STATE_CONNECTED;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.PROFILE_HEADSET_FLAG;
+        int headsetMask = (BluetoothReceiver.HEADSET_STATE_CONNECTING
+                | BluetoothReceiver.HEADSET_STATE_CONNECTED);
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("connectHeadset() bluetooth not enabled");
@@ -839,9 +911,9 @@
             state = mHeadset.getState(device);
             if (state == BluetoothHeadset.STATE_CONNECTED) {
                 assertTrue(mHeadset.isConnected(device));
-                if ((mReceiver.getFiredFlags() & mask) == mask
-                        && (mReceiver.getHeadsetFiredFlags() & headsetMask) == headsetMask) {
-                    mReceiver.resetFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask
+                        && (mBluetoothReceiver.getHeadsetFiredFlags() & headsetMask) == headsetMask) {
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("connectHeadset() completed in %d ms: device=%s",
                             (System.currentTimeMillis() - s), device));
                     return;
@@ -850,9 +922,9 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        int headsetFiredFlags = mReceiver.getHeadsetFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        int headsetFiredFlags = mBluetoothReceiver.getHeadsetFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("connectHeadset() timeout: state=%d (expected %d), "
                 + "flags=0x%x (expected 0x%x), headsetFlags=0x%s (expected 0x%x)", state,
                 BluetoothHeadset.STATE_CONNECTED, firedFlags, mask, headsetFiredFlags,
@@ -860,9 +932,9 @@
     }
 
     public void disconnectHeadset(BluetoothAdapter adapter, BluetoothDevice device) {
-        int mask = PROFILE_HEADSET_FLAG;
-        int headsetMask = HEADSET_STATE_DISCONNECTED;
-        mReceiver.resetFiredFlags();
+        int mask = BluetoothReceiver.PROFILE_HEADSET_FLAG;
+        int headsetMask = BluetoothReceiver.HEADSET_STATE_DISCONNECTED;
+        mBluetoothReceiver.resetFiredFlags();
 
         if (!adapter.isEnabled()) {
             fail("disconnectHeadset() bluetooth not enabled");
@@ -898,9 +970,9 @@
             state = mHeadset.getState(device);
             if (state == BluetoothHeadset.STATE_DISCONNECTED) {
                 assertFalse(mHeadset.isConnected(device));
-                if ((mReceiver.getFiredFlags() & mask) == mask
-                        && (mReceiver.getHeadsetFiredFlags() & headsetMask) == headsetMask) {
-                    mReceiver.resetFiredFlags();
+                if ((mBluetoothReceiver.getFiredFlags() & mask) == mask
+                        && (mBluetoothReceiver.getHeadsetFiredFlags() & headsetMask) == headsetMask) {
+                    mBluetoothReceiver.resetFiredFlags();
                     writeOutput(String.format("disconnectHeadset() completed in %d ms: device=%s",
                             (System.currentTimeMillis() - s), device));
                     return;
@@ -909,9 +981,9 @@
             sleep(POLL_TIME);
         }
 
-        int firedFlags = mReceiver.getFiredFlags();
-        int headsetFiredFlags = mReceiver.getHeadsetFiredFlags();
-        mReceiver.resetFiredFlags();
+        int firedFlags = mBluetoothReceiver.getFiredFlags();
+        int headsetFiredFlags = mBluetoothReceiver.getHeadsetFiredFlags();
+        mBluetoothReceiver.resetFiredFlags();
         fail(String.format("disconnectHeadset() timeout: state=%d (expected %d), "
                 + "flags=0x%x (expected 0x%x), headsetFlags=0x%s (expected 0x%x)", state,
                 BluetoothHeadset.STATE_DISCONNECTED, firedFlags, mask, headsetFiredFlags,
@@ -931,6 +1003,29 @@
         }
     }
 
+    private BluetoothReceiver getBluetoothReceiver(Context context) {
+        BluetoothReceiver receiver = new BluetoothReceiver();
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
+        filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
+        filter.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
+        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
+        filter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
+        filter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
+        context.registerReceiver(receiver, filter);
+        return receiver;
+    }
+
+    private PairReceiver getPairReceiver(Context context, BluetoothDevice device, int passkey,
+            byte[] pin) {
+        PairReceiver receiver = new PairReceiver(device, passkey, pin);
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(BluetoothDevice.ACTION_PAIRING_REQUEST);
+        filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
+        context.registerReceiver(receiver, filter);
+        return receiver;
+    }
+
     private void sleep(long time) {
         try {
             Thread.sleep(time);
diff --git a/docs/html/sdk/android-2.2.jd b/docs/html/sdk/android-2.2.jd
index 495fd80..063a10f 100644
--- a/docs/html/sdk/android-2.2.jd
+++ b/docs/html/sdk/android-2.2.jd
@@ -42,7 +42,7 @@
 
 <p>Android {@sdkPlatformVersion} is a {@sdkPlatformMajorMinor} platform release including user
 features, developer features, API changes, and bug
-fixes. For  information on developer features and API changes, see the 
+fixes. For  information on developer features and API changes, see the
 <a href="#api">Framework API</a> section.</p>
 
 <p>For developers, the Android {@sdkPlatformVersion} platform is available as a
@@ -62,7 +62,7 @@
 
 <h2 id="features">Platform Highlights</h2>
 
-<p>For a list of new user features and platform highlights, see the <a 
+<p>For a list of new user features and platform highlights, see the <a
 href="http://developer.android.com/sdk/android-2.2-highlights.html">Android
 2.2 Platform Highlights</a> document.</p>
 
@@ -316,8 +316,8 @@
 
 <ul>
   <li> New <code>android:backupAgent</code> attribute of the
-<code>&lt;application&gt;</code> element. Specifies the component name of the 
-BackupAgent subclass provided by the application to handle backup/restore 
+<code>&lt;application&gt;</code> element. Specifies the component name of the
+BackupAgent subclass provided by the application to handle backup/restore
 operations, if any.</li>
   <li> New <code>android:restoreAnyVersion</code> attribute of the
 <code>&lt;application&gt;</code> element. Boolean value that indicates whether
@@ -436,6 +436,11 @@
 <p>Localized UI strings match the locales that are accessible
 through Settings.</p>
 
+<p class="note"><strong>Note:</strong> Android supports more locales than are listed above. However,
+the entire collection of locale strings cannot fit on a single system image, so the above list is
+only what's included in the system image for the SDK. All of Android's supported locales are
+available in the <a href="http://source.android.com/">Android Open Source Project</a>.</p>
+
 <h2 id="skins">Emulator Skins</h2>
 
 <p>The downloadable platform includes a set of emulator skins that you can use
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 2bb7783..1d94160 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -33,7 +33,11 @@
                   public MediaBufferObserver {
     enum CreationFlags {
         kPreferSoftwareCodecs    = 1,
-        kIgnoreCodecSpecificData = 2
+        kIgnoreCodecSpecificData = 2,
+
+        // The client wants to access the output buffer's video
+        // data for example for thumbnail extraction.
+        kClientNeedsFramebuffer  = 4,
     };
     static sp<MediaSource> Create(
             const sp<IOMX> &omx,
diff --git a/include/ui/InputDispatcher.h b/include/ui/InputDispatcher.h
index 4955d47..b0b855e 100644
--- a/include/ui/InputDispatcher.h
+++ b/include/ui/InputDispatcher.h
@@ -109,9 +109,6 @@
     // (ignored for KeyEvents)
     float xOffset, yOffset;
 
-    // The window type of the input target.
-    int32_t windowType;
-
     // The subset of pointer ids to include in motion events dispatched to this input target
     // if FLAG_SPLIT is set.
     BitSet32 pointerIds;
@@ -1004,8 +1001,7 @@
     void addWindowTargetLocked(const InputWindow* window, int32_t targetFlags,
             BitSet32 pointerIds);
     void addMonitoringTargetsLocked();
-    bool shouldPokeUserActivityForCurrentInputTargetsLocked();
-    void pokeUserActivityLocked(nsecs_t eventTime, int32_t eventType);
+    void pokeUserActivityLocked(const EventEntry* eventEntry);
     bool checkInjectionPermission(const InputWindow* window, const InjectionState* injectionState);
     bool isWindowObscuredAtPointLocked(const InputWindow* window, int32_t x, int32_t y) const;
     bool isWindowFinishedWithPreviousInputLocked(const InputWindow* window);
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index 92daee1..303075f 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -340,6 +340,11 @@
             mInboundQueue.dequeue(entry);
             mPendingEvent = entry;
         }
+
+        // Poke user activity for this event.
+        if (mPendingEvent->policyFlags & POLICY_FLAG_PASS_TO_USER) {
+            pokeUserActivityLocked(mPendingEvent);
+        }
     }
 
     // Now we have an event to dispatch.
@@ -686,11 +691,6 @@
 
     // Dispatch the key.
     dispatchEventToCurrentInputTargetsLocked(currentTime, entry, false);
-
-    // Poke user activity.
-    if (shouldPokeUserActivityForCurrentInputTargetsLocked()) {
-        pokeUserActivityLocked(entry->eventTime, POWER_MANAGER_BUTTON_EVENT);
-    }
     return true;
 }
 
@@ -753,31 +753,6 @@
 
     // Dispatch the motion.
     dispatchEventToCurrentInputTargetsLocked(currentTime, entry, false);
-
-    // Poke user activity.
-    if (shouldPokeUserActivityForCurrentInputTargetsLocked()) {
-        int32_t eventType;
-        if (isPointerEvent) {
-            switch (entry->action) {
-            case AMOTION_EVENT_ACTION_DOWN:
-                eventType = POWER_MANAGER_TOUCH_EVENT;
-                break;
-            case AMOTION_EVENT_ACTION_UP:
-                eventType = POWER_MANAGER_TOUCH_UP_EVENT;
-                break;
-            default:
-                if (entry->eventTime - entry->downTime >= EVENT_IGNORE_DURATION) {
-                    eventType = POWER_MANAGER_TOUCH_EVENT;
-                } else {
-                    eventType = POWER_MANAGER_LONG_TOUCH_EVENT;
-                }
-                break;
-            }
-        } else {
-            eventType = POWER_MANAGER_BUTTON_EVENT;
-        }
-        pokeUserActivityLocked(entry->eventTime, eventType);
-    }
     return true;
 }
 
@@ -829,6 +804,8 @@
 
     assert(eventEntry->dispatchInProgress); // should already have been set to true
 
+    pokeUserActivityLocked(eventEntry);
+
     for (size_t i = 0; i < mCurrentInputTargets.size(); i++) {
         const InputTarget& inputTarget = mCurrentInputTargets.itemAt(i);
 
@@ -1338,7 +1315,6 @@
     target.flags = targetFlags;
     target.xOffset = - window->frameLeft;
     target.yOffset = - window->frameTop;
-    target.windowType = window->layoutParamsType;
     target.pointerIds = pointerIds;
 }
 
@@ -1351,7 +1327,6 @@
         target.flags = 0;
         target.xOffset = 0;
         target.yOffset = 0;
-        target.windowType = -1;
     }
 }
 
@@ -1418,19 +1393,32 @@
     }
 }
 
-bool InputDispatcher::shouldPokeUserActivityForCurrentInputTargetsLocked() {
-    for (size_t i = 0; i < mCurrentInputTargets.size(); i++) {
-        if (mCurrentInputTargets[i].windowType == InputWindow::TYPE_KEYGUARD) {
-            return false;
+void InputDispatcher::pokeUserActivityLocked(const EventEntry* eventEntry) {
+    int32_t eventType = POWER_MANAGER_BUTTON_EVENT;
+    if (eventEntry->type == EventEntry::TYPE_MOTION) {
+        const MotionEntry* motionEntry = static_cast<const MotionEntry*>(eventEntry);
+        if (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER) {
+            switch (motionEntry->action) {
+            case AMOTION_EVENT_ACTION_DOWN:
+                eventType = POWER_MANAGER_TOUCH_EVENT;
+                break;
+            case AMOTION_EVENT_ACTION_UP:
+                eventType = POWER_MANAGER_TOUCH_UP_EVENT;
+                break;
+            default:
+                if (motionEntry->eventTime - motionEntry->downTime >= EVENT_IGNORE_DURATION) {
+                    eventType = POWER_MANAGER_TOUCH_EVENT;
+                } else {
+                    eventType = POWER_MANAGER_LONG_TOUCH_EVENT;
+                }
+                break;
+            }
         }
     }
-    return true;
-}
 
-void InputDispatcher::pokeUserActivityLocked(nsecs_t eventTime, int32_t eventType) {
     CommandEntry* commandEntry = postCommandLocked(
             & InputDispatcher::doPokeUserActivityLockedInterruptible);
-    commandEntry->eventTime = eventTime;
+    commandEntry->eventTime = eventEntry->eventTime;
     commandEntry->userActivityEventType = eventType;
 }
 
diff --git a/libs/utils/StreamingZipInflater.cpp b/libs/utils/StreamingZipInflater.cpp
index 7ebde78..1f62ac5 100644
--- a/libs/utils/StreamingZipInflater.cpp
+++ b/libs/utils/StreamingZipInflater.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#define LOG_NDEBUG 1
 #define LOG_TAG "szipinf"
 #include <utils/Log.h>
 
@@ -157,7 +158,7 @@
             */
             int result = Z_OK;
             if (mStreamNeedsInit) {
-                LOGI("Initializing zlib to inflate");
+                LOGD("Initializing zlib to inflate");
                 result = inflateInit2(&mInflateState, -MAX_WBITS);
                 mStreamNeedsInit = false;
             }
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 57bea8c..064a00c 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -1059,6 +1059,32 @@
     return mVideoSource != NULL ? OK : UNKNOWN_ERROR;
 }
 
+void AwesomePlayer::finishSeekIfNecessary(int64_t videoTimeUs) {
+    if (!mSeeking) {
+        return;
+    }
+
+    if (mAudioPlayer != NULL) {
+        LOGV("seeking audio to %lld us (%.2f secs).", timeUs, timeUs / 1E6);
+
+        // If we don't have a video time, seek audio to the originally
+        // requested seek time instead.
+
+        mAudioPlayer->seekTo(videoTimeUs < 0 ? mSeekTimeUs : videoTimeUs);
+        mAudioPlayer->resume();
+        mWatchForAudioSeekComplete = true;
+        mWatchForAudioEOS = true;
+    } else if (!mSeekNotificationSent) {
+        // If we're playing video only, report seek complete now,
+        // otherwise audio player will notify us later.
+        notifyListener_l(MEDIA_SEEK_COMPLETE);
+    }
+
+    mFlags |= FIRST_FRAME;
+    mSeeking = false;
+    mSeekNotificationSent = false;
+}
+
 void AwesomePlayer::onVideoEvent() {
     Mutex::Autolock autoLock(mLock);
     if (!mVideoEventPending) {
@@ -1120,6 +1146,14 @@
                     continue;
                 }
 
+                // So video playback is complete, but we may still have
+                // a seek request pending that needs to be applied
+                // to the audio track.
+                if (mSeeking) {
+                    LOGV("video stream ended while seeking!");
+                }
+                finishSeekIfNecessary(-1);
+
                 mFlags |= VIDEO_AT_EOS;
                 postStreamDoneEvent_l(err);
                 return;
@@ -1146,24 +1180,7 @@
         mVideoTimeUs = timeUs;
     }
 
-    if (mSeeking) {
-        if (mAudioPlayer != NULL) {
-            LOGV("seeking audio to %lld us (%.2f secs).", timeUs, timeUs / 1E6);
-
-            mAudioPlayer->seekTo(timeUs);
-            mAudioPlayer->resume();
-            mWatchForAudioSeekComplete = true;
-            mWatchForAudioEOS = true;
-        } else if (!mSeekNotificationSent) {
-            // If we're playing video only, report seek complete now,
-            // otherwise audio player will notify us later.
-            notifyListener_l(MEDIA_SEEK_COMPLETE);
-        }
-
-        mFlags |= FIRST_FRAME;
-        mSeeking = false;
-        mSeekNotificationSent = false;
-    }
+    finishSeekIfNecessary(timeUs);
 
     TimeSource *ts = (mFlags & AUDIO_AT_EOS) ? &mSystemTimeSource : mTimeSource;
 
diff --git a/media/libstagefright/MPEG2TSWriter.cpp b/media/libstagefright/MPEG2TSWriter.cpp
index b3daf67..81a2b0d 100644
--- a/media/libstagefright/MPEG2TSWriter.cpp
+++ b/media/libstagefright/MPEG2TSWriter.cpp
@@ -725,6 +725,14 @@
 
     size_t PES_packet_length = accessUnit->size() + 8;
 
+    if (PES_packet_length >= 65536) {
+        // This really should only happen for video.
+        CHECK_EQ(stream_id, 0xe0u);
+
+        // It's valid to set this to 0 for video according to the specs.
+        PES_packet_length = 0;
+    }
+
     uint8_t *ptr = buffer->data();
     *ptr++ = 0x47;
     *ptr++ = 0x40 | (PID >> 8);
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 4648ad3..9a49a9b 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -493,12 +493,29 @@
 
         LOGV("Attempting to allocate OMX node '%s'", componentName);
 
+        uint32_t quirks = getComponentQuirks(componentName, createEncoder);
+
+        if (!createEncoder
+                && (quirks & kOutputBuffersAreUnreadable)
+                && (flags & kClientNeedsFramebuffer)) {
+            if (strncmp(componentName, "OMX.SEC.", 8)) {
+                // For OMX.SEC.* decoders we can enable a special mode that
+                // gives the client access to the framebuffer contents.
+
+                LOGW("Component '%s' does not give the client access to "
+                     "the framebuffer contents. Skipping.",
+                     componentName);
+
+                continue;
+            }
+        }
+
         status_t err = omx->allocateNode(componentName, observer, &node);
         if (err == OK) {
             LOGV("Successfully allocated OMX node '%s'", componentName);
 
             sp<OMXCodec> codec = new OMXCodec(
-                    omx, node, getComponentQuirks(componentName, createEncoder),
+                    omx, node, quirks,
                     createEncoder, mime, componentName,
                     source);
 
@@ -681,6 +698,33 @@
 
     initOutputFormat(meta);
 
+    if ((flags & kClientNeedsFramebuffer)
+            && !strncmp(mComponentName, "OMX.SEC.", 8)) {
+        OMX_INDEXTYPE index;
+
+        status_t err =
+            mOMX->getExtensionIndex(
+                    mNode,
+                    "OMX.SEC.index.ThumbnailMode",
+                    &index);
+
+        if (err != OK) {
+            return err;
+        }
+
+        OMX_BOOL enable = OMX_TRUE;
+        err = mOMX->setConfig(mNode, index, &enable, sizeof(enable));
+
+        if (err != OK) {
+            CODEC_LOGE("setConfig('OMX.SEC.index.ThumbnailMode') "
+                       "returned error 0x%08x", err);
+
+            return err;
+        }
+
+        mQuirks &= ~kOutputBuffersAreUnreadable;
+    }
+
     return OK;
 }
 
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index af9c70c..a800a93 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -112,7 +112,7 @@
     sp<MediaSource> decoder =
         OMXCodec::Create(
                 client->interface(), source->getFormat(), false, source,
-                NULL, flags);
+                NULL, flags | OMXCodec::kClientNeedsFramebuffer);
 
     if (decoder.get() == NULL) {
         LOGV("unable to instantiate video decoder.");
diff --git a/media/libstagefright/foundation/ALooperRoster.cpp b/media/libstagefright/foundation/ALooperRoster.cpp
index 7683113..8aa1b15 100644
--- a/media/libstagefright/foundation/ALooperRoster.cpp
+++ b/media/libstagefright/foundation/ALooperRoster.cpp
@@ -54,7 +54,10 @@
     Mutex::Autolock autoLock(mLock);
 
     ssize_t index = mHandlers.indexOfKey(handlerID);
-    CHECK_GE(index, 0);
+
+    if (index < 0) {
+        return;
+    }
 
     const HandlerInfo &info = mHandlers.valueAt(index);
 
@@ -84,7 +87,8 @@
 
     if (looper == NULL) {
         LOGW("failed to post message. "
-             "Target handler still registered, but object gone.");
+             "Target handler %d still registered, but object gone.",
+             msg->target());
 
         mHandlers.removeItemsAt(index);
         return;
@@ -111,7 +115,8 @@
 
         if (handler == NULL) {
             LOGW("failed to deliver message. "
-                 "Target handler registered, but object gone.");
+                 "Target handler %d registered, but object gone.",
+                 msg->target());
 
             mHandlers.removeItemsAt(index);
             return;
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 46a0c65..3020a09 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -258,6 +258,8 @@
 
     bool getBitrate(int64_t *bitrate);
 
+    void finishSeekIfNecessary(int64_t videoTimeUs);
+
     AwesomePlayer(const AwesomePlayer &);
     AwesomePlayer &operator=(const AwesomePlayer &);
 };
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 163b2dbc..3fb322a 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -840,7 +840,7 @@
 #define VERSION_MAJOR 1
 #define VERSION_MINOR 2
 static char const * const gVendorString     = "Google Inc.";
-static char const * const gVersionString    = "1.2 Android Driver 1.1.0";
+static char const * const gVersionString    = "1.2 Android Driver 1.2.0";
 static char const * const gClientApiString  = "OpenGL ES";
 static char const * const gExtensionsString =
         "EGL_KHR_image_base "
diff --git a/opengl/libagl/state.cpp b/opengl/libagl/state.cpp
index a0f720a..8b4136a 100644
--- a/opengl/libagl/state.cpp
+++ b/opengl/libagl/state.cpp
@@ -33,7 +33,7 @@
 // ----------------------------------------------------------------------------
 
 static char const * const gVendorString     = "Android";
-static char const * const gRendererString   = "Android PixelFlinger 1.3";
+static char const * const gRendererString   = "Android PixelFlinger 1.4";
 static char const * const gVersionString    = "OpenGL ES-CM 1.0";
 static char const * const gExtensionsString =
     "GL_OES_byte_coordinates "              // OK
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
index 0309430..9ef6e6f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java
@@ -710,7 +710,6 @@
         NetworkInfo info = (NetworkInfo)(intent.getParcelableExtra(
                 ConnectivityManager.EXTRA_NETWORK_INFO));
         int connectionStatus = intent.getIntExtra(ConnectivityManager.EXTRA_INET_CONDITION, 0);
-        Slog.d(TAG, "got CONNECTIVITY_ACTION - info=" + info + ", status = " + connectionStatus);
 
         int inetCondition = (connectionStatus > INET_CONDITION_THRESHOLD ? 1 : 0);
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
index b1c6ad8..de30ccd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
@@ -392,8 +392,6 @@
     }
 
     public void updateNotification(IBinder key, StatusBarNotification notification) {
-        Slog.d(TAG, "updateNotification key=" + key + " notification=" + notification);
-
         NotificationData oldList;
         int oldIndex = mOngoing.findEntry(key);
         if (oldIndex >= 0) {
@@ -628,27 +626,27 @@
 
         if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
             if ((state & StatusBarManager.DISABLE_EXPAND) != 0) {
-                Slog.d(TAG, "DISABLE_EXPAND: yes");
+                if (SPEW) Slog.d(TAG, "DISABLE_EXPAND: yes");
                 animateCollapse();
             }
         }
         if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
             if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
-                Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes");
+                if (SPEW) Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes");
                 if (mTicking) {
                     mTicker.halt();
                 } else {
                     setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out);
                 }
             } else {
-                Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no");
+                if (SPEW) Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no");
                 if (!mExpandedVisible) {
                     setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in);
                 }
             }
         } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) {
             if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) {
-                Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes");
+                if (SPEW) Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes");
                 mTicker.halt();
             }
         }
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 88203c3..9d10ce5 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -93,8 +93,8 @@
  */
 public class KeyguardViewMediator implements KeyguardViewCallback,
         KeyguardUpdateMonitor.SimStateCallback {
-    private final static boolean DEBUG = false && Config.LOGD;
-    private final static boolean DBG_WAKE = DEBUG || true;
+    private final static boolean DEBUG = false;
+    private final static boolean DBG_WAKE = false;
 
     private final static String TAG = "KeyguardViewMediator";
 
@@ -605,7 +605,7 @@
      * @see #onWakeKeyWhenKeyguardShowingTq(int)
      */
     private void wakeWhenReadyLocked(int keyCode) {
-        if (DBG_WAKE) Log.d(TAG, "wakeWhenReadyLocked(" + keyCode + ")");
+        if (true || DBG_WAKE) Log.d(TAG, "wakeWhenReadyLocked(" + keyCode + ")");
 
         /**
          * acquire the handoff lock that will keep the cpu running.  this will
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 50b3abe..a7e02a5 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -84,7 +84,7 @@
 
 class BackupManagerService extends IBackupManager.Stub {
     private static final String TAG = "BackupManagerService";
-    private static final boolean DEBUG = true;
+    private static final boolean DEBUG = false;
 
     // How often we perform a backup pass.  Privileged external callers can
     // trigger an immediate pass.
@@ -664,11 +664,11 @@
                 // backup.
                 RandomAccessFile in = null;
                 try {
-                    Slog.i(TAG, "Found stale backup journal, scheduling:");
+                    Slog.i(TAG, "Found stale backup journal, scheduling");
                     in = new RandomAccessFile(f, "r");
                     while (true) {
                         String packageName = in.readUTF();
-                        Slog.i(TAG, "    + " + packageName);
+                        Slog.i(TAG, "  " + packageName);
                         dataChangedImpl(packageName);
                     }
                 } catch (EOFException e) {
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 84024b8..fe1b231 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -89,7 +89,7 @@
  */
 public class LocationManagerService extends ILocationManager.Stub implements Runnable {
     private static final String TAG = "LocationManagerService";
-    private static final boolean LOCAL_LOGV = false;
+    private static final boolean LOCAL_LOGV = true;
 
     // The last time a location was written, by provider name.
     private HashMap<String,Long> mLastWriteTime = new HashMap<String,Long>();
@@ -224,15 +224,18 @@
 
         @Override
         public String toString() {
+            String result;
             if (mListener != null) {
-                return "Receiver{"
+                result = "Receiver{"
                         + Integer.toHexString(System.identityHashCode(this))
                         + " Listener " + mKey + "}";
             } else {
-                return "Receiver{"
+                result = "Receiver{"
                         + Integer.toHexString(System.identityHashCode(this))
                         + " Intent " + mKey + "}";
             }
+            result += "mUpdateRecords: " + mUpdateRecords;
+            return result;
         }
 
         public boolean isListener() {
@@ -1004,7 +1007,7 @@
         public String toString() {
             return "UpdateRecord{"
                     + Integer.toHexString(System.identityHashCode(this))
-                    + " " + mProvider + " " + mReceiver + "}";
+                    + " mProvider: " + mProvider + " mUid: " + mUid + "}";
         }
         
         void dump(PrintWriter pw, String prefix) {
@@ -1119,9 +1122,6 @@
 
     private void requestLocationUpdatesLocked(String provider, long minTime, float minDistance,
             boolean singleShot, Receiver receiver) {
-        if (LOCAL_LOGV) {
-            Slog.v(TAG, "_requestLocationUpdates: listener = " + receiver);
-        }
 
         LocationProviderInterface p = mProvidersByName.get(provider);
         if (p == null) {
@@ -1159,6 +1159,9 @@
                 // Notify the listener that updates are currently disabled
                 receiver.callProviderEnabledLocked(provider, false);
             }
+            if (LOCAL_LOGV) {
+                Slog.v(TAG, "_requestLocationUpdates: provider = " + provider + " listener = " + receiver);
+            }
         } finally {
             Binder.restoreCallingIdentity(identity);
         }
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 0a5b72b..e8c1613 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -684,9 +684,6 @@
     public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,
             String tag, int id, Notification notification, int[] idOut)
     {
-        Slog.d(TAG, "enqueueNotificationWithTag: calling uid=" + callingUid 
-                + ", pid=" + callingPid);
-        
         checkIncomingCall(pkg);
 
         // Limit the number of notifications that any given package except the android
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index cc7a027..d324c2b 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -2500,7 +2500,9 @@
             return;
         }
 
-        Log.d(TAG, "Scanning app dir " + dir);
+        if (false) {
+            Log.d(TAG, "Scanning app dir " + dir);
+        }
 
         int i;
         for (i=0; i<files.length; i++) {
@@ -2866,10 +2868,8 @@
                 TAG, "Scanning package " + pkg.packageName);
         if (mPackages.containsKey(pkg.packageName)
                 || mSharedLibraries.containsKey(pkg.packageName)) {
-            Slog.w(TAG, "*************************************************");
             Slog.w(TAG, "Application package " + pkg.packageName
                     + " already installed.  Skipping duplicate.");
-            Slog.w(TAG, "*************************************************");
             mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE;
             return null;
         }
@@ -3286,7 +3286,9 @@
              *        only for non-system apps and system app upgrades.
              */
             if (pkg.applicationInfo.nativeLibraryDir != null) {
-                final File sharedLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
+                final File nativeLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir);
+                final String dataPathString = dataPath.getPath();
+
                 if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) {
                     /*
                      * Upgrading from a previous version of the OS sometimes
@@ -3295,15 +3297,24 @@
                      * Recent changes in the JNI library search path
                      * necessitates we remove those to match previous behavior.
                      */
-                    if (NativeLibraryHelper.removeNativeBinariesFromDirLI(sharedLibraryDir)) {
+                    if (NativeLibraryHelper.removeNativeBinariesFromDirLI(nativeLibraryDir)) {
                         Log.i(TAG, "removed obsolete native libraries for system package " + path);
                     }
-                } else if (!isExternal(pkg)) {
-                    Log.i(TAG, path + " changed; unpacking");
-                    mInstaller.unlinkNativeLibraryDirectory(dataPath.getPath());
-                    NativeLibraryHelper.copyNativeBinariesLI(scanFile, sharedLibraryDir);
+                } else if (nativeLibraryDir.getParent().equals(dataPathString)) {
+                    /*
+                     * If this is an internal application or our
+                     * nativeLibraryPath points to our data directory, unpack
+                     * the libraries. The native library path pointing to the
+                     * data directory for an application in an ASEC container
+                     * can happen for older apps that existed before an OTA to
+                     * Gingerbread.
+                     */
+                    Slog.i(TAG, "Unpacking native libraries for " + path);
+                    mInstaller.unlinkNativeLibraryDirectory(dataPathString);
+                    NativeLibraryHelper.copyNativeBinariesLI(scanFile, nativeLibraryDir);
                 } else {
-                    mInstaller.linkNativeLibraryDirectory(dataPath.getPath(),
+                    Slog.i(TAG, "Linking native library dir for " + path);
+                    mInstaller.linkNativeLibraryDirectory(dataPathString,
                             pkg.applicationInfo.nativeLibraryDir);
                 }
             }
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index b90b4bf..638bd45 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1971,8 +1971,8 @@
                     / stepsToTarget;
             if (mSpew) {
                 String noticeMe = nominalCurrentValue == curValue ? "" : "  ******************";
-                Slog.i(TAG, "Setting target " + mask + ": cur=" + curValue
-                        + " target=" + targetValue + " delta=" + delta
+                Slog.i(TAG, "setTargetLocked mask=" + mask + " curValue=" + curValue
+                        + " target=" + target + " targetValue=" + targetValue + " delta=" + delta
                         + " nominalCurrentValue=" + nominalCurrentValue
                         + noticeMe);
             }
@@ -2010,20 +2010,20 @@
             }
             if (mSpew) Slog.d(TAG, "Animating curIntValue=" + curIntValue + ": " + mask);
             setLightBrightness(mask, curIntValue);
-            finishAnimation(more, curIntValue);
+            finishAnimationLocked(more, curIntValue);
             return more;
         }
 
-        void jumpToTarget() {
-            if (mSpew) Slog.d(TAG, "jumpToTarget targetValue=" + targetValue + ": " + mask);
+        void jumpToTargetLocked() {
+            if (mSpew) Slog.d(TAG, "jumpToTargetLocked targetValue=" + targetValue + ": " + mask);
             setLightBrightness(mask, targetValue);
             final int tv = targetValue;
             curValue = tv;
             targetValue = -1;
-            finishAnimation(false, tv);
+            finishAnimationLocked(false, tv);
         }
 
-        private void finishAnimation(boolean more, int curIntValue) {
+        private void finishAnimationLocked(boolean more, int curIntValue) {
             animating = more;
             if (!more) {
                 if (mask == SCREEN_BRIGHT_BIT && curIntValue == Power.BRIGHTNESS_OFF) {
@@ -2042,21 +2042,18 @@
                     }
                 }
             } else {
-                boolean animate;
-                boolean jump;
                 synchronized (mLocks) {
-                    jump = animating; // we haven't already run this animation
-                    animate = jump && targetValue == Power.BRIGHTNESS_OFF; // we're turning off
+                    // we're turning off
+                    final boolean animate = animating && targetValue == Power.BRIGHTNESS_OFF;
+                    if (animate) {
+                        // It's pretty scary to hold mLocks for this long, and we should
+                        // redesign this, but it works for now.
+                        nativeStartSurfaceFlingerAnimation(
+                                mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR
+                                ? 0 : mAnimationSetting);
+                    }
+                    mScreenBrightness.jumpToTargetLocked();
                 }
-                if (animate) {
-                    // TODO: I think it's possible that if you sleep & wake multiple times
-                    // quickly for different reasons, mScreenOffReason for the first animation
-                    // might get stomped on as it starts the second animation.
-                    nativeStartSurfaceFlingerAnimation(
-                            mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR
-                            ? 0 : mAnimationSetting);
-                }
-                mScreenBrightness.jumpToTarget();
             }
         }
     }
@@ -2785,8 +2782,10 @@
             }
 
             // update our animation state
-            mScreenBrightness.targetValue = brightness;
-            mScreenBrightness.jumpToTarget();
+            synchronized (mLocks) {
+                mScreenBrightness.targetValue = brightness;
+                mScreenBrightness.jumpToTargetLocked();
+            }
         }
     }
 
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 4177432..e5dfb18 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -54,7 +54,7 @@
 public class StatusBarManagerService extends IStatusBarService.Stub
 {
     static final String TAG = "StatusBarManagerService";
-    static final boolean SPEW = true;
+    static final boolean SPEW = false;
 
     final Context mContext;
     Handler mHandler = new Handler();
@@ -154,7 +154,6 @@
         synchronized (mDisableRecords) {
             manageDisableListLocked(what, token, pkg);
             final int net = gatherDisableActionsLocked();
-            Slog.d(TAG, "disable... net=0x" + Integer.toHexString(net));
             if (net != mDisabled) {
                 mDisabled = net;
                 mHandler.post(new Runnable() {
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index 7e23422..33702793 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -254,6 +254,7 @@
         if (!checkNotifyPermission("notifyServiceState()")){
             return;
         }
+        Slog.i(TAG, "notifyServiceState: " + state);
         synchronized (mRecords) {
             mServiceState = state;
             for (int i = mRecords.size() - 1; i >= 0; i--) {
@@ -295,6 +296,7 @@
         if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
             return;
         }
+        Slog.i(TAG, "notifyMessageWaitingChanged: " + mwi);
         synchronized (mRecords) {
             mMessageWaiting = mwi;
             for (int i = mRecords.size() - 1; i >= 0; i--) {
@@ -314,6 +316,7 @@
         if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
             return;
         }
+        Slog.i(TAG, "notifyCallForwardingChanged: " + cfi);
         synchronized (mRecords) {
             mCallForwarding = cfi;
             for (int i = mRecords.size() - 1; i >= 0; i--) {
@@ -354,6 +357,9 @@
         if (!checkNotifyPermission("notifyDataConnection()" )) {
             return;
         }
+        Slog.i(TAG, "notifyDataConnection: state=" + state + " isDataConnectivityPossible="
+                + isDataConnectivityPossible + " reason=" + reason
+                + " interfaceName=" + interfaceName + " networkType=" + networkType);
         synchronized (mRecords) {
             mDataConnectionState = state;
             mDataConnectionPossible = isDataConnectivityPossible;
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index a63b3d8..c1e9965 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -1656,7 +1656,9 @@
                 Settings.System.getInt(mContext.getContentResolver(),
                                        Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0);
             if (action.equals(Intent.ACTION_SCREEN_ON)) {
-                Slog.d(TAG, "ACTION_SCREEN_ON");
+                if (DBG) {
+                    Slog.d(TAG, "ACTION_SCREEN_ON");
+                }
                 mAlarmManager.cancel(mIdleIntent);
                 mDeviceIdle = false;
                 mScreenOff = false;
@@ -1671,7 +1673,9 @@
                     sendEnableNetworksMessage();
                 }
             } else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
-                Slog.d(TAG, "ACTION_SCREEN_OFF");
+                if (DBG) {
+                    Slog.d(TAG, "ACTION_SCREEN_OFF");
+                }
                 mScreenOff = true;
                 mWifiStateTracker.enableRssiPolling(false);
                 /*
@@ -1688,21 +1692,28 @@
                         // as long as we would if connected (below)
                         // TODO - fix the race conditions and switch back to the immediate turn-off
                         long triggerTime = System.currentTimeMillis() + (2*60*1000); // 2 min
-                        Slog.d(TAG, "setting ACTION_DEVICE_IDLE timer for 120,000 ms");
+                        if (DBG) {
+                            Slog.d(TAG, "setting ACTION_DEVICE_IDLE timer for 120,000 ms");
+                        }
                         mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent);
                         //  // do not keep Wifi awake when screen is off if Wifi is not associated
                         //  mDeviceIdle = true;
                         //  updateWifiState();
                     } else {
                         long triggerTime = System.currentTimeMillis() + idleMillis;
-                        Slog.d(TAG, "setting ACTION_DEVICE_IDLE timer for " + idleMillis + "ms");
+                        if (DBG) {
+                            Slog.d(TAG, "setting ACTION_DEVICE_IDLE timer for " + idleMillis
+                                    + "ms");
+                        }
                         mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent);
                     }
                 }
                 /* we can return now -- there's nothing to do until we get the idle intent back */
                 return;
             } else if (action.equals(ACTION_DEVICE_IDLE)) {
-                Slog.d(TAG, "got ACTION_DEVICE_IDLE");
+                if (DBG) {
+                    Slog.d(TAG, "got ACTION_DEVICE_IDLE");
+                }
                 mDeviceIdle = true;
                 reportStartWorkSource();
             } else if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
@@ -1714,11 +1725,15 @@
                  * the already-set timer.
                  */
                 int pluggedType = intent.getIntExtra("plugged", 0);
-                Slog.d(TAG, "ACTION_BATTERY_CHANGED pluggedType: " + pluggedType);
+                if (DBG) {
+                    Slog.d(TAG, "ACTION_BATTERY_CHANGED pluggedType: " + pluggedType);
+                }
                 if (mScreenOff && shouldWifiStayAwake(stayAwakeConditions, mPluggedType) &&
                         !shouldWifiStayAwake(stayAwakeConditions, pluggedType)) {
                     long triggerTime = System.currentTimeMillis() + idleMillis;
-                    Slog.d(TAG, "setting ACTION_DEVICE_IDLE timer for " + idleMillis + "ms");
+                    if (DBG) {
+                        Slog.d(TAG, "setting ACTION_DEVICE_IDLE timer for " + idleMillis + "ms");
+                    }
                     mAlarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime, mIdleIntent);
                     mPluggedType = pluggedType;
                     return;
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 1bc5e4b..a73a4ce 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -120,7 +120,6 @@
     static final long USB_DISCONNECT_DELAY = 1000;
 
     public Tethering(Context context, Looper looper) {
-        Log.d(TAG, "Tethering starting");
         mContext = context;
         mLooper = looper;
 
@@ -457,7 +456,6 @@
                 mUsbMassStorageOff = true;
                 updateUsbStatus();
             } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
-                Log.d(TAG, "Tethering got CONNECTIVITY_ACTION");
                 mTetherMasterSM.sendMessage(TetherMasterSM.CMD_UPSTREAM_CHANGED);
             } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
                 mBooted = true;
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index f9c1679..4a6b5f4 100755
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -82,7 +82,7 @@
 
     private static final String TAG = "GpsLocationProvider";
 
-    private static final boolean DEBUG = false;
+    private static final boolean DEBUG = true;
     private static final boolean VERBOSE = false;
 
     // these need to match GpsPositionMode enum in gps.h
@@ -1113,7 +1113,7 @@
      * called from native code to update our status
      */
     private void reportStatus(int status) {
-        if (VERBOSE) Log.v(TAG, "reportStatus status: " + status);
+        if (DEBUG) Log.v(TAG, "reportStatus status: " + status);
 
         synchronized(mListeners) {
             boolean wasNavigating = mNavigating;
@@ -1240,6 +1240,7 @@
                 int result = mConnMgr.startUsingNetworkFeature(
                         ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
                 if (result == Phone.APN_ALREADY_ACTIVE) {
+                    if (DEBUG) Log.d(TAG, "Phone.APN_ALREADY_ACTIVE");
                     if (mAGpsApn != null) {
                         native_agps_data_conn_open(mAGpsApn);
                         mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
@@ -1249,8 +1250,10 @@
                         native_agps_data_conn_failed();
                     }
                 } else if (result == Phone.APN_REQUEST_STARTED) {
+                    if (DEBUG) Log.d(TAG, "Phone.APN_ALREADYAPN_REQUEST_STARTED_ACTIVE");
                     // Nothing to do here
                 } else {
+                    if (DEBUG) Log.d(TAG, "startUsingNetworkFeature failed");
                     mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
                     native_agps_data_conn_failed();
                 }
diff --git a/services/java/com/android/server/location/GpsXtraDownloader.java b/services/java/com/android/server/location/GpsXtraDownloader.java
index bc96980..813d255 100644
--- a/services/java/com/android/server/location/GpsXtraDownloader.java
+++ b/services/java/com/android/server/location/GpsXtraDownloader.java
@@ -44,6 +44,7 @@
 public class GpsXtraDownloader {
 
     private static final String TAG = "GpsXtraDownloader";
+    static final boolean DEBUG = false;
     
     private Context mContext;
     private String[] mXtraServers;
@@ -107,7 +108,7 @@
 
     protected static byte[] doDownload(String url, boolean isProxySet, 
             String proxyHost, int proxyPort) {
-        if (Config.LOGD) Log.d(TAG, "Downloading XTRA data from " + url);
+        if (DEBUG) Log.d(TAG, "Downloading XTRA data from " + url);
 
         AndroidHttpClient client = null;
         try {
@@ -130,7 +131,7 @@
             HttpResponse response = client.execute(req);
             StatusLine status = response.getStatusLine();
             if (status.getStatusCode() != 200) { // HTTP 200 is success.
-                if (Config.LOGD) Log.d(TAG, "HTTP error: " + status.getReasonPhrase());
+                if (DEBUG) Log.d(TAG, "HTTP error: " + status.getReasonPhrase());
                 return null;
             }
 
@@ -159,7 +160,7 @@
             }
             return body;
         } catch (Exception e) {
-            if (Config.LOGD) Log.d(TAG, "error " + e);
+            if (DEBUG) Log.d(TAG, "error " + e);
         } finally {
             if (client != null) {
                 client.close();
diff --git a/services/jni/com_android_server_location_GpsLocationProvider.cpp b/services/jni/com_android_server_location_GpsLocationProvider.cpp
index 1d93f82..f5e17f5 100755
--- a/services/jni/com_android_server_location_GpsLocationProvider.cpp
+++ b/services/jni/com_android_server_location_GpsLocationProvider.cpp
@@ -16,7 +16,7 @@
 
 #define LOG_TAG "GpsLocationProvider"
 
-//#define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
 
 #include "JNIHelp.h"
 #include "jni.h"
@@ -106,6 +106,7 @@
 
 static void set_capabilities_callback(uint32_t capabilities)
 {
+    LOGD("set_capabilities_callback: %ld\n", capabilities);
     JNIEnv* env = AndroidRuntime::getJNIEnv();
     env->CallVoidMethod(mCallbacksObj, method_setEngineCapabilities, capabilities);
     checkAndClearExceptionFromCallback(env, __FUNCTION__);
diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
index 46ef118..9561c6e 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
@@ -37,7 +37,7 @@
  */
 
 public class CallerInfoAsyncQuery {
-    private static final boolean DBG = (SystemProperties.getInt("ro.debuggable", 0) == 1);
+    private static final boolean DBG = false;
     private static final String LOG_TAG = "CallerInfoAsyncQuery";
 
     private static final int EVENT_NEW_QUERY = 1;
@@ -128,13 +128,13 @@
                     // However, if there is any code that this Handler calls (such as in
                     // super.handleMessage) that DOES place unexpected messages on the
                     // queue, then we need pass these messages on.
-                    if (DBG) log("Unexpected command (CookieWrapper is null): " + msg.what +
+                    if (DBG) Log.d(LOG_TAG, "Unexpected command (CookieWrapper is null): " + msg.what +
                             " ignored by CallerInfoWorkerHandler, passing onto parent.");
 
                     super.handleMessage(msg);
                 } else {
 
-                    if (DBG) log("Processing event: " + cw.event + " token (arg1): " + msg.arg1 +
+                    if (DBG) Log.d(LOG_TAG, "Processing event: " + cw.event + " token (arg1): " + msg.arg1 +
                         " command: " + msg.what + " query URI: " + sanitizeUriToString(args.uri));
 
                     switch (cw.event) {
@@ -190,7 +190,7 @@
          */
         @Override
         protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
-            if (DBG) log("##### onQueryComplete() #####   query complete for token: " + token);
+            if (DBG) Log.d(LOG_TAG, "##### onQueryComplete() #####   query complete for token: " + token);
 
             //get the cookie and notify the listener.
             CookieWrapper cw = (CookieWrapper) cookie;
@@ -199,7 +199,7 @@
                 // from within this code.
                 // However, if there is any code that calls this method, we should
                 // check the parameters to make sure they're viable.
-                if (DBG) log("Cookie is null, ignoring onQueryComplete() request.");
+                if (DBG) Log.d(LOG_TAG, "Cookie is null, ignoring onQueryComplete() request.");
                 return;
             }
 
@@ -228,7 +228,7 @@
                     mCallerInfo = new CallerInfo().markAsVoiceMail();
                 } else {
                     mCallerInfo = CallerInfo.getCallerInfo(mQueryContext, mQueryUri, cursor);
-                    if (DBG) log("==> Got mCallerInfo: " + mCallerInfo);
+                    if (DBG) Log.d(LOG_TAG, "==> Got mCallerInfo: " + mCallerInfo);
 
                     // Use the number entered by the user for display.
                     if (!TextUtils.isEmpty(cw.number)) {
@@ -236,7 +236,7 @@
                     }
                 }
 
-                if (DBG) log("constructing CallerInfo object for token: " + token);
+                if (DBG) Log.d(LOG_TAG, "constructing CallerInfo object for token: " + token);
 
                 //notify that we can clean up the queue after this.
                 CookieWrapper endMarker = new CookieWrapper();
@@ -246,7 +246,7 @@
 
             //notify the listener that the query is complete.
             if (cw.listener != null) {
-                if (DBG) log("notifying listener: " + cw.listener.getClass().toString() +
+                if (DBG) Log.d(LOG_TAG, "notifying listener: " + cw.listener.getClass().toString() +
                              " for token: " + token + mCallerInfo);
                 cw.listener.onQueryComplete(token, cw.cookie, mCallerInfo);
             }
@@ -269,7 +269,7 @@
         CallerInfoAsyncQuery c = new CallerInfoAsyncQuery();
         c.allocate(context, contactRef);
 
-        if (DBG) log("starting query for URI: " + contactRef + " handler: " + c.toString());
+        if (DBG) Log.d(LOG_TAG, "starting query for URI: " + contactRef + " handler: " + c.toString());
 
         //create cookieWrapper, start query
         CookieWrapper cw = new CookieWrapper();
@@ -296,9 +296,9 @@
     public static CallerInfoAsyncQuery startQuery(int token, Context context, String number,
             OnQueryCompleteListener listener, Object cookie) {
         if (DBG) {
-            log("##### CallerInfoAsyncQuery startQuery()... #####");
-            log("- number: " + /*number*/ "xxxxxxx");
-            log("- cookie: " + cookie);
+            Log.d(LOG_TAG, "##### CallerInfoAsyncQuery startQuery()... #####");
+            Log.d(LOG_TAG, "- number: " + /*number*/ "xxxxxxx");
+            Log.d(LOG_TAG, "- cookie: " + cookie);
         }
 
         // Construct the URI object and query params, and start the query.
@@ -309,7 +309,7 @@
 
         if (PhoneNumberUtils.isUriNumber(number)) {
             // "number" is really a SIP address.
-            if (DBG) log("  - Treating number as a SIP address: " + /*number*/ "xxxxxxx");
+            if (DBG) Log.d(LOG_TAG, "  - Treating number as a SIP address: " + /*number*/ "xxxxxxx");
 
             // We look up SIP addresses directly in the Data table:
             contactRef = Data.CONTENT_URI;
@@ -341,11 +341,11 @@
         }
 
         if (DBG) {
-            log("==> contactRef: " + sanitizeUriToString(contactRef));
-            log("==> selection: " + selection);
+            Log.d(LOG_TAG, "==> contactRef: " + sanitizeUriToString(contactRef));
+            Log.d(LOG_TAG, "==> selection: " + selection);
             if (selectionArgs != null) {
                 for (int i = 0; i < selectionArgs.length; i++) {
-                    log("==> selectionArgs[" + i + "]: " + selectionArgs[i]);
+                    Log.d(LOG_TAG, "==> selectionArgs[" + i + "]: " + selectionArgs[i]);
                 }
             }
         }
@@ -383,7 +383,7 @@
      */
     public void addQueryListener(int token, OnQueryCompleteListener listener, Object cookie) {
 
-        if (DBG) log("adding listener to query: " + sanitizeUriToString(mHandler.mQueryUri) +
+        if (DBG) Log.d(LOG_TAG, "adding listener to query: " + sanitizeUriToString(mHandler.mQueryUri) +
                 " handler: " + mHandler.toString());
 
         //create cookieWrapper, add query request to end of queue.
@@ -431,11 +431,4 @@
             return "";
         }
     }
-
-    /**
-     * static logging method
-     */
-    private static void log(String msg) {
-        Log.d(LOG_TAG, msg);
-    }
 }
diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
index 1968552..b9a2e60 100755
--- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java
+++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java
@@ -28,6 +28,7 @@
 import android.os.Message;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.android.internal.telephony.Call;
@@ -673,6 +674,18 @@
             this(owner, callee, getUriString(callee));
         }
 
+        @Override
+        public String getCnapName() {
+            String displayName = mPeer.getDisplayName();
+            return TextUtils.isEmpty(displayName) ? null
+                                                  : displayName;
+        }
+
+        @Override
+        public int getNumberPresentation() {
+            return Connection.PRESENTATION_ALLOWED;
+        }
+
         void initIncomingCall(SipAudioCall sipAudioCall, Call.State newState) {
             setState(newState);
             mSipAudioCall = sipAudioCall;
diff --git a/tools/obbtool/Android.mk b/tools/obbtool/Android.mk
index 9866876..d118bd7 100644
--- a/tools/obbtool/Android.mk
+++ b/tools/obbtool/Android.mk
@@ -29,21 +29,18 @@
 
 include $(BUILD_HOST_EXECUTABLE)
 
-# Non-Linux hosts might not have OpenSSL libcrypto
-ifeq ($(HOST_OS),linux)
-    include $(CLEAR_VARS)
+#####################################################
+include $(CLEAR_VARS)
 
-    LOCAL_MODULE := pbkdf2gen
+LOCAL_MODULE := pbkdf2gen
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -Wall -Werror
+LOCAL_SRC_FILES := pbkdf2gen.cpp
+LOCAL_LDLIBS += -ldl
+LOCAL_C_INCLUDES := external/openssl/include $(LOCAL_C_INCLUDES)
+LOCAL_STATIC_LIBRARIES := libcrypto_static
 
-    LOCAL_MODULE_TAGS := optional
+include $(BUILD_HOST_EXECUTABLE)
 
-    LOCAL_CFLAGS := -Wall -Werror
-
-    LOCAL_SRC_FILES := pbkdf2gen.cpp
-
-    LOCAL_SHARED_LIBRARIES := libcrypto
-
-    include $(BUILD_HOST_EXECUTABLE)
-endif # HOST_OS == linux
-
+#######################################################
 endif # TARGET_BUILD_APPS
diff --git a/voip/java/android/net/sip/SipManager.java b/voip/java/android/net/sip/SipManager.java
index ee0e3cd..2f03e34 100644
--- a/voip/java/android/net/sip/SipManager.java
+++ b/voip/java/android/net/sip/SipManager.java
@@ -126,22 +126,16 @@
      * Returns true if the SIP API is supported by the system.
      */
     public static boolean isApiSupported(Context context) {
-        return true;
-        /* TODO: uncomment this before ship
         return context.getPackageManager().hasSystemFeature(
                 PackageManager.FEATURE_SIP);
-         */
     }
 
     /**
      * Returns true if the system supports SIP-based VoIP.
      */
     public static boolean isVoipSupported(Context context) {
-        return true;
-        /* TODO: uncomment this before ship
         return context.getPackageManager().hasSystemFeature(
                 PackageManager.FEATURE_SIP_VOIP) && isApiSupported(context);
-         */
     }
 
     /**
diff --git a/voip/java/com/android/server/sip/SipHelper.java b/voip/java/com/android/server/sip/SipHelper.java
index 2514262..13e6f14 100644
--- a/voip/java/com/android/server/sip/SipHelper.java
+++ b/voip/java/com/android/server/sip/SipHelper.java
@@ -365,6 +365,10 @@
             Response response = mMessageFactory.createResponse(
                     Response.BUSY_HERE, request);
 
+            if (inviteTransaction == null) {
+                inviteTransaction = getServerTransaction(event);
+            }
+
             if (inviteTransaction.getState() != TransactionState.COMPLETED) {
                 if (DEBUG) Log.d(TAG, "send BUSY HERE: " + response);
                 inviteTransaction.sendResponse(response);
diff --git a/voip/java/com/android/server/sip/SipService.java b/voip/java/com/android/server/sip/SipService.java
index 1df08c0..84e0803 100644
--- a/voip/java/com/android/server/sip/SipService.java
+++ b/voip/java/com/android/server/sip/SipService.java
@@ -68,7 +68,7 @@
 public final class SipService extends ISipService.Stub {
     static final String TAG = "SipService";
     static final boolean DEBUGV = false;
-    private static final boolean DEBUG = true;
+    private static final boolean DEBUG = false;
     private static final boolean DEBUG_TIMER = DEBUG && false;
     private static final int EXPIRY_TIME = 3600;
     private static final int SHORT_EXPIRY_TIME = 10;
@@ -79,6 +79,7 @@
     private String mNetworkType;
     private boolean mConnected;
     private WakeupTimer mTimer;
+    private WifiScanProcess mWifiScanProcess;
     private WifiManager.WifiLock mWifiLock;
     private boolean mWifiOnly;
 
@@ -104,7 +105,7 @@
         if (SipManager.isApiSupported(context)) {
             ServiceManager.addService("sip", new SipService(context));
             context.sendBroadcast(new Intent(SipManager.ACTION_SIP_SERVICE_UP));
-            Log.i(TAG, "SIP service started");
+            if (DEBUG) Log.i(TAG, "SIP service started");
         }
     }
 
@@ -222,7 +223,7 @@
         SipSessionGroupExt group = mSipGroups.get(localProfileUri);
         if (group == null) return;
         if (!isCallerCreatorOrRadio(group)) {
-            Log.d(TAG, "only creator or radio can close this profile");
+            Log.w(TAG, "only creator or radio can close this profile");
             return;
         }
 
@@ -244,7 +245,7 @@
         if (isCallerCreatorOrRadio(group)) {
             return group.isOpened();
         } else {
-            Log.i(TAG, "only creator or radio can query on the profile");
+            Log.w(TAG, "only creator or radio can query on the profile");
             return false;
         }
     }
@@ -257,7 +258,7 @@
         if (isCallerCreatorOrRadio(group)) {
             return group.isRegistered();
         } else {
-            Log.i(TAG, "only creator or radio can query on the profile");
+            Log.w(TAG, "only creator or radio can query on the profile");
             return false;
         }
     }
@@ -271,7 +272,7 @@
         if (isCallerCreator(group)) {
             group.setListener(listener);
         } else {
-            Log.i(TAG, "only creator can set listener on the profile");
+            Log.w(TAG, "only creator can set listener on the profile");
         }
     }
 
@@ -285,7 +286,7 @@
             SipSessionGroupExt group = createGroup(localProfile);
             return group.createSession(listener);
         } catch (SipException e) {
-            Log.w(TAG, "createSession()", e);
+            if (DEBUG) Log.d(TAG, "createSession()", e);
             return null;
         }
     }
@@ -303,7 +304,7 @@
             s.connect(InetAddress.getByName("192.168.1.1"), 80);
             return s.getLocalAddress().getHostAddress();
         } catch (IOException e) {
-            Log.w(TAG, "determineLocalIp()", e);
+            if (DEBUG) Log.d(TAG, "determineLocalIp()", e);
             // dont do anything; there should be a connectivity change going
             return null;
         }
@@ -371,6 +372,7 @@
                     mContext.getSystemService(Context.WIFI_SERVICE))
                     .createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
             mWifiLock.acquire();
+            if (!mConnected) startWifiScanner();
         }
     }
 
@@ -379,6 +381,20 @@
             if (DEBUG) Log.d(TAG, "~~~~~~~~~~~~~~~~~~~~~ release wifi lock");
             mWifiLock.release();
             mWifiLock = null;
+            stopWifiScanner();
+        }
+    }
+
+    private synchronized void startWifiScanner() {
+        if (mWifiScanProcess == null) {
+            mWifiScanProcess = new WifiScanProcess();
+        }
+        mWifiScanProcess.start();
+    }
+
+    private synchronized void stopWifiScanner() {
+        if (mWifiScanProcess != null) {
+            mWifiScanProcess.stop();
         }
     }
 
@@ -413,8 +429,10 @@
                 for (SipSessionGroupExt group : mSipGroups.values()) {
                     group.onConnectivityChanged(true);
                 }
+                if (isWifi && (mWifiLock != null)) stopWifiScanner();
             } else {
                 mMyWakeLock.reset(); // in case there's a leak
+                if (isWifi && (mWifiLock != null)) startWifiScanner();
             }
         } catch (SipException e) {
             Log.e(TAG, "onConnectivityChanged()", e);
@@ -430,6 +448,21 @@
         }
     }
 
+    private synchronized boolean callingSelf(SipSessionGroupExt ringingGroup,
+            SipSessionGroup.SipSessionImpl ringingSession) {
+        String callId = ringingSession.getCallId();
+        for (SipSessionGroupExt group : mSipGroups.values()) {
+            if ((group != ringingGroup) && group.containsSession(callId)) {
+                if (DEBUG) Log.d(TAG, "call self: "
+                        + ringingSession.getLocalProfile().getUriString()
+                        + " -> " + group.getLocalProfile().getUriString());
+                return true;
+            }
+        }
+        return false;
+    }
+
+
     private class SipSessionGroupExt extends SipSessionAdapter {
         private SipSessionGroup mSipGroup;
         private PendingIntent mIncomingCallPendingIntent;
@@ -452,6 +485,10 @@
             return mSipGroup.getLocalProfile();
         }
 
+        public boolean containsSession(String callId) {
+            return mSipGroup.containsSession(callId);
+        }
+
         // network connectivity is tricky because network can be disconnected
         // at any instant so need to deal with exceptions carefully even when
         // you think you are connected
@@ -467,7 +504,7 @@
                     return createSipSessionGroup(null, localProfile, password);
                 } else {
                     // recursive
-                    Log.wtf(TAG, "impossible!");
+                    Log.wtf(TAG, "impossible! recursive!");
                     throw new RuntimeException("createSipSessionGroup");
                 }
             }
@@ -551,7 +588,7 @@
                     (SipSessionGroup.SipSessionImpl) s;
             synchronized (SipService.this) {
                 try {
-                    if (!isRegistered()) {
+                    if (!isRegistered() || callingSelf(this, session)) {
                         session.endCall();
                         return;
                     }
@@ -592,6 +629,36 @@
         }
     }
 
+    private class WifiScanProcess implements Runnable {
+        private static final String TAG = "\\WIFI_SCAN/";
+        private static final int INTERVAL = 60;
+        private boolean mRunning = false;
+
+        private WifiManager mWifiManager;
+
+        public void start() {
+            if (mRunning) return;
+            mRunning = true;
+            mTimer.set(INTERVAL * 1000, this);
+        }
+
+        WifiScanProcess() {
+            mWifiManager = (WifiManager)
+                    mContext.getSystemService(Context.WIFI_SERVICE);
+        }
+
+        public void run() {
+            // scan and associate now
+            if (DEBUGV) Log.v(TAG, "just wake up here for wifi scanning...");
+            mWifiManager.startScanActive();
+        }
+
+        public void stop() {
+            mRunning = false;
+            mTimer.cancel(this);
+        }
+    }
+
     // KeepAliveProcess is controlled by AutoRegistrationProcess.
     // All methods will be invoked in sync with SipService.this.
     private class KeepAliveProcess implements Runnable {
diff --git a/voip/java/com/android/server/sip/SipSessionGroup.java b/voip/java/com/android/server/sip/SipSessionGroup.java
index d861fa5..50ce7dc 100644
--- a/voip/java/com/android/server/sip/SipSessionGroup.java
+++ b/voip/java/com/android/server/sip/SipSessionGroup.java
@@ -82,6 +82,11 @@
     private static final boolean DEBUG = true;
     private static final boolean DEBUG_PING = DEBUG && false;
     private static final String ANONYMOUS = "anonymous";
+    // Limit the size of thread pool to 1 for the order issue when the phone is
+    // waken up from sleep and there are many packets to be processed in the SIP
+    // stack. Note: The default thread pool size in NIST SIP stack is -1 which is
+    // unlimited.
+    private static final String THREAD_POOL_SIZE = "1";
     private static final int EXPIRY_TIME = 3600; // in seconds
     private static final int CANCEL_CALL_TIMER = 3; // in seconds
     private static final long WAKE_LOCK_HOLDING_TIME = 500; // in milliseconds
@@ -129,6 +134,8 @@
         SipFactory sipFactory = SipFactory.getInstance();
         Properties properties = new Properties();
         properties.setProperty("javax.sip.STACK_NAME", getStackName());
+        properties.setProperty(
+                "gov.nist.javax.sip.THREAD_POOL_SIZE", THREAD_POOL_SIZE);
         String outboundProxy = myself.getProxyAddress();
         if (!TextUtils.isEmpty(outboundProxy)) {
             Log.v(TAG, "outboundProxy is " + outboundProxy);
@@ -224,6 +231,10 @@
         }
     }
 
+    synchronized boolean containsSession(String callId) {
+        return mSessionMap.containsKey(callId);
+    }
+
     private synchronized SipSessionImpl getSipSession(EventObject event) {
         String key = SipHelper.getCallId(event);
         SipSessionImpl session = mSessionMap.get(key);
@@ -575,6 +586,7 @@
         }
 
         private void processCommand(EventObject command) throws SipException {
+            if (isLoggable(command)) Log.d(TAG, "process cmd: " + command);
             if (!process(command)) {
                 onError(SipErrorCode.IN_PROGRESS,
                         "cannot initiate a new transaction to execute: "
@@ -1043,6 +1055,13 @@
                 mSipHelper.sendCancel(mClientTransaction);
                 startSessionTimer(CANCEL_CALL_TIMER);
                 return true;
+            } else if (isRequestEvent(Request.INVITE, evt)) {
+                // Call self? Send BUSY HERE so server may redirect the call to
+                // voice mailbox.
+                RequestEvent event = (RequestEvent) evt;
+                mSipHelper.sendInviteBusyHere(event,
+                        event.getServerTransaction());
+                return true;
             }
             return false;
         }
@@ -1344,6 +1363,10 @@
         return DEBUG;
     }
 
+    private static boolean isLoggable(EventObject evt) {
+        return isLoggable(null, evt);
+    }
+
     private static boolean isLoggable(SipSessionImpl s, EventObject evt) {
         if (!isLoggable(s)) return false;
         if (evt == null) return false;