Merge "Avoid duplicated code calculating the stts sample duration"
diff --git a/api/13.xml b/api/13.xml
index ff279e1..9af0640 100644
--- a/api/13.xml
+++ b/api/13.xml
@@ -1024,6 +1024,17 @@
  visibility="public"
 >
 </field>
+<field name="SET_POINTER_SPEED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.permission.SET_POINTER_SPEED&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="SET_PREFERRED_APPLICATIONS"
  type="java.lang.String"
  transient="false"
@@ -3128,6 +3139,17 @@
  visibility="public"
 >
 </field>
+<field name="compatibleWidthLimitDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843621"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="completionHint"
  type="int"
  transient="false"
@@ -5878,6 +5900,17 @@
  visibility="public"
 >
 </field>
+<field name="largestWidthLimitDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843622"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="launchMode"
  type="int"
  transient="false"
@@ -7913,6 +7946,17 @@
  visibility="public"
 >
 </field>
+<field name="requiresSmallestWidthDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843620"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="resizeMode"
  type="int"
  transient="false"
@@ -15164,6 +15208,325 @@
  visibility="public"
 >
 </field>
+<field name="TextAppearance_Holo"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974075"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_DialogWindowTitle"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974103"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Inverse"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974076"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Large"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974077"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Large_Inverse"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974078"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Medium"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974079"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Medium_Inverse"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974080"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_SearchResult_Subtitle"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974084"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_SearchResult_Title"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974083"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Small"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974081"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Small_Inverse"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974082"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974085"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_ActionBar_Subtitle"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974099"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_ActionBar_Title"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974098"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_ActionMode_Subtitle"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974101"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_ActionMode_Title"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974100"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_Button"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974086"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_DropDownHint"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974091"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_DropDownItem"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974092"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_EditText"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974094"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_IconMenu_Item"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974087"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_PopupMenu"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974095"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_PopupMenu_Large"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974096"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_PopupMenu_Small"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974097"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_TabWidget"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974088"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_TextView"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974089"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_TextView_PopupMenu"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974090"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_Widget_TextView_SpinnerItem"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974093"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TextAppearance_Holo_WindowTitle"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974102"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="TextAppearance_Inverse"
  type="int"
  transient="false"
@@ -15670,6 +16033,28 @@
  visibility="public"
 >
 </field>
+<field name="Theme_Holo_Light_NoActionBar"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974064"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Theme_Holo_Light_NoActionBar_Fullscreen"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974065"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="Theme_Holo_Light_Panel"
  type="int"
  transient="false"
@@ -15978,6 +16363,39 @@
  visibility="public"
 >
 </field>
+<field name="Widget_ActionBar_TabBar"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974068"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Widget_ActionBar_TabText"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974067"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Widget_ActionBar_TabView"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974066"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="Widget_ActionButton"
  type="int"
  transient="false"
@@ -16231,6 +16649,39 @@
  visibility="public"
 >
 </field>
+<field name="Widget_Holo_ActionBar_TabBar"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974071"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Widget_Holo_ActionBar_TabText"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974070"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Widget_Holo_ActionBar_TabView"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974069"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="Widget_Holo_ActionButton"
  type="int"
  transient="false"
@@ -16506,6 +16957,39 @@
  visibility="public"
 >
 </field>
+<field name="Widget_Holo_Light_ActionBar_TabBar"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974074"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Widget_Holo_Light_ActionBar_TabText"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974073"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="Widget_Holo_Light_ActionBar_TabView"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16974072"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="Widget_Holo_Light_ActionButton"
  type="int"
  transient="false"
@@ -22707,7 +23191,7 @@
  synchronized="false"
  static="false"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="id" type="int">
@@ -22981,7 +23465,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -23434,7 +23918,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="protected"
 >
 <parameter name="id" type="int">
@@ -23798,7 +24282,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="protected"
 >
 <parameter name="id" type="int">
@@ -23880,7 +24364,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -24102,7 +24586,7 @@
  synchronized="false"
  static="false"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="id" type="int">
@@ -24452,7 +24936,7 @@
  synchronized="false"
  static="false"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="id" type="int">
@@ -24465,7 +24949,7 @@
  synchronized="false"
  static="false"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="id" type="int">
@@ -30529,6 +31013,21 @@
  visibility="public"
 >
 </method>
+<method name="onViewCreated"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="view" type="android.view.View">
+</parameter>
+<parameter name="savedInstanceState" type="android.os.Bundle">
+</parameter>
+</method>
 <method name="registerForContextMenu"
  return="void"
  abstract="false"
@@ -30568,6 +31067,19 @@
 <parameter name="hasMenu" type="boolean">
 </parameter>
 </method>
+<method name="setInitialSavedState"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="state" type="android.app.Fragment.SavedState">
+</parameter>
+</method>
 <method name="setRetainInstance"
  return="void"
  abstract="false"
@@ -30659,6 +31171,53 @@
 </parameter>
 </constructor>
 </class>
+<class name="Fragment.SavedState"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.ClassLoaderCreator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
 <class name="FragmentBreadCrumbs"
  extends="android.view.ViewGroup"
  abstract="false"
@@ -31092,6 +31651,19 @@
 <parameter name="listener" type="android.app.FragmentManager.OnBackStackChangedListener">
 </parameter>
 </method>
+<method name="saveFragmentInstanceState"
+ return="android.app.Fragment.SavedState"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="f" type="android.app.Fragment">
+</parameter>
+</method>
 <field name="POP_BACK_STACK_INCLUSIVE"
  type="int"
  transient="false"
@@ -31262,6 +31834,19 @@
 <parameter name="name" type="java.lang.String">
 </parameter>
 </method>
+<method name="attach"
+ return="android.app.FragmentTransaction"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fragment" type="android.app.Fragment">
+</parameter>
+</method>
 <method name="commit"
  return="int"
  abstract="true"
@@ -31284,6 +31869,19 @@
  visibility="public"
 >
 </method>
+<method name="detach"
+ return="android.app.FragmentTransaction"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fragment" type="android.app.Fragment">
+</parameter>
+</method>
 <method name="disallowAddToBackStack"
  return="android.app.FragmentTransaction"
  abstract="true"
@@ -31442,6 +32040,25 @@
 <parameter name="exit" type="int">
 </parameter>
 </method>
+<method name="setCustomAnimations"
+ return="android.app.FragmentTransaction"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="enter" type="int">
+</parameter>
+<parameter name="exit" type="int">
+</parameter>
+<parameter name="popEnter" type="int">
+</parameter>
+<parameter name="popExit" type="int">
+</parameter>
+</method>
 <method name="setTransition"
  return="android.app.FragmentTransaction"
  abstract="true"
@@ -32623,7 +33240,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="callback" type="android.app.KeyguardManager.OnKeyguardExitResult">
@@ -32647,7 +33264,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="tag" type="java.lang.String">
@@ -32659,7 +33276,7 @@
  abstract="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <method name="disableKeyguard"
@@ -57840,6 +58457,28 @@
  visibility="public"
 >
 </field>
+<field name="CONFIG_SCREEN_SIZE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1024"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CONFIG_SMALLEST_SCREEN_SIZE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2048"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="CONFIG_TOUCHSCREEN"
  type="int"
  transient="false"
@@ -58588,6 +59227,16 @@
  visibility="public"
 >
 </field>
+<field name="compatibleWidthLimitDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="dataDir"
  type="java.lang.String"
  transient="false"
@@ -58628,6 +59277,16 @@
  visibility="public"
 >
 </field>
+<field name="largestWidthLimitDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="manageSpaceActivityName"
  type="java.lang.String"
  transient="false"
@@ -58678,6 +59337,16 @@
  visibility="public"
 >
 </field>
+<field name="requiresSmallestWidthDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="sharedLibraryFiles"
  type="java.lang.String[]"
  transient="false"
@@ -61053,6 +61722,28 @@
  visibility="public"
 >
 </field>
+<field name="FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.faketouch.multitouch.distinct&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.hardware.faketouch.multitouch.jazzhand&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="FEATURE_LIVE_WALLPAPER"
  type="java.lang.String"
  transient="false"
@@ -63902,6 +64593,39 @@
  visibility="public"
 >
 </field>
+<field name="SCREEN_HEIGHT_DP_UNDEFINED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SCREEN_WIDTH_DP_UNDEFINED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SMALLEST_SCREEN_WIDTH_DP_UNDEFINED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="TOUCHSCREEN_FINGER"
  type="int"
  transient="false"
@@ -64034,6 +64758,17 @@
  visibility="public"
 >
 </field>
+<field name="UI_MODE_TYPE_TELEVISION"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="UI_MODE_TYPE_UNDEFINED"
  type="int"
  transient="false"
@@ -64145,6 +64880,16 @@
  visibility="public"
 >
 </field>
+<field name="screenHeightDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="screenLayout"
  type="int"
  transient="false"
@@ -64155,6 +64900,26 @@
  visibility="public"
 >
 </field>
+<field name="screenWidthDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="smallestScreenWidthDp"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="touchscreen"
  type="int"
  transient="false"
@@ -84584,6 +85349,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.os.Parcelable">
+</implements>
 <constructor name="Point"
  type="android.graphics.Point"
  static="false"
@@ -84614,6 +85381,17 @@
 <parameter name="src" type="android.graphics.Point">
 </parameter>
 </constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="equals"
  return="boolean"
  abstract="false"
@@ -84655,6 +85433,19 @@
 <parameter name="dy" type="int">
 </parameter>
 </method>
+<method name="readFromParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="in" type="android.os.Parcel">
+</parameter>
+</method>
 <method name="set"
  return="void"
  abstract="false"
@@ -84670,6 +85461,31 @@
 <parameter name="y" type="int">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="out" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.Creator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="x"
  type="int"
  transient="false"
@@ -84699,6 +85515,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.os.Parcelable">
+</implements>
 <constructor name="PointF"
  type="android.graphics.PointF"
  static="false"
@@ -84729,6 +85547,17 @@
 <parameter name="p" type="android.graphics.Point">
 </parameter>
 </constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="equals"
  return="boolean"
  abstract="false"
@@ -84796,6 +85625,19 @@
 <parameter name="dy" type="float">
 </parameter>
 </method>
+<method name="readFromParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="in" type="android.os.Parcel">
+</parameter>
+</method>
 <method name="set"
  return="void"
  abstract="false"
@@ -84824,6 +85666,31 @@
 <parameter name="p" type="android.graphics.PointF">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="out" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.Creator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="x"
  type="float"
  transient="false"
@@ -95253,6 +96120,17 @@
  visibility="public"
 >
 </method>
+<method name="getRawDescriptors"
+ return="byte[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getSerial"
  return="java.lang.String"
  abstract="false"
@@ -114060,6 +114938,28 @@
  visibility="public"
 >
 </field>
+<field name="TYPE_BLUETOOTH"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="7"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TYPE_ETHERNET"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="9"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="TYPE_MOBILE"
  type="int"
  transient="false"
@@ -143402,6 +144302,21 @@
 <parameter name="args" type="java.lang.String[]">
 </parameter>
 </method>
+<method name="dumpAsync"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fd" type="java.io.FileDescriptor">
+</parameter>
+<parameter name="args" type="java.lang.String[]">
+</parameter>
+</method>
 <method name="flushPendingCommands"
  return="void"
  abstract="false"
@@ -144032,6 +144947,17 @@
  visibility="public"
 >
 </field>
+<field name="HONEYCOMB_MR2"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="13"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <class name="Bundle"
  extends="java.lang.Object"
@@ -147863,6 +148789,23 @@
 <exception name="RemoteException" type="android.os.RemoteException">
 </exception>
 </method>
+<method name="dumpAsync"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fd" type="java.io.FileDescriptor">
+</parameter>
+<parameter name="args" type="java.lang.String[]">
+</parameter>
+<exception name="RemoteException" type="android.os.RemoteException">
+</exception>
+</method>
 <method name="getInterfaceDescriptor"
  return="java.lang.String"
  abstract="true"
@@ -150169,6 +151112,19 @@
 <parameter name="descriptor" type="android.os.ParcelFileDescriptor">
 </parameter>
 </constructor>
+<method name="adoptFd"
+ return="android.os.ParcelFileDescriptor"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fd" type="int">
+</parameter>
+</method>
 <method name="close"
  return="void"
  abstract="false"
@@ -150217,6 +151173,36 @@
  visibility="public"
 >
 </method>
+<method name="dup"
+ return="android.os.ParcelFileDescriptor"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="orig" type="java.io.FileDescriptor">
+</parameter>
+<exception name="IOException" type="java.io.IOException">
+</exception>
+</method>
+<method name="fromFd"
+ return="android.os.ParcelFileDescriptor"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fd" type="int">
+</parameter>
+<exception name="IOException" type="java.io.IOException">
+</exception>
+</method>
 <method name="fromSocket"
  return="android.os.ParcelFileDescriptor"
  abstract="false"
@@ -150596,6 +151582,31 @@
 >
 </field>
 </interface>
+<interface name="Parcelable.ClassLoaderCreator"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable.Creator">
+</implements>
+<method name="createFromParcel"
+ return="T"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="source" type="android.os.Parcel">
+</parameter>
+<parameter name="loader" type="java.lang.ClassLoader">
+</parameter>
+</method>
+</interface>
 <interface name="Parcelable.Creator"
  abstract="true"
  static="true"
@@ -150893,7 +151904,7 @@
  value="10"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -184155,6 +185166,17 @@
  visibility="public"
 >
 </field>
+<field name="NETWORK_TYPE_HSPAP"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="15"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="NETWORK_TYPE_HSUPA"
  type="int"
  transient="false"
@@ -205789,6 +206811,17 @@
  visibility="public"
 >
 </field>
+<field name="DENSITY_TV"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="213"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="DENSITY_XHIGH"
  type="int"
  transient="false"
@@ -209950,11 +210983,11 @@
 <method name="getHeight"
  return="int"
  abstract="false"
- native="true"
+ native="false"
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -209993,6 +211026,19 @@
  visibility="public"
 >
 </method>
+<method name="getRectSize"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="outSize" type="android.graphics.Rect">
+</parameter>
+</method>
 <method name="getRefreshRate"
  return="float"
  abstract="false"
@@ -210015,16 +211061,29 @@
  visibility="public"
 >
 </method>
-<method name="getWidth"
- return="int"
+<method name="getSize"
+ return="void"
  abstract="false"
- native="true"
+ native="false"
  synchronized="false"
  static="false"
  final="false"
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="outSize" type="android.graphics.Point">
+</parameter>
+</method>
+<method name="getWidth"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="deprecated"
+ visibility="public"
+>
 </method>
 <field name="DEFAULT_DISPLAY"
  type="int"
@@ -212742,6 +213801,17 @@
  visibility="public"
 >
 </method>
+<method name="getModifiers"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getNumber"
  return="char"
  abstract="false"
@@ -220966,7 +222036,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="ev" type="android.view.MotionEvent">
+<parameter name="event" type="android.view.MotionEvent">
 </parameter>
 </method>
 <method name="clear"
diff --git a/api/current.txt b/api/current.txt
index ac0a22e..b9f2322 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -1474,6 +1474,35 @@
     field public static final int MediaButton_Rew = 16973884; // 0x103003c
     field public static final int TextAppearance = 16973886; // 0x103003e
     field public static final int TextAppearance_DialogWindowTitle = 16973889; // 0x1030041
+    field public static final int TextAppearance_Holo = 16974075; // 0x10300fb
+    field public static final int TextAppearance_Holo_DialogWindowTitle = 16974103; // 0x1030117
+    field public static final int TextAppearance_Holo_Inverse = 16974076; // 0x10300fc
+    field public static final int TextAppearance_Holo_Large = 16974077; // 0x10300fd
+    field public static final int TextAppearance_Holo_Large_Inverse = 16974078; // 0x10300fe
+    field public static final int TextAppearance_Holo_Medium = 16974079; // 0x10300ff
+    field public static final int TextAppearance_Holo_Medium_Inverse = 16974080; // 0x1030100
+    field public static final int TextAppearance_Holo_SearchResult_Subtitle = 16974084; // 0x1030104
+    field public static final int TextAppearance_Holo_SearchResult_Title = 16974083; // 0x1030103
+    field public static final int TextAppearance_Holo_Small = 16974081; // 0x1030101
+    field public static final int TextAppearance_Holo_Small_Inverse = 16974082; // 0x1030102
+    field public static final int TextAppearance_Holo_Widget = 16974085; // 0x1030105
+    field public static final int TextAppearance_Holo_Widget_ActionBar_Subtitle = 16974099; // 0x1030113
+    field public static final int TextAppearance_Holo_Widget_ActionBar_Title = 16974098; // 0x1030112
+    field public static final int TextAppearance_Holo_Widget_ActionMode_Subtitle = 16974101; // 0x1030115
+    field public static final int TextAppearance_Holo_Widget_ActionMode_Title = 16974100; // 0x1030114
+    field public static final int TextAppearance_Holo_Widget_Button = 16974086; // 0x1030106
+    field public static final int TextAppearance_Holo_Widget_DropDownHint = 16974091; // 0x103010b
+    field public static final int TextAppearance_Holo_Widget_DropDownItem = 16974092; // 0x103010c
+    field public static final int TextAppearance_Holo_Widget_EditText = 16974094; // 0x103010e
+    field public static final int TextAppearance_Holo_Widget_IconMenu_Item = 16974087; // 0x1030107
+    field public static final int TextAppearance_Holo_Widget_PopupMenu = 16974095; // 0x103010f
+    field public static final int TextAppearance_Holo_Widget_PopupMenu_Large = 16974096; // 0x1030110
+    field public static final int TextAppearance_Holo_Widget_PopupMenu_Small = 16974097; // 0x1030111
+    field public static final int TextAppearance_Holo_Widget_TabWidget = 16974088; // 0x1030108
+    field public static final int TextAppearance_Holo_Widget_TextView = 16974089; // 0x1030109
+    field public static final int TextAppearance_Holo_Widget_TextView_PopupMenu = 16974090; // 0x103010a
+    field public static final int TextAppearance_Holo_Widget_TextView_SpinnerItem = 16974093; // 0x103010d
+    field public static final int TextAppearance_Holo_WindowTitle = 16974102; // 0x1030116
     field public static final int TextAppearance_Inverse = 16973887; // 0x103003f
     field public static final int TextAppearance_Large = 16973890; // 0x1030042
     field public static final int TextAppearance_Large_Inverse = 16973891; // 0x1030043
@@ -1523,11 +1552,11 @@
     field public static final int Theme_Holo_Light_NoActionBar = 16974064; // 0x10300f0
     field public static final int Theme_Holo_Light_NoActionBar_Fullscreen = 16974065; // 0x10300f1
     field public static final int Theme_Holo_Light_Panel = 16973948; // 0x103007c
-    field public static final int Theme_Holo_Light_SplitActionBarWhenNarrow = 16974077; // 0x10300fd
+    field public static final int Theme_Holo_Light_SplitActionBarWhenNarrow = 16974106; // 0x103011a
     field public static final int Theme_Holo_NoActionBar = 16973932; // 0x103006c
     field public static final int Theme_Holo_NoActionBar_Fullscreen = 16973933; // 0x103006d
     field public static final int Theme_Holo_Panel = 16973947; // 0x103007b
-    field public static final int Theme_Holo_SplitActionBarWhenNarrow = 16974076; // 0x10300fc
+    field public static final int Theme_Holo_SplitActionBarWhenNarrow = 16974105; // 0x1030119
     field public static final int Theme_Holo_Wallpaper = 16973949; // 0x103007d
     field public static final int Theme_Holo_Wallpaper_NoTitleBar = 16973950; // 0x103007e
     field public static final int Theme_InputMethod = 16973908; // 0x1030054
@@ -13591,7 +13620,7 @@
     field public static final int GINGERBREAD_MR1 = 10; // 0xa
     field public static final int HONEYCOMB = 11; // 0xb
     field public static final int HONEYCOMB_MR1 = 12; // 0xc
-    field public static final int HONEYCOMB_MR2 = 10000; // 0x2710
+    field public static final int HONEYCOMB_MR2 = 13; // 0xd
     field public static final int ICE_CREAM_SANDWICH = 10000; // 0x2710
   }
 
@@ -17364,6 +17393,28 @@
 
 }
 
+package android.security {
+
+  public final class KeyChain {
+    ctor public KeyChain();
+    method public static void choosePrivateKeyAlias(android.app.Activity, android.security.KeyChainAliasCallback, java.lang.String[], java.security.Principal[], java.lang.String, int);
+    method public static java.security.cert.X509Certificate[] getCertificateChain(android.content.Context, java.lang.String) throws java.lang.InterruptedException, android.security.KeyChainException;
+    method public static java.security.PrivateKey getPrivateKey(android.content.Context, java.lang.String) throws java.lang.InterruptedException, android.security.KeyChainException;
+  }
+
+  public abstract interface KeyChainAliasCallback {
+    method public abstract void alias(java.lang.String);
+  }
+
+  public class KeyChainException extends java.lang.Exception {
+    ctor public KeyChainException();
+    ctor public KeyChainException(java.lang.String);
+    ctor public KeyChainException(java.lang.String, java.lang.Throwable);
+    ctor public KeyChainException(java.lang.Throwable);
+  }
+
+}
+
 package android.service.wallpaper {
 
   public abstract class WallpaperService extends android.app.Service {
diff --git a/core/java/android/nfc/INfcAdapter.aidl b/core/java/android/nfc/INfcAdapter.aidl
index d11fea0..dcbe9da 100644
--- a/core/java/android/nfc/INfcAdapter.aidl
+++ b/core/java/android/nfc/INfcAdapter.aidl
@@ -62,6 +62,4 @@
     int createLlcpSocket(int sap, int miu, int rw, int linearBufferLength);
     boolean disable();
     boolean enable();
-    String getProperties(String param);
-    int setProperties(String param, String value);
 }
diff --git a/core/java/android/nfc/INfcAdapterExtras.aidl b/core/java/android/nfc/INfcAdapterExtras.aidl
index 8677a50..3f8b856 100755
--- a/core/java/android/nfc/INfcAdapterExtras.aidl
+++ b/core/java/android/nfc/INfcAdapterExtras.aidl
@@ -29,6 +29,4 @@
     Bundle transceive(in byte[] data_in);
     int getCardEmulationRoute();
     void setCardEmulationRoute(int route);
-    void registerTearDownApdus(String packageName, in ApduList apdu);
-    void unregisterTearDownApdus(String packageName);
 }
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index d7bbab6..8ff5beb 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -232,7 +232,7 @@
         public static final int HONEYCOMB_MR1 = 12;
         
         /**
-         * Current development version.
+         * June 2011: Android 3.2.
          *
          * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve
          * screen compatibility mode, etc.</p>
@@ -244,7 +244,7 @@
          * large as the current screen will provide the user with a UI to
          * switch them in to screen size compatibility mode.</p>
          */
-        public static final int HONEYCOMB_MR2 = CUR_DEVELOPMENT;
+        public static final int HONEYCOMB_MR2 = 13;
 
         /**
          * Current version under development.
diff --git a/core/java/android/security/package.html b/core/java/android/security/package.html
deleted file mode 100644
index dfc6303..0000000
--- a/core/java/android/security/package.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<HTML>
-<BODY>
-Utilities for encrypting messages from hash functions.
-{@hide}
-</BODY>
-</HTML>
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 755ecf5..bc1ad3c 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -56,14 +56,7 @@
  *          setContentView(mTextureView);
  *      }
  *
- *      protected void onDestroy() {
- *          super.onDestroy();
- *
- *          mCamera.stopPreview();
- *          mCamera.release();
- *      }
- *
- *      public void onSurfaceTextureAvailable(SurfaceTexture surface) {
+ *      public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
  *          mCamera = Camera.open();
  *
  *          try {
@@ -77,6 +70,11 @@
  *      public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
  *          // Ignored, Camera does all the work for us
  *      }
+ *      
+ *      public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ *          mCamera.stopPreview();
+ *          mCamera.release();
+ *      }
  *  }
  * </pre>
  * 
@@ -155,6 +153,21 @@
         }
     }
 
+    @Override
+    protected void onDetachedFromWindow() {
+        super.onDetachedFromWindow();
+
+        if (isHardwareAccelerated() && mLayer != null) {
+            if (mListener != null) {
+                mListener.onSurfaceTextureDestroyed(mSurface);
+            }
+
+            mLayer.destroy();            
+            mSurface = null;
+            mLayer = null;
+        }
+    }
+
     /**
      * The layer type of a TextureView is ignored since a TextureView is always
      * considered to act as a hardware layer. The optional paint supplied to this
@@ -217,6 +230,9 @@
         super.onSizeChanged(w, h, oldw, oldh);
         if (mSurface != null) {
             nSetDefaultBufferSize(mSurface.mSurfaceTexture, getWidth(), getHeight());
+            if (mListener != null) {
+                mListener.onSurfaceTextureSizeChanged(mSurface, getWidth(), getHeight());
+            }
         }
     }
 
@@ -242,7 +258,7 @@
             mSurface.setOnFrameAvailableListener(mUpdateListener);
 
             if (mListener != null) {
-                mListener.onSurfaceTextureAvailable(mSurface);
+                mListener.onSurfaceTextureAvailable(mSurface, getWidth(), getHeight());
             }
         }
 
@@ -316,8 +332,10 @@
          * 
          * @param surface The surface returned by
          *                {@link android.view.TextureView#getSurfaceTexture()}
+         * @param width The width of the surface
+         * @param height The height of the surface
          */
-        public void onSurfaceTextureAvailable(SurfaceTexture surface);
+        public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height);
 
         /**
          * Invoked when the {@link SurfaceTexture}'s buffers size changed.
@@ -328,6 +346,15 @@
          * @param height The new height of the surface
          */
         public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height);
+
+        /**
+         * Invoked when the specified {@link SurfaceTexture} is about to be destroyed.
+         * After this method is invoked, no rendering should happen inside the surface
+         * texture.
+         * 
+         * @param surface The surface about to be destroyed
+         */
+        public void onSurfaceTextureDestroyed(SurfaceTexture surface);
     }
 
     private static native void nSetDefaultBufferSize(int surfaceTexture, int width, int height);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 30ac3f7..441cdc1 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -76,6 +76,7 @@
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Locale;
 import java.util.WeakHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
@@ -8665,7 +8666,7 @@
 
     /**
      * Resolving the layout direction. LTR is set initially.
-     * We are supposing here that the parent directionality will be resolved before its children
+     * We are supposing here that the parent directionality will be resolved before its children.
      */
     private void resolveLayoutDirection() {
         mPrivateFlags2 &= ~RESOLVED_LAYOUT_RTL;
@@ -8680,6 +8681,34 @@
             case LAYOUT_DIRECTION_RTL:
                 mPrivateFlags2 |= RESOLVED_LAYOUT_RTL;
                 break;
+            case LAYOUT_DIRECTION_LOCALE:
+                if(isLayoutDirectionRtl(Locale.getDefault())) {
+                    mPrivateFlags2 |= RESOLVED_LAYOUT_RTL;
+                }
+                break;
+            default:
+                // Nothing to do, LTR by default
+        }
+    }
+
+    /**
+     * Check if a Locale is corresponding to a RTL script.
+     *
+     * @param locale Locale to check
+     * @return true if a Locale is corresponding to a RTL script.
+     */
+    private static boolean isLayoutDirectionRtl(Locale locale) {
+        if (locale == null || locale.equals(Locale.ROOT)) return false;
+        // Be careful: this code will need to be changed when vertical scripts will be supported
+        // OR if ICU4C is updated to have the "likelySubtags" file
+        switch(Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
+            case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+                return false;
+            case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+            case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+                return true;
+            default:
+                return false;
         }
     }
 
diff --git a/core/java/android/view/ViewAncestor.java b/core/java/android/view/ViewAncestor.java
index d587788..17d7454 100644
--- a/core/java/android/view/ViewAncestor.java
+++ b/core/java/android/view/ViewAncestor.java
@@ -4364,17 +4364,16 @@
             final IAccessibilityInteractionConnectionCallback callback =
                 (IAccessibilityInteractionConnectionCallback) message.obj;
 
-            View root = ViewAncestor.this.mView;
-            if (root == null) {
-                return;
-            }
-
-            FindByAccessibilitytIdPredicate predicate = mFindByAccessibilityIdPredicate;
-            predicate.init(accessibilityId);
-
-            View target = root.findViewByPredicate(predicate);
-            if (target != null) {
-                AccessibilityNodeInfo info = target.createAccessibilityNodeInfo();
+            AccessibilityNodeInfo info = null;
+            try {
+                FindByAccessibilitytIdPredicate predicate = mFindByAccessibilityIdPredicate;
+                predicate.init(accessibilityId);
+                View root = ViewAncestor.this.mView;
+                View target = root.findViewByPredicate(predicate);
+                if (target != null) {
+                    info = target.createAccessibilityNodeInfo();
+                }
+            } finally {
                 try {
                     callback.setFindAccessibilityNodeInfoResult(info, interactionId);
                 } catch (RemoteException re) {
@@ -4399,13 +4398,14 @@
             final IAccessibilityInteractionConnectionCallback callback =
                 (IAccessibilityInteractionConnectionCallback) message.obj;
 
-            View root = ViewAncestor.this.mView;
-            if (root == null) {
-                return;
-            }
-            View target = root.findViewById(viewId);
-            if (target != null) {
-                AccessibilityNodeInfo info = target.createAccessibilityNodeInfo();
+            AccessibilityNodeInfo info = null;
+            try {
+                View root = ViewAncestor.this.mView;
+                View target = root.findViewById(viewId);
+                if (target != null) {
+                    info = target.createAccessibilityNodeInfo();
+                }
+            } finally {
                 try {
                     callback.setFindAccessibilityNodeInfoResult(info, interactionId);
                 } catch (RemoteException re) {
@@ -4434,32 +4434,32 @@
                 (IAccessibilityInteractionConnectionCallback) args.arg2;
             mPool.release(args);
 
-            View root = ViewAncestor.this.mView;
-            if (root == null) {
-                return;
-            }
-
-            ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList;
-            foundViews.clear();
-
-            root.findViewsWithText(foundViews, text);
-            if (foundViews.isEmpty()) {
-                return;
-            }
-
-            List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
-            infos.clear();
-
-            final int viewCount = foundViews.size();
-            for (int i = 0; i < viewCount; i++) {
-                View foundView = foundViews.get(i);
-                infos.add(foundView.createAccessibilityNodeInfo());
-            }
-
+            List<AccessibilityNodeInfo> infos = null;
             try {
-                callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
-            } catch (RemoteException re) {
-                /* ignore - the other side will time out */
+                View root = ViewAncestor.this.mView;
+
+                ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList;
+                foundViews.clear();
+
+                root.findViewsWithText(foundViews, text);
+                if (foundViews.isEmpty()) {
+                    return;
+                }
+
+                infos = mTempAccessibilityNodeInfoList;
+                infos.clear();
+
+                final int viewCount = foundViews.size();
+                for (int i = 0; i < viewCount; i++) {
+                    View foundView = foundViews.get(i);
+                    infos.add(foundView.createAccessibilityNodeInfo());
+                 }
+            } finally {
+                try {
+                    callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
+                } catch (RemoteException re) {
+                    /* ignore - the other side will time out */
+                }
             }
         }
 
@@ -4485,30 +4485,28 @@
                 (IAccessibilityInteractionConnectionCallback) args.arg1;
             mPool.release(args);
 
-            if (ViewAncestor.this.mView == null) {
-                return;
-            }
-
             boolean succeeded = false;
-            switch (action) {
-                case AccessibilityNodeInfo.ACTION_FOCUS: {
-                    succeeded = performActionFocus(accessibilityId);
-                } break;
-                case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: {
-                    succeeded = performActionClearFocus(accessibilityId);
-                } break;
-                case AccessibilityNodeInfo.ACTION_SELECT: {
-                    succeeded = performActionSelect(accessibilityId);
-                } break;
-                case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION: {
-                    succeeded = performActionClearSelection(accessibilityId);
-                } break;
-            }
-
             try {
-                callback.setPerformAccessibilityActionResult(succeeded, interactionId);
-            } catch (RemoteException re) {
-                /* ignore - the other side will time out */
+                switch (action) {
+                    case AccessibilityNodeInfo.ACTION_FOCUS: {
+                        succeeded = performActionFocus(accessibilityId);
+                    } break;
+                    case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: {
+                        succeeded = performActionClearFocus(accessibilityId);
+                    } break;
+                    case AccessibilityNodeInfo.ACTION_SELECT: {
+                        succeeded = performActionSelect(accessibilityId);
+                    } break;
+                    case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION: {
+                        succeeded = performActionClearSelection(accessibilityId);
+                    } break;
+                }
+            } finally {
+                try {
+                    callback.setPerformAccessibilityActionResult(succeeded, interactionId);
+                } catch (RemoteException re) {
+                    /* ignore - the other side will time out */
+                }
             }
         }
 
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index a4801fd..5fa65b4 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -870,6 +870,27 @@
     }
 
     @Override
+    public boolean equals(Object object) {
+        if (this == object) {
+            return true;
+        }
+        if (object == null) {
+            return false;
+        }
+        if (getClass() != object.getClass()) {
+            return false;
+        }
+        AccessibilityNodeInfo other = (AccessibilityNodeInfo) object;
+        if (mAccessibilityViewId != other.mAccessibilityViewId) {
+            return false;
+        }
+        if (mAccessibilityWindowId != other.mAccessibilityWindowId) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
diff --git a/core/java/android/webkit/HTML5VideoFullScreen.java b/core/java/android/webkit/HTML5VideoFullScreen.java
index 57cda97..44229a4 100644
--- a/core/java/android/webkit/HTML5VideoFullScreen.java
+++ b/core/java/android/webkit/HTML5VideoFullScreen.java
@@ -318,10 +318,12 @@
 
     @Override
     protected void switchProgressView(boolean playerBuffering) {
-        if (playerBuffering) {
-            mProgressView.setVisibility(View.VISIBLE);
-        } else {
-            mProgressView.setVisibility(View.GONE);
+        if (mProgressView != null) {
+            if (playerBuffering) {
+                mProgressView.setVisibility(View.VISIBLE);
+            } else {
+                mProgressView.setVisibility(View.GONE);
+            }
         }
         return;
     }
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 1014d7e..95e4880 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -422,6 +422,9 @@
      */
     private int mLastTouchX;
     private int mLastTouchY;
+    private int mStartTouchX;
+    private int mStartTouchY;
+    private float mAverageAngle;
 
     /**
      * Time of the last touch event.
@@ -1189,7 +1192,6 @@
         final ViewConfiguration configuration = ViewConfiguration.get(getContext());
         int slop = configuration.getScaledTouchSlop();
         mTouchSlopSquare = slop * slop;
-        mMinLockSnapReverseDistance = slop;
         slop = configuration.getScaledDoubleTapSlop();
         mDoubleTapSlopSquare = slop * slop;
         final float density = getContext().getResources().getDisplayMetrics().density;
@@ -5595,15 +5597,26 @@
         }
     }
 
-    // Here are the snap align logic:
-    // 1. If it starts nearly horizontally or vertically, snap align;
-    // 2. If there is a dramitic direction change, let it go;
-    // 3. If there is a same direction back and forth, lock it.
-
-    // adjustable parameters
-    private int mMinLockSnapReverseDistance;
-    private static final float MAX_SLOPE_FOR_DIAG = 1.5f;
-    private static final int MIN_BREAK_SNAP_CROSS_DISTANCE = 80;
+    /*
+     * Here is the snap align logic:
+     * 1. If it starts nearly horizontally or vertically, snap align;
+     * 2. If there is a dramitic direction change, let it go;
+     *
+     * Adjustable parameters. Angle is the radians on a unit circle, limited
+     * to quadrant 1. Values range from 0f (horizontal) to PI/2 (vertical)
+     */
+    private static final float HSLOPE_TO_START_SNAP = .1f;
+    private static final float HSLOPE_TO_BREAK_SNAP = .2f;
+    private static final float VSLOPE_TO_START_SNAP = 1.25f;
+    private static final float VSLOPE_TO_BREAK_SNAP = .95f;
+    /*
+     *  These values are used to influence the average angle when entering
+     *  snap mode. If is is the first movement entering snap, we set the average
+     *  to the appropriate ideal. If the user is entering into snap after the
+     *  first movement, then we average the average angle with these values.
+     */
+    private static final float ANGLE_VERT = 2f;
+    private static final float ANGLE_HORIZ = 0f;
 
     private boolean hitFocusedPlugin(int contentX, int contentY) {
         if (DebugFlags.WEB_VIEW) {
@@ -5709,6 +5722,12 @@
         return true;
     }
 
+    private float calculateDragAngle(int dx, int dy) {
+        dx = Math.abs(dx);
+        dy = Math.abs(dy);
+        return (float) Math.atan2(dy, dx);
+    }
+
     /*
      * Common code for single touch and multi-touch.
      * (x, y) denotes current focus point, which is the touch point for single touch
@@ -5954,16 +5973,17 @@
                     // if mZoomManager.supportsPanDuringZoom() is true.
                     final ScaleGestureDetector detector =
                       mZoomManager.getMultiTouchGestureDetector();
+                    mAverageAngle = calculateDragAngle(deltaX, deltaY);
                     if (detector == null || !detector.isInProgress()) {
                         // if it starts nearly horizontal or vertical, enforce it
-                        int ax = Math.abs(deltaX);
-                        int ay = Math.abs(deltaY);
-                        if (ax > MAX_SLOPE_FOR_DIAG * ay) {
+                        if (mAverageAngle < HSLOPE_TO_START_SNAP) {
                             mSnapScrollMode = SNAP_X;
                             mSnapPositive = deltaX > 0;
-                        } else if (ay > MAX_SLOPE_FOR_DIAG * ax) {
+                            mAverageAngle = ANGLE_HORIZ;
+                        } else if (mAverageAngle > VSLOPE_TO_START_SNAP) {
                             mSnapScrollMode = SNAP_Y;
                             mSnapPositive = deltaY > 0;
+                            mAverageAngle = ANGLE_VERT;
                         }
                     }
 
@@ -5983,35 +6003,30 @@
                 if (deltaX == 0 && deltaY == 0) {
                     keepScrollBarsVisible = done = true;
                 } else {
-                    if (mSnapScrollMode == SNAP_X || mSnapScrollMode == SNAP_Y) {
-                        int ax = Math.abs(deltaX);
-                        int ay = Math.abs(deltaY);
+                    mAverageAngle = (mAverageAngle +
+                            calculateDragAngle(deltaX, deltaY)) / 2;
+                    if (mSnapScrollMode != SNAP_NONE) {
+                        if (mSnapScrollMode == SNAP_Y) {
+                            // radical change means getting out of snap mode
+                            if (mAverageAngle < VSLOPE_TO_BREAK_SNAP) {
+                                mSnapScrollMode = SNAP_NONE;
+                            }
+                        }
                         if (mSnapScrollMode == SNAP_X) {
                             // radical change means getting out of snap mode
-                            if (ay > MAX_SLOPE_FOR_DIAG * ax
-                                    && ay > MIN_BREAK_SNAP_CROSS_DISTANCE) {
+                            if (mAverageAngle > HSLOPE_TO_BREAK_SNAP) {
                                 mSnapScrollMode = SNAP_NONE;
                             }
-                            // reverse direction means lock in the snap mode
-                            if (ax > MAX_SLOPE_FOR_DIAG * ay &&
-                                    (mSnapPositive
-                                    ? deltaX < -mMinLockSnapReverseDistance
-                                    : deltaX > mMinLockSnapReverseDistance)) {
-                                mSnapScrollMode |= SNAP_LOCK;
-                            }
-                        } else {
-                            // radical change means getting out of snap mode
-                            if (ax > MAX_SLOPE_FOR_DIAG * ay
-                                    && ax > MIN_BREAK_SNAP_CROSS_DISTANCE) {
-                                mSnapScrollMode = SNAP_NONE;
-                            }
-                            // reverse direction means lock in the snap mode
-                            if (ay > MAX_SLOPE_FOR_DIAG * ax &&
-                                    (mSnapPositive
-                                    ? deltaY < -mMinLockSnapReverseDistance
-                                    : deltaY > mMinLockSnapReverseDistance)) {
-                                mSnapScrollMode |= SNAP_LOCK;
-                            }
+                        }
+                    } else {
+                        if (mAverageAngle < HSLOPE_TO_START_SNAP) {
+                            mSnapScrollMode = SNAP_X;
+                            mSnapPositive = deltaX > 0;
+                            mAverageAngle = (mAverageAngle + ANGLE_HORIZ) / 2;
+                        } else if (mAverageAngle > VSLOPE_TO_START_SNAP) {
+                            mSnapScrollMode = SNAP_Y;
+                            mSnapPositive = deltaY > 0;
+                            mAverageAngle = (mAverageAngle + ANGLE_VERT) / 2;
                         }
                     }
                     if (mSnapScrollMode != SNAP_NONE) {
@@ -6021,13 +6036,9 @@
                             deltaX = 0;
                         }
                     }
+                    mLastTouchX = x;
+                    mLastTouchY = y;
                     if ((deltaX | deltaY) != 0) {
-                        if (deltaX != 0) {
-                            mLastTouchX = x;
-                        }
-                        if (deltaY != 0) {
-                            mLastTouchY = y;
-                        }
                         mHeldMotionless = MOTIONLESS_FALSE;
                     }
                     mLastTouchTime = eventTime;
@@ -6337,8 +6348,8 @@
 
     private void startTouch(float x, float y, long eventTime) {
         // Remember where the motion event started
-        mLastTouchX = Math.round(x);
-        mLastTouchY = Math.round(y);
+        mStartTouchX = mLastTouchX = Math.round(x);
+        mStartTouchY = mLastTouchY = Math.round(y);
         mLastTouchTime = eventTime;
         mVelocityTracker = VelocityTracker.obtain();
         mSnapScrollMode = SNAP_NONE;
@@ -9023,8 +9034,9 @@
     /**
      *  Update our cache with updatedText.
      *  @param updatedText  The new text to put in our cache.
+     *  @hide
      */
-    /* package */ void updateCachedTextfield(String updatedText) {
+    protected void updateCachedTextfield(String updatedText) {
         // Also place our generation number so that when we look at the cache
         // we recognize that it is up to date.
         nativeUpdateCachedTextfield(updatedText, mTextGeneration);
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index fe6fb2f..883656b 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -991,16 +991,16 @@
             settings.getUseFixedViewport() &&
             (mInitialZoomOverview || mInZoomOverview)) {
             // Keep mobile site's text wrap scale unchanged.  For mobile sites,
-            // the text wrap scale is the same as zoom overview scale, which is 1.0f.
-            if (exceedsMinScaleIncrement(mTextWrapScale, 1.0f) ||
-                    exceedsMinScaleIncrement(newZoomOverviewScale, 1.0f)) {
+            // the text wrap scale is the same as zoom overview scale.
+            if (exceedsMinScaleIncrement(mTextWrapScale, mDefaultScale) ||
+                    exceedsMinScaleIncrement(newZoomOverviewScale, mDefaultScale)) {
                 mTextWrapScale = getReadingLevelScale();
             } else {
                 mTextWrapScale = newZoomOverviewScale;
             }
         }
 
-        if (!mMinZoomScaleFixed) {
+        if (!mMinZoomScaleFixed || settings.getUseWideViewPort()) {
             mMinZoomScale = newZoomOverviewScale;
             mMaxZoomScale = Math.max(mMaxZoomScale, mMinZoomScale);
         }
@@ -1013,9 +1013,9 @@
         // Make sure mobile sites are correctly handled since mobile site will
         // change content width after rotating.
         boolean mobileSiteInOverview = mInZoomOverview &&
-                !exceedsMinScaleIncrement(newZoomOverviewScale, 1.0f);
+                !exceedsMinScaleIncrement(newZoomOverviewScale, mDefaultScale);
         if (!mWebView.drawHistory() &&
-            (scaleLessThanOverview ||
+            ((scaleLessThanOverview && settings.getUseWideViewPort())||
                 ((mInitialZoomOverview || mobileSiteInOverview) &&
                     scaleHasDiff && zoomOverviewWidthChanged))) {
             mInitialZoomOverview = false;
@@ -1071,7 +1071,8 @@
         updateZoomRange(viewState, viewSize.x, drawData.mMinPrefWidth);
         setupZoomOverviewWidth(drawData, mWebView.getViewWidth());
         final float overviewScale = getZoomOverviewScale();
-        if (!mMinZoomScaleFixed) {
+        WebSettings settings = mWebView.getSettings();
+        if (!mMinZoomScaleFixed || settings.getUseWideViewPort()) {
             mMinZoomScale = (mInitialScale > 0) ?
                     Math.min(mInitialScale, overviewScale) : overviewScale;
             mMaxZoomScale = Math.max(mMaxZoomScale, mMinZoomScale);
@@ -1079,8 +1080,6 @@
 
         if (!mWebView.drawHistory()) {
             float scale;
-            WebSettings settings = mWebView.getSettings();
-
             if (mInitialScale > 0) {
                 scale = mInitialScale;
             } else if (viewState.mViewScale > 0) {
diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java
index 9834485..bda82a3 100644
--- a/core/java/android/widget/GridLayout.java
+++ b/core/java/android/widget/GridLayout.java
@@ -536,70 +536,76 @@
         return margin == UNDEFINED ? getDefaultMarginValue(view, lp, leading, horizontal) : margin;
     }
 
-    private static boolean isUndefined(Interval span) {
-        return span.min == UNDEFINED || span.max == UNDEFINED;
+    private static int valueIfDefined(int value, int defaultValue) {
+        return (value != UNDEFINED) ? value : defaultValue;
     }
 
+    // install default indices for cells that don't define them
     private void validateLayoutParams() {
-        // install default indices for cells if *none* are defined
-        if (mHorizontalAxis.maxIndex1() == UNDEFINED || (mVerticalAxis.maxIndex1() == UNDEFINED)) {
-            boolean horizontal = mOrientation == HORIZONTAL;
-            int count = horizontal ? mHorizontalAxis.count : mVerticalAxis.count;
-            if (count == UNDEFINED) {
-                count = Integer.MAX_VALUE;
-            }
-            int x = 0;
-            int y = 0;
-            int maxSize = 0;
-            for (int i = 0, size = getChildCount(); i < size; i++) {
-                LayoutParams lp = getLayoutParams1(getChildAt(i));
+        new Object() {
+            public int maxSize = 0;
 
-                Interval hSpan = lp.columnGroup.span;
-                int cellWidth = hSpan.size();
-
-                Interval vSpan = lp.rowGroup.span;
-                int cellHeight = vSpan.size();
-
-                if (horizontal) {
-                    if (x + cellWidth > count) {
-                        x = 0;
-                        y += maxSize;
-                        maxSize = 0;
-                    }
+            private int valueIfDefined2(int value, int defaultValue) {
+                if (value != UNDEFINED) {
+                    maxSize = 0;
+                    return value;
                 } else {
-                    if (y + cellHeight > count) {
-                        y = 0;
-                        x += maxSize;
-                        maxSize = 0;
+                    return defaultValue;
+                }
+            }
+
+            {
+                final boolean horizontal = (mOrientation == HORIZONTAL);
+                final int axis = horizontal ? mHorizontalAxis.count : mVerticalAxis.count;
+                final int count = valueIfDefined(axis, Integer.MAX_VALUE);
+
+                int row = 0;
+                int col = 0;
+                for (int i = 0, N = getChildCount(); i < N; i++) {
+                    LayoutParams lp = getLayoutParams1(getChildAt(i));
+
+                    Group colGroup = lp.columnGroup;
+                    Interval cols = colGroup.span;
+                    int colSpan = cols.size();
+
+                    Group rowGroup = lp.rowGroup;
+                    Interval rows = rowGroup.span;
+                    int rowSpan = rows.size();
+
+                    if (horizontal) {
+                        row = valueIfDefined2(rows.min, row);
+
+                        int newCol = valueIfDefined(cols.min, (col + colSpan > count) ? 0 : col);
+                        if (newCol < col) {
+                            row += maxSize;
+                            maxSize = 0;
+                        }
+                        col = newCol;
+                        maxSize = max(maxSize, rowSpan);
+                    } else {
+                        col = valueIfDefined2(cols.min, col);
+
+                        int newRow = valueIfDefined(rows.min, (row + rowSpan > count) ? 0 : row);
+                        if (newRow < row) {
+                            col += maxSize;
+                            maxSize = 0;
+                        }
+                        row = newRow;
+                        maxSize = max(maxSize, colSpan);
+                    }
+
+                    lp.setColumnGroupSpan(new Interval(col, col + colSpan));
+                    lp.setRowGroupSpan(new Interval(row, row + rowSpan));
+
+                    if (horizontal) {
+                        col = col + colSpan;
+                    } else {
+                        row = row + rowSpan;
                     }
                 }
-                lp.setHorizontalGroupSpan(new Interval(x, x + cellWidth));
-                lp.setVerticalGroupSpan(new Interval(y, y + cellHeight));
-
-                if (horizontal) {
-                    x = x + cellWidth;
-                } else {
-                    y = y + cellHeight;
-                }
-                maxSize = max(maxSize, horizontal ? cellHeight : cellWidth);
             }
-        } else {
-            /*
-            At least one row and one column index have been defined.
-            Assume missing row/cols are in error and set them to zero so that
-            they will display top/left and the developer can add the right indices.
-            Without this UNDEFINED would cause ArrayIndexOutOfBoundsException.
-            */
-            for (int i = 0, size = getChildCount(); i < size; i++) {
-                LayoutParams lp = getLayoutParams1(getChildAt(i));
-                if (isUndefined(lp.columnGroup.span)) {
-                    lp.setHorizontalGroupSpan(LayoutParams.DEFAULT_SPAN);
-                }
-                if (isUndefined(lp.rowGroup.span)) {
-                    lp.setVerticalGroupSpan(LayoutParams.DEFAULT_SPAN);
-                }
-            }
-        }
+        };
+        invalidateStructure();
     }
 
     private void invalidateStructure() {
@@ -927,13 +933,11 @@
             this.horizontal = horizontal;
         }
 
-        private int maxIndex(boolean internal) {
+        private int maxIndex() {
             // note the number Integer.MIN_VALUE + 1 comes up in undefined cells
             int count = -1;
             for (int i = 0, size = getChildCount(); i < size; i++) {
-                LayoutParams params = internal ?
-                        getLayoutParams1(getChildAt(i)) :
-                        getLayoutParams(getChildAt(i));
+                LayoutParams params = getLayoutParams(getChildAt(i));
                 Group g = horizontal ? params.columnGroup : params.rowGroup;
                 count = max(count, g.span.min);
                 count = max(count, g.span.max);
@@ -941,13 +945,9 @@
             return count == -1 ? UNDEFINED : count;
         }
 
-        private int maxIndex1() {
-            return maxIndex(true);
-        }
-
         public int getCount() {
-            if (!countWasExplicitySet && !countValid) {
-                count = max(0, maxIndex(false)); // if there are no cells, the count is zero
+            if (!countValid) {
+                count = max(0, maxIndex()); // if there are no cells, the count is zero
                 countValid = true;
             }
             return count;
@@ -1391,7 +1391,7 @@
 
         private float[] getWeights() {
             if (weights == null) {
-                int N = getCount() + 1;
+                int N = getCount();
                 weights = new float[N];
             }
             computeWeights();
@@ -1424,7 +1424,7 @@
             float[] weights = getWeights();
             float totalWeight = sum(weights);
 
-            if (totalWeight == 0f) {
+            if (totalWeight == 0f && weights.length > 0) {
                 weights[weights.length - 1] = 1;
                 totalWeight = 1;
             }
@@ -1432,11 +1432,12 @@
             int[] locations = getLocations();
             int cumulativeDelta = 0;
 
-            for (int i = 0; i < locations.length; i++) {
+            // note |weights| = |locations| - 1
+            for (int i = 0; i < weights.length; i++) {
                 float weight = weights[i];
                 int delta = (int) (totalDelta * weight / totalWeight);
                 cumulativeDelta += delta;
-                locations[i] = mins[i] + cumulativeDelta;
+                locations[i + 1] = mins[i + 1] + cumulativeDelta;
 
                 totalDelta -= delta;
                 totalWeight -= weight;
@@ -1534,22 +1535,22 @@
         private static final int DEFAULT_MARGIN = UNDEFINED;
         private static final int DEFAULT_ROW = UNDEFINED;
         private static final int DEFAULT_COLUMN = UNDEFINED;
-        private static final Interval DEFAULT_SPAN = new Interval(0, 1);
+        private static final Interval DEFAULT_SPAN = new Interval(UNDEFINED, UNDEFINED + 1);
         private static final int DEFAULT_SPAN_SIZE = DEFAULT_SPAN.size();
-        private static final Alignment DEFAULT_HORIZONTAL_ALIGNMENT = LEFT;
-        private static final Alignment DEFAULT_VERTCIAL_ALGIGNMENT = BASELINE;
-        private static final Group DEFAULT_HORIZONTAL_GROUP =
-                new Group(DEFAULT_SPAN, DEFAULT_HORIZONTAL_ALIGNMENT);
-        private static final Group DEFAULT_VERTICAL_GROUP =
-                new Group(DEFAULT_SPAN, DEFAULT_VERTCIAL_ALGIGNMENT);
+        private static final Alignment DEFAULT_COLUMN_ALIGNMENT = LEFT;
+        private static final Alignment DEFAULT_ROW_ALIGNMENT = BASELINE;
+        private static final Group DEFAULT_COLUMN_GROUP =
+                new Group(DEFAULT_SPAN, DEFAULT_COLUMN_ALIGNMENT);
+        private static final Group DEFAULT_ROW_GROUP =
+                new Group(DEFAULT_SPAN, DEFAULT_ROW_ALIGNMENT);
         private static final int DEFAULT_WEIGHT_0 = 0;
         private static final int DEFAULT_WEIGHT_1 = 1;
 
         // Misc
 
         private static final Rect CONTAINER_BOUNDS = new Rect(0, 0, 2, 2);
-        private static final Alignment[] HORIZONTAL_ALIGNMENTS = { LEFT, CENTER, RIGHT };
-        private static final Alignment[] VERTICAL_ALIGNMENTS = { TOP, CENTER, BOTTOM };
+        private static final Alignment[] COLUMN_ALIGNMENTS = { LEFT, CENTER, RIGHT };
+        private static final Alignment[] ROW_ALIGNMENTS = { TOP, CENTER, BOTTOM };
 
         // TypedArray indices
 
@@ -1623,7 +1624,7 @@
          * Constructs a new LayoutParams with default values as defined in {@link LayoutParams}.
          */
         public LayoutParams() {
-            this(DEFAULT_HORIZONTAL_GROUP, DEFAULT_VERTICAL_GROUP);
+            this(DEFAULT_ROW_GROUP, DEFAULT_COLUMN_GROUP);
         }
 
         // Copying constructors
@@ -1714,23 +1715,23 @@
 
         // Gravity. For conversion from the static the integers defined in the Gravity class,
         // use Gravity.apply() to apply gravity to a view of zero size and see where it ends up.
-        private static Alignment getHorizontalAlignment(int gravity, int width) {
+        private static Alignment getColumnAlignment(int gravity, int width) {
             Rect r = new Rect(0, 0, 0, 0);
             Gravity.apply(gravity, 0, 0, CONTAINER_BOUNDS, r);
 
-            boolean fill = width == MATCH_PARENT;
-            Alignment defaultAlignment = fill ? FILL : DEFAULT_HORIZONTAL_ALIGNMENT;
-            return getAlignment(HORIZONTAL_ALIGNMENTS, FILL, r.left, r.right,
+            boolean fill = (width == MATCH_PARENT);
+            Alignment defaultAlignment = fill ? FILL : DEFAULT_COLUMN_ALIGNMENT;
+            return getAlignment(COLUMN_ALIGNMENTS, FILL, r.left, r.right,
                     !definesHorizontal(gravity), defaultAlignment);
         }
 
-        private static Alignment getVerticalAlignment(int gravity, int height) {
+        private static Alignment getRowAlignment(int gravity, int height) {
             Rect r = new Rect(0, 0, 0, 0);
             Gravity.apply(gravity, 0, 0, CONTAINER_BOUNDS, r);
 
-            boolean fill = height == MATCH_PARENT;
-            Alignment defaultAlignment = fill ? FILL : DEFAULT_VERTCIAL_ALGIGNMENT;
-            return getAlignment(VERTICAL_ALIGNMENTS, FILL, r.top, r.bottom,
+            boolean fill = (height == MATCH_PARENT);
+            Alignment defaultAlignment = fill ? FILL : DEFAULT_ROW_ALIGNMENT;
+            return getAlignment(ROW_ALIGNMENTS, FILL, r.top, r.bottom,
                     !definesVertical(gravity), defaultAlignment);
         }
 
@@ -1746,13 +1747,13 @@
                 int column = a.getInteger(COLUMN, DEFAULT_COLUMN);
                 int columnSpan = a.getInteger(COLUMN_SPAN, DEFAULT_SPAN_SIZE);
                 Interval hSpan = new Interval(column, column + columnSpan);
-                this.columnGroup = new Group(hSpan, getHorizontalAlignment(gravity, width));
+                this.columnGroup = new Group(hSpan, getColumnAlignment(gravity, width));
                 this.columnWeight = a.getFloat(COLUMN_WEIGHT, getDefaultWeight(width));
 
                 int row = a.getInteger(ROW, DEFAULT_ROW);
                 int rowSpan = a.getInteger(ROW_SPAN, DEFAULT_SPAN_SIZE);
                 Interval vSpan = new Interval(row, row + rowSpan);
-                this.rowGroup = new Group(vSpan, getVerticalAlignment(gravity, height));
+                this.rowGroup = new Group(vSpan, getRowAlignment(gravity, height));
                 this.rowWeight = a.getFloat(ROW_WEIGHT, getDefaultWeight(height));
             } finally {
                 a.recycle();
@@ -1768,8 +1769,8 @@
          * @attr ref android.R.styleable#GridLayout_Layout_layout_gravity
          */
         public void setGravity(int gravity) {
-            columnGroup = columnGroup.copyWriteAlignment(getHorizontalAlignment(gravity, width));
-            rowGroup = rowGroup.copyWriteAlignment(getVerticalAlignment(gravity, height));
+            columnGroup = columnGroup.copyWriteAlignment(getColumnAlignment(gravity, width));
+            rowGroup = rowGroup.copyWriteAlignment(getRowAlignment(gravity, height));
         }
 
         @Override
@@ -1778,11 +1779,11 @@
             this.height = attributes.getLayoutDimension(heightAttr, DEFAULT_HEIGHT);
         }
 
-        private void setVerticalGroupSpan(Interval span) {
+        private void setRowGroupSpan(Interval span) {
             rowGroup = rowGroup.copyWriteSpan(span);
         }
 
-        private void setHorizontalGroupSpan(Interval span) {
+        private void setColumnGroupSpan(Interval span) {
             columnGroup = columnGroup.copyWriteSpan(span);
         }
     }
@@ -2073,30 +2074,30 @@
         /**
          * Construct a new Group, {@code group}, where:
          * <ul>
-         *     <li> {@code group.span = [min, max]} </li>
+         *     <li> {@code group.span = [start, start + size]} </li>
          *     <li> {@code group.alignment = alignment} </li>
          * </ul>
          *
-         * @param min       the minimum
-         * @param max       the maximum
+         * @param start     the start
+         * @param size      the size
          * @param alignment the alignment
          */
-        public Group(int min, int max, Alignment alignment) {
-            this(new Interval(min, max), alignment);
+        public Group(int start, int size, Alignment alignment) {
+            this(new Interval(start, start + size), alignment);
         }
 
         /**
          * Construct a new Group, {@code group}, where:
          * <ul>
-         *     <li> {@code group.span = [min, min + 1]} </li>
+         *     <li> {@code group.span = [start, start + 1]} </li>
          *     <li> {@code group.alignment = alignment} </li>
          * </ul>
          *
-         * @param min       the minimum
+         * @param start     the start index
          * @param alignment the alignment
          */
-        public Group(int min, Alignment alignment) {
-            this(min, min + 1, alignment);
+        public Group(int start, Alignment alignment) {
+            this(start, 1, alignment);
         }
 
         private Group copyWriteSpan(Interval span) {
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index c3b1098..8d5df6f 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -156,9 +156,7 @@
         mContextDisplayMode = mActionView.isSplitActionBar() ?
                 CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
 
-        TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar);
-        mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
-        a.recycle();
+        mContentHeight = mActionView.getContentHeight();
     }
 
     public void onConfigurationChanged(Configuration newConfig) {
@@ -179,9 +177,7 @@
         mActionView.setCollapsable(!mHasEmbeddedTabs &&
                 getNavigationMode() == NAVIGATION_MODE_TABS);
 
-        TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar);
-        mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
-        a.recycle();
+        mContentHeight = mActionView.getContentHeight();
 
         if (mTabScrollView != null) {
             mTabScrollView.getLayoutParams().height = mContentHeight;
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 55849e5..e3286dd 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -273,6 +273,10 @@
         requestLayout();
     }
 
+    public int getContentHeight() {
+        return mContentHeight;
+    }
+
     public void setSplitActionBar(boolean splitActionBar) {
         if (mSplitActionBar != splitActionBar) {
             if (mMenuView != null) {
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 4207d70..82a3b8a 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1652,25 +1652,54 @@
   <public type="attr" name="resizeMode" id="0x01010363" />
 
 <!-- ===============================================================
-     Resources added in version 13 of the platform (Honeycomb MR 2)
+     Resources added in version 13 of the platform (Honeycomb MR 2 / 3.2)
      =============================================================== -->
   <eat-comment />
   <public type="attr" name="requiresSmallestWidthDp" id="0x01010364" />
-  <public type="attr" name="compatibleWidthLimitDp" />
-  <public type="attr" name="largestWidthLimitDp" />
+  <public type="attr" name="compatibleWidthLimitDp" id="0x01010365" />
+  <public type="attr" name="largestWidthLimitDp" id="0x01010366" />
 
-  <public type="style" name="Theme.Holo.Light.NoActionBar" />
-  <public type="style" name="Theme.Holo.Light.NoActionBar.Fullscreen" />
+  <public type="style" name="Theme.Holo.Light.NoActionBar" id="0x010300f0" />
+  <public type="style" name="Theme.Holo.Light.NoActionBar.Fullscreen" id="0x010300f1" />
 
-  <public type="style" name="Widget.ActionBar.TabView" />
-  <public type="style" name="Widget.ActionBar.TabText" />
-  <public type="style" name="Widget.ActionBar.TabBar" />
-  <public type="style" name="Widget.Holo.ActionBar.TabView" />
-  <public type="style" name="Widget.Holo.ActionBar.TabText" />
-  <public type="style" name="Widget.Holo.ActionBar.TabBar" />
-  <public type="style" name="Widget.Holo.Light.ActionBar.TabView" />
-  <public type="style" name="Widget.Holo.Light.ActionBar.TabText" />
-  <public type="style" name="Widget.Holo.Light.ActionBar.TabBar" />
+  <public type="style" name="Widget.ActionBar.TabView" id="0x010300f2" />
+  <public type="style" name="Widget.ActionBar.TabText" id="0x010300f3" />
+  <public type="style" name="Widget.ActionBar.TabBar" id="0x010300f4" />
+  <public type="style" name="Widget.Holo.ActionBar.TabView" id="0x010300f5" />
+  <public type="style" name="Widget.Holo.ActionBar.TabText" id="0x010300f6" />
+  <public type="style" name="Widget.Holo.ActionBar.TabBar" id="0x010300f7" />
+  <public type="style" name="Widget.Holo.Light.ActionBar.TabView" id="0x010300f8" />
+  <public type="style" name="Widget.Holo.Light.ActionBar.TabText" id="0x010300f9" />
+  <public type="style" name="Widget.Holo.Light.ActionBar.TabBar" id="0x010300fa" />
+  <public type="style" name="TextAppearance.Holo" id="0x010300fb" />
+  <public type="style" name="TextAppearance.Holo.Inverse" id="0x010300fc" />
+  <public type="style" name="TextAppearance.Holo.Large" id="0x010300fd" />
+  <public type="style" name="TextAppearance.Holo.Large.Inverse" id="0x010300fe" />
+  <public type="style" name="TextAppearance.Holo.Medium" id="0x010300ff" />
+  <public type="style" name="TextAppearance.Holo.Medium.Inverse" id="0x01030100" />
+  <public type="style" name="TextAppearance.Holo.Small" id="0x01030101" />
+  <public type="style" name="TextAppearance.Holo.Small.Inverse" id="0x01030102" />
+  <public type="style" name="TextAppearance.Holo.SearchResult.Title" id="0x01030103" />
+  <public type="style" name="TextAppearance.Holo.SearchResult.Subtitle" id="0x01030104" />
+  <public type="style" name="TextAppearance.Holo.Widget" id="0x01030105" />
+  <public type="style" name="TextAppearance.Holo.Widget.Button" id="0x01030106" />
+  <public type="style" name="TextAppearance.Holo.Widget.IconMenu.Item" id="0x01030107" />
+  <public type="style" name="TextAppearance.Holo.Widget.TabWidget" id="0x01030108" />
+  <public type="style" name="TextAppearance.Holo.Widget.TextView" id="0x01030109" />
+  <public type="style" name="TextAppearance.Holo.Widget.TextView.PopupMenu" id="0x0103010a" />
+  <public type="style" name="TextAppearance.Holo.Widget.DropDownHint" id="0x0103010b" />
+  <public type="style" name="TextAppearance.Holo.Widget.DropDownItem" id="0x0103010c" />
+  <public type="style" name="TextAppearance.Holo.Widget.TextView.SpinnerItem" id="0x0103010d" />
+  <public type="style" name="TextAppearance.Holo.Widget.EditText" id="0x0103010e" />
+  <public type="style" name="TextAppearance.Holo.Widget.PopupMenu" id="0x0103010f" />
+  <public type="style" name="TextAppearance.Holo.Widget.PopupMenu.Large" id="0x01030110" />
+  <public type="style" name="TextAppearance.Holo.Widget.PopupMenu.Small" id="0x01030111" />
+  <public type="style" name="TextAppearance.Holo.Widget.ActionBar.Title" id="0x01030112" />
+  <public type="style" name="TextAppearance.Holo.Widget.ActionBar.Subtitle" id="0x01030113" />
+  <public type="style" name="TextAppearance.Holo.Widget.ActionMode.Title" id="0x01030114" />
+  <public type="style" name="TextAppearance.Holo.Widget.ActionMode.Subtitle" id="0x01030115" />
+  <public type="style" name="TextAppearance.Holo.WindowTitle" id="0x01030116" />
+  <public type="style" name="TextAppearance.Holo.DialogWindowTitle" id="0x01030117" />
 
 <!-- ===============================================================
      Resources added in version 14 of the platform (Ice Cream Sandwich)
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index dc86626..19b05c9 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1783,7 +1783,6 @@
         <item name="android:gravity">center</item>
         <item name="android:paddingLeft">16dip</item>
         <item name="android:paddingRight">16dip</item>
-        <item name="android:minHeight">56dip</item>
         <item name="android:scaleType">center</item>
     </style>
 
diff --git a/data/sounds/AllAudio.mk b/data/sounds/AllAudio.mk
index 4e7a403..2e18a10 100644
--- a/data/sounds/AllAudio.mk
+++ b/data/sounds/AllAudio.mk
@@ -18,3 +18,5 @@
 $(call inherit-product, frameworks/base/data/sounds/AudioPackage2.mk)
 $(call inherit-product, frameworks/base/data/sounds/AudioPackage3.mk)
 $(call inherit-product, frameworks/base/data/sounds/AudioPackage4.mk)
+$(call inherit-product, frameworks/base/data/sounds/AudioPackage5.mk)
+$(call inherit-product, frameworks/base/data/sounds/AudioPackage6.mk)
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index 8a92cd6..612ff93 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -1988,7 +1988,8 @@
                                   String16* outName,
                                   const String16* defType = NULL,
                                   const String16* defPackage = NULL,
-                                  const char** outErrorMsg = NULL);
+                                  const char** outErrorMsg = NULL,
+                                  bool* outPublicOnly = NULL);
 
     static bool stringToInt(const char16_t* s, size_t len, Res_value* outValue);
     static bool stringToFloat(const char16_t* s, size_t len, Res_value* outValue);
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index 39d65be..4f1596d 100644
--- a/keystore/java/android/security/KeyChain.java
+++ b/keystore/java/android/security/KeyChain.java
@@ -76,8 +76,6 @@
  * avoid prompting the user with {@link #choosePrivateKeyAlias
  * choosePrivateKeyAlias} on subsequent connections. If the alias is
  * no longer valid, null will be returned on lookups using that value
- *
- * @hide to be unhidden as part of KeyChain API
  */
 // TODO reference intent for credential installation when public
 public final class KeyChain {
diff --git a/keystore/java/android/security/KeyChainAliasCallback.java b/keystore/java/android/security/KeyChainAliasCallback.java
index daa348b..fc9e64b 100644
--- a/keystore/java/android/security/KeyChainAliasCallback.java
+++ b/keystore/java/android/security/KeyChainAliasCallback.java
@@ -22,8 +22,6 @@
 /**
  * The KeyChainAliasCallback is the callback for {@link
  * KeyChain#choosePrivateKeyAlias}.
- *
- * @hide to be unhidden as part of KeyChain API
  */
 public interface KeyChainAliasCallback {
 
diff --git a/keystore/java/android/security/KeyChainException.java b/keystore/java/android/security/KeyChainException.java
index 3953f58..ef97ffb 100644
--- a/keystore/java/android/security/KeyChainException.java
+++ b/keystore/java/android/security/KeyChainException.java
@@ -18,8 +18,6 @@
 
 /**
  * Thrown on problems accessing the {@link KeyChain}.
- *
- * @hide to be unhidden as part of KeyChain API
  */
 public class KeyChainException extends Exception {
 
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 4a6a3db..cb6c246 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -2663,6 +2663,9 @@
                     goto nope;
                 }
             }
+            if (outTypeSpecFlags) {
+                *outTypeSpecFlags = ResTable_typeSpec::SPEC_PUBLIC;
+            }
             return m->id;
 nope:
             ;
@@ -2677,6 +2680,9 @@
                          index);
                     return 0;
                 }
+                if (outTypeSpecFlags) {
+                    *outTypeSpecFlags = ResTable_typeSpec::SPEC_PUBLIC;
+                }
                 return  Res_MAKEARRAY(index);
             }
         }
@@ -2687,6 +2693,8 @@
         return 0;
     }
 
+    bool fakePublic = false;
+
     // Figure out the package and type we are looking in...
 
     const char16_t* packageEnd = NULL;
@@ -2698,7 +2706,13 @@
         else if (*p == '/') typeEnd = p;
         p++;
     }
-    if (*name == '@') name++;
+    if (*name == '@') {
+        name++;
+        if (*name == '*') {
+            fakePublic = true;
+            name++;
+        }
+    }
     if (name >= nameEnd) {
         return 0;
     }
@@ -2803,6 +2817,9 @@
                 if (dtohl(entry->key.index) == (size_t)ei) {
                     if (outTypeSpecFlags) {
                         *outTypeSpecFlags = typeConfigs->typeSpecFlags[i];
+                        if (fakePublic) {
+                            *outTypeSpecFlags |= ResTable_typeSpec::SPEC_PUBLIC;
+                        }
                     }
                     return Res_MAKEID(group->id-1, ti, i);
                 }
@@ -2819,7 +2836,8 @@
                                  String16* outName,
                                  const String16* defType,
                                  const String16* defPackage,
-                                 const char** outErrorMsg)
+                                 const char** outErrorMsg,
+                                 bool* outPublicOnly)
 {
     const char16_t* packageEnd = NULL;
     const char16_t* typeEnd = NULL;
@@ -2836,6 +2854,16 @@
     p = refStr;
     if (*p == '@') p++;
 
+    if (outPublicOnly != NULL) {
+        *outPublicOnly = true;
+    }
+    if (*p == '*') {
+        p++;
+        if (outPublicOnly != NULL) {
+            *outPublicOnly = false;
+        }
+    }
+
     if (packageEnd) {
         *outPackage = String16(p, packageEnd-p);
         p = packageEnd+1;
diff --git a/media/libmedia/MediaScanner.cpp b/media/libmedia/MediaScanner.cpp
index 28c86426..45bdff4 100644
--- a/media/libmedia/MediaScanner.cpp
+++ b/media/libmedia/MediaScanner.cpp
@@ -89,7 +89,7 @@
     if (pathRemaining >= 8 /* strlen(".nomedia") */ ) {
         strcpy(fileSpot, ".nomedia");
         if (access(path, F_OK) == 0) {
-            LOGD("found .nomedia, setting noMedia flag\n");
+            LOGV("found .nomedia, setting noMedia flag\n");
             noMedia = true;
         }
 
diff --git a/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java b/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java
index 6001be9..7775dbf 100644
--- a/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java
+++ b/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java
@@ -207,20 +207,4 @@
     public NfcExecutionEnvironment getEmbeddedExecutionEnvironment() {
         return sEmbeddedEe;
     }
-
-    public void registerTearDownApdus(String packageName, ApduList apdus) {
-        try {
-            sService.registerTearDownApdus(packageName, apdus);
-        } catch (RemoteException e) {
-            attemptDeadServiceRecovery(e);
-        }
-    }
-
-    public void unregisterTearDownApdus(String packageName) {
-        try {
-            sService.unregisterTearDownApdus(packageName);
-        } catch (RemoteException e) {
-            attemptDeadServiceRecovery(e);
-        }
-    }
 }
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 86ffb4d..91a8855 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -16,25 +16,25 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <style name="TextAppearance.StatusBar.Title" parent="@android:style/TextAppearance.StatusBar">
+    <style name="TextAppearance.StatusBar.Title" parent="@*android:style/TextAppearance.StatusBar">
         <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
         <item name="android:textStyle">bold</item>
         <item name="android:textColor">?android:attr/textColorPrimary</item>
     </style>
 
     <style name="TextAppearance.StatusBar.IntruderAlert"
-        parent="@android:style/TextAppearance.StatusBar">
+        parent="@*android:style/TextAppearance.StatusBar">
     </style>
 
     <style name="TextAppearance.StatusBar.SystemPanel"
-        parent="@android:style/TextAppearance.StatusBar">
+        parent="@*android:style/TextAppearance.StatusBar">
         <item name="android:textAppearance">?android:attr/textAppearance</item>
         <item name="android:textStyle">normal</item>
         <item name="android:textColor">#FF808080</item>
     </style>
 
     <style name="TextAppearance.StatusBar.TextButton"
-        parent="@android:style/TextAppearance.StatusBar">
+        parent="@*android:style/TextAppearance.StatusBar">
         <item name="android:textAppearance">?android:attr/textAppearance</item>
         <item name="android:textStyle">normal</item>
         <item name="android:textColor">#FFFFFFFF</item>
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
index 318cf37..abd87b8 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
@@ -125,8 +125,6 @@
                 }
             }
 
-            // Not sure if this is needed in CDMALTE phone.
-            // mDataRoaming = regCodeIsRoaming(regState);
             mLteSS.setRadioTechnology(type);
             mLteSS.setState(regCodeToServiceState(regState));
         } else {
@@ -212,6 +210,12 @@
 
         if (DBG) log("pollStateDone: oldSS=[" + ss + "] newSS=[" + newSS + "]");
 
+        if (cm.getSimState().isSIMReady()) {
+            // If CSIM is used, check roaming status according to SID/NID
+            // on EFcdmahome record.
+            newSS.setRoaming(!isInHomeSidNid(newSS.getSystemId(), newSS.getNetworkId()));
+        }
+
         boolean hasRegistered = ss.getState() != ServiceState.STATE_IN_SERVICE
                 && newSS.getState() == ServiceState.STATE_IN_SERVICE;
 
@@ -464,6 +468,33 @@
         return provisioningState;
     }
 
+    /**
+     * Check whether the specified SID and NID pair appears in the HOME SID/NID list
+     * read from NV or SIM.
+     *
+     * @return true if provided sid/nid pair belongs to operator's home network.
+     */
+    private boolean isInHomeSidNid(int sid, int nid) {
+        // if SID/NID is not available, do not declare roaming.
+        if (isSidsAllZeros()) return true;
+
+        // length of SID/NID shold be same
+        if (mHomeSystemId.length != mHomeNetworkId.length) return true;
+
+        if (sid == 0) return true;
+
+        for (int i = 0; i < mHomeSystemId.length; i++) {
+            // Use SID only if NID is a reserved value.
+            // SID 0 and NID 0 and 65535 are reserved. (C.0005 2.6.5.2)
+            if ((mHomeSystemId[i] == sid) &&
+                ((mHomeNetworkId[i] == 0) || (mHomeNetworkId[i] == 65535) ||
+                 (nid == 0) || (nid == 65535) || (mHomeNetworkId[i] == nid))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     @Override
     protected void log(String s) {
         Log.d(LOG_TAG, "[CdmaLteSST] " + s);
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index 5ebdd22..e41985e 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -130,8 +130,8 @@
     private String curPlmn = null;
 
     protected String mMdn;
-    private int mHomeSystemId[] = null;
-    private int mHomeNetworkId[] = null;
+    protected int mHomeSystemId[] = null;
+    protected int mHomeNetworkId[] = null;
     protected String mMin;
     protected String mPrlVersion;
     protected boolean mIsMinInfoReady = false;
@@ -1481,7 +1481,7 @@
         }
     }
 
-    private boolean isSidsAllZeros() {
+    protected boolean isSidsAllZeros() {
         if (mHomeSystemId != null) {
             for (int i=0; i < mHomeSystemId.length; i++) {
                 if (mHomeSystemId[i] != 0) {
diff --git a/tests/BiDiTests/Android b/tests/BiDiTests/Android
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/BiDiTests/Android
diff --git a/tests/BiDiTests/AndroidManifest.xml b/tests/BiDiTests/AndroidManifest.xml
index ad27a62..135c5dd 100644
--- a/tests/BiDiTests/AndroidManifest.xml
+++ b/tests/BiDiTests/AndroidManifest.xml
@@ -57,6 +57,13 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".BiDiTestLinearLayoutLocaleActivity"
+                  android:windowSoftInputMode="stateAlwaysHidden">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".BiDiTestFrameLayoutLtrActivity"
                   android:windowSoftInputMode="stateAlwaysHidden">
             <intent-filter>
@@ -71,6 +78,13 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".BiDiTestFrameLayoutLocaleActivity"
+                  android:windowSoftInputMode="stateAlwaysHidden">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".BiDiTestRelativeLayoutLtrActivity"
                   android:windowSoftInputMode="stateAlwaysHidden">
             <intent-filter>
@@ -99,6 +113,13 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".BiDiTestRelativeLayoutLocaleActivity2"
+                  android:windowSoftInputMode="stateAlwaysHidden">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".BiDiTestTableLayoutLtrActivity"
                   android:windowSoftInputMode="stateAlwaysHidden">
             <intent-filter>
@@ -113,6 +134,13 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".BiDiTestTableLayoutLocaleActivity"
+                  android:windowSoftInputMode="stateAlwaysHidden">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
     </application>
 
 </manifest>
diff --git a/tests/BiDiTests/res/layout/basic.xml b/tests/BiDiTests/res/layout/basic.xml
index f254e3c..d5f5ba7 100644
--- a/tests/BiDiTests/res/layout/basic.xml
+++ b/tests/BiDiTests/res/layout/basic.xml
@@ -15,34 +15,34 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
 
-       <Button android:id="@+id/button"
-               android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button_text"
-               android:textSize="32dip"
-        />
+        <Button android:id="@+id/button"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button_text"
+                android:textSize="32dip"
+                />
 
         <TextView android:id="@+id/textview"
-              android:layout_height="wrap_content"
-              android:layout_width="wrap_content"
-              android:textSize="32dip"
-              android:text="@string/textview_text"
-        />
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="32dip"
+                  android:text="@string/textview_text"
+                />
 
         <EditText android:id="@+id/edittext"
-              android:layout_height="wrap_content"
-              android:layout_width="match_parent"
-              android:textSize="32dip"
-        />
+                  android:layout_height="wrap_content"
+                  android:layout_width="match_parent"
+                  android:textSize="32dip"
+                />
 
     </LinearLayout>
 
diff --git a/tests/BiDiTests/res/layout/canvas.xml b/tests/BiDiTests/res/layout/canvas.xml
index 77007af3..03b1bb2 100644
--- a/tests/BiDiTests/res/layout/canvas.xml
+++ b/tests/BiDiTests/res/layout/canvas.xml
@@ -15,20 +15,20 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
 
     <SeekBar android:id="@+id/seekbar"
-               android:layout_height="wrap_content"
-               android:layout_width="match_parent"
-               />
+             android:layout_height="wrap_content"
+             android:layout_width="match_parent"
+            />
 
     <view class="com.android.bidi.BiDiTestView"
-        android:id="@+id/testview"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="#FF0000"
-    />
+          android:id="@+id/testview"
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:background="#FF0000"
+            />
 
 </LinearLayout>
diff --git a/tests/BiDiTests/res/layout/frame_layout_locale.xml b/tests/BiDiTests/res/layout/frame_layout_locale.xml
new file mode 100644
index 0000000..812e0dc
--- /dev/null
+++ b/tests/BiDiTests/res/layout/frame_layout_locale.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             android:id="@+id/frame_layout_ltr"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             android:layoutDirection="locale"
+             android:background="#FF000000">
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="right|center_vertical"
+            android:background="#FFFF0000">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="left|center_vertical"
+            android:background="#FF00FF00">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="top|center_horizontal"
+            android:background="#FF0000FF">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="bottom|center_horizontal"
+            android:background="#FF00FFFF">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="top|start"
+            android:background="#FFFFFFFF">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="top|end"
+            android:background="#FFFFFF00">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="bottom|start"
+            android:background="#FFFFFFFF">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="bottom|end"
+            android:background="#FFFFFF00">
+    </FrameLayout>
+
+    <FrameLayout
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_gravity="center_horizontal|center_vertical"
+            android:background="#FF888888">
+    </FrameLayout>
+
+</FrameLayout>
+
diff --git a/tests/BiDiTests/res/layout/frame_layout_ltr.xml b/tests/BiDiTests/res/layout/frame_layout_ltr.xml
index 61fd06e..79effe6 100644
--- a/tests/BiDiTests/res/layout/frame_layout_ltr.xml
+++ b/tests/BiDiTests/res/layout/frame_layout_ltr.xml
@@ -15,74 +15,74 @@
 -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/frame_layout_ltr"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="ltr"
-    android:background="#FF000000">
+             android:id="@+id/frame_layout_ltr"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             android:layoutDirection="ltr"
+             android:background="#FF000000">
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="right|center_vertical"
             android:background="#FFFF0000">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="left|center_vertical"
             android:background="#FF00FF00">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|center_horizontal"
             android:background="#FF0000FF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|center_horizontal"
             android:background="#FF00FFFF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|start"
             android:background="#FFFFFFFF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|end"
             android:background="#FFFFFF00">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|start"
             android:background="#FFFFFFFF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|end"
             android:background="#FFFFFF00">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="center_horizontal|center_vertical"
             android:background="#FF888888">
-        </FrameLayout>
+    </FrameLayout>
 
 </FrameLayout>
 
diff --git a/tests/BiDiTests/res/layout/frame_layout_rtl.xml b/tests/BiDiTests/res/layout/frame_layout_rtl.xml
index 598b41a..a793862 100644
--- a/tests/BiDiTests/res/layout/frame_layout_rtl.xml
+++ b/tests/BiDiTests/res/layout/frame_layout_rtl.xml
@@ -15,74 +15,74 @@
 -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/frame_layout_ltr"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="rtl"
-    android:background="#FF000000">
+             android:id="@+id/frame_layout_ltr"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             android:layoutDirection="rtl"
+             android:background="#FF000000">
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="right|center_vertical"
             android:background="#FFFF0000">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="left|center_vertical"
             android:background="#FF00FF00">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|center_horizontal"
             android:background="#FF0000FF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|center_horizontal"
             android:background="#FF00FFFF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|start"
             android:background="#FFFFFFFF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|end"
             android:background="#FFFFFF00">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|start"
             android:background="#FFFFFFFF">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|end"
             android:background="#FFFFFF00">
-        </FrameLayout>
+    </FrameLayout>
 
-        <FrameLayout
+    <FrameLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="center_horizontal|center_vertical"
             android:background="#FF888888">
-        </FrameLayout>
+    </FrameLayout>
 
 </FrameLayout>
 
diff --git a/tests/BiDiTests/res/layout/linear_layout_locale.xml b/tests/BiDiTests/res/layout/linear_layout_locale.xml
new file mode 100644
index 0000000..72046cb
--- /dev/null
+++ b/tests/BiDiTests/res/layout/linear_layout_locale.xml
@@ -0,0 +1,257 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/linear_layout_rtl"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="locale">
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="inherit">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="ltr">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="rtl">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="locale">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="inherit">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="ltr">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="rtl">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="locale">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/linear_layout_ltr.xml b/tests/BiDiTests/res/layout/linear_layout_ltr.xml
index d4386f2..bea087e 100644
--- a/tests/BiDiTests/res/layout/linear_layout_ltr.xml
+++ b/tests/BiDiTests/res/layout/linear_layout_ltr.xml
@@ -15,198 +15,243 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/linear_layout_ltr"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="ltr">
+              android:id="@+id/linear_layout_ltr"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="ltr">
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="inherit">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="inherit">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="ltr">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="ltr">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="rtl">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="rtl">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="inherit">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="locale">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="ltr">
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="inherit">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="rtl">
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="ltr">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
+                />
+    </LinearLayout>
 
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="rtl">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="locale">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
     </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/linear_layout_rtl.xml b/tests/BiDiTests/res/layout/linear_layout_rtl.xml
index 9d07263..12f14ef 100644
--- a/tests/BiDiTests/res/layout/linear_layout_rtl.xml
+++ b/tests/BiDiTests/res/layout/linear_layout_rtl.xml
@@ -15,198 +15,243 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/linear_layout_rtl"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="rtl">
+              android:id="@+id/linear_layout_rtl"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="rtl">
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="inherit">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="inherit">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="ltr">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="ltr">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="rtl">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="rtl">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="inherit">
+                  android:orientation="horizontal"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="locale">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="ltr">
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="inherit">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
-
+                />
     </LinearLayout>
 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layoutDirection="rtl">
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="ltr">
 
-       <Button android:layout_height="wrap_content"
-               android:layout_width="wrap_content"
-               android:text="@string/button1_text"
-               android:textSize="24dip"
-        />
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
 
         <TextView android:id="@+id/textview"
                   android:layout_height="wrap_content"
                   android:layout_width="wrap_content"
                   android:textSize="24dip"
                   android:text="@string/textview_text"
-        />
+                />
 
         <Button android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:text="@string/button2_text"
                 android:textSize="24dip"
-         />
+                />
+    </LinearLayout>
 
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="rtl">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="locale">
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button1_text"
+                android:textSize="24dip"
+                />
+
+        <TextView android:id="@+id/textview"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:textSize="24dip"
+                  android:text="@string/textview_text"
+                />
+
+        <Button android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:text="@string/button2_text"
+                android:textSize="24dip"
+                />
     </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/main.xml b/tests/BiDiTests/res/layout/main.xml
index e39d1d6..eb73d44 100644
--- a/tests/BiDiTests/res/layout/main.xml
+++ b/tests/BiDiTests/res/layout/main.xml
@@ -15,26 +15,26 @@
 -->
 
 <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@android:id/tabhost"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent">
+         android:id="@android:id/tabhost"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent">
 
     <LinearLayout
-        android:orientation="vertical"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:padding="5dp">
-
-        <TabWidget
-            android:id="@android:id/tabs"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content" />
-
-        <FrameLayout
-            android:id="@android:id/tabcontent"
+            android:orientation="vertical"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
-            android:padding="5dp" />
+            android:padding="5dp">
+
+        <TabWidget
+                android:id="@android:id/tabs"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"/>
+
+        <FrameLayout
+                android:id="@android:id/tabcontent"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent"
+                android:padding="5dp"/>
 
     </LinearLayout>
 
diff --git a/tests/BiDiTests/res/layout/relative_layout_2_locale.xml b/tests/BiDiTests/res/layout/relative_layout_2_locale.xml
new file mode 100644
index 0000000..c99a99b
--- /dev/null
+++ b/tests/BiDiTests/res/layout/relative_layout_2_locale.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/relative_layout_ltr"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="locale">
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px">
+
+        <TextView android:id="@+id/label_1"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_1"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_1"/>
+
+        <Button android:id="@+id/ok_1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_1"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_1"
+                android:layout_alignTop="@id/ok_1"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="ltr">
+
+        <TextView android:id="@+id/label_2"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_2"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_2"/>
+
+        <Button android:id="@+id/ok_2"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_2"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_2"
+                android:layout_alignTop="@id/ok_2"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="inherit">
+
+        <TextView android:id="@+id/label_3"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_3"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_3"/>
+
+        <Button android:id="@+id/ok_3"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_3"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_3"
+                android:layout_alignTop="@id/ok_3"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="rtl">
+
+        <TextView android:id="@+id/label_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_4"/>
+
+        <Button android:id="@+id/ok_4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_4"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_4"
+                android:layout_alignTop="@id/ok_4"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="locale">
+
+        <TextView android:id="@+id/label_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_4"/>
+
+        <Button android:id="@+id/ok_4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_4"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_4"
+                android:layout_alignTop="@id/ok_4"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/relative_layout_2_ltr.xml b/tests/BiDiTests/res/layout/relative_layout_2_ltr.xml
new file mode 100644
index 0000000..c4cab11
--- /dev/null
+++ b/tests/BiDiTests/res/layout/relative_layout_2_ltr.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/relative_layout_ltr"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="ltr">
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px">
+
+        <TextView android:id="@+id/label_1"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_1"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_1"/>
+
+        <Button android:id="@+id/ok_1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_1"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_1"
+                android:layout_alignTop="@id/ok_1"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="ltr">
+
+        <TextView android:id="@+id/label_2"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_2"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_2"/>
+
+        <Button android:id="@+id/ok_2"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_2"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_2"
+                android:layout_alignTop="@id/ok_2"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="inherit">
+
+        <TextView android:id="@+id/label_3"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_3"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_3"/>
+
+        <Button android:id="@+id/ok_3"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_3"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_3"
+                android:layout_alignTop="@id/ok_3"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="rtl">
+
+        <TextView android:id="@+id/label_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_4"/>
+
+        <Button android:id="@+id/ok_4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_4"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_4"
+                android:layout_alignTop="@id/ok_4"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="locale">
+
+        <TextView android:id="@+id/label_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_4"/>
+
+        <Button android:id="@+id/ok_4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_4"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_4"
+                android:layout_alignTop="@id/ok_4"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/relative_layout_2_rtl.xml b/tests/BiDiTests/res/layout/relative_layout_2_rtl.xml
new file mode 100644
index 0000000..009d442
--- /dev/null
+++ b/tests/BiDiTests/res/layout/relative_layout_2_rtl.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/relative_layout_ltr"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="rtl">
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px">
+
+        <TextView android:id="@+id/label_1"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_1"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_1"/>
+
+        <Button android:id="@+id/ok_1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_1"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_1"
+                android:layout_alignTop="@id/ok_1"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="ltr">
+
+        <TextView android:id="@+id/label_2"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_2"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_2"/>
+
+        <Button android:id="@+id/ok_2"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_2"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_2"
+                android:layout_alignTop="@id/ok_2"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="inherit">
+
+        <TextView android:id="@+id/label_3"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_3"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_3"/>
+
+        <Button android:id="@+id/ok_3"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_3"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_3"
+                android:layout_alignTop="@id/ok_3"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="rtl">
+
+        <TextView android:id="@+id/label_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_4"/>
+
+        <Button android:id="@+id/ok_4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_4"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_4"
+                android:layout_alignTop="@id/ok_4"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:background="#FF000000"
+                    android:padding="10px"
+                    android:layoutDirection="locale">
+
+        <TextView android:id="@+id/label_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:text="Type here:"/>
+
+        <EditText android:id="@+id/entry_4"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:layout_below="@id/label_4"/>
+
+        <Button android:id="@+id/ok_4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/entry_4"
+                android:layout_alignParentRight="true"
+                android:layout_marginLeft="10px"
+                android:text="OK"/>
+
+        <Button android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toLeftOf="@id/ok_4"
+                android:layout_alignTop="@id/ok_4"
+                android:text="Cancel"/>
+    </RelativeLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/relative_layout_ltr.xml b/tests/BiDiTests/res/layout/relative_layout_ltr.xml
index d789707..e9e8661 100644
--- a/tests/BiDiTests/res/layout/relative_layout_ltr.xml
+++ b/tests/BiDiTests/res/layout/relative_layout_ltr.xml
@@ -15,74 +15,74 @@
 -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/frame_layout_ltr"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="ltr"
-    android:background="#FF000000">
+             android:id="@+id/frame_layout_ltr"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             android:layoutDirection="ltr"
+             android:background="#FF000000">
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="right|center_vertical"
             android:background="#FFFF0000">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="left|center_vertical"
             android:background="#FF00FF00">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|center_horizontal"
             android:background="#FF0000FF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|center_horizontal"
             android:background="#FF00FFFF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|start"
             android:background="#FFFFFFFF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|end"
             android:background="#FFFFFF00">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|start"
             android:background="#FFFFFFFF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|end"
             android:background="#FFFFFF00">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="center_horizontal|center_vertical"
             android:background="#FF888888">
-        </RelativeLayout>
+    </RelativeLayout>
 
 </FrameLayout>
 
diff --git a/tests/BiDiTests/res/layout/relative_layout_ltr_2.xml b/tests/BiDiTests/res/layout/relative_layout_ltr_2.xml
deleted file mode 100644
index a13ef8b..0000000
--- a/tests/BiDiTests/res/layout/relative_layout_ltr_2.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/relative_layout_ltr"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="ltr">
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px">
-
-        <TextView android:id="@+id/label_1"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_1"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_1" />
-
-        <Button android:id="@+id/ok_1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_1"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_1"
-                android:layout_alignTop="@id/ok_1"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px"
-            android:layoutDirection="ltr">
-
-        <TextView android:id="@+id/label_2"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_2"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_2" />
-
-        <Button android:id="@+id/ok_2"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_2"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_2"
-                android:layout_alignTop="@id/ok_2"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px"
-            android:layoutDirection="inherit">
-
-        <TextView android:id="@+id/label_3"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_3"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_3" />
-
-        <Button android:id="@+id/ok_3"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_3"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_3"
-                android:layout_alignTop="@id/ok_3"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px"
-            android:layoutDirection="rtl">
-
-        <TextView android:id="@+id/label_4"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_4"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_4" />
-
-        <Button android:id="@+id/ok_4"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_4"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_4"
-                android:layout_alignTop="@id/ok_4"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/relative_layout_rtl.xml b/tests/BiDiTests/res/layout/relative_layout_rtl.xml
index 5808924..57b2ad0 100644
--- a/tests/BiDiTests/res/layout/relative_layout_rtl.xml
+++ b/tests/BiDiTests/res/layout/relative_layout_rtl.xml
@@ -15,74 +15,74 @@
 -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/frame_layout_rtl"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="rtl"
-    android:background="#FF000000">
+             android:id="@+id/frame_layout_rtl"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             android:layoutDirection="rtl"
+             android:background="#FF000000">
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="right|center_vertical"
             android:background="#FFFF0000">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="left|center_vertical"
             android:background="#FF00FF00">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|center_horizontal"
             android:background="#FF0000FF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|center_horizontal"
             android:background="#FF00FFFF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|start"
             android:background="#FFFFFFFF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="top|end"
             android:background="#FFFFFF00">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|start"
             android:background="#FFFFFFFF">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="bottom|end"
             android:background="#FFFFFF00">
-        </RelativeLayout>
+    </RelativeLayout>
 
-        <RelativeLayout
+    <RelativeLayout
             android:layout_width="100dp"
             android:layout_height="100dp"
             android:layout_gravity="center_horizontal|center_vertical"
             android:background="#FF888888">
-        </RelativeLayout>
+    </RelativeLayout>
 
 </FrameLayout>
 
diff --git a/tests/BiDiTests/res/layout/relative_layout_rtl_2.xml b/tests/BiDiTests/res/layout/relative_layout_rtl_2.xml
deleted file mode 100644
index 1a6b3d5..0000000
--- a/tests/BiDiTests/res/layout/relative_layout_rtl_2.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/relative_layout_ltr"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="rtl">
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px">
-
-        <TextView android:id="@+id/label_1"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_1"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_1" />
-
-        <Button android:id="@+id/ok_1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_1"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_1"
-                android:layout_alignTop="@id/ok_1"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px"
-            android:layoutDirection="ltr">
-
-        <TextView android:id="@+id/label_2"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_2"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_2" />
-
-        <Button android:id="@+id/ok_2"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_2"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_2"
-                android:layout_alignTop="@id/ok_2"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px"
-            android:layoutDirection="inherit">
-
-        <TextView android:id="@+id/label_3"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_3"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_3" />
-
-        <Button android:id="@+id/ok_3"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_3"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_3"
-                android:layout_alignTop="@id/ok_3"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:background="#FF000000"
-            android:padding="10px"
-            android:layoutDirection="rtl">
-
-        <TextView android:id="@+id/label_4"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:text="Type here:" />
-
-        <EditText android:id="@+id/entry_4"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/label_4" />
-
-        <Button android:id="@+id/ok_4"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/entry_4"
-                android:layout_alignParentRight="true"
-                android:layout_marginLeft="10px"
-                android:text="OK" />
-
-        <Button android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_toLeftOf="@id/ok_4"
-                android:layout_alignTop="@id/ok_4"
-                android:text="Cancel" />
-
-    </RelativeLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/table_layout_locale.xml b/tests/BiDiTests/res/layout/table_layout_locale.xml
new file mode 100644
index 0000000..847eb07
--- /dev/null
+++ b/tests/BiDiTests/res/layout/table_layout_locale.xml
@@ -0,0 +1,258 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/linear_layout_ltr"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="locale">
+
+    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2">
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button1_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_right_text"
+                    android:textSize="24dip"
+                    android:gravity="right"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_after_text"
+                    android:textSize="24dip"
+                    android:gravity="after"
+                    />
+        </TableRow>
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button2_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_left_text"
+                    android:textSize="24dip"
+                    android:gravity="left"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_before_text"
+                    android:textSize="24dip"
+                    android:gravity="before"
+                    />
+        </TableRow>
+    </TableLayout>
+
+    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="inherit">
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button1_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_right_text"
+                    android:textSize="24dip"
+                    android:gravity="right"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_after_text"
+                    android:textSize="24dip"
+                    android:gravity="after"
+                    />
+        </TableRow>
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button2_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_left_text"
+                    android:textSize="24dip"
+                    android:gravity="left"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_before_text"
+                    android:textSize="24dip"
+                    android:gravity="before"
+                    />
+        </TableRow>
+    </TableLayout>
+
+    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="ltr">
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button1_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_right_text"
+                    android:textSize="24dip"
+                    android:gravity="right"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_after_text"
+                    android:textSize="24dip"
+                    android:gravity="after"
+                    />
+        </TableRow>
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button2_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_left_text"
+                    android:textSize="24dip"
+                    android:gravity="left"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_before_text"
+                    android:textSize="24dip"
+                    android:gravity="before"
+                    />
+        </TableRow>
+    </TableLayout>
+
+    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="rtl">
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button1_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_right_text"
+                    android:textSize="24dip"
+                    android:gravity="right"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_after_text"
+                    android:textSize="24dip"
+                    android:gravity="after"
+                    />
+        </TableRow>
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button2_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_left_text"
+                    android:textSize="24dip"
+                    android:gravity="left"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_before_text"
+                    android:textSize="24dip"
+                    android:gravity="before"
+                    />
+        </TableRow>
+    </TableLayout>
+
+    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="locale">
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button1_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_right_text"
+                    android:textSize="24dip"
+                    android:gravity="right"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_after_text"
+                    android:textSize="24dip"
+                    android:gravity="after"
+                    />
+        </TableRow>
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button2_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_left_text"
+                    android:textSize="24dip"
+                    android:gravity="left"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_before_text"
+                    android:textSize="24dip"
+                    android:gravity="before"
+                    />
+        </TableRow>
+    </TableLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/table_layout_ltr.xml b/tests/BiDiTests/res/layout/table_layout_ltr.xml
index 8e1891e..49d1d0d 100644
--- a/tests/BiDiTests/res/layout/table_layout_ltr.xml
+++ b/tests/BiDiTests/res/layout/table_layout_ltr.xml
@@ -15,35 +15,35 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/linear_layout_ltr"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="ltr">
+              android:id="@+id/linear_layout_ltr"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="ltr">
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -51,47 +51,46 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
         </TableRow>
-
     </TableLayout>
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2"
-        android:layoutDirection="inherit">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="inherit">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -99,47 +98,46 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
         </TableRow>
-
     </TableLayout>
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2"
-        android:layoutDirection="ltr">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="ltr">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -147,47 +145,46 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
         </TableRow>
-
     </TableLayout>
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2"
-        android:layoutDirection="rtl">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="rtl">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -195,21 +192,67 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
+        </TableRow>
+    </TableLayout>
+
+    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="locale">
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button1_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_right_text"
+                    android:textSize="24dip"
+                    android:gravity="right"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_after_text"
+                    android:textSize="24dip"
+                    android:gravity="after"
+                    />
         </TableRow>
 
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button2_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_left_text"
+                    android:textSize="24dip"
+                    android:gravity="left"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_before_text"
+                    android:textSize="24dip"
+                    android:gravity="before"
+                    />
+        </TableRow>
     </TableLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/res/layout/table_layout_rtl.xml b/tests/BiDiTests/res/layout/table_layout_rtl.xml
index bd664e4..a665e45 100644
--- a/tests/BiDiTests/res/layout/table_layout_rtl.xml
+++ b/tests/BiDiTests/res/layout/table_layout_rtl.xml
@@ -15,35 +15,35 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/linear_layout_ltr"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layoutDirection="rtl">
+              android:id="@+id/linear_layout_ltr"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:layoutDirection="rtl">
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -51,47 +51,46 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
         </TableRow>
-
     </TableLayout>
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2"
-        android:layoutDirection="inherit">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="inherit">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -99,47 +98,46 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
         </TableRow>
-
     </TableLayout>
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2"
-        android:layoutDirection="ltr">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="ltr">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -147,47 +145,46 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
         </TableRow>
-
     </TableLayout>
 
     <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:stretchColumns="1,2"
-        android:layoutDirection="rtl">
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="rtl">
 
         <TableRow>
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button1_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_right_text"
                     android:textSize="24dip"
                     android:gravity="right"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_after_text"
                     android:textSize="24dip"
                     android:gravity="after"
-             />
+                    />
         </TableRow>
 
         <TableRow>
@@ -195,21 +192,67 @@
                     android:layout_width="wrap_content"
                     android:text="@string/button2_text"
                     android:textSize="24dip"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_left_text"
                     android:textSize="24dip"
                     android:gravity="left"
-             />
+                    />
             <Button android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:text="@string/button_before_text"
                     android:textSize="24dip"
                     android:gravity="before"
-             />
+                    />
+        </TableRow>
+    </TableLayout>
+
+    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:stretchColumns="1,2"
+                 android:layoutDirection="locale">
+
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button1_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_right_text"
+                    android:textSize="24dip"
+                    android:gravity="right"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_after_text"
+                    android:textSize="24dip"
+                    android:gravity="after"
+                    />
         </TableRow>
 
+        <TableRow>
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button2_text"
+                    android:textSize="24dip"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_left_text"
+                    android:textSize="24dip"
+                    android:gravity="left"
+                    />
+            <Button android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:text="@string/button_before_text"
+                    android:textSize="24dip"
+                    android:gravity="before"
+                    />
+        </TableRow>
     </TableLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java
index 2662683..1ffe7ee 100644
--- a/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestActivity.java
@@ -57,6 +57,11 @@
             setContent(intent);
         tabHost.addTab(spec);
 
+        intent = new Intent().setClass(this, BiDiTestLinearLayoutLocaleActivity.class);
+        spec = tabHost.newTabSpec("linear-layout-locale").setIndicator("Linear LOC").
+            setContent(intent);
+        tabHost.addTab(spec);
+
         intent = new Intent().setClass(this, BiDiTestFrameLayoutLtrActivity.class);
         spec = tabHost.newTabSpec("frame-layout-ltr").setIndicator("Frame LTR").
             setContent(intent);
@@ -67,6 +72,11 @@
             setContent(intent);
         tabHost.addTab(spec);
 
+        intent = new Intent().setClass(this, BiDiTestFrameLayoutLocaleActivity.class);
+        spec = tabHost.newTabSpec("frame-layout-locale").setIndicator("Frame LOC").
+            setContent(intent);
+        tabHost.addTab(spec);
+
         intent = new Intent().setClass(this, BiDiTestRelativeLayoutLtrActivity.class);
         spec = tabHost.newTabSpec("relative-layout-ltr").setIndicator("Relative LTR").
             setContent(intent);
@@ -87,6 +97,11 @@
             setContent(intent);
         tabHost.addTab(spec);
 
+        intent = new Intent().setClass(this, BiDiTestRelativeLayoutLocaleActivity2.class);
+        spec = tabHost.newTabSpec("relative-layout-locale-2").setIndicator("Relative2 LOC").
+            setContent(intent);
+        tabHost.addTab(spec);
+
         intent = new Intent().setClass(this, BiDiTestTableLayoutLtrActivity.class);
         spec = tabHost.newTabSpec("table-layout-ltr").setIndicator("Table LTR").
             setContent(intent);
@@ -97,6 +112,11 @@
             setContent(intent);
         tabHost.addTab(spec);
 
+        intent = new Intent().setClass(this, BiDiTestTableLayoutLocaleActivity.class);
+        spec = tabHost.newTabSpec("table-layout-locale").setIndicator("Table LOC").
+            setContent(intent);
+        tabHost.addTab(spec);
+
         tabHost.setCurrentTab(0);
     }
 }
\ No newline at end of file
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestFrameLayoutLocaleActivity.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestFrameLayoutLocaleActivity.java
new file mode 100644
index 0000000..457c52a
--- /dev/null
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestFrameLayoutLocaleActivity.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.bidi;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class BiDiTestFrameLayoutLocaleActivity extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.frame_layout_locale);
+    }
+}
+
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestLinearLayoutLocaleActivity.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestLinearLayoutLocaleActivity.java
new file mode 100644
index 0000000..8694dd1
--- /dev/null
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestLinearLayoutLocaleActivity.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.bidi;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class BiDiTestLinearLayoutLocaleActivity extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.linear_layout_locale);
+    }
+}
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutLocaleActivity2.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutLocaleActivity2.java
new file mode 100644
index 0000000..8a52b38
--- /dev/null
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutLocaleActivity2.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.bidi;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class BiDiTestRelativeLayoutLocaleActivity2 extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.relative_layout_2_locale);
+    }
+}
+
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutLtrActivity2.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutLtrActivity2.java
index 476375c..65a5ed0 100644
--- a/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutLtrActivity2.java
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutLtrActivity2.java
@@ -25,7 +25,7 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        setContentView(R.layout.relative_layout_ltr_2);
+        setContentView(R.layout.relative_layout_2_ltr);
     }
 }
 
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutRtlActivity2.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutRtlActivity2.java
index db2af7f..dad5491 100644
--- a/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutRtlActivity2.java
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestRelativeLayoutRtlActivity2.java
@@ -25,7 +25,7 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        setContentView(R.layout.relative_layout_rtl_2);
+        setContentView(R.layout.relative_layout_2_rtl);
     }
 }
 
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestTableLayoutLocaleActivity.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestTableLayoutLocaleActivity.java
new file mode 100644
index 0000000..9222aa2
--- /dev/null
+++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestTableLayoutLocaleActivity.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.bidi;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class BiDiTestTableLayoutLocaleActivity extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.table_layout_locale);
+    }
+}
+
diff --git a/tests/GridLayoutTest/res/layout/grid3.xml b/tests/GridLayoutTest/res/layout/grid3.xml
index ace7b4c..31dc75a 100644
--- a/tests/GridLayoutTest/res/layout/grid3.xml
+++ b/tests/GridLayoutTest/res/layout/grid3.xml
@@ -19,59 +19,61 @@
 
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:useDefaultMargins="true"
+        android:marginsIncludedInAlignment="false"
+        android:columnCount="4"
         >
 
-    <Button
-            android:text="fill"
-            android:width="200dip"
-            android:height="100dip"
-            android:layout_marginLeft="50dip"
-            android:layout_row="0"
-            android:layout_column="0"
-            android:layout_gravity="fill_horizontal"
+    <TextView
+            android:text="Email account"
+            android:textSize="48dip"
+            android:layout_columnSpan="4"
+            android:layout_gravity="center_horizontal"
+            />
+
+    <TextView
+            android:text="You can configure email in just a few steps:"
+            android:textSize="20dip"
+            android:layout_columnSpan="4"
+            android:layout_gravity="left"
+            />
+
+    <TextView
+            android:text="Email address:"
+            android:layout_gravity="right"
             />
 
     <EditText
-            android:layout_row="0"
-            android:layout_column="1"
+            android:layout_width="100dip"
             />
 
-    <Button
-            android:text="left"
-            android:layout_row="1"
-            android:layout_column="0"
-            />
-
-    <EditText
-            android:layout_row="1"
-            android:layout_column="1"
-            />
-
-    <Button
-            android:text="right"
-            android:layout_row="2"
+    <TextView
+            android:text="Password:"
             android:layout_column="0"
             android:layout_gravity="right"
             />
 
     <EditText
-            android:layout_margin="50dip"
-            android:textSize="100dip"
-            android:layout_row="2"
-            android:layout_column="1"
+            android:layout_width="50dip"
+            />
+
+    <Space
+            android:layout_rowWeight="1"
+            android:layout_columnWeight="1"
+            android:layout_row="4"
+            android:layout_column="2"
             />
 
     <Button
-            android:text="center"
-            android:layout_row="3"
-            android:layout_column="0"
-            android:layout_gravity="center_horizontal"
+            android:text="Manual setup"
+            android:layout_row="5"
+            android:layout_column="3"
+            android:layout_gravity="fill_horizontal"
             />
 
-    <EditText
-            android:layout_height="fill_parent"
-            android:layout_row="3"
-            android:layout_column="1"
+    <Button
+            android:text="Next"
+            android:layout_column="3"
+            android:layout_gravity="fill_horizontal"
             />
-
 </GridLayout>
diff --git a/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java
index 937eacb..4d3a843 100644
--- a/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java
+++ b/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java
@@ -19,19 +19,19 @@
 import android.app.Activity;
 import android.content.Context;
 import android.os.Bundle;
-import android.os.Debug;
 import android.util.Log;
-import android.view.Gravity;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Button;
 
+import static android.view.Gravity.*;
+
 public abstract class AbstractLayoutTest extends Activity {
 
-    public static final String[] HORIZONTAL_NAMES = new String[] { "LEFT", "center", "east", "fill" };
-    public static final int[] HORIZONTAL_ALIGNMENTS = new int[] { Gravity.LEFT, Gravity.CENTER, Gravity.RIGHT, Gravity.FILL };
-    public static final String[] VERTICAL_NAMES = new String[] { "north", "center", "baseline", "south", "fill" };
-    public static final int[] VERTICAL_ALIGNMENTS = new int[] { Gravity.TOP, Gravity.CENTER, Gravity.NO_GRAVITY, Gravity.BOTTOM, Gravity.FILL };
+    public static final String[] HORIZONTAL_NAMES = { "LEFT", "CENTER", "RIGHT", "FILL" };
+    public static final int[] HORIZONTAL_ALIGNMENTS = { LEFT, CENTER, RIGHT, FILL };
+    public static final String[] VERTICAL_NAMES = { "TOP", "CENTER", "BASELINE", "BOTTOM", "FILL" };
+    public static final int[] VERTICAL_ALIGNMENTS = { TOP, CENTER, NO_GRAVITY, BOTTOM, FILL };
 
     public View create(Context context, String name, int size) {
         Button result = new Button(context);
diff --git a/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java
index 2eecb8a..c5681e2 100644
--- a/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java
+++ b/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java
@@ -36,6 +36,7 @@
                 GridLayout.Group rowGroup = new GridLayout.Group(UNDEFINED, null);
                 GridLayout.Group colGroup = new GridLayout.Group(UNDEFINED, null);
                 GridLayout.LayoutParams lp = new GridLayout.LayoutParams(rowGroup, colGroup);
+                //GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
                 lp.setGravity(va | ha);
                 View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
                 container.addView(v, lp);
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index 7f97098..9bb5ba8 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -52,13 +52,7 @@
     }
 
     @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        mRenderThread.finish();
-    }
-
-    @Override
-    public void onSurfaceTextureAvailable(SurfaceTexture surface) {
+    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
         mRenderThread = new RenderThread(surface);
         mRenderThread.start();
 
@@ -81,6 +75,16 @@
     public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
     }
 
+    @Override
+    public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+        mRenderThread.finish();
+        try {
+            mRenderThread.join();
+        } catch (InterruptedException e) {
+            Log.e(RenderThread.LOG_TAG, "Could not wait for render thread");
+        }
+    }
+
     private static class RenderThread extends Thread {
         private static final String LOG_TAG = "GLTextureView";
 
@@ -108,26 +112,23 @@
         public void run() {
             initGL();
 
-            float red = 0.0f;
+            float red = 1.0f;
             while (!mFinished) {
                 checkCurrent();
 
+                Log.d(LOG_TAG, "Rendering frame");
+
                 GLES20.glClearColor(red, 0.0f, 0.0f, 1.0f);
-                int error = GLES20.glGetError();
-                if (error != GLES20.GL_NO_ERROR) {
-                    Log.w(LOG_TAG, "GL error = 0x" + Integer.toHexString(error));
-                }
+                checkGlError();
 
                 GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
-                error = GLES20.glGetError();
-                if (error != GLES20.GL_NO_ERROR) {
-                    Log.w(LOG_TAG, "GL error = 0x" + Integer.toHexString(error));
-                }
+                checkGlError();
 
                 if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
                     throw new RuntimeException("Cannot swap buffers");
                 }
-                
+                checkEglError();
+
                 try {
                     Thread.sleep(20);
                 } catch (InterruptedException e) {
@@ -141,6 +142,20 @@
             finishGL();
         }
 
+        private void checkEglError() {
+            int error = mEgl.eglGetError();
+            if (error != EGL10.EGL_SUCCESS) {
+                Log.w(LOG_TAG, "EGL error = 0x" + Integer.toHexString(error));
+            }
+        }
+
+        private void checkGlError() {
+            int error = GLES20.glGetError();
+            if (error != GLES20.GL_NO_ERROR) {
+                Log.w(LOG_TAG, "GL error = 0x" + Integer.toHexString(error));
+            }
+        }
+
         private void finishGL() {
             mEgl.eglDestroyContext(mEglDisplay, mEglContext);
             mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
index 2feda57..fa2e39a 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
@@ -16,6 +16,7 @@
 
 package com.android.test.hwui;
 
+import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.animation.ValueAnimator;
 import android.app.Activity;
@@ -25,6 +26,7 @@
 import android.view.Gravity;
 import android.view.TextureView;
 import android.view.View;
+import android.widget.Button;
 import android.widget.FrameLayout;
 
 import java.io.IOException;
@@ -33,27 +35,44 @@
 public class TextureViewActivity extends Activity implements TextureView.SurfaceTextureListener {
     private Camera mCamera;
     private TextureView mTextureView;
+    private FrameLayout mContent;
+    private AnimatorSet mAnimatorSet;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        mContent = new FrameLayout(this);
+
         mTextureView = new TextureView(this);
         mTextureView.setSurfaceTextureListener(this);
 
-        setContentView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER));
+        Button button = new Button(this);
+        button.setText("Remove/Add");
+        button.setOnClickListener(new View.OnClickListener() {
+            private boolean mAdded = true;
+
+            @Override
+            public void onClick(View v) {
+                if (mAdded) {
+                    mAnimatorSet.cancel();
+                    mContent.removeView(mTextureView);
+                } else {
+                    mContent.addView(mTextureView);
+                }
+                mAdded = !mAdded;
+            }
+        });
+
+        mContent.addView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER));
+        mContent.addView(button, new FrameLayout.LayoutParams(
+                FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT,
+                Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
+        setContentView(mContent);
     }
 
     @Override
-    protected void onDestroy() {
-        super.onDestroy();
-
-        mCamera.stopPreview();
-        mCamera.release();
-    }
-
-    @Override
-    public void onSurfaceTextureAvailable(SurfaceTexture surface) {
+    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
         mCamera = Camera.open();
 
         try {
@@ -66,27 +85,35 @@
 
         mTextureView.setCameraDistance(5000);
 
-        ObjectAnimator animator = ObjectAnimator.ofFloat(mTextureView, "rotationY", 0.0f, 360.0f);
-        animator.setRepeatMode(ObjectAnimator.REVERSE);
-        animator.setRepeatCount(ObjectAnimator.INFINITE);
-        animator.setDuration(4000);
-        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+        ObjectAnimator rotationY = ObjectAnimator.ofFloat(mTextureView, "rotationY", 0.0f, 360.0f);
+        rotationY.setRepeatMode(ObjectAnimator.REVERSE);
+        rotationY.setRepeatCount(ObjectAnimator.INFINITE);
+        rotationY.setDuration(4000);
+        rotationY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
             @Override
             public void onAnimationUpdate(ValueAnimator animation) {
                 ((View) mTextureView.getParent()).invalidate();
             }
         });
-        animator.start();
 
-        animator = ObjectAnimator.ofFloat(mTextureView, "alpha", 1.0f, 0.0f);
-        animator.setRepeatMode(ObjectAnimator.REVERSE);
-        animator.setRepeatCount(ObjectAnimator.INFINITE);
-        animator.setDuration(4000);
-        animator.start();
+        ObjectAnimator alpha = ObjectAnimator.ofFloat(mTextureView, "alpha", 1.0f, 0.0f);
+        alpha.setRepeatMode(ObjectAnimator.REVERSE);
+        alpha.setRepeatCount(ObjectAnimator.INFINITE);
+        alpha.setDuration(4000);
+
+        mAnimatorSet = new AnimatorSet();
+        mAnimatorSet.play(alpha).with(rotationY);
+        mAnimatorSet.start();
     }
 
     @Override
     public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
         // Ignored, the Camera does all the work for us
     }
+
+    @Override
+    public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+        mCamera.stopPreview();
+        mCamera.release();
+    }
 }
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 5c5b4fd..81b924a 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -1963,10 +1963,11 @@
                                  bool onlyPublic) const
 {
     String16 package, type, name;
+    bool refOnlyPublic = true;
     if (!ResTable::expandResourceRef(
         ref.string(), ref.size(), &package, &type, &name,
         defType, defPackage ? defPackage:&mAssetsPackage,
-        outErrorMsg)) {
+        outErrorMsg, &refOnlyPublic)) {
         NOISY(printf("Expanding resource: ref=%s\n",
                      String8(ref).string()));
         NOISY(printf("Expanding resource: defType=%s\n",
@@ -1979,7 +1980,7 @@
                      String8(name).string()));
         return 0;
     }
-    uint32_t res = getResId(package, type, name, onlyPublic);
+    uint32_t res = getResId(package, type, name, onlyPublic && refOnlyPublic);
     NOISY(printf("Expanded resource: p=%s, t=%s, n=%s, res=%d\n",
                  String8(package).string(), String8(type).string(),
                  String8(name).string(), res));
diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h
index bbb8140..734c541 100644
--- a/tools/aapt/ResourceTable.h
+++ b/tools/aapt/ResourceTable.h
@@ -162,13 +162,13 @@
     uint32_t getResId(const String16& package,
                       const String16& type,
                       const String16& name,
-                      bool onlyPublic = false) const;
+                      bool onlyPublic = true) const;
 
     uint32_t getResId(const String16& ref,
                       const String16* defType = NULL,
                       const String16* defPackage = NULL,
                       const char** outErrorMsg = NULL,
-                      bool onlyPublic = false) const;
+                      bool onlyPublic = true) const;
 
     static bool isValidResourceName(const String16& s);