Merge "Fix item cache bug" into nyc-dev
diff --git a/annotations/src/android/support/annotation/RequiresApi.java b/annotations/src/android/support/annotation/RequiresApi.java
index 39f0b51..ddd3158 100644
--- a/annotations/src/android/support/annotation/RequiresApi.java
+++ b/annotations/src/android/support/annotation/RequiresApi.java
@@ -36,6 +36,14 @@
 @Retention(CLASS)
 @Target({TYPE,METHOD,CONSTRUCTOR,FIELD})
 public @interface RequiresApi {
+    /**
+     * The API level to require. Alias for {@link #api} which allows you to leave out the
+     * {@code api=} part.
+     */
     @IntRange(from=1)
-    int value();
+    int value() default 1;
+
+    /** The API level to require */
+    @IntRange(from=1)
+    int api() default 1;
 }
diff --git a/build.gradle b/build.gradle
index 9832ab9..ff93bdc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,12 +9,12 @@
         maven { url "../../prebuilts/maven_repo/android" }
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.1.0'
+        classpath 'com.android.tools.build:gradle:2.2.0-alpha1'
     }
 }
 
-ext.supportVersion = '24.0.0-SNAPSHOT'
-ext.extraVersion = 25
+ext.supportVersion = '24.0.0'
+ext.extraVersion = 33
 ext.supportRepoOut = ''
 ext.buildToolsVersion = '23.0.2'
 ext.buildNumber = Integer.toString(ext.extraVersion)
diff --git a/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlayFragment.java b/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlayFragment.java
index 4825cb1..64029cd 100644
--- a/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlayFragment.java
+++ b/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlayFragment.java
@@ -157,9 +157,9 @@
                     mFadeCompleteListener.onFadeInComplete();
                 }
             } else {
-                if (getVerticalGridView() != null) {
-                    // Reset focus to the controls row
-                    getVerticalGridView().setSelectedPosition(0);
+                VerticalGridView verticalView = getVerticalGridView();
+                // reset focus to the primary actions only if the selected row was the controls row
+                if (verticalView != null && verticalView.getSelectedPosition() == 0) {
                     resetControlsToPrimaryActions(null);
                 }
                 if (mFadeCompleteListener != null) {
diff --git a/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlaySupportFragment.java b/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlaySupportFragment.java
index 9fd1805..a4e3f24 100644
--- a/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlaySupportFragment.java
+++ b/v17/leanback/src/android/support/v17/leanback/app/PlaybackOverlaySupportFragment.java
@@ -159,9 +159,9 @@
                     mFadeCompleteListener.onFadeInComplete();
                 }
             } else {
-                if (getVerticalGridView() != null) {
-                    // Reset focus to the controls row
-                    getVerticalGridView().setSelectedPosition(0);
+                VerticalGridView verticalView = getVerticalGridView();
+                // reset focus to the primary actions only if the selected row was the controls row
+                if (verticalView != null && verticalView.getSelectedPosition() == 0) {
                     resetControlsToPrimaryActions(null);
                 }
                 if (mFadeCompleteListener != null) {
diff --git a/v17/preference-leanback/res/layout/leanback_list_preference_item_multi.xml b/v17/preference-leanback/res/layout/leanback_list_preference_item_multi.xml
index 728ecff..e7f6f85 100644
--- a/v17/preference-leanback/res/layout/leanback_list_preference_item_multi.xml
+++ b/v17/preference-leanback/res/layout/leanback_list_preference_item_multi.xml
@@ -31,6 +31,8 @@
         android:id="@+id/button"
         android:layout_width="@dimen/lb_preference_item_icon_size"
         android:layout_height="@dimen/lb_preference_item_icon_size"
+        android:focusable="false"
+        android:clickable="false"
         android:layout_marginEnd="@dimen/lb_preference_item_icon_margin_end"
         android:layout_gravity="center_vertical" />
 
diff --git a/v17/preference-leanback/res/layout/leanback_list_preference_item_single.xml b/v17/preference-leanback/res/layout/leanback_list_preference_item_single.xml
index 354ca41..836b82e 100644
--- a/v17/preference-leanback/res/layout/leanback_list_preference_item_single.xml
+++ b/v17/preference-leanback/res/layout/leanback_list_preference_item_single.xml
@@ -31,6 +31,8 @@
         android:id="@+id/button"
         android:layout_width="@dimen/lb_preference_item_icon_size"
         android:layout_height="@dimen/lb_preference_item_icon_size"
+        android:focusable="false"
+        android:clickable="false"
         android:layout_marginEnd="@dimen/lb_preference_item_icon_margin_end"
         android:layout_gravity="center_vertical" />
 
diff --git a/v4/api/current.txt b/v4/api/current.txt
index fad9324..89e6daa 100644
--- a/v4/api/current.txt
+++ b/v4/api/current.txt
@@ -105,18 +105,6 @@
     field public static final int MODE_IGNORED = 1; // 0x1
   }
 
-   abstract class BaseFragmentActivityDonut extends android.app.Activity {
-  }
-
-   abstract class BaseFragmentActivityEclair extends android.support.v4.app.BaseFragmentActivityDonut {
-  }
-
-   abstract class BaseFragmentActivityHoneycomb extends android.support.v4.app.BaseFragmentActivityEclair {
-  }
-
-   abstract class BaseFragmentActivityJB extends android.support.v4.app.BaseFragmentActivityHoneycomb {
-  }
-
   public final class BundleCompat {
     method public static android.os.IBinder getBinder(android.os.Bundle, java.lang.String);
     method public static void putBinder(android.os.Bundle, java.lang.String, android.os.IBinder);
@@ -256,7 +244,7 @@
     field public static final android.os.Parcelable.Creator<android.support.v4.app.Fragment.SavedState> CREATOR;
   }
 
-  public class FragmentActivity extends android.support.v4.app.BaseFragmentActivityJB implements android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback {
+  public class FragmentActivity extends android.app.Activity implements android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback {
     ctor public FragmentActivity();
     method public java.lang.Object getLastCustomNonConfigurationInstance();
     method public android.support.v4.app.FragmentManager getSupportFragmentManager();
diff --git a/v4/donut/android/support/v4/app/BaseFragmentActivityDonut.java b/v4/donut/android/support/v4/app/BaseFragmentActivityDonut.java
index 2778c92..4179632 100644
--- a/v4/donut/android/support/v4/app/BaseFragmentActivityDonut.java
+++ b/v4/donut/android/support/v4/app/BaseFragmentActivityDonut.java
@@ -25,6 +25,8 @@
 
 /**
  * Base class for {@code FragmentActivity} to be able to use Donut APIs.
+ *
+ * @hide
  */
 abstract class BaseFragmentActivityDonut extends Activity {
 
diff --git a/v4/donut/android/support/v4/os/BuildCompat.java b/v4/donut/android/support/v4/os/BuildCompat.java
index cf35e7b..9792598 100644
--- a/v4/donut/android/support/v4/os/BuildCompat.java
+++ b/v4/donut/android/support/v4/os/BuildCompat.java
@@ -31,13 +31,13 @@
     /**
      * Check if the device is running on the Android N release or newer.
      * This method is suitable for use with preview SDKs and associated
-     * prerelease device builds.
+     * pre-release device builds.
      *
-     * @return true if N APIs are available for use
+     * @return {@code true} if N APIs are available for use
      */
     public static boolean isAtLeastN() {
-        if (TextUtils.isEmpty(VERSION.CODENAME)) {
-            return false;
+        if (TextUtils.isEmpty(VERSION.CODENAME) || "REL".equals(VERSION.CODENAME)) {
+            return VERSION.SDK_INT > 23;
         }
         final char prefix = VERSION.CODENAME.charAt(0);
         return prefix >= 'N' && prefix <= 'Z';
diff --git a/v4/eclair/android/support/v4/app/BaseFragmentActivityEclair.java b/v4/eclair/android/support/v4/app/BaseFragmentActivityEclair.java
index c5f6d2b..a77f057 100644
--- a/v4/eclair/android/support/v4/app/BaseFragmentActivityEclair.java
+++ b/v4/eclair/android/support/v4/app/BaseFragmentActivityEclair.java
@@ -22,6 +22,8 @@
 
 /**
  * Base class for {@code FragmentActivity} to be able to use v5 APIs.
+ *
+ * @hide
  */
 abstract class BaseFragmentActivityEclair extends BaseFragmentActivityDonut {
 
diff --git a/v4/honeycomb/android/support/v4/app/BaseFragmentActivityHoneycomb.java b/v4/honeycomb/android/support/v4/app/BaseFragmentActivityHoneycomb.java
index 8acd31e..10e6a79 100644
--- a/v4/honeycomb/android/support/v4/app/BaseFragmentActivityHoneycomb.java
+++ b/v4/honeycomb/android/support/v4/app/BaseFragmentActivityHoneycomb.java
@@ -23,6 +23,8 @@
 
 /**
  * Base class for {@code FragmentActivity} to be able to use v11 APIs.
+ *
+ * @hide
  */
 abstract class BaseFragmentActivityHoneycomb extends BaseFragmentActivityEclair {
 
diff --git a/v4/java/android/support/v4/media/MediaBrowserServiceCompat.java b/v4/java/android/support/v4/media/MediaBrowserServiceCompat.java
index 4528d05..9163cd7 100644
--- a/v4/java/android/support/v4/media/MediaBrowserServiceCompat.java
+++ b/v4/java/android/support/v4/media/MediaBrowserServiceCompat.java
@@ -16,6 +16,30 @@
 
 package android.support.v4.media;
 
+import static android.support.v4.media.MediaBrowserProtocol.CLIENT_MSG_ADD_SUBSCRIPTION;
+import static android.support.v4.media.MediaBrowserProtocol.CLIENT_MSG_CONNECT;
+import static android.support.v4.media.MediaBrowserProtocol.CLIENT_MSG_DISCONNECT;
+import static android.support.v4.media.MediaBrowserProtocol.CLIENT_MSG_GET_MEDIA_ITEM;
+import static android.support.v4.media.MediaBrowserProtocol.CLIENT_MSG_REGISTER_CALLBACK_MESSENGER;
+import static android.support.v4.media.MediaBrowserProtocol.CLIENT_MSG_REMOVE_SUBSCRIPTION;
+import static android.support.v4.media.MediaBrowserProtocol.CLIENT_MSG_UNREGISTER_CALLBACK_MESSENGER;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_CALLBACK_TOKEN;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_CALLING_UID;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_MEDIA_ITEM_ID;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_MEDIA_ITEM_LIST;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_MEDIA_SESSION_TOKEN;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_OPTIONS;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_PACKAGE_NAME;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_RESULT_RECEIVER;
+import static android.support.v4.media.MediaBrowserProtocol.DATA_ROOT_HINTS;
+import static android.support.v4.media.MediaBrowserProtocol.EXTRA_CLIENT_VERSION;
+import static android.support.v4.media.MediaBrowserProtocol.EXTRA_MESSENGER_BINDER;
+import static android.support.v4.media.MediaBrowserProtocol.EXTRA_SERVICE_VERSION;
+import static android.support.v4.media.MediaBrowserProtocol.SERVICE_MSG_ON_CONNECT;
+import static android.support.v4.media.MediaBrowserProtocol.SERVICE_MSG_ON_CONNECT_FAILED;
+import static android.support.v4.media.MediaBrowserProtocol.SERVICE_MSG_ON_LOAD_CHILDREN;
+import static android.support.v4.media.MediaBrowserProtocol.SERVICE_VERSION_CURRENT;
+
 import android.app.Service;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -49,8 +73,6 @@
 import java.util.HashMap;
 import java.util.List;
 
-import static android.support.v4.media.MediaBrowserProtocol.*;
-
 /**
  * Base class for media browse services.
  * <p>
@@ -873,11 +895,18 @@
 
     /**
      * Gets the root hints sent from the currently connected {@link MediaBrowserCompat}.
+     * The root hints are service-specific arguments included in an optional bundle sent to the
+     * media browser service when connecting and retrieving the root id for browsing, or null if
+     * none. The contents of this bundle may affect the information returned when browsing.
+     * <p>
      * Note that this will return null when connected to {@link android.media.browse.MediaBrowser}
      * and running on API 23 or lower.
      *
      * @throws IllegalStateException If this method is called outside of {@link #onLoadChildren}
      *             or {@link #onLoadItem}
+     * @see MediaBrowserServiceCompat.BrowserRoot#EXTRA_RECENT
+     * @see MediaBrowserServiceCompat.BrowserRoot#EXTRA_OFFLINE
+     * @see MediaBrowserServiceCompat.BrowserRoot#EXTRA_SUGGESTED
      */
     public final Bundle getBrowserRootHints() {
         return mImpl.getBrowserRootHints();
diff --git a/v4/jellybean/android/support/v4/app/BaseFragmentActivityJB.java b/v4/jellybean/android/support/v4/app/BaseFragmentActivityJB.java
index 615c762..147251c 100644
--- a/v4/jellybean/android/support/v4/app/BaseFragmentActivityJB.java
+++ b/v4/jellybean/android/support/v4/app/BaseFragmentActivityJB.java
@@ -23,6 +23,8 @@
 
 /**
  * Base class for {@code FragmentActivity} to be able to use v16 APIs.
+ *
+ * @hide
  */
 abstract class BaseFragmentActivityJB extends BaseFragmentActivityHoneycomb {
 
diff --git a/v7/appcompat/src/android/support/v7/app/AlertDialog.java b/v7/appcompat/src/android/support/v7/app/AlertDialog.java
index 78a1f50..5c0a1d7 100644
--- a/v7/appcompat/src/android/support/v7/app/AlertDialog.java
+++ b/v7/appcompat/src/android/support/v7/app/AlertDialog.java
@@ -26,7 +26,10 @@
 import android.support.annotation.ArrayRes;
 import android.support.annotation.AttrRes;
 import android.support.annotation.DrawableRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
 import android.support.annotation.StringRes;
+import android.support.annotation.StyleRes;
 import android.support.v7.appcompat.R;
 import android.util.TypedValue;
 import android.view.ContextThemeWrapper;
@@ -66,7 +69,7 @@
  */
 public class AlertDialog extends AppCompatDialog implements DialogInterface {
 
-    private AlertController mAlert;
+    private final AlertController mAlert;
 
     /**
      * No layout hint.
@@ -78,33 +81,29 @@
      */
     static final int LAYOUT_HINT_SIDE = 1;
 
-    protected AlertDialog(Context context) {
-        this(context, resolveDialogTheme(context, 0), true);
+    protected AlertDialog(@NonNull Context context) {
+        this(context, 0);
     }
 
     /**
      * Construct an AlertDialog that uses an explicit theme.  The actual style
      * that an AlertDialog uses is a private implementation, however you can
      * here supply either the name of an attribute in the theme from which
-     * to get the dialog's style (such as {@link android.R.attr#alertDialogTheme}.
+     * to get the dialog's style (such as {@link R.attr#alertDialogTheme}.
      */
-    protected AlertDialog(Context context, int theme) {
-        this(context, theme, true);
-    }
-
-    AlertDialog(Context context, int theme, boolean createThemeContextWrapper) {
-        super(context, resolveDialogTheme(context, theme));
+    protected AlertDialog(@NonNull Context context, @StyleRes int themeResId) {
+        super(context, resolveDialogTheme(context, themeResId));
         mAlert = new AlertController(getContext(), this, getWindow());
     }
 
-    protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
-        super(context, resolveDialogTheme(context, 0));
+    protected AlertDialog(@NonNull Context context, boolean cancelable,
+            @Nullable OnCancelListener cancelListener) {
+        this(context, 0);
         setCancelable(cancelable);
         setOnCancelListener(cancelListener);
-        mAlert = new AlertController(context, this, getWindow());
     }
 
-    static int resolveDialogTheme(Context context, int resid) {
+    private static int resolveDialogTheme(@NonNull Context context, @StyleRes int resid) {
         if (resid >= 0x01000000) {   // start of real resource IDs.
             return resid;
         } else {
@@ -276,6 +275,7 @@
 
     public static class Builder {
         private final AlertController.AlertParams P;
+        private final int mTheme;
 
         /**
          * Creates a builder for an alert dialog that uses the default alert
@@ -287,7 +287,7 @@
          *
          * @param context the parent context
          */
-        public Builder(Context context) {
+        public Builder(@NonNull Context context) {
             this(context, resolveDialogTheme(context, 0));
         }
 
@@ -317,9 +317,10 @@
          *                   this dialog, or {@code 0} to use the parent
          *                   {@code context}'s default alert dialog theme
          */
-        public Builder(Context context, int themeResId) {
+        public Builder(@NonNull Context context, @StyleRes int themeResId) {
             P = new AlertController.AlertParams(new ContextThemeWrapper(
                     context, resolveDialogTheme(context, themeResId)));
+            mTheme = themeResId;
         }
 
         /**
@@ -330,6 +331,7 @@
          *
          * @return A Context for built Dialogs.
          */
+        @NonNull
         public Context getContext() {
             return P.mContext;
         }
@@ -873,6 +875,7 @@
          * be able to put padding around the view.
          * @hide
          */
+        @Deprecated
         public Builder setView(View view, int viewSpacingLeft, int viewSpacingTop,
                 int viewSpacingRight, int viewSpacingBottom) {
             P.mView = view;
@@ -919,8 +922,9 @@
          * create and display the dialog.
          */
         public AlertDialog create() {
-            // Context has already been wrapped with the appropriate theme.
-            final AlertDialog dialog = new AlertDialog(P.mContext, 0, false);
+            // We can't use Dialog's 3-arg constructor with the createThemeContextWrapper param,
+            // so we always have to re-set the theme
+            final AlertDialog dialog = new AlertDialog(P.mContext, mTheme);
             P.apply(dialog.mAlert);
             dialog.setCancelable(P.mCancelable);
             if (P.mCancelable) {
diff --git a/v7/appcompat/tests/src/android/support/v7/app/AlertDialogTest.java b/v7/appcompat/tests/src/android/support/v7/app/AlertDialogTest.java
index 213a898..6a9d8c1 100644
--- a/v7/appcompat/tests/src/android/support/v7/app/AlertDialogTest.java
+++ b/v7/appcompat/tests/src/android/support/v7/app/AlertDialogTest.java
@@ -23,6 +23,7 @@
 import android.support.annotation.ColorInt;
 import android.support.annotation.StringRes;
 import android.support.test.InstrumentationRegistry;
+import android.support.test.annotation.UiThreadTest;
 import android.support.test.espresso.Espresso;
 import android.support.test.espresso.ViewInteraction;
 import android.support.v7.appcompat.test.R;
@@ -30,6 +31,7 @@
 import android.test.suitebuilder.annotation.MediumTest;
 import android.test.suitebuilder.annotation.SmallTest;
 import android.text.TextUtils;
+import android.util.TypedValue;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.ArrayAdapter;
@@ -101,6 +103,21 @@
 
     @Test
     @SmallTest
+    @UiThreadTest
+    public void testBuilderTheme() {
+        final Context context = mActivityTestRule.getActivity();
+        final AlertDialog dialog = new AlertDialog.Builder(context, R.style.Theme_TextColors)
+                .setTitle(R.string.alert_dialog_title)
+                .setMessage(R.string.alert_dialog_content)
+                .create();
+
+        final TypedValue tv = new TypedValue();
+        dialog.getContext().getTheme().resolveAttribute(android.R.attr.textColorPrimary, tv, true);
+        assertEquals(0xFF0000FF, tv.data);
+    }
+
+    @Test
+    @SmallTest
     public void testBasicContent() {
         final Context context = mActivityTestRule.getActivity();
         AlertDialog.Builder builder = new AlertDialog.Builder(context)
diff --git a/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java b/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java
index 286ccda..e7bff81 100644
--- a/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java
+++ b/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java
@@ -277,7 +277,7 @@
      * Prior to L, there is no way to query this variable which is why we override the setter and
      * track it here.
      */
-    private boolean mClipToPadding;
+    private boolean mClipToPadding = true;
 
     /**
      * Note: this Runnable is only ever posted if:
@@ -2132,6 +2132,7 @@
                 needsFocusFailureLayout = found == null;
             }
             if (needsFocusFailureLayout) {
+                consumePendingUpdateOperations();
                 eatRequestLayout();
                 mLayout.onFocusSearchFailed(focused, direction, mRecycler, mState);
                 resumeRequestLayout(false);
@@ -2140,6 +2141,7 @@
         } else {
             result = ff.findNextFocus(this, focused, direction);
             if (result == null && canRunFocusFailure) {
+                consumePendingUpdateOperations();
                 eatRequestLayout();
                 result = mLayout.onFocusSearchFailed(focused, direction, mRecycler, mState);
                 resumeRequestLayout(false);
diff --git a/v7/recyclerview/tests/src/android/support/v7/widget/RecyclerViewLayoutTest.java b/v7/recyclerview/tests/src/android/support/v7/widget/RecyclerViewLayoutTest.java
index 252ca6b..75a3efd 100644
--- a/v7/recyclerview/tests/src/android/support/v7/widget/RecyclerViewLayoutTest.java
+++ b/v7/recyclerview/tests/src/android/support/v7/widget/RecyclerViewLayoutTest.java
@@ -561,6 +561,53 @@
     }
 
     @Test
+    public void testFocusSearchAfterChangedData() throws Throwable {
+        final RecyclerView recyclerView = new RecyclerView(getActivity());
+        TestLayoutManager tlm = new TestLayoutManager() {
+            @Override
+            public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
+                layoutRange(recycler, 0, 2);
+                layoutLatch.countDown();
+            }
+
+            @Nullable
+            @Override
+            public View onFocusSearchFailed(View focused, int direction,
+                                            RecyclerView.Recycler recycler,
+                                            RecyclerView.State state) {
+                try {
+                    View view = recycler.getViewForPosition(state.getItemCount() - 1);
+                } catch (Throwable t) {
+                    postExceptionToInstrumentation(t);
+                }
+                return null;
+            }
+        };
+        recyclerView.setLayoutManager(tlm);
+        final TestAdapter adapter = new TestAdapter(10) {
+            @Override
+            public void onBindViewHolder(TestViewHolder holder, int position) {
+                super.onBindViewHolder(holder, position);
+                holder.itemView.setFocusable(false);
+                holder.itemView.setFocusableInTouchMode(false);
+            }
+        };
+        recyclerView.setAdapter(adapter);
+        tlm.expectLayouts(1);
+        setRecyclerView(recyclerView);
+        tlm.waitForLayout(1);
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                adapter.mItems.remove(9);
+                adapter.notifyItemRemoved(9);
+                recyclerView.focusSearch(recyclerView.getChildAt(1), View.FOCUS_DOWN);
+            }
+        });
+        checkForMainThreadException();
+    }
+
+    @Test
     public void  testFocusSearchFailFrozen() throws Throwable {
         RecyclerView recyclerView = new RecyclerView(getActivity());
         final CountDownLatch focusLatch = new CountDownLatch(1);
diff --git a/v8/renderscript/rs_support/Android.mk b/v8/renderscript/rs_support/Android.mk
index dbac81c..de8fae0 100644
--- a/v8/renderscript/rs_support/Android.mk
+++ b/v8/renderscript/rs_support/Android.mk
@@ -142,18 +142,34 @@
 ifeq ($(ARCH_ARM_HAVE_ARMV7A),true)
 LOCAL_CFLAGS_arm := -DARCH_ARM_HAVE_VFP -DARCH_ARM_USE_INTRINSICS
 LOCAL_ASFLAGS_arm := -mfpu=neon
-# Clang does not support nested .irp in *_Blur.S
-LOCAL_CLANG_ASFLAGS_arm += -no-integrated-as
 LOCAL_SRC_FILES_arm := \
-        cpu_ref/rsCpuIntrinsics_neon_3DLUT.S \
-	cpu_ref/rsCpuIntrinsics_neon_ColorMatrix.S \
-        cpu_ref/rsCpuIntrinsics_neon_Blend.S \
-        cpu_ref/rsCpuIntrinsics_neon_Blur.S \
-	cpu_ref/rsCpuIntrinsics_neon_Convolve.S \
-	cpu_ref/rsCpuIntrinsics_neon_Resize.S \
-        cpu_ref/rsCpuIntrinsics_neon_YuvToRGB.S
+    cpu_ref/rsCpuIntrinsics_neon_3DLUT.S \
+    cpu_ref/rsCpuIntrinsics_neon_Blend.S \
+    cpu_ref/rsCpuIntrinsics_neon_Blur.S \
+    cpu_ref/rsCpuIntrinsics_neon_ColorMatrix.S \
+    cpu_ref/rsCpuIntrinsics_neon_Convolve.S \
+    cpu_ref/rsCpuIntrinsics_neon_Resize.S \
+    cpu_ref/rsCpuIntrinsics_neon_YuvToRGB.S
 endif
 
+LOCAL_CFLAGS_arm64 += \
+    -DARCH_ARM_USE_INTRINSICS \
+    -DARCH_ARM64_USE_INTRINSICS \
+    -DARCH_ARM64_HAVE_NEON
+LOCAL_SRC_FILES_arm64 += \
+    cpu_ref/rsCpuIntrinsics_advsimd_3DLUT.S \
+    cpu_ref/rsCpuIntrinsics_advsimd_Blend.S \
+    cpu_ref/rsCpuIntrinsics_advsimd_Blur.S \
+    cpu_ref/rsCpuIntrinsics_advsimd_ColorMatrix.S \
+    cpu_ref/rsCpuIntrinsics_advsimd_Convolve.S \
+    cpu_ref/rsCpuIntrinsics_advsimd_Resize.S \
+    cpu_ref/rsCpuIntrinsics_advsimd_YuvToRGB.S
+
+LOCAL_CFLAGS_x86 += -DARCH_X86_HAVE_SSSE3
+LOCAL_SRC_FILES_x86 += cpu_ref/rsCpuIntrinsics_x86.cpp
+LOCAL_CFLAGS_x86_64 += -DARCH_X86_HAVE_SSSE3
+LOCAL_SRC_FILES_x86_64 += cpu_ref/rsCpuIntrinsics_x86.cpp
+
 LOCAL_REQUIRED_MODULES := libblasV8
 LOCAL_STATIC_LIBRARIES := libbnnmlowpV8
 LOCAL_LDFLAGS += -llog -ldl -Wl,--exclude-libs,libc++_static.a