Merge "Make 'idmap --scan' accept more than one input directory"
diff --git a/core/java/android/preference/PreferenceFragment.java b/core/java/android/preference/PreferenceFragment.java
index 66642de..db04c71 100644
--- a/core/java/android/preference/PreferenceFragment.java
+++ b/core/java/android/preference/PreferenceFragment.java
@@ -214,6 +214,9 @@
 
     @Override
     public void onDestroyView() {
+        if (mList != null) {
+            mList.setOnKeyListener(null);
+        }
         mList = null;
         mHandler.removeCallbacks(mRequestFocus);
         mHandler.removeMessages(MSG_BIND_PREFERENCES);
diff --git a/core/java/android/preference/PreferenceGroup.java b/core/java/android/preference/PreferenceGroup.java
index 5e84086..f17506b 100644
--- a/core/java/android/preference/PreferenceGroup.java
+++ b/core/java/android/preference/PreferenceGroup.java
@@ -148,16 +148,15 @@
             }
         }
 
-        int insertionIndex = Collections.binarySearch(mPreferenceList, preference);
-        if (insertionIndex < 0) {
-            insertionIndex = insertionIndex * -1 - 1;
-        }
-
         if (!onPrepareAddPreference(preference)) {
             return false;
         }
 
         synchronized(this) {
+            int insertionIndex = Collections.binarySearch(mPreferenceList, preference);
+            if (insertionIndex < 0) {
+                insertionIndex = insertionIndex * -1 - 1;
+            }
             mPreferenceList.add(insertionIndex, preference);
         }
 
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index 932b354..0e3a69f 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -401,12 +401,11 @@
      }
 
     LayoutParams createOrReuseLayoutParams(View v) {
-        final ViewGroup.LayoutParams currentLp = v.getLayoutParams();
-        if (currentLp instanceof ViewGroup.LayoutParams) {
-            LayoutParams lp = (LayoutParams) currentLp;
-            return lp;
+        final LayoutParams currentLp = v.getLayoutParams();
+        if (currentLp != null) {
+            return currentLp;
         }
-        return new ViewGroup.LayoutParams(0, 0);
+        return new LayoutParams(0, 0);
     }
 
     void refreshChildren() {
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java
index c40289e..559181b 100644
--- a/core/java/android/widget/FastScroller.java
+++ b/core/java/android/widget/FastScroller.java
@@ -383,6 +383,7 @@
                     break;
             }
         }
+        ta.recycle();
 
         updateAppearance();
     }
diff --git a/core/res/res/layout/list_content.xml b/core/res/res/layout/list_content.xml
index 1414032..45ade4d 100644
--- a/core/res/res/layout/list_content.xml
+++ b/core/res/res/layout/list_content.xml
@@ -44,8 +44,7 @@
             
         <ListView android:id="@android:id/list"
                 android:layout_width="match_parent" 
-                android:layout_height="match_parent"
-                android:drawSelectorOnTop="false" />
+                android:layout_height="match_parent" />
         <TextView android:id="@+android:id/internalEmpty"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
diff --git a/core/res/res/layout/preference_list_fragment.xml b/core/res/res/layout/preference_list_fragment.xml
index 4e895b0..f073c33 100644
--- a/core/res/res/layout/preference_list_fragment.xml
+++ b/core/res/res/layout/preference_list_fragment.xml
@@ -41,6 +41,7 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:padding="@dimen/preference_fragment_padding_side"
+        android:textAppearance="?android:attr/textAppearanceMedium"
         android:gravity="center"
         android:visibility="gone" />
 
diff --git a/rs/java/android/renderscript/AllocationAdapter.java b/rs/java/android/renderscript/AllocationAdapter.java
index 9bfd6ec..6d7e97e 100644
--- a/rs/java/android/renderscript/AllocationAdapter.java
+++ b/rs/java/android/renderscript/AllocationAdapter.java
@@ -244,23 +244,23 @@
     /**
      *
      *
-     * Create an arbitrary window into the base allocation
+     * Create an arbitrary window into the base allocation.
      * The type describes the shape of the window.
      *
      * Any dimensions present in the type must be equal or smaller
      * to the dimensions in the source allocation.  A dimension
      * present in the allocation that is not present in the type
-     * will be constrained away with the selectors
+     * will be constrained away with the selectors.
      *
-     * If a dimension is present in the type and allcation one of
-     * two things will happen
+     * If a dimension is present in both the type and allocation, one of
+     * two things will happen.
      *
-     * If the type is smaller than the allocation a window will be
+     * If the type is smaller than the allocation, a window will be
      * created, the selected value in the adapter for that dimension
-     * will act as the base address and the type will describe the
+     * will act as the base address, and the type will describe the
      * size of the view starting at that point.
      *
-     * If the type and allocation dimension are of the same size
+     * If the type and allocation dimension are of the same size,
      * then setting the selector for the dimension will be an error.
      */
     static public AllocationAdapter createTyped(RenderScript rs, Allocation a, Type t) {
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 83fb7c2..af6f185 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -511,7 +511,8 @@
 
         mHomeStack.moveHomeStackTaskToTop(homeStackTaskType);
         ActivityRecord r = getHomeActivity();
-        if (r != null) {
+        // Only resume home activity if isn't finishing.
+        if (r != null && !r.finishing) {
             mService.setFocusedActivityLocked(r, reason);
             return resumeTopActivitiesLocked(mHomeStack, prev, null);
         }
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 806f241..c4d541c 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -6192,10 +6192,13 @@
         int retryCount = 0;
         WindowState appWin = null;
 
-        final boolean appIsImTarget = mInputMethodTarget != null
-                && mInputMethodTarget.mAppToken != null
-                && mInputMethodTarget.mAppToken.appToken != null
-                && mInputMethodTarget.mAppToken.appToken.asBinder() == appToken;
+        boolean appIsImTarget;
+        synchronized(mWindowMap) {
+            appIsImTarget = mInputMethodTarget != null
+                    && mInputMethodTarget.mAppToken != null
+                    && mInputMethodTarget.mAppToken.appToken != null
+                    && mInputMethodTarget.mAppToken.appToken.asBinder() == appToken;
+        }
 
         final int aboveAppLayer = (mPolicy.windowTypeToLayerLw(TYPE_APPLICATION) + 1)
                 * TYPE_LAYER_MULTIPLIER + TYPE_LAYER_OFFSET;