am e831f2b2: am 2f5eddd3: am 8b5349cf: am c3494a45: Merge "Checking for multiuser before trying to create one" into mnc-dev

* commit 'e831f2b27ebe7767db3f877b66e2ea76a7ea4119':
  Checking for multiuser before trying to create one
diff --git a/hostsidetests/security/Android.mk b/hostsidetests/security/Android.mk
index d9fbc65..3e35e45 100644
--- a/hostsidetests/security/Android.mk
+++ b/hostsidetests/security/Android.mk
@@ -31,13 +31,23 @@
 
 selinux_general_seapp_contexts := $(call intermediates-dir-for,ETC,general_seapp_contexts)/general_seapp_contexts
 
+selinux_general_seapp_neverallows := $(call intermediates-dir-for,ETC,general_seapp_neverallows)/general_seapp_neverallows
+
 selinux_general_file_contexts := $(call intermediates-dir-for,ETC,general_file_contexts)/general_file_contexts
 
 selinux_general_property_contexts := $(call intermediates-dir-for,ETC,general_property_contexts)/general_property_contexts
 
 selinux_general_service_contexts := $(call intermediates-dir-for,ETC,general_service_contexts)/general_service_contexts
 
-LOCAL_JAVA_RESOURCE_FILES := $(HOST_OUT_EXECUTABLES)/sepolicy-analyze $(HOST_OUT_EXECUTABLES)/checkseapp $(HOST_OUT_EXECUTABLES)/checkfc $(selinux_general_seapp_contexts) $(selinux_general_file_contexts) $(selinux_general_property_contexts) $(selinux_general_service_contexts)
+LOCAL_JAVA_RESOURCE_FILES := \
+    $(HOST_OUT_EXECUTABLES)/sepolicy-analyze \
+    $(HOST_OUT_EXECUTABLES)/checkseapp \
+    $(HOST_OUT_EXECUTABLES)/checkfc \
+    $(selinux_general_seapp_contexts) \
+    $(selinux_general_seapp_neverallows) \
+    $(selinux_general_file_contexts) \
+    $(selinux_general_property_contexts) \
+    $(selinux_general_service_contexts)
 
 selinux_general_policy := $(call intermediates-dir-for,ETC,general_sepolicy.conf)/general_sepolicy.conf
 
diff --git a/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java b/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java
index a0d3167..37498f0 100644
--- a/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/cts/security/SELinuxHostTest.java
@@ -66,6 +66,7 @@
     private File deviceFcFile;
     private File devicePcFile;
     private File deviceSvcFile;
+    private File seappNeverAllowFile;
 
     /**
      * A reference to the device under test.
@@ -133,6 +134,7 @@
         aospFcFile = copyResourceToTempFile("/general_file_contexts");
         aospPcFile = copyResourceToTempFile("/general_property_contexts");
         aospSvcFile = copyResourceToTempFile("/general_service_contexts");
+        seappNeverAllowFile = copyResourceToTempFile("/general_seapp_neverallows");
     }
 
     /**
@@ -204,14 +206,12 @@
      * @throws Exception
      */
     public void testValidSeappContexts() throws Exception {
-        File OutputFile = File.createTempFile("seapp_output", ".tmp");
-        OutputFile.deleteOnExit();
 
         /* run checkseapp on seapp_contexts */
         ProcessBuilder pb = new ProcessBuilder(checkSeapp.getAbsolutePath(),
                 "-p", devicePolicyFile.getAbsolutePath(),
-                deviceSeappFile.getAbsolutePath(),
-                "-o", OutputFile.getAbsolutePath());
+                seappNeverAllowFile.getAbsolutePath(),
+                deviceSeappFile.getAbsolutePath());
         pb.redirectOutput(ProcessBuilder.Redirect.PIPE);
         pb.redirectErrorStream(true);
         Process p = pb.start();
@@ -667,15 +667,15 @@
     }
 
     /*
-     * There will at least be some kernel thread running and all kthreads should
-     * be in kernel context.
+     * All kthreads should be in kernel context.
      */
     public void testKernelDomain() throws DeviceNotAvailableException {
         String domain = "u:r:kernel:s0";
         List<ProcessDetails> procs = ProcessDetails.getProcMap(mDevice).get(domain);
-        assertNotNull(procs);
-        for (ProcessDetails p : procs) {
-            assertTrue("Non Kernel thread \"" + p + "\" found!", p.isKernel());
+        if (procs != null) {
+            for (ProcessDetails p : procs) {
+                assertTrue("Non Kernel thread \"" + p + "\" found!", p.isKernel());
+            }
         }
     }
 
diff --git a/suite/audio_quality/lib/include/Log.h b/suite/audio_quality/lib/include/Log.h
index d7520f0..b33c21f 100644
--- a/suite/audio_quality/lib/include/Log.h
+++ b/suite/audio_quality/lib/include/Log.h
@@ -64,6 +64,6 @@
 #define ASSERT(cond) if(!(cond)) {  Log::Instance()->printf(Log::ELogE, \
         "assertion failed %s %d", __FILE__, __LINE__); \
     Log::Finalize(); \
-    *(char*)0 = 0; /* this will crash */};
+    abort(); };
 
 #endif // CTSAUDIO_LOG_H
diff --git a/suite/audio_quality/lib/src/FileUtil.cpp b/suite/audio_quality/lib/src/FileUtil.cpp
index dffc394..3b87016 100644
--- a/suite/audio_quality/lib/src/FileUtil.cpp
+++ b/suite/audio_quality/lib/src/FileUtil.cpp
@@ -81,7 +81,7 @@
     mBuffer = new char[DEFAULT_BUFFER_SIZE];
     if (mBuffer == NULL) {
         // cannot use ASSERT here, just crash
-        *(char*)0 = 0;
+        abort();
     }
     mBufferSize = DEFAULT_BUFFER_SIZE;
 }
@@ -130,7 +130,7 @@
             mBuffer = new char[2 * size];
             if (mBuffer == NULL) {
                 // cannot use ASSERT here, just crash
-                *(char*)0 = 0;
+                abort();
             }
             mBufferSize = 2 * size;
             // re-try
diff --git a/suite/audio_quality/lib/src/Log.cpp b/suite/audio_quality/lib/src/Log.cpp
index d4cf353..1d2434a 100644
--- a/suite/audio_quality/lib/src/Log.cpp
+++ b/suite/audio_quality/lib/src/Log.cpp
@@ -23,7 +23,7 @@
 
 #define ASSERT_PLAIN(cond) if(!(cond)) { fprintf(stderr, \
         "assertion failed %s %d", __FILE__, __LINE__); \
-    *(char*)0 = 0; /* this will crash */};
+    abort(); };
 
 Log* Log::Instance(const char* dirName)
 {
diff --git a/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java b/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
index 65f89f3..9f66e15 100644
--- a/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
@@ -44,25 +44,25 @@
         final Point min = getScreenSize();
         final int w = min.x * 3;
         final int h = min.y * 2;
-
         assertDesiredMinimum(new Point(min.x / 2, min.y / 2), min);
 
-        assertDesiredMinimum(new Point(w, h),
-                             new Point(w, h));
+        assertDesiredMinimum(new Point(w, h), min);
 
-        assertDesiredMinimum(new Point(min.x / 2, h),
-                             new Point(min.x, h));
+        assertDesiredMinimum(new Point(min.x / 2, h), min);
 
-        assertDesiredMinimum(new Point(w, min.y / 2),
-                             new Point(w, min.y));
+        assertDesiredMinimum(new Point(w, min.y / 2), min);
     }
 
-    private void assertDesiredMinimum(Point suggestedSize, Point expectedSize) {
+    private void assertDesiredMinimum(Point suggestedSize, Point minSize) {
         mWallpaperManager.suggestDesiredDimensions(suggestedSize.x, suggestedSize.y);
         Point actualSize = new Point(mWallpaperManager.getDesiredMinimumWidth(),
                 mWallpaperManager.getDesiredMinimumHeight());
         if (actualSize.x > 0 || actualSize.y > 0) {
-            assertEquals(expectedSize, actualSize);
+            if((actualSize.x < minSize.x || actualSize.y < minSize.y)){
+                throw new AssertionError("Expected at least x: " + minSize.x + " y: "
+                                         + minSize.y + ", got x: " + actualSize.x +
+                                         " y: " + actualSize.y );
+            }
         }
     }
 
diff --git a/tests/tests/content/src/android/content/cts/DummyProvider.java b/tests/tests/content/src/android/content/cts/DummyProvider.java
index 9c50cb9..926ec1d 100644
--- a/tests/tests/content/src/android/content/cts/DummyProvider.java
+++ b/tests/tests/content/src/android/content/cts/DummyProvider.java
@@ -16,8 +16,6 @@
 
 package android.content.cts;
 
-import dalvik.annotation.TestTargetClass;
-
 import android.content.ContentProvider;
 import android.content.ContentValues;
 import android.content.Context;
@@ -33,7 +31,6 @@
  * @see AsyncQueryHandlerTest
  * @see ContentQueryMapTest
  */
-@TestTargetClass(ContentProvider.class)
 public class DummyProvider extends ContentProvider {
     private static final String MOCK_OPERATION = "mockOperation";
 
diff --git a/tests/tests/net/src/android/net/cts/LocalSocketTest.java b/tests/tests/net/src/android/net/cts/LocalSocketTest.java
index 865ec21..9da8fbe 100644
--- a/tests/tests/net/src/android/net/cts/LocalSocketTest.java
+++ b/tests/tests/net/src/android/net/cts/LocalSocketTest.java
@@ -16,16 +16,19 @@
 
 package android.net.cts;
 
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import android.net.Credentials;
 import android.net.LocalServerSocket;
 import android.net.LocalSocket;
 import android.net.LocalSocketAddress;
 import android.test.AndroidTestCase;
 
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 public class LocalSocketTest extends AndroidTestCase{
     public final static String mSockAddr = "com.android.net.LocalSocketTest";
 
@@ -113,7 +116,7 @@
 
     public void testAccessors() throws IOException{
         LocalSocket socket = new LocalSocket();
-        LocalSocketAddress addr = new LocalSocketAddress("secondary");
+        LocalSocketAddress addr = new LocalSocketAddress(mSockAddr);
 
         assertFalse(socket.isBound());
         socket.bind(addr);
@@ -129,9 +132,9 @@
         socket.setSendBufferSize(3998);
         assertEquals(3998 << 1, socket.getSendBufferSize());
 
-        // Timeout is not support at present, so set is ignored
-        socket.setSoTimeout(1996);
         assertEquals(0, socket.getSoTimeout());
+        socket.setSoTimeout(1996);
+        assertTrue(socket.getSoTimeout() > 0);
 
         try {
             socket.getRemoteSocketAddress();
@@ -167,5 +170,125 @@
         } catch (UnsupportedOperationException e) {
             // expected
         }
+
+        socket.close();
+    }
+
+    public void testAvailable() throws Exception {
+        LocalServerSocket localServerSocket = new LocalServerSocket(mSockAddr);
+        LocalSocket clientSocket = new LocalSocket();
+
+        // establish connection between client and server
+        LocalSocketAddress locSockAddr = new LocalSocketAddress(mSockAddr);
+        clientSocket.connect(locSockAddr);
+        assertTrue(clientSocket.isConnected());
+        LocalSocket serverSocket = localServerSocket.accept();
+
+        OutputStream clientOutputStream = clientSocket.getOutputStream();
+        InputStream serverInputStream = serverSocket.getInputStream();
+        assertEquals(0, serverInputStream.available());
+
+        byte[] buffer = new byte[50];
+        clientOutputStream.write(buffer);
+        assertEquals(50, serverInputStream.available());
+
+        InputStream clientInputStream = clientSocket.getInputStream();
+        OutputStream serverOutputStream = serverSocket.getOutputStream();
+        assertEquals(0, clientInputStream.available());
+        serverOutputStream.write(buffer);
+        assertEquals(50, serverInputStream.available());
+
+        clientSocket.close();
+        serverSocket.close();
+        localServerSocket.close();
+    }
+
+    public void testFlush() throws Exception {
+        LocalServerSocket localServerSocket = new LocalServerSocket(mSockAddr);
+        LocalSocket clientSocket = new LocalSocket();
+
+        // establish connection between client and server
+        LocalSocketAddress locSockAddr = new LocalSocketAddress(mSockAddr);
+        clientSocket.connect(locSockAddr);
+        assertTrue(clientSocket.isConnected());
+        LocalSocket serverSocket = localServerSocket.accept();
+
+        OutputStream clientOutputStream = clientSocket.getOutputStream();
+        InputStream serverInputStream = serverSocket.getInputStream();
+        testFlushWorks(clientOutputStream, serverInputStream);
+
+        OutputStream serverOutputStream = serverSocket.getOutputStream();
+        InputStream clientInputStream = clientSocket.getInputStream();
+        testFlushWorks(serverOutputStream, clientInputStream);
+
+        clientSocket.close();
+        serverSocket.close();
+        localServerSocket.close();
+    }
+
+    private void testFlushWorks(OutputStream outputStream, InputStream inputStream)
+            throws Exception {
+        final int bytesToTransfer = 50;
+        StreamReader inputStreamReader = new StreamReader(inputStream, bytesToTransfer);
+
+        byte[] buffer = new byte[bytesToTransfer];
+        outputStream.write(buffer);
+        assertEquals(bytesToTransfer, inputStream.available());
+
+        // Start consuming the data.
+        inputStreamReader.start();
+
+        // This doesn't actually flush any buffers, it just polls until the reader has read all the
+        // bytes.
+        outputStream.flush();
+
+        inputStreamReader.waitForCompletion(5000);
+        inputStreamReader.assertBytesRead(bytesToTransfer);
+        assertEquals(0, inputStream.available());
+    }
+
+    private static class StreamReader extends Thread {
+        private final InputStream is;
+        private final int expectedByteCount;
+        private final CountDownLatch completeLatch = new CountDownLatch(1);
+
+        private volatile Exception exception;
+        private int bytesRead;
+
+        private StreamReader(InputStream is, int expectedByteCount) {
+            this.is = is;
+            this.expectedByteCount = expectedByteCount;
+        }
+
+        @Override
+        public void run() {
+            try {
+                byte[] buffer = new byte[10];
+                int readCount;
+                while ((readCount = is.read(buffer)) >= 0) {
+                    bytesRead += readCount;
+                    if (bytesRead >= expectedByteCount) {
+                        break;
+                    }
+                }
+            } catch (IOException e) {
+                exception = e;
+            } finally {
+                completeLatch.countDown();
+            }
+        }
+
+        public void waitForCompletion(long waitMillis) throws Exception {
+            if (!completeLatch.await(waitMillis, TimeUnit.MILLISECONDS)) {
+                fail("Timeout waiting for completion");
+            }
+            if (exception != null) {
+                throw new Exception("Read failed", exception);
+            }
+        }
+
+        public void assertBytesRead(int expected) {
+            assertEquals(expected, bytesRead);
+        }
     }
 }
diff --git a/tests/tests/os/src/android/os/cts/BundleTest.java b/tests/tests/os/src/android/os/cts/BundleTest.java
index 0db5fd0..36326b3 100644
--- a/tests/tests/os/src/android/os/cts/BundleTest.java
+++ b/tests/tests/os/src/android/os/cts/BundleTest.java
@@ -730,6 +730,26 @@
         assertTrue(mBundle.hasFileDescriptors());
     }
 
+    public void testHasFileDescriptorsOnNullValuedCollection() {
+        assertFalse(mBundle.hasFileDescriptors());
+
+        mBundle.putParcelableArray("foo", new Parcelable[1]);
+        assertFalse(mBundle.hasFileDescriptors());
+        mBundle.clear();
+
+        SparseArray<Parcelable> sparseArray = new SparseArray<Parcelable>();
+        sparseArray.put(0, null);
+        mBundle.putSparseParcelableArray("bar", sparseArray);
+        assertFalse(mBundle.hasFileDescriptors());
+        mBundle.clear();
+
+        ArrayList<Parcelable> arrayList = new ArrayList<Parcelable>();
+        arrayList.add(null);
+        mBundle.putParcelableArrayList("baz", arrayList);
+        assertFalse(mBundle.hasFileDescriptors());
+        mBundle.clear();
+    }
+
     public void testSetClassLoader() {
         mBundle.setClassLoader(new MockClassLoader());
     }
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 7b4adb0..fd8f4da3 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -109,7 +109,7 @@
         String myAppDirectory = getContext().getApplicationInfo().dataDir;
         for (ApplicationInfo app : apps) {
             if (!myAppDirectory.equals(app.dataDir)) {
-                writableDirs.addAll(getWritableDirectoryiesAndSubdirectoriesOf(new File(app.dataDir)));
+                writableDirs.addAll(getWritableDirectoriesAndSubdirectoriesOf(new File(app.dataDir)));
             }
         }
 
@@ -420,7 +420,7 @@
     @LargeTest
     public void testAllOtherDirectoriesNotWritable() throws Exception {
         File start = new File("/");
-        Set<File> writableDirs = getWritableDirectoryiesAndSubdirectoriesOf(start);
+        Set<File> writableDirs = getWritableDirectoriesAndSubdirectoriesOf(start);
 
         assertTrue("Found writable directories: " + writableDirs.toString(),
                 writableDirs.isEmpty());
@@ -611,7 +611,7 @@
         Set<File> writableDirs = new HashSet<File>();
         for (String dir : OTHER_RANDOM_DIRECTORIES) {
             File start = new File(dir);
-            writableDirs.addAll(getWritableDirectoryiesAndSubdirectoriesOf(start));
+            writableDirs.addAll(getWritableDirectoriesAndSubdirectoriesOf(start));
         }
 
         assertTrue("Found writable directories: " + writableDirs.toString(),
@@ -1028,7 +1028,7 @@
         return retval;
     }
 
-    private Set<File> getWritableDirectoryiesAndSubdirectoriesOf(File dir) throws Exception {
+    private Set<File> getWritableDirectoriesAndSubdirectoriesOf(File dir) throws Exception {
         Set<File> retval = new HashSet<File>();
         if (!dir.isDirectory()) {
             return retval;
@@ -1057,7 +1057,7 @@
         }
 
         for (File f : subFiles) {
-            retval.addAll(getWritableDirectoryiesAndSubdirectoriesOf(f));
+            retval.addAll(getWritableDirectoriesAndSubdirectoriesOf(f));
         }
 
         return retval;
diff --git a/tests/tests/renderscript/libcoremathtestcpp/Android.mk b/tests/tests/renderscript/libcoremathtestcpp/Android.mk
index 3b693e0..c62f20e 100644
--- a/tests/tests/renderscript/libcoremathtestcpp/Android.mk
+++ b/tests/tests/renderscript/libcoremathtestcpp/Android.mk
@@ -24,10 +24,13 @@
 
 LOCAL_CFLAGS := -std=c++11
 
+LOCAL_SDK_VERSION := 21
+LOCAL_NDK_STL_VARIANT := stlport_static
+
 LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
 LOCAL_C_INCLUDES += frameworks/rs/cpp
 LOCAL_C_INCLUDES += frameworks/rs
 
-LOCAL_SHARED_LIBRARIES := libdl liblog libRScpp
-LOCAL_STATIC_LIBRARIES := libcutils
+LOCAL_LDFLAGS := -llog -ldl
+LOCAL_STATIC_LIBRARIES := libRScpp_static libcutils
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
index 7e867f7..9e42a6c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
@@ -779,6 +779,47 @@
         assertTrue(result[0] == 2);
     }
 
+  public void testDimReturnsZero() {
+    Allocation a;
+    a = Allocation.createSized(mRS, Element.F32(mRS), 100);
+    assertTrue(a.getType().getX() == 100);
+    assertTrue(a.getType().getY() == 0);
+    assertTrue(a.getType().getZ() == 0);
+    a.destroy();
+
+    Type.Builder b;
+    b = new Type.Builder(mRS, Element.F32(mRS));
+    a = Allocation.createTyped(mRS, b.create());
+
+    assertTrue(a.getType().getX() == 1);
+    assertTrue(a.getType().getY() == 0);
+    assertTrue(a.getType().getZ() == 0);
+
+    a.destroy();
+
+    b = new Type.Builder(mRS, Element.F32(mRS)).setX(102);
+    a = Allocation.createTyped(mRS, b.create());
+
+    assertTrue(a.getType().getX() == 102);
+    assertTrue(a.getType().getY() == 0);
+    assertTrue(a.getType().getZ() == 0);
+    a.destroy();
+    b = new Type.Builder(mRS, Element.F32(mRS)).setX(102).setY(123);
+    a = Allocation.createTyped(mRS, b.create());
+
+    assertTrue(a.getType().getX() == 102);
+    assertTrue(a.getType().getY() == 123);
+    assertTrue(a.getType().getZ() == 0);
+    a.destroy();
+    b = new Type.Builder(mRS, Element.F32(mRS)).setX(2).setY(33).setZ(23);
+    a = Allocation.createTyped(mRS, b.create());
+
+    assertTrue(a.getType().getX() == 2);
+    assertTrue(a.getType().getY() == 33);
+    assertTrue(a.getType().getZ() == 23);
+
+    a.destroy();
+   }
 }
 
 
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
index f38bdb0..df8a6fe 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ImageProcessingTest.java
@@ -47,6 +47,7 @@
 import android.renderscript.Short4;
 
 import android.renderscript.Matrix4f;
+import android.renderscript.Script;
 
 import android.renderscript.Type;
 
@@ -58,6 +59,7 @@
 import android.renderscript.ScriptIntrinsicConvolve3x3;
 import android.renderscript.ScriptIntrinsicConvolve5x5;
 import android.renderscript.ScriptIntrinsicLUT;
+import android.util.Log;
 
 public class ImageProcessingTest extends RSBaseCompute {
     private Allocation a1, a2;
@@ -100,67 +102,551 @@
     public void testBlend() {
         ScriptIntrinsicBlend mBlend;
         mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS));
-
-        Allocation a1_copy, a2_copy;
-        a1_copy = Allocation.createTyped(mRS, a1.getType());
-        a2_copy = Allocation.createTyped(mRS, a2.getType());
-
-        for (int i = 0; i < 14; i++) {
-
-            a1_copy.copy2DRangeFrom(0, 0, a1.getType().getX(), a1.getType().getY(), a1, 0, 0);
-            a2_copy.copy2DRangeFrom(0, 0, a2.getType().getX(), a2.getType().getY(), a2, 0, 0);
+        int w = 256;
+        int h = 256;
+        Allocation src = creatAllocation(w, h);
+        Allocation dst = creatAllocation(w, h);
+        byte[] srcData = new byte[w * h * 4];
+        byte[] dstData = new byte[w * h * 4];
+        byte[] resultData = new byte[w * h * 4];
+        Script.LaunchOptions opt = new Script.LaunchOptions();
+        // unclipped but with options
+        for (int i = 0; i < 28; i++) {
+            buildSrc(srcData, w, h);
+            buildDst(dstData, w, h);
+            src.copyFromUnchecked(srcData);
+            dst.copyFromUnchecked(dstData);
 
             switch (i) {
-            case 0:
-                mBlend.forEachSrc(a1_copy, a2_copy);
-                break;
-            case 1:
-                mBlend.forEachDst(a1_copy, a2_copy);
-                break;
-            case 2:
-                mBlend.forEachSrcOver(a1_copy, a2_copy);
-                break;
-            case 3:
-                mBlend.forEachDstOver(a1_copy, a2_copy);
-                break;
-            case 4:
-                mBlend.forEachSrcIn(a1_copy, a2_copy);
-                break;
-            case 5:
-                mBlend.forEachDstIn(a1_copy, a2_copy);
-                break;
-            case 6:
-                mBlend.forEachSrcOut(a1_copy, a2_copy);
-                break;
-            case 7:
-                mBlend.forEachDstOut(a1_copy, a2_copy);
-                break;
-            case 8:
-                mBlend.forEachSrcAtop(a1_copy, a2_copy);
-                break;
-            case 9:
-                mBlend.forEachDstAtop(a1_copy, a2_copy);
-                break;
-            case 10:
-                mBlend.forEachXor(a1_copy, a2_copy);
-                break;
-            case 11:
-                mBlend.forEachAdd(a1_copy, a2_copy);
-                break;
-            case 12:
-                mBlend.forEachSubtract(a1_copy, a2_copy);
-                break;
-            case 13:
-                mBlend.forEachMultiply(a1_copy, a2_copy);
-                break;
+                case 0:
+                    mBlend.forEachSrc(src, dst);
+                    break;
+                case 1:
+                    mBlend.forEachDst(src, dst);
+                    break;
+                case 2:
+                    mBlend.forEachSrcOver(src, dst);
+                    break;
+                case 3:
+                    mBlend.forEachDstOver(src, dst);
+                    break;
+                case 4:
+                    mBlend.forEachSrcIn(src, dst);
+                    break;
+                case 5:
+                    mBlend.forEachDstIn(src, dst);
+                    break;
+                case 6:
+                    mBlend.forEachSrcOut(src, dst);
+                    break;
+                case 7:
+                    mBlend.forEachDstOut(src, dst);
+                    break;
+                case 8:
+                    mBlend.forEachSrcAtop(src, dst);
+                    break;
+                case 9:
+                    mBlend.forEachDstAtop(src, dst);
+                    break;
+                case 10:
+                    mBlend.forEachXor(src, dst);
+                    break;
+                case 11:
+                    mBlend.forEachAdd(src, dst);
+                    break;
+                case 12:
+                    mBlend.forEachSubtract(src, dst);
+                    break;
+                case 13:
+                    mBlend.forEachMultiply(src, dst);
+                    break;
+                case 14:
+                    mBlend.forEachSrc(src, dst, opt);
+                    break;
+                case 15:
+                    mBlend.forEachDst(src, dst, opt);
+                    break;
+                case 16:
+                    mBlend.forEachSrcOver(src, dst, opt);
+                    break;
+                case 17:
+                    mBlend.forEachDstOver(src, dst, opt);
+                    break;
+                case 18:
+                    mBlend.forEachSrcIn(src, dst, opt);
+                    break;
+                case 19:
+                    mBlend.forEachDstIn(src, dst, opt);
+                    break;
+                case 20:
+                    mBlend.forEachSrcOut(src, dst, opt);
+                    break;
+                case 21:
+                    mBlend.forEachDstOut(src, dst, opt);
+                    break;
+                case 22:
+                    mBlend.forEachSrcAtop(src, dst, opt);
+                    break;
+                case 23:
+                    mBlend.forEachDstAtop(src, dst, opt);
+                    break;
+                case 24:
+                    mBlend.forEachXor(src, dst, opt);
+                    break;
+                case 25:
+                    mBlend.forEachAdd(src, dst, opt);
+                    break;
+                case 26:
+                    mBlend.forEachSubtract(src, dst, opt);
+                    break;
+                case 27:
+                    mBlend.forEachMultiply(src, dst, opt);
+                    break;
             }
+            dst.copyTo(resultData);
+            String name = javaBlend(i%14, srcData, dstData);
+            assertTrue(name, similar(resultData,dstData));
+            Log.v("BlendUnit", name + " " + similar(resultData, dstData));
 
-            // validate
+        }
+    }
 
+    // utility to create and allocation of a given dimension
+    protected Allocation creatAllocation(int w, int h) {
+        Type.Builder b = new Type.Builder(mRS, Element.RGBA_8888(mRS));
+        b.setX(w);
+        b.setY(h);
+        return  Allocation.createTyped(mRS, b.create(), Allocation.USAGE_SCRIPT);
+    }
+
+   // Compare two images ensuring returning false if error is greater than 2
+   // so that it can  support integer and float non identical versions
+    public boolean similar(byte[] a, byte[] b) {
+        for (int i = 0; i < a.length; i++) {
+            int v1 = 0xFF & a[i];
+            int v2 = 0xFF & b[i];
+            int error = Math.abs(v1 - v2);
+            if (error > 2) {
+                return false;
+            }
+        }
+        return true;
+    }
+    // Build a test pattern to be the source pattern designed to provide a wide range of values
+    public void buildSrc(byte[] srcData, int width, int height) {
+        for (int i = 0; i < srcData.length / 4; i++) {
+            int x = i % width;
+            int y = i / width;
+            int d = (x - width / 2) * (x - width / 2) + (y - height / 2) * (y - height / 2);
+            d = (255 * d) / ((width / 2) * (width / 2));
+            d = (d > 255) ? 0 : d;
+
+            srcData[i * 4 + 0] = (byte) d; // red
+            srcData[i * 4 + 1] = (byte) d; // green
+            srcData[i * 4 + 2] = (byte) 0; // blue
+            srcData[i * 4 + 3] = (byte) y; // alpha
+        }
+    }
+
+    // Build a test pattern to be the destination pattern designed to provide a wide range of values
+    public void buildDst(byte[] dstData, int width, int height) {
+        for (int i = 0; i < dstData.length / 4; i++) {
+            int x = i % width;
+            int y = i / width;
+
+            dstData[i * 4 + 0] = (byte) 0; // red
+            dstData[i * 4 + 1] = (byte) 0; // green
+            dstData[i * 4 + 2] = (byte) y; // blue
+            dstData[i * 4 + 3] = (byte) x; // alpha
         }
 
     }
 
+    public String javaBlend(int type, byte[] src, byte[] dst) {
+
+        for (int i = 0; i < dst.length; i += 4) {
+            byte[] rgba = func[type].filter(src[i], src[i + 1], src[i + 2], src[i + 3],
+                    dst[i], dst[i + 1], dst[i + 2], dst[i + 3]);
+            dst[i] = rgba[0];
+            dst[i + 1] = rgba[1];
+            dst[i + 2] = rgba[2];
+            dst[i + 3] = rgba[3];
+        }
+        return func[type].name;
+    }
+
+    // Base class for Java blend implementation supporting float and int implementations
+
+    abstract class BlendFunc {
+        float srcR, srcG, srcB, srcA;
+        float dstR, dstG, dstB, dstA;
+        int s_srcR, s_srcG, s_srcB, s_srcA;
+        int s_dstR, s_dstG, s_dstB, s_dstA;
+        byte[] rgba = new byte[4];
+        String name;
+
+        final int clamp(int c) {
+            final int N = 255;
+            c &= ~(c >> 31);
+            c -= N;
+            c &= (c >> 31);
+            c += N;
+            return c;
+        }
+
+        int pack(float a, float r, float g, float b) {
+            int ia = clamp((int) (255 * a));
+            int ir = clamp((int) (255 * r));
+            int ig = clamp((int) (255 * g));
+            int ib = clamp((int) (255 * b));
+            rgba[0] = (byte) ir;
+            rgba[1] = (byte) ig;
+            rgba[2] = (byte) ib;
+            rgba[3] = (byte) ia;
+            return (ia << 24) | (ir << 16) | (ig << 8) | ib;
+        }
+
+        int pack(int a, int r, int g, int b) {
+
+            rgba[0] = (byte) clamp(r);
+            rgba[1] = (byte) clamp(g);
+            rgba[2] = (byte) clamp(b);
+            rgba[3] = (byte) clamp(a);
+            return 0;
+        }
+
+        void unpackSrc(int src) {
+            s_srcR = (0xFF & (src >> 16));
+            s_srcG = (0xFF & (src >> 8));
+            s_srcB = (0xFF & (src >> 0));
+            s_srcA = (0xFF & (src >> 24));
+            float scale = 1 / 255f;
+
+            srcR = (0xFF & (src >> 16)) * scale;
+            srcG = (0xFF & (src >> 8)) * scale;
+            srcB = (0xFF & (src >> 0)) * scale;
+            srcA = (0xFF & (src >> 24)) * scale;
+        }
+
+        void unpackDst(int dst) {
+            float scale = 1 / 255f;
+
+            s_dstR = (0xFF & (dst >> 16));
+            s_dstG = (0xFF & (dst >> 8));
+            s_dstB = (0xFF & (dst >> 0));
+            s_dstA = (0xFF & (dst >> 24));
+
+            dstR = (0xFF & (dst >> 16)) * scale;
+            dstG = (0xFF & (dst >> 8)) * scale;
+            dstB = (0xFF & (dst >> 0)) * scale;
+            dstA = (0xFF & (dst >> 24)) * scale;
+        }
+
+        int filter(int scr, int dst) {
+            unpackSrc(scr);
+            unpackDst(dst);
+            return blend();
+        }
+
+        byte[] filter(byte srcR, byte srcG, byte srcB, byte srcA,
+                      byte dstR, byte dstG, byte dstB, byte dstA) {
+            float scale = 1 / 255f;
+            this.srcR = (0xFF & (srcR)) * scale;
+            this.srcG = (0xFF & (srcG)) * scale;
+            this.srcB = (0xFF & (srcB)) * scale;
+            this.srcA = (0xFF & (srcA)) * scale;
+
+            this.dstR = (0xFF & (dstR)) * scale;
+            this.dstG = (0xFF & (dstG)) * scale;
+            this.dstB = (0xFF & (dstB)) * scale;
+            this.dstA = (0xFF & (dstA)) * scale;
+            s_dstR = (0xFF & (dstR));
+            s_dstG = (0xFF & (dstG));
+            s_dstB = (0xFF & (dstB));
+            s_dstA = (0xFF & (dstA));
+
+            s_srcR = (0xFF & (srcR));
+            s_srcG = (0xFF & (srcG));
+            s_srcB = (0xFF & (srcB));
+            s_srcA = (0xFF & (srcA));
+
+            blend();
+            return rgba;
+        }
+
+        abstract int blend();
+    }
+
+    BlendFunc blend_dstAtop = new BlendFunc() {
+        // dst = dst.rgb * src.a + (1.0 - dst.a) * src.rgb
+        // dst.a = src.a
+        {
+            name = "blend_dstAtop";
+        }
+
+        @Override
+        int blend() {
+            float r = (dstR * srcA + (1 - dstA) * srcR);
+            float g = (dstG * srcA + (1 - dstA) * srcG);
+            float b = (dstB * srcA + (1 - dstA) * srcB);
+            float a = srcA;
+
+            return pack(a, r, g, b);
+        }
+    };
+    BlendFunc blend_dstIn = new BlendFunc() {
+        // Sets dst = dst * src.a
+        {
+            name = "blend_dstIn";
+        }
+
+        @Override
+        int blend() {
+            float r = (dstR * srcA);
+            float g = (dstG * srcA);
+            float b = (dstB * srcA);
+            float a = (dstA * srcA);
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc blend_add = new BlendFunc() {
+        // dst = dst + src
+        {
+            name = "blend_add";
+        }
+
+        @Override
+        int blend() {
+
+            int r = Math.min(s_dstR + s_srcR, 255);
+            int g = Math.min(s_dstG + s_srcG, 255);
+            int b = Math.min(s_dstB + s_srcB, 255);
+            int a = Math.min(s_dstA + s_srcA, 255);
+            return pack(a, r, g, b);
+
+        }
+    };
+
+    BlendFunc blend_clear = new BlendFunc() {
+        // Sets dst = {0, 0, 0, 0}
+        {
+            name = "blend_clear";
+        }
+
+        @Override
+        int blend() {
+            return pack(0, 0, 0, 0);
+        }
+    };
+
+    BlendFunc blend_dst = new BlendFunc() {
+        // Sets dst = dst
+        {
+            name = "blend_dst";
+        }
+
+        @Override
+        int blend() {
+            return pack(dstA, dstR, dstG, dstB);
+        }
+    };
+
+    BlendFunc blend_dstOut = new BlendFunc() {
+        // Sets dst = dst * (1.0 - src.a)
+        {
+            name = "blend_dstOut";
+        }
+
+        @Override
+        int blend() {
+            float r = (dstR * (1 - srcA));
+            float g = (dstG * (1 - srcA));
+            float b = (dstB * (1 - srcA));
+            float a = (dstA * (1 - srcA));
+            return pack(a, r, g, b);
+        }
+    };
+    BlendFunc blend_dstOver = new BlendFunc() {
+        // Sets dst = dst + src * (1.0 - dst.a)
+        {
+            name = "blend_dstOver";
+        }
+
+        @Override
+        int blend() {
+            float r = dstR + (srcR * (1 - dstA));
+            float g = dstG + (srcG * (1 - dstA));
+            float b = dstB + (srcB * (1 - dstA));
+            float a = dstA + (srcA * (1 - dstA));
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc blend_multiply = new BlendFunc() {
+        // dst = dst * src
+        {
+            name = "blend_multiply";
+        }
+
+        @Override
+        int blend() {
+            float r = (srcR * dstR);
+            float g = (srcG * dstG);
+            float b = (srcB * dstB);
+            float a = (srcA * dstA);
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc blend_src = new BlendFunc() {
+        // Sets dst =  src
+        {
+            name = "blend_src";
+        }
+
+        int blend() {
+            return pack(srcA, srcR, srcG, srcB);
+
+        }
+    };
+
+    BlendFunc blend_srcAtop = new BlendFunc() {
+        // dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb
+        // dst.a = dst.a
+        {
+            name = "blend_srcAtop";
+        }
+
+        @Override
+        int blend() {
+            float r = (srcR * dstA + (1 - srcA) * dstR);
+            float g = (srcG * dstA + (1 - srcA) * dstG);
+            float b = (srcB * dstA + (1 - srcA) * dstB);
+            float a = (srcA * dstA + (1 - srcA) * dstA);
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc blend_srcIn = new BlendFunc() {
+        // dst = src * dst.a
+        {
+            name = "blend_srcIn";
+        }
+
+        @Override
+        int blend() {
+            float r = (srcR * dstA);
+            float g = (srcG * dstA);
+            float b = (srcB * dstA);
+            float a = (srcA * dstA);
+            ;
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc blend_srcOut = new BlendFunc() {
+        // Sets dst = src * (1.0 - dst.a)
+        {
+            name = "blend_srcOut";
+        }
+
+        @Override
+        int blend() {
+            float r = (srcR * (1 - dstA));
+            float g = (srcG * (1 - dstA));
+            float b = (srcB * (1 - dstA));
+            float a = (srcA * (1 - dstA));
+            ;
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc blend_srcOver = new BlendFunc() {
+        // Sets dst = src + dst * (1.0 - src.a)
+        {
+            name = "blend_srcOver";
+        }
+
+        @Override
+        int blend() {
+            float r = srcR + (dstR * (1 - srcA));
+            float g = srcG + (dstG * (1 - srcA));
+            float b = srcB + (dstB * (1 - srcA));
+            float a = srcA + (dstA * (1 - srcA));
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc blend_subtract = new BlendFunc() {
+        // Sets dst =  dst - src
+        {
+            name = "blend_subtract";
+        }
+
+        @Override
+        int blend() {
+            float r = Math.max(dstR - srcR, 0);
+            float g = Math.max(dstG - srcG, 0);
+            float b = Math.max(dstB - srcB, 0);
+            float a = Math.max(dstA - srcA, 0);
+            return pack(a, r, g, b);
+        }
+    };
+
+    // Porter/Duff xor compositing
+    BlendFunc blend_pdxor = new BlendFunc() {
+        // dst.rgb = src.rgb*(1-dst.a)+(1-src.a)*dst.rgb;
+        // dst.a = src.a+dst.a - 2*src.a*dst.a
+        {
+            name = "blend_pdxor";
+        }
+
+        @Override
+        int blend() {
+            float r = srcR * (1 - dstA) + (dstR * (1 - srcA));
+            float g = srcG * (1 - dstA) + (dstG * (1 - srcA));
+            float b = srcB * (1 - dstA) + (dstB * (1 - srcA));
+            float a = srcA + dstA - (2 * srcA * dstA);
+            return pack(a, r, g, b);
+        }
+    };
+
+    // NOT Porter/Duff xor compositing simple XOR
+    BlendFunc blend_xor = new BlendFunc() {
+        // Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a}
+        {
+            name = "blend_xor";
+        }
+
+        @Override
+        int blend() {
+            float scale = 1 / 255f;
+            float r = (((int) (dstR * 255)) ^ ((int) (srcR * 255))) * scale;
+            float g = (((int) (dstG * 255)) ^ ((int) (srcG * 255))) * scale;
+            float b = (((int) (dstB * 255)) ^ ((int) (srcB * 255))) * scale;
+            float a = (((int) (dstA * 255)) ^ ((int) (srcA * 255))) * scale;
+            return pack(a, r, g, b);
+        }
+    };
+
+    BlendFunc[] func = {
+            blend_src,
+            blend_dst,
+            blend_srcOver,
+            blend_dstOver,
+            blend_srcIn,
+            blend_dstIn,
+            blend_srcOut,
+            blend_dstOut,
+            blend_srcAtop,
+            blend_dstAtop,
+            blend_xor,
+            blend_add,
+            blend_subtract,
+            blend_multiply,
+    };
+
     public void testColorMatrix() {
         ScriptIntrinsicColorMatrix mColorMatrix;
         mColorMatrix = ScriptIntrinsicColorMatrix.create(mRS, Element.U8_4(mRS));
@@ -198,7 +684,6 @@
 
     }
 
-
     public void testConvolve3x3() {
         ScriptIntrinsicConvolve3x3 mConvolve3x3;
         mConvolve3x3 = ScriptIntrinsicConvolve3x3.create(mRS, Element.U8_4(mRS));
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java
index c8b3640..9392db1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicResize.java
@@ -97,87 +97,87 @@
     }
 
 
-    public void test_U8_4_SCALE10_10_inSqure() {
+    public void test_U8_4_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 4, 1.f, 1.f);
         checkError();
     }
-    public void test_U8_3_SCALE10_10_inSqure() {
+    public void test_U8_3_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 3, 1.f, 1.f);
         checkError();
     }
-    public void test_U8_2_SCALE10_10_inSqure() {
+    public void test_U8_2_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 2, 1.f, 1.f);
         checkError();
     }
-    public void test_U8_1_SCALE10_10_inSqure() {
+    public void test_U8_1_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 1, 1.f, 1.f);
         checkError();
     }
 
-    public void test_U8_4_SCALE20_20_inSqure() {
+    public void test_U8_4_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 4, 2.f, 2.f);
         checkError();
     }
-    public void test_U8_3_SCALE20_20_inSqure() {
+    public void test_U8_3_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 3, 2.f, 2.f);
         checkError();
     }
-    public void test_U8_2_SCALE20_20_inSqure() {
+    public void test_U8_2_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 2, 2.f, 2.f);
         checkError();
     }
-    public void test_U8_1_SCALE20_20_inSqure() {
+    public void test_U8_1_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 1, 2.f, 2.f);
         checkError();
     }
 
-    public void test_U8_4_SCALE05_20_inSqure() {
+    public void test_U8_4_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 4, 0.5f, 2.f);
         checkError();
     }
-    public void test_U8_3_SCALE05_20_inSqure() {
+    public void test_U8_3_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 3, 0.5f, 2.f);
         checkError();
     }
-    public void test_U8_2_SCALE05_20_inSqure() {
+    public void test_U8_2_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 2, 0.5f, 2.f);
         checkError();
     }
-    public void test_U8_1_SCALE05_20_inSqure() {
+    public void test_U8_1_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 1, 0.5f, 2.f);
         checkError();
     }
 
-    public void test_U8_4_SCALE20_05_inSqure() {
+    public void test_U8_4_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 4, 2.f, 0.5f);
         checkError();
     }
-    public void test_U8_3_SCALE20_05_inSqure() {
+    public void test_U8_3_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 3, 2.f, 0.5f);
         checkError();
     }
-    public void test_U8_2_SCALE20_05_inSqure() {
+    public void test_U8_2_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 2, 2.f, 0.5f);
         checkError();
     }
-    public void test_U8_1_SCALE20_05_inSqure() {
+    public void test_U8_1_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 1, 2.f, 0.5f);
         checkError();
     }
 
-    public void test_U8_4_SCALE05_05_inSqure() {
+    public void test_U8_4_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 4, 0.5f, 0.5f);
         checkError();
     }
-    public void test_U8_3_SCALE05_05_inSqure() {
+    public void test_U8_3_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 3, 0.5f, 0.5f);
         checkError();
     }
-    public void test_U8_2_SCALE05_05_inSqure() {
+    public void test_U8_2_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 2, 0.5f, 0.5f);
         checkError();
     }
-    public void test_U8_1_SCALE05_05_inSqure() {
+    public void test_U8_1_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.UNSIGNED_8, 1, 0.5f, 0.5f);
         checkError();
     }
@@ -268,87 +268,87 @@
     }
 
 
-    public void test_F32_4_SCALE10_10_inSqure() {
+    public void test_F32_4_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 4, 1.f, 1.f);
         checkError();
     }
-    public void test_F32_3_SCALE10_10_inSqure() {
+    public void test_F32_3_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 3, 1.f, 1.f);
         checkError();
     }
-    public void test_F32_2_SCALE10_10_inSqure() {
+    public void test_F32_2_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 2, 1.f, 1.f);
         checkError();
     }
-    public void test_F32_1_SCALE10_10_inSqure() {
+    public void test_F32_1_SCALE10_10_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 1, 1.f, 1.f);
         checkError();
     }
 
-    public void test_F32_4_SCALE20_20_inSqure() {
+    public void test_F32_4_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 4, 2.f, 2.f);
         checkError();
     }
-    public void test_F32_3_SCALE20_20_inSqure() {
+    public void test_F32_3_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 3, 2.f, 2.f);
         checkError();
     }
-    public void test_F32_2_SCALE20_20_inSqure() {
+    public void test_F32_2_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 2, 2.f, 2.f);
         checkError();
     }
-    public void test_F32_1_SCALE20_20_inSqure() {
+    public void test_F32_1_SCALE20_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 1, 2.f, 2.f);
         checkError();
     }
 
-    public void test_F32_4_SCALE05_20_inSqure() {
+    public void test_F32_4_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 4, 0.5f, 2.f);
         checkError();
     }
-    public void test_F32_3_SCALE05_20_inSqure() {
+    public void test_F32_3_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 3, 0.5f, 2.f);
         checkError();
     }
-    public void test_F32_2_SCALE05_20_inSqure() {
+    public void test_F32_2_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 2, 0.5f, 2.f);
         checkError();
     }
-    public void test_F32_1_SCALE05_20_inSqure() {
+    public void test_F32_1_SCALE05_20_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 1, 0.5f, 2.f);
         checkError();
     }
 
-    public void test_F32_4_SCALE20_05_inSqure() {
+    public void test_F32_4_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 4, 2.f, 0.5f);
         checkError();
     }
-    public void test_F32_3_SCALE20_05_inSqure() {
+    public void test_F32_3_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 3, 2.f, 0.5f);
         checkError();
     }
-    public void test_F32_2_SCALE20_05_inSqure() {
+    public void test_F32_2_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 2, 2.f, 0.5f);
         checkError();
     }
-    public void test_F32_1_SCALE20_05_inSqure() {
+    public void test_F32_1_SCALE20_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 1, 2.f, 0.5f);
         checkError();
     }
 
-    public void test_F32_4_SCALE05_05_inSqure() {
+    public void test_F32_4_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 4, 0.5f, 0.5f);
         checkError();
     }
-    public void test_F32_3_SCALE05_05_inSqure() {
+    public void test_F32_3_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 3, 0.5f, 0.5f);
         checkError();
     }
-    public void test_F32_2_SCALE05_05_inSqure() {
+    public void test_F32_2_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 2, 0.5f, 0.5f);
         checkError();
     }
-    public void test_F32_1_SCALE05_05_inSqure() {
+    public void test_F32_1_SCALE05_05_inSquare() {
         testResize(inX, inX, Element.DataType.FLOAT_32, 1, 0.5f, 0.5f);
         checkError();
     }
diff --git a/tests/tests/rscpp/librscpptest/Android.mk b/tests/tests/rscpp/librscpptest/Android.mk
index df8ce29f..0fa6f27 100644
--- a/tests/tests/rscpp/librscpptest/Android.mk
+++ b/tests/tests/rscpp/librscpptest/Android.mk
@@ -45,6 +45,8 @@
 LOCAL_C_INCLUDES += frameworks/rs/cpp
 LOCAL_C_INCLUDES += frameworks/rs
 
+LOCAL_CPPFLAGS := -std=c++11
+
 LOCAL_SHARED_LIBRARIES := libdl liblog
 LOCAL_STATIC_LIBRARIES := libRScpp_static libcutils
 
diff --git a/tests/tests/rscpp/librscpptest/rs_jni.cpp b/tests/tests/rscpp/librscpptest/rs_jni.cpp
index 4e60f4b..47fa6c5 100644
--- a/tests/tests/rscpp/librscpptest/rs_jni.cpp
+++ b/tests/tests/rscpp/librscpptest/rs_jni.cpp
@@ -492,4 +492,3 @@
     return (mRS->getError() == RS_SUCCESS);
 
 }
-
diff --git a/tests/tests/security/src/android/security/cts/BannedFilesTest.java b/tests/tests/security/src/android/security/cts/BannedFilesTest.java
index 00c4631..54709b4 100644
--- a/tests/tests/security/src/android/security/cts/BannedFilesTest.java
+++ b/tests/tests/security/src/android/security/cts/BannedFilesTest.java
@@ -58,6 +58,17 @@
         assertFalse("/dev/socket/fotabinder", new File("/dev/socket/fotabinder").exists());
     }
 
+    /**
+     * Detect devices allowing shell commands to be executed as system
+     * through sockets.
+     *
+     * ANDROID-19679287
+     * CVE-2015-2231
+     */
+    public void testNoSystemCmdSocket() {
+        assertFalse("/dev/socket/fota", new File("/dev/socket/fota").exists());
+    }
+
     public void testNoSu() {
         assertFalse("/sbin/su",        new File("/sbin/su").exists());
         assertFalse("/system/bin/su",  new File("/system/bin/su").exists());
diff --git a/tests/tests/text/src/android/text/cts/TextUtilsTest.java b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
index 694513e..9258318 100644
--- a/tests/tests/text/src/android/text/cts/TextUtilsTest.java
+++ b/tests/tests/text/src/android/text/cts/TextUtilsTest.java
@@ -44,9 +44,6 @@
 import android.util.Log;
 import android.util.StringBuilderPrinter;
 
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-
 import java.util.ArrayList;
 import java.util.Locale;
 import java.util.regex.Pattern;
@@ -2033,11 +2030,6 @@
         assertTrue(builder.length() > 0);
     }
 
-    @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLayoutDirectionFromLocale",
-            args = {Locale.class}
-    )
     public void testGetLayoutDirectionFromLocale() {
         assertEquals(LAYOUT_DIRECTION_LTR,
                 TextUtils.getLayoutDirectionFromLocale(null));
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index 6eb09eb..0a55b54 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -19,7 +19,6 @@
 import android.content.Context;
 import android.test.AndroidTestCase;
 import android.text.format.DateUtils;
-import dalvik.annotation.KnownFailure;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Formatter;
diff --git a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
index 73fd763..432ec84 100644
--- a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
@@ -16,8 +16,6 @@
 
 package android.text.method.cts;
 
-import dalvik.annotation.KnownFailure;
-
 import android.cts.util.WidgetTestUtils;
 import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;