Merge "Add LocationManagerImpl class to act as a public wrapper for the ILocationProvider interface"
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 60d8e72..e241c77 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -127,11 +127,6 @@
     static final int TOUCH_MODE_FLING = 4;
 
     /**
-     * Indicates that the user is currently dragging the fast scroll thumb
-     */
-    static final int TOUCH_MODE_FAST_SCROLL = 5;
-
-    /**
      * Regular layout - usually an unsolicited layout from the view system
      */
     static final int LAYOUT_NORMAL = 0;
@@ -440,6 +435,8 @@
     private Runnable mClearScrollingCache;
     private int mMinimumVelocity;
     private int mMaximumVelocity;
+    
+    final boolean[] mIsScrap = new boolean[1];
 
     /**
      * Interface definition for a callback to be invoked when the list or grid
@@ -1239,9 +1236,13 @@
      * converting an old view or making a new one.
      *
      * @param position The position to display
+     * @param isScrap Array of at least 1 boolean, the first entry will become true if
+     *                the returned view was taken from the scrap heap, false if otherwise.
+     * 
      * @return A view displaying the data associated with the specified position
      */
-    View obtainView(int position) {
+    View obtainView(int position, boolean[] isScrap) {
+        isScrap[0] = false;
         View scrapView;
 
         scrapView = mRecycler.getScrapView(position);
@@ -1269,6 +1270,8 @@
                     ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.MOVE_TO_SCRAP_HEAP,
                             position, -1);
                 }
+            } else {
+                isScrap[0] = true;                
             }
         } else {
             child = mAdapter.getView(position, null, this);
@@ -1543,6 +1546,9 @@
         // Dismiss the popup in case onSaveInstanceState() was not invoked
         dismissPopup();
 
+        // Detach any view left in the scrap heap
+        mRecycler.clear();
+
         final ViewTreeObserver treeObserver = getViewTreeObserver();
         if (treeObserver != null) {
             treeObserver.removeOnTouchModeChangeListener(this);
@@ -3595,12 +3601,12 @@
             for (int i = 0; i < count; ++i) {
                 final View victim = activeViews[i];
                 if (victim != null) {
-                    int whichScrap = ((AbsListView.LayoutParams)
-                            victim.getLayoutParams()).viewType;
+                    int whichScrap = ((AbsListView.LayoutParams) victim.getLayoutParams()).viewType;
 
                     activeViews[i] = null;
 
                     if (whichScrap == AdapterView.ITEM_VIEW_TYPE_IGNORE) {
+                        removeDetachedView(victim, false);
                         // Do not move views that should be ignored
                         continue;
                     }
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index ce985e3..b455d47 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -1485,8 +1485,8 @@
          * @return the view for the specified item
          */
         @Override
-        protected View obtainView(int position) {
-            View view = super.obtainView(position);
+        View obtainView(int position, boolean[] isScrap) {
+            View view = super.obtainView(position, isScrap);
 
             if (view instanceof TextView) {
                 ((TextView) view).setHorizontallyScrolling(true);
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java
index ffe9908..2e91e52 100644
--- a/core/java/android/widget/GridView.java
+++ b/core/java/android/widget/GridView.java
@@ -931,7 +931,7 @@
         mItemCount = mAdapter == null ? 0 : mAdapter.getCount();
         final int count = mItemCount;
         if (count > 0) {
-            final View child = obtainView(0);
+            final View child = obtainView(0, mIsScrap);
 
             AbsListView.LayoutParams p = (AbsListView.LayoutParams)child.getLayoutParams();
             if (p == null) {
@@ -1203,7 +1203,7 @@
         View child;
 
         if (!mDataChanged) {
-            // Try to use an exsiting view for this position
+            // Try to use an existing view for this position
             child = mRecycler.getActiveView(position);
             if (child != null) {
                 // Found it -- we're using an existing child
@@ -1215,10 +1215,10 @@
 
         // Make a new view for this position, or convert an unused view if
         // possible
-        child = obtainView(position);
+        child = obtainView(position, mIsScrap);
 
         // This needs to be positioned and measured
-        setupChild(child, position, y, flow, childrenLeft, selected, false, where);
+        setupChild(child, position, y, flow, childrenLeft, selected, mIsScrap[0], where);
 
         return child;
     }
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index e0d2cef..f4008f9 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -1033,7 +1033,7 @@
         mItemCount = mAdapter == null ? 0 : mAdapter.getCount();
         if (mItemCount > 0 && (widthMode == MeasureSpec.UNSPECIFIED ||
                 heightMode == MeasureSpec.UNSPECIFIED)) {
-            final View child = obtainView(0);
+            final View child = obtainView(0, mIsScrap);
 
             measureScrapChild(child, 0, widthMeasureSpec);
 
@@ -1142,9 +1142,10 @@
         endPosition = (endPosition == NO_POSITION) ? adapter.getCount() - 1 : endPosition;
         final AbsListView.RecycleBin recycleBin = mRecycler;
         final boolean recyle = recycleOnMeasure();
+        final boolean[] isScrap = mIsScrap;
 
         for (i = startPosition; i <= endPosition; ++i) {
-            child = obtainView(i);
+            child = obtainView(i, isScrap);
 
             measureScrapChild(child, i, widthMeasureSpec);
 
@@ -1665,10 +1666,10 @@
         }
 
         // Make a new view for this position, or convert an unused view if possible
-        child = obtainView(position);
+        child = obtainView(position, mIsScrap);
 
         // This needs to be positioned and measured
-        setupChild(child, position, y, flow, childrenLeft, selected, false);
+        setupChild(child, position, y, flow, childrenLeft, selected, mIsScrap[0]);
 
         return child;
     }
@@ -2823,17 +2824,19 @@
 
     private View addViewAbove(View theView, int position) {
         int abovePosition = position - 1;
-        View view = obtainView(abovePosition);
+        View view = obtainView(abovePosition, mIsScrap);
         int edgeOfNewChild = theView.getTop() - mDividerHeight;
-        setupChild(view, abovePosition, edgeOfNewChild, false, mListPadding.left, false, false);
+        setupChild(view, abovePosition, edgeOfNewChild, false, mListPadding.left,
+                false, mIsScrap[0]);
         return view;
     }
 
     private View addViewBelow(View theView, int position) {
         int belowPosition = position + 1;
-        View view = obtainView(belowPosition);
+        View view = obtainView(belowPosition, mIsScrap);
         int edgeOfNewChild = theView.getBottom() + mDividerHeight;
-        setupChild(view, belowPosition, edgeOfNewChild, true, mListPadding.left, false, false);
+        setupChild(view, belowPosition, edgeOfNewChild, true, mListPadding.left,
+                false, mIsScrap[0]);
         return view;
     }
 
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 880e459..115dd62 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -266,7 +266,7 @@
         return new Allocation(id, rs, null);
     }
 
-    static public Allocation createFromBitmapBoxed(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
+    static Allocation createFromBitmapBoxed(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
         throws IllegalArgumentException {
 
         rs.validate();
diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java
index fcf487c..b80e619 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -156,9 +156,7 @@
             mBufferIDs.length);
 
         Element ie = Element.createPixel(mRS, Element.DataType.UNSIGNED_5_6_5, Element.DataKind.PIXEL_RGB);
-        android.util.Log.e("rs", "load 1");
         mImages[0] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p01, ie, true);
-        android.util.Log.e("rs", "load 2");
         mImages[1] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p02, ie, true);
         mImages[2] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p03, ie, true);
         mImages[3] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p04, ie, true);
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 19699dc..b4ec1a2 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -463,8 +463,9 @@
 {
     const Element *src = static_cast<const Element *>(_src);
     const Element *dst = static_cast<const Element *>(_dst);
-    rsAssert(!(w & (w-1)));
-    rsAssert(!(h & (h-1)));
+
+    // Check for pow2 on pre es 2.0 versions.
+    rsAssert(rsc->checkVersion2_0() || (!(w & (w-1)) && !(h & (h-1))));
 
     //LOGE("rsi_AllocationCreateFromBitmap %i %i %i %i %i", w, h, dstFmt, srcFmt, genMips);
     rsi_TypeBegin(rsc, _dst);
diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java
index a09aa5c..2294069 100644
--- a/media/java/android/media/MediaFile.java
+++ b/media/java/android/media/MediaFile.java
@@ -120,6 +120,7 @@
         addFileType("RTX", FILE_TYPE_MID, "audio/midi");
         addFileType("OTA", FILE_TYPE_MID, "audio/midi");
         
+        addFileType("MPEG", FILE_TYPE_MP4, "video/mpeg");
         addFileType("MP4", FILE_TYPE_MP4, "video/mp4");
         addFileType("M4V", FILE_TYPE_M4V, "video/mp4");
         addFileType("3GP", FILE_TYPE_3GPP, "video/3gpp");