Merge change 5236 into donut

* changes:
  RelativeLayout was ignoring some dependencies.
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index 68dafa1..b2aa574 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -40,7 +40,6 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.LinkedList;
-import java.util.ArrayList;
 import java.util.HashSet;
 
 /**
@@ -279,6 +278,17 @@
         graph.getSortedViews(mSortedVerticalChildren, ABOVE, BELOW, ALIGN_BASELINE,
                 ALIGN_TOP, ALIGN_BOTTOM);
         graph.getSortedViews(mSortedHorizontalChildren, LEFT_OF, RIGHT_OF, ALIGN_LEFT, ALIGN_RIGHT);
+
+        if (DEBUG_GRAPH) {
+            d(LOG_TAG, "=== Ordered list of vertical children");
+            for (View view : mSortedVerticalChildren) {
+                DependencyGraph.printViewId(getResources(), view);
+            }
+            d(LOG_TAG, "=== Ordered list of horizontal children");
+            for (View view : mSortedHorizontalChildren) {
+                DependencyGraph.printViewId(getResources(), view);
+            }
+        }        
     }
 
     @Override
@@ -333,7 +343,6 @@
             ignore = findViewById(mIgnoreGravity);
         }
 
-
         View[] views = mSortedVerticalChildren;
         int count = views.length;
         for (int i = 0; i < count; i++) {
@@ -755,7 +764,7 @@
     private View getRelatedView(int[] rules, int relation) {
         int id = rules[relation];
         if (id != 0) {
-            View v = findViewById(id);
+            View v = mGraph.mNodes.get(id).view;
             if (v == null) {
                 return null;
             }
@@ -763,7 +772,7 @@
             // Find the first non-GONE view up the chain
             while (v.getVisibility() == View.GONE) {
                 rules = ((LayoutParams) v.getLayoutParams()).getRules();
-                v = v.findViewById(rules[relation]);
+                v = mGraph.mNodes.get((rules[relation])).view;
                 if (v == null) {
                     return null;
                 }
@@ -1100,12 +1109,6 @@
 
     private static class DependencyGraph {
         /**
-         * List of views with no id. These views cannot be dependencies of
-         * other views, so treat the apart for faster processing.
-         */
-        private ArrayList<View> mNakedRoots = new ArrayList<View>();
-
-        /**
          * List of nodes in the graph. Each node is identified by its
          * view id (see View#getId()).
          */
@@ -1129,7 +1132,6 @@
             }
             nodes.clear();
 
-            mNakedRoots.clear();
             mRoots.clear();
         }
 
@@ -1139,13 +1141,7 @@
          * @param view The view to be added as a node to the graph.
          */
         void add(View view) {
-            final int id = view.getId();
-
-            if (id != View.NO_ID) {
-                mNodes.put(id, Node.acquire(view));
-            } else {
-                mNakedRoots.add(view);
-            }
+            mNodes.put(view.getId(), Node.acquire(view));
         }
 
         /**
@@ -1162,12 +1158,6 @@
             final LinkedList<Node> roots = findRoots(rules);
             int index = 0;
 
-            final ArrayList<View> nakedRoots = mNakedRoots;
-            final int count = nakedRoots.size();
-            for ( ; index < count; index++) {
-                sorted[index] = nakedRoots.get(index);
-            }
-
             while (roots.size() > 0) {
                 final Node node = roots.removeFirst();
                 final View view = node.view;
@@ -1259,17 +1249,13 @@
          * @param rules The list of rules to take into account.
          */
         void log(Resources resources, int... rules) {
-            for (View view : mNakedRoots) {
-                printViewId(resources, view);
-            }
-
             final LinkedList<Node> roots = findRoots(rules);
             for (Node node : roots) {
                 printNode(resources, node);
             }
         }
 
-        private static void printViewId(Resources resources, View view) {
+        static void printViewId(Resources resources, View view) {
             if (view.getId() != View.NO_ID) {
                 d(LOG_TAG, resources.getResourceEntryName(view.getId()));
             } else {