Merge "Fix crashing dispatchDraw test" into lmp-dev
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 0a4e6e4..c69d16a 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -62,15 +62,14 @@
 $(PRODUCT_OUT)/data/app/CtsVerifier.apk $(verifier-zip): $(verifier-dir)/power/execute_power_tests.py
 $(PRODUCT_OUT)/data/app/CtsVerifier.apk $(verifier-zip): $(verifier-dir)/power/power_monitors/monsoon.py
 
-#Copy the necessary host-side scripts to include in the
-#zip file:
-$(verifier-dir)/power/power_monitors/monsoon.py: cts/apps/CtsVerifier/assets/scripts/power_monitors/monsoon.py
+# Copy the necessary host-side scripts to include in the zip file:
+$(verifier-dir)/power/power_monitors/monsoon.py: cts/apps/CtsVerifier/assets/scripts/power_monitors/monsoon.py | $(ACP)
 	$(hide) mkdir -p $(verifier-dir)/power/power_monitors
-	$(hide)  $(ACP) -fp  cts/apps/CtsVerifier/assets/scripts/power_monitors/*.py $(verifier-dir)/power/power_monitors/.
+	$(hide) $(ACP) -fp cts/apps/CtsVerifier/assets/scripts/power_monitors/*.py $(verifier-dir)/power/power_monitors/.
 
-$(verifier-dir)/power/execute_power_tests.py: cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py
+$(verifier-dir)/power/execute_power_tests.py: cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py | $(ACP)
 	$(hide) mkdir -p $(verifier-dir)/power
-	$(hide)  $(ACP) -fp   cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py $@
+	$(hide) $(ACP) -fp cts/apps/CtsVerifier/assets/scripts/execute_power_tests.py $@
 
 cts : $(verifier-zip)
 ifeq ($(HOST_OS),linux)
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 4e57588..da93a59 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1091,6 +1091,16 @@
             <meta-data android:name="test_category" android:value="@string/test_category_projection" />
         </activity>
 
+
+        <activity android:name=".projection.offscreen.ProjectionOffscreenActivity"
+                  android:label="@string/poa_test">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_projection" />
+        </activity>
+
         <service android:name=".projection.ProjectionService"
                  android:label="@string/projection_service_name"
                  android:process=":projectionservice" />
diff --git a/apps/CtsVerifier/res/layout/poa_main.xml b/apps/CtsVerifier/res/layout/poa_main.xml
new file mode 100644
index 0000000..578a6a6
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/poa_main.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <include layout="@layout/pass_fail_buttons" />
+
+    <TextView
+        android:id="@+id/poa_status_text"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:textAppearance="@style/InstructionsFont" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/poa_touch.xml b/apps/CtsVerifier/res/layout/poa_touch.xml
new file mode 100644
index 0000000..0085227
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/poa_touch.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" >
+    <com.android.cts.verifier.projection.offscreen.ColorChangeOnKeyView
+        android:id="@+id/multi_touch_view"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+</RelativeLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 15747b3..e42cf48 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1054,6 +1054,10 @@
     <string name="pta_info">This tests whether multitouch works.\n
         Touching the screen should render a dot at the location you touched.\n
         Touching with additional fingers will render additoinal dots and you should be able to drag them around.</string>
+    <string name="poa_test">Projection Offscreen Activity</string>
+    <string name="poa_info">This tests whether a virtual display will continue to respond to and render even when the screen is off.\n
+        Simply follow the instructions and the test will detect the pass conditions.\n
+        Note that turning on the screen too early will result in a failure.</string>
 
     <!-- Strings for RotationVectorTest and GameRotationVectorTest -->
     <string name="rotation_vector_test">Rotation Vector Accuracy Test</string>
@@ -1067,5 +1071,4 @@
         3. Place the mobile device back to the reference position.\n
         4. Pass if it returns to the original arrow orientation within one second.\n
     </string>
-
 </resources>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectedPresentation.java b/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectedPresentation.java
index 4990ed4..53d715a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectedPresentation.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectedPresentation.java
@@ -47,5 +47,4 @@
         getWindow().setLocalFocus(true, false);
         getWindow().injectInputEvent(event);
     }
-
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionPresentationType.java b/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionPresentationType.java
index 28f5d46..fbcd1a3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionPresentationType.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionPresentationType.java
@@ -21,5 +21,6 @@
     BASIC_WIDGETS,
     MULTI_TOUCH,
     SCROLLING_LIST,
-    VIDEO_PLAYBACK
+    VIDEO_PLAYBACK,
+    OFFSCREEN
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionService.java b/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionService.java
index bfe5a30..11f8e0c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/projection/ProjectionService.java
@@ -31,6 +31,7 @@
 
 import com.android.cts.verifier.projection.cube.CubePresentation;
 import com.android.cts.verifier.projection.list.ListPresentation;
+import com.android.cts.verifier.projection.offscreen.OffscreenPresentation;
 import com.android.cts.verifier.projection.touch.TouchPresentation;
 import com.android.cts.verifier.projection.video.VideoPresentation;
 import com.android.cts.verifier.projection.widgets.WidgetPresentation;
@@ -62,6 +63,9 @@
 
             case MULTI_TOUCH:
                 return new TouchPresentation(ProjectionService.this, mDisplay.getDisplay());
+
+            case OFFSCREEN:
+                return new OffscreenPresentation(ProjectionService.this, mDisplay.getDisplay());
         }
 
         return null;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ColorChangeOnKeyView.java b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ColorChangeOnKeyView.java
new file mode 100644
index 0000000..297009a
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ColorChangeOnKeyView.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.projection.offscreen;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.util.AttributeSet;
+import android.view.KeyEvent;
+import android.view.View;
+
+/**
+ * Changes color from black to blue on keyevent
+ */
+public class ColorChangeOnKeyView extends View {
+    private int mColor = Color.BLACK;
+
+    public ColorChangeOnKeyView(Context context) {
+        super(context);
+    }
+
+    public ColorChangeOnKeyView(Context context, AttributeSet attrs) {
+        super(context, attrs, 0);
+    }
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+            mColor = Color.BLUE;
+            invalidate();
+            return true;
+    }
+
+    @Override
+    public void onDraw(Canvas canvas) {
+        canvas.drawColor(mColor);
+    }
+
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/OffscreenPresentation.java b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/OffscreenPresentation.java
new file mode 100644
index 0000000..18ba20d
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/OffscreenPresentation.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.projection.offscreen;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.view.Display;
+
+import com.android.cts.verifier.R;
+import com.android.cts.verifier.projection.ProjectedPresentation;
+
+/**
+ * Draws a presentation that will be interacted with fake events while the screen is off
+ */
+public class OffscreenPresentation extends ProjectedPresentation {
+
+    public OffscreenPresentation(Context outerContext, Display display) {
+        super(outerContext, display);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.poa_touch);
+    }
+
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ProjectionOffscreenActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ProjectionOffscreenActivity.java
new file mode 100644
index 0000000..500ebf7
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ProjectionOffscreenActivity.java
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.projection.offscreen;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
+import android.graphics.Color;
+import android.graphics.PixelFormat;
+import android.media.Image;
+import android.media.ImageReader;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.RemoteException;
+import android.os.SystemClock;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.TextView;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+import com.android.cts.verifier.projection.IProjectionService;
+import com.android.cts.verifier.projection.ProjectionPresentationType;
+import com.android.cts.verifier.projection.ProjectionService;
+
+import java.nio.ByteBuffer;
+
+public class ProjectionOffscreenActivity extends PassFailButtons.Activity
+        implements ImageReader.OnImageAvailableListener {
+    private static String TAG = ProjectionOffscreenActivity.class.getSimpleName();
+    private static final int WIDTH = 800;
+    private static final int HEIGHT = 480;
+    private static final int DENSITY = DisplayMetrics.DENSITY_MEDIUM;
+    private static final int TIME_SCREEN_OFF = 5000; // Time screen must remain off for test to run
+    private static final int DELAYED_RUNNABLE_TIME = 1000; // Time after screen turned off
+                                                           // keyevent is sent
+    private static final int RENDERER_DELAY_THRESHOLD = 2000; // Time after keyevent sent that
+                                                              // rendering must happen by
+
+    protected ImageReader mReader;
+    protected IProjectionService mService;
+    protected TextView mStatusView;
+    protected int mPreviousColor = Color.BLACK;
+    private long mTimeScreenTurnedOff = 0;
+    private long mTimeKeyEventSent = 0;
+    private enum TestStatus { PASSED, FAILED, RUNNING };
+    protected TestStatus mTestStatus = TestStatus.RUNNING;
+
+    private final Runnable sendKeyEventRunnable = new Runnable() {
+            @Override
+        public void run() {
+            try {
+                mService.onKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_DOWN));
+                mTimeKeyEventSent = SystemClock.uptimeMillis();
+            } catch (RemoteException e) {
+                Log.e(TAG, "Error running onKeyEvent", e);
+            }
+        }
+    };
+
+    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
+            new Handler(Looper.getMainLooper()).postDelayed(
+                    sendKeyEventRunnable, DELAYED_RUNNABLE_TIME);
+            mStatusView.setText("Running test...");
+            mTimeScreenTurnedOff = SystemClock.uptimeMillis();
+        } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
+            if (SystemClock.uptimeMillis() - mTimeScreenTurnedOff < TIME_SCREEN_OFF) {
+                mStatusView.setText("ERROR: Turned on screen too early");
+                getPassButton().setEnabled(false);
+                mTestStatus = TestStatus.FAILED;
+            }
+        }
+    }
+
+};
+
+    protected final ServiceConnection mConnection = new ServiceConnection() {
+
+            @Override
+        public void onServiceConnected(ComponentName name, IBinder binder) {
+            mService = IProjectionService.Stub.asInterface(binder);
+            new Handler().post(new Runnable() {
+
+                    @Override
+                public void run() {
+                    Log.i(TAG, "onServiceConnected thread " + Thread.currentThread());
+                    try {
+                        mService.startRendering(mReader.getSurface(), WIDTH, HEIGHT, DENSITY,
+                                ProjectionPresentationType.OFFSCREEN.ordinal());
+                    } catch (RemoteException e) {
+                        Log.e(TAG, "Failed to execute startRendering", e);
+                    }
+
+                    IntentFilter filter = new IntentFilter();
+                    filter.addAction(Intent.ACTION_SCREEN_OFF);
+                    filter.addAction(Intent.ACTION_SCREEN_ON);
+
+                    registerReceiver(mReceiver, filter);
+                    mStatusView.setText(
+                            "Please turn off your screen and turn it back on after 5 seconds");
+                }
+
+            });
+
+        }
+
+            @Override
+        public void onServiceDisconnected(ComponentName name) {
+            mService = null;
+        }
+
+    };
+
+
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        View view = getLayoutInflater().inflate(R.layout.poa_main, null);
+        mStatusView = (TextView) view.findViewById(R.id.poa_status_text);
+        mStatusView.setText("Waiting for service to bind...");
+
+        setContentView(view);
+
+        setInfoResources(R.string.poa_test, R.string.poa_info, -1);
+        setPassFailButtonClickListeners();
+        mReader = ImageReader.newInstance(WIDTH, HEIGHT, PixelFormat.RGBA_8888, 2);
+        mReader.setOnImageAvailableListener(this, null);
+        bindService(new Intent(this, ProjectionService.class), mConnection,
+                Context.BIND_AUTO_CREATE);
+
+        getPassButton().setEnabled(false);
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        unregisterReceiver(mReceiver);
+        mReader.close();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        if (mTestStatus == TestStatus.FAILED) {
+            PassFailButtons.setTestResultAndFinish(this, getTestId(), getTestDetails(), false);
+        }
+    }
+
+    @Override
+    public void onImageAvailable(ImageReader reader) {
+        Log.i(TAG, "onImageAvailable: " + reader);
+
+        if (mTimeKeyEventSent != 0
+                && mTestStatus == TestStatus.RUNNING
+                && mTimeKeyEventSent + RENDERER_DELAY_THRESHOLD < SystemClock.uptimeMillis()) {
+            mTestStatus = TestStatus.FAILED;
+            mStatusView.setText("Failed: took too long to render");
+        }
+
+        Image image = reader.acquireLatestImage();
+        if (mTestStatus == TestStatus.RUNNING) {
+            int ret = scanImage(image);
+            if (ret == -1) {
+                mStatusView.setText("Failed: saw unexpected color");
+                getPassButton().setEnabled(false);
+                mTestStatus = TestStatus.FAILED;
+            } else if (ret != mPreviousColor && ret == Color.BLUE) {
+                mStatusView.setText("Success: virtual display rendered expected color");
+                getPassButton().setEnabled(true);
+                mTestStatus = TestStatus.PASSED;
+            }
+        }
+        image.close();
+    }
+
+    // modified from the VirtualDisplay Cts test
+    /**
+     * Gets the color of the image and ensures all the pixels are the same color
+     * @param image input image
+     * @return The color of the image, or -1 for failure
+     */
+    private int scanImage(Image image) {
+        final Image.Plane plane = image.getPlanes()[0];
+        final ByteBuffer buffer = plane.getBuffer();
+        final int width = image.getWidth();
+        final int height = image.getHeight();
+        final int pixelStride = plane.getPixelStride();
+        final int rowStride = plane.getRowStride();
+        final int rowPadding = rowStride - pixelStride * width;
+
+        Log.d(TAG, "- Scanning image: width=" + width + ", height=" + height
+                + ", pixelStride=" + pixelStride + ", rowStride=" + rowStride);
+
+        int offset = 0;
+        int blackPixels = 0;
+        int bluePixels = 0;
+        int otherPixels = 0;
+        for (int y = 0; y < height; y++) {
+            for (int x = 0; x < width; x++) {
+                int pixel = 0;
+                pixel |= (buffer.get(offset) & 0xff) << 16;     // R
+                pixel |= (buffer.get(offset + 1) & 0xff) << 8;  // G
+                pixel |= (buffer.get(offset + 2) & 0xff);       // B
+                pixel |= (buffer.get(offset + 3) & 0xff) << 24; // A
+                if (pixel == Color.BLACK || pixel == 0) {
+                    blackPixels += 1;
+                } else if (pixel == Color.BLUE) {
+                    bluePixels += 1;
+                } else {
+                    otherPixels += 1;
+                    if (otherPixels < 10) {
+                        Log.d(TAG, "- Found unexpected color: " + Integer.toHexString(pixel));
+                    }
+                }
+                offset += pixelStride;
+            }
+            offset += rowPadding;
+        }
+
+        // Return a color if it represents more than one quarter of the pixels.
+        // We use this threshold in case the display is being letterboxed when
+        // mirroring so there might be large black bars on the sides, which is normal.
+        Log.d(TAG, "- Pixels: " + blackPixels + " black, "
+                + bluePixels + " blue, "
+                + otherPixels + " other");
+        if (blackPixels == width * height) {
+            return Color.BLACK;
+        } else if (bluePixels == width * height) {
+            return Color.BLUE;
+        } else {
+            return -1;
+        }
+    }
+}
diff --git a/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs b/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs
index 30b40c4..15c781c 100644
--- a/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs
+++ b/tests/src/android/renderscript/cts/intrinsic_colormatrix.rs
@@ -17,10 +17,8 @@
 #include "shared.rsh"
 
 
-void reference(rs_matrix4x4 m, float4 add, rs_allocation in, rs_allocation out) {
-    uint32_t w = rsAllocationGetDimX(in);
-    uint32_t h = rsAllocationGetDimY(in);
-
+void reference(rs_matrix4x4 m, float4 add, rs_allocation in, rs_allocation out,
+               int x1, int y1, int x2, int y2) {
     rs_element ein = rsAllocationGetElement(in);
     rs_element eout = rsAllocationGetElement(out);
     rs_data_type dtin = rsElementGetDataType(ein);
@@ -28,8 +26,8 @@
     uint32_t vsin = rsElementGetVectorSize(ein);
     uint32_t vsout = rsElementGetVectorSize(eout);
 
-    for (uint32_t y = 0; y < h; y++) {
-        for (uint32_t x = 0; x < w; x++) {
+    for (uint32_t y = y1; y < y2; y++) {
+        for (uint32_t x = x1; x < x2; x++) {
             float4 pin = 0.f;
 
             if (dtin == RS_TYPE_FLOAT_32) {
diff --git a/tests/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java b/tests/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java
index d3bac81..89eede6 100644
--- a/tests/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java
+++ b/tests/tests/admin/src/android/admin/cts/DevicePolicyManagerTest.java
@@ -262,20 +262,6 @@
         }
     }
 
-    public void testSetApplicationsHidden_failIfNotDeviceOrProfileOwner() {
-        if (!mDeviceAdmin) {
-            Log.w(TAG, "Skipping testSetApplicationsHidden_failIfNotDeviceOrProfileOwner");
-            return;
-        }
-        try {
-            Intent pdfViewIntent = new Intent(Intent.ACTION_VIEW).setType("application/pdf");
-            mDevicePolicyManager.setApplicationsHidden(mComponent, pdfViewIntent, true);
-            fail("did not throw expected SecurityException");
-        } catch (SecurityException e) {
-            assertProfileOwnerMessage(e.getMessage());
-        }
-    }
-
     public void testIsApplicationHidden_failIfNotDeviceOrProfileOwner() {
         if (!mDeviceAdmin) {
             Log.w(TAG, "Skipping testIsApplicationHidden_failIfNotDeviceOrProfileOwner");
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java
index cc618ee..1a5c272 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java
@@ -57,7 +57,7 @@
         super.tearDown();
     }
 
-    public void testCameraCharacteristicsAndroidColorCorrectionAvailableAberrationCorrectionModes() throws Exception {
+    public void testCameraCharacteristicsAndroidColorCorrectionAvailableAberrationModes() throws Exception {
         String[] ids = mCameraManager.getCameraIdList();
         for (int i = 0; i < ids.length; i++) {
             CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
@@ -66,13 +66,13 @@
 
             {
 
-                assertNotNull("Invalid property: android.colorCorrection.availableAberrationCorrectionModes",
-                        props.get(CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_CORRECTION_MODES));
+                assertNotNull("Invalid property: android.colorCorrection.availableAberrationModes",
+                        props.get(CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES));
                 List<Key<?>> allKeys = props.getKeys();
                 assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
                         ids[i]), allKeys);
-                assertTrue("Key not in keys list: android.colorCorrection.availableAberrationCorrectionModes", allKeys.contains(
-                        CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_CORRECTION_MODES));
+                assertTrue("Key not in keys list: android.colorCorrection.availableAberrationModes", allKeys.contains(
+                        CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES));
 
             }
 
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
index 2ccbc3d..93e5038 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
@@ -338,7 +338,7 @@
         }
 
         if (!mStaticInfo.isManualColorAberrationControlSupported()) {
-            waiverKeys.add(CaptureResult.COLOR_CORRECTION_ABERRATION_CORRECTION_MODE);
+            waiverKeys.add(CaptureResult.COLOR_CORRECTION_ABERRATION_MODE);
         }
 
         if (!mStaticInfo.isManualToneMapSupported()) {
@@ -410,7 +410,7 @@
         resultKeys.add(CaptureResult.COLOR_CORRECTION_MODE);
         resultKeys.add(CaptureResult.COLOR_CORRECTION_TRANSFORM);
         resultKeys.add(CaptureResult.COLOR_CORRECTION_GAINS);
-        resultKeys.add(CaptureResult.COLOR_CORRECTION_ABERRATION_CORRECTION_MODE);
+        resultKeys.add(CaptureResult.COLOR_CORRECTION_ABERRATION_MODE);
         resultKeys.add(CaptureResult.CONTROL_AE_ANTIBANDING_MODE);
         resultKeys.add(CaptureResult.CONTROL_AE_EXPOSURE_COMPENSATION);
         resultKeys.add(CaptureResult.CONTROL_AE_LOCK);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
index 81152a0..761a5a3 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
@@ -19,20 +19,25 @@
 import static com.android.ex.camera2.blocking.BlockingSessionListener.*;
 
 import android.graphics.ImageFormat;
+import android.hardware.camera2.CameraCaptureSession;
 import android.hardware.camera2.CameraCaptureSession.CaptureListener;
 import android.hardware.camera2.CameraDevice;
 import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.TotalCaptureResult;
 import android.hardware.camera2.cts.CameraTestUtils.SimpleImageReaderListener;
 import android.hardware.camera2.cts.helpers.StaticMetadata;
 import android.hardware.camera2.cts.helpers.StaticMetadata.CheckLevel;
 import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase;
 import android.util.Log;
+import android.util.Pair;
 import android.util.Size;
 import android.view.Surface;
 import android.cts.util.DeviceReportLog;
 import android.media.Image;
 import android.media.ImageReader;
 import android.os.ConditionVariable;
+import android.os.SystemClock;
 
 import com.android.cts.util.ReportLog;
 import com.android.cts.util.ResultType;
@@ -43,13 +48,15 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Test camera2 API use case performance KPIs, such as camera open time, session creation time,
  * shutter lag etc. The KPI data will be reported in cts results.
  */
 public class PerformanceTest extends Camera2SurfaceViewTestCase {
-    private static final String TAG = "SurfaceViewPreviewTest";
+    private static final String TAG = "PerformanceTest";
     private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
     private static final int NUM_TEST_LOOPS = 5;
     private static final int NUM_MAX_IMAGES = 4;
@@ -101,23 +108,23 @@
                         // for the first image comes out.
                         imageListener = new SimpleImageListener();
                         mReader.setOnImageAvailableListener(imageListener, mHandler);
-                        startTimeMs = System.currentTimeMillis();
+                        startTimeMs = SystemClock.elapsedRealtime();
 
                         // Blocking open camera
                         simpleOpenCamera(id);
-                        openTimeMs = System.currentTimeMillis();
+                        openTimeMs = SystemClock.elapsedRealtime();
                         cameraOpenTimes[i] = openTimeMs - startTimeMs;
 
                         // Blocking configure outputs.
                         configureReaderAndPreviewOutputs();
-                        configureTimeMs = System.currentTimeMillis();
+                        configureTimeMs = SystemClock.elapsedRealtime();
                         configureStreamTimes[i] = configureTimeMs - openTimeMs;
 
                         // Blocking start preview (start preview to first image arrives)
                         CameraTestUtils.SimpleCaptureListener resultListener =
                                 new CameraTestUtils.SimpleCaptureListener();
                         blockingStartPreview(resultListener, imageListener);
-                        previewStartedTimeMs = System.currentTimeMillis();
+                        previewStartedTimeMs = SystemClock.elapsedRealtime();
                         startPreviewTimes[i] = previewStartedTimeMs - configureTimeMs;
                         cameraLaunchTimes[i] = previewStartedTimeMs - startTimeMs;
 
@@ -125,15 +132,15 @@
                         waitForNumResults(resultListener, NUM_RESULTS_WAIT);
 
                         // Blocking stop preview
-                        startTimeMs = System.currentTimeMillis();
+                        startTimeMs = SystemClock.elapsedRealtime();
                         blockingStopPreview();
-                        stopPreviewTimes[i] = System.currentTimeMillis() - startTimeMs;
+                        stopPreviewTimes[i] = SystemClock.elapsedRealtime() - startTimeMs;
                     }
                     finally {
                         // Blocking camera close
-                        startTimeMs = System.currentTimeMillis();
+                        startTimeMs = SystemClock.elapsedRealtime();
                         closeDevice();
-                        cameraCloseTimes[i] = System.currentTimeMillis() - startTimeMs;
+                        cameraCloseTimes[i] = SystemClock.elapsedRealtime() - startTimeMs;
                     }
                 }
 
@@ -166,6 +173,94 @@
         }
     }
 
+    /**
+     * Test camera capture KPI for YUV_420_888 format: the time duration between
+     * sending out a single image capture request and receiving image data and
+     * capture result.
+     * <p>
+     * It enumerates the following metrics: capture latency, computed by
+     * measuring the time between sending out the capture request and getting
+     * the image data; partial result latency, computed by measuring the time
+     * between sending out the capture request and getting the partial result;
+     * capture result latency, computed by measuring the time between sending
+     * out the capture request and getting the full capture result.
+     * </p>
+     */
+    public void testSingleCapture() throws Exception {
+        double[] captureTimes = new double[NUM_TEST_LOOPS];
+        double[] getPartialTimes = new double[NUM_TEST_LOOPS];
+        double[] getResultTimes = new double[NUM_TEST_LOOPS];
+
+        for (String id : mCameraIds) {
+            try {
+                openDevice(id);
+                long startTimeMs;
+                boolean isPartialTimingValid = true;
+                for (int i = 0; i < NUM_TEST_LOOPS; i++) {
+
+                    // setup builders and listeners
+                    CaptureRequest.Builder previewBuilder =
+                            mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+                    CaptureRequest.Builder captureBuilder =
+                            mCamera.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
+                    CameraTestUtils.SimpleCaptureListener previewResultListener =
+                            new CameraTestUtils.SimpleCaptureListener();
+                    SimpleTimingResultListener captureResultListener =
+                            new SimpleTimingResultListener();
+                    SimpleImageListener imageListener = new SimpleImageListener();
+
+                    prepareCaptureAndStartPreview(previewBuilder, captureBuilder,
+                            mOrderedPreviewSizes.get(0), mOrderedStillSizes.get(0),
+                            ImageFormat.YUV_420_888, previewResultListener,
+                            NUM_MAX_IMAGES, imageListener);
+
+                    // Capture an image and get image data
+                    startTimeMs = SystemClock.elapsedRealtime();
+                    CaptureRequest request = captureBuilder.build();
+                    mSession.capture(request, captureResultListener, mHandler);
+
+                    Pair<CaptureResult, Long> partialResultNTime =
+                            captureResultListener.getPartialResultNTimeForRequest(
+                                    request, NUM_RESULTS_WAIT);
+                    Pair<CaptureResult, Long> captureResultNTime =
+                            captureResultListener.getCaptureResultNTimeForRequest(
+                                    request, NUM_RESULTS_WAIT);
+                    imageListener.waitForImageAvailable(
+                            CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
+
+                    captureTimes[i] = imageListener.getTimeReceivedImage() - startTimeMs;
+                    getPartialTimes[i] = partialResultNTime.second - startTimeMs;
+                    if (getPartialTimes[i] < 0) {
+                        isPartialTimingValid = false;
+                    }
+                    getResultTimes[i] = captureResultNTime.second - startTimeMs;
+
+                    // simulate real scenario (preview runs a bit)
+                    waitForNumResults(previewResultListener, NUM_RESULTS_WAIT);
+
+                    stopPreview();
+
+                }
+                mReportLog.printArray("Camera " + id
+                        + ": Camera capture latency", captureTimes,
+                        ResultType.LOWER_BETTER, ResultUnit.MS);
+                // If any of the partial results do not contain AE and AF state, then no report
+                if (isPartialTimingValid) {
+                    mReportLog.printArray("Camera " + id
+                            + ": Camera partial result latency", getPartialTimes,
+                            ResultType.LOWER_BETTER, ResultUnit.MS);
+                }
+                mReportLog.printArray("Camera " + id
+                        + ": Camera capture result latency", getResultTimes,
+                        ResultType.LOWER_BETTER, ResultUnit.MS);
+            }
+            finally {
+                closeImageReader();
+                closeDevice();
+            }
+        }
+    }
+
     private void blockingStopPreview() throws Exception {
         stopPreview();
         mSessionListener.getStateWaiter().waitForState(SESSION_CLOSED,
@@ -186,6 +281,19 @@
         imageListener.waitForImageAvailable(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
     }
 
+    private void blockingCaptureImage(CaptureListener listener,
+            SimpleImageListener imageListener) throws Exception {
+        if (mReaderSurface == null) {
+            throw new IllegalStateException("reader surface must be initialized first");
+        }
+
+        CaptureRequest.Builder captureBuilder =
+                mCamera.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
+        captureBuilder.addTarget(mReaderSurface);
+        mSession.capture(captureBuilder.build(), listener, mHandler);
+        imageListener.waitForImageAvailable(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
+    }
+
     /**
      * Configure reader and preview outputs and wait until done.
      */
@@ -231,6 +339,7 @@
     private static class SimpleImageListener implements ImageReader.OnImageAvailableListener {
         private ConditionVariable imageAvailable = new ConditionVariable();
         private boolean imageReceived = false;
+        private long mTimeReceivedImage = 0;
 
         @Override
         public void onImageAvailable(ImageReader reader) {
@@ -240,6 +349,7 @@
                     Log.v(TAG, "First image arrives");
                 }
                 imageReceived = true;
+                mTimeReceivedImage = SystemClock.elapsedRealtime();
                 imageAvailable.open();
             }
             image = reader.acquireNextImage();
@@ -266,5 +376,107 @@
                         + CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS + "ms");
             }
         }
+
+        public long getTimeReceivedImage() {
+            return mTimeReceivedImage;
+        }
+    }
+
+    private static class SimpleTimingResultListener
+            extends CameraCaptureSession.CaptureListener {
+        private final LinkedBlockingQueue<Pair<CaptureResult, Long> > mPartialResultQueue =
+                new LinkedBlockingQueue<Pair<CaptureResult, Long> >();
+        private final LinkedBlockingQueue<Pair<CaptureResult, Long> > mResultQueue =
+                new LinkedBlockingQueue<Pair<CaptureResult, Long> > ();
+
+        @Override
+        public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+                TotalCaptureResult result) {
+            try {
+                Long time = SystemClock.elapsedRealtime();
+                mResultQueue.put(new Pair<CaptureResult, Long>(result, time));
+            } catch (InterruptedException e) {
+                throw new UnsupportedOperationException(
+                        "Can't handle InterruptedException in onCaptureCompleted");
+            }
+        }
+
+        @Override
+        public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
+                CaptureResult partialResult) {
+            try {
+                // check if AE and AF state exists
+                Long time = -1L;
+                if (partialResult.get(CaptureResult.CONTROL_AE_STATE) != null &&
+                        partialResult.get(CaptureResult.CONTROL_AF_STATE) != null) {
+                    time = SystemClock.elapsedRealtime();
+                }
+                mPartialResultQueue.put(new Pair<CaptureResult, Long>(partialResult, time));
+            } catch (InterruptedException e) {
+                throw new UnsupportedOperationException(
+                        "Can't handle InterruptedException in onCaptureProgressed");
+            }
+        }
+
+        public Pair<CaptureResult, Long> getPartialResultNTime(long timeout) {
+            try {
+                Pair<CaptureResult, Long> result =
+                        mPartialResultQueue.poll(timeout, TimeUnit.MILLISECONDS);
+                assertNotNull("Wait for a partial result timed out in " + timeout + "ms", result);
+                return result;
+            } catch (InterruptedException e) {
+                throw new UnsupportedOperationException("Unhandled interrupted exception", e);
+            }
+        }
+
+        public Pair<CaptureResult, Long> getCaptureResultNTime(long timeout) {
+            try {
+                Pair<CaptureResult, Long> result =
+                        mResultQueue.poll(timeout, TimeUnit.MILLISECONDS);
+                assertNotNull("Wait for a capture result timed out in " + timeout + "ms", result);
+                return result;
+            } catch (InterruptedException e) {
+                throw new UnsupportedOperationException("Unhandled interrupted exception", e);
+            }
+        }
+
+        public Pair<CaptureResult, Long> getPartialResultNTimeForRequest(CaptureRequest myRequest,
+                int numResultsWait) {
+            if (numResultsWait < 0) {
+                throw new IllegalArgumentException("numResultsWait must be no less than 0");
+            }
+
+            Pair<CaptureResult, Long> result;
+            int i = 0;
+            do {
+                result = getPartialResultNTime(CameraTestUtils.CAPTURE_RESULT_TIMEOUT_MS);
+                if (result.first.getRequest().equals(myRequest)) {
+                    return result;
+                }
+            } while (i++ < numResultsWait);
+
+            throw new TimeoutRuntimeException("Unable to get the expected capture result after "
+                    + "waiting for " + numResultsWait + " results");
+        }
+
+        public Pair<CaptureResult, Long> getCaptureResultNTimeForRequest(CaptureRequest myRequest,
+                int numResultsWait) {
+            if (numResultsWait < 0) {
+                throw new IllegalArgumentException("numResultsWait must be no less than 0");
+            }
+
+            Pair<CaptureResult, Long> result;
+            int i = 0;
+            do {
+                result = getCaptureResultNTime(CameraTestUtils.CAPTURE_RESULT_TIMEOUT_MS);
+                if (result.first.getRequest().equals(myRequest)) {
+                    return result;
+                }
+            } while (i++ < numResultsWait);
+
+            throw new TimeoutRuntimeException("Unable to get the expected capture result after "
+                    + "waiting for " + numResultsWait + " results");
+        }
+
     }
 }
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/RobustnessTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/RobustnessTest.java
new file mode 100644
index 0000000..bdbe44f
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/RobustnessTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.camera2.cts;
+
+import android.graphics.SurfaceTexture;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.cts.testcases.Camera2AndroidTestCase;
+import android.util.Log;
+import android.view.Surface;
+
+import com.android.ex.camera2.blocking.BlockingSessionListener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * Tests exercising edge cases in camera setup, configuration, and usage.
+ */
+public class RobustnessTest extends Camera2AndroidTestCase {
+    private static final String TAG = "RobustnessTest";
+
+    private static final int FAILED_CONFIGURE_TIMEOUT = 5000; //ms
+
+    /**
+     * Test that a {@link CameraCaptureSession} configured with a {@link Surface} with invalid
+     * dimensions fails gracefully.
+     */
+    public void testBadSurfaceDimensions() throws Exception {
+        for (String id : mCameraIds) {
+            try {
+                Log.i(TAG, "Testing Camera " + id);
+                openDevice(id);
+
+                // Setup Surface with unconfigured dimensions.
+                SurfaceTexture surfaceTexture = new SurfaceTexture(0);
+                Surface surface = new Surface(surfaceTexture);
+                List<Surface> surfaces = new ArrayList<>();
+                surfaces.add(surface);
+
+                // Setup a capture request and listener
+                CaptureRequest.Builder request =
+                        mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+                request.addTarget(surface);
+                CameraCaptureSession.CaptureListener mockCaptureListener =
+                        mock(CameraCaptureSession.CaptureListener.class);
+
+                // Check that correct session callback is hit.
+                CameraCaptureSession.StateListener sessionListener =
+                        mock(CameraCaptureSession.StateListener.class);
+                mCamera.createCaptureSession(surfaces, sessionListener, mHandler);
+                verify(sessionListener, timeout(FAILED_CONFIGURE_TIMEOUT).atLeastOnce()).
+                        onConfigureFailed(any(CameraCaptureSession.class));
+                verify(sessionListener, never()).onConfigured(any(CameraCaptureSession.class));
+                verify(sessionListener, never()).onActive(any(CameraCaptureSession.class));
+                verify(sessionListener, never()).onReady(any(CameraCaptureSession.class));
+                verify(sessionListener, never()).onClosed(any(CameraCaptureSession.class));
+            } finally {
+                closeDevice(id);
+            }
+        }
+    }
+}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
index 7cf6f24..cbd51f5 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
@@ -192,7 +192,7 @@
                 requestKeys.add(CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE);
                 if (mStaticInfo.isHardwareLevelFull()) {
                     requestKeys.add(CaptureRequest.TONEMAP_CURVE);
-                    requestKeys.add(CaptureRequest.COLOR_CORRECTION_ABERRATION_CORRECTION_MODE);
+                    requestKeys.add(CaptureRequest.COLOR_CORRECTION_ABERRATION_MODE);
                 }
 
                 break;
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
index 1b82b1d..d2d3248 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
@@ -1402,7 +1402,7 @@
      */
     public int[] getAvailableColorAberrationModesChecked() {
         Key<int[]> key =
-                CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_CORRECTION_MODES;
+                CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES;
         int[] modes = getValueFromKeyNonNull(key);
 
         if (modes == null) {
@@ -1411,11 +1411,11 @@
 
         List<Integer> modeList = Arrays.asList(CameraTestUtils.toObject(modes));
         checkTrueForKey(key, " Camera devices must always support OFF mode",
-                modeList.contains(CameraMetadata.COLOR_CORRECTION_ABERRATION_CORRECTION_MODE_OFF));
+                modeList.contains(CameraMetadata.COLOR_CORRECTION_ABERRATION_MODE_OFF));
         checkElementDistinct(key, modeList);
         checkArrayValuesInRange(key, modes,
-                CameraMetadata.COLOR_CORRECTION_ABERRATION_CORRECTION_MODE_OFF,
-                CameraMetadata.COLOR_CORRECTION_ABERRATION_CORRECTION_MODE_HIGH_QUALITY);
+                CameraMetadata.COLOR_CORRECTION_ABERRATION_MODE_OFF,
+                CameraMetadata.COLOR_CORRECTION_ABERRATION_MODE_HIGH_QUALITY);
 
         return modes;
     }
@@ -1618,7 +1618,7 @@
      * @return {@code true} if manual color aberration control is supported
      */
     public boolean isManualColorAberrationControlSupported() {
-        return areKeysAvailable(CaptureRequest.COLOR_CORRECTION_ABERRATION_CORRECTION_MODE);
+        return areKeysAvailable(CaptureRequest.COLOR_CORRECTION_ABERRATION_MODE);
     }
 
     /**
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
index 3fa7b58..6e8ddef 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
@@ -622,7 +622,7 @@
      * @param maxNumImages The max number of images set to the image reader
      * @param imageListener The single capture capture image listener
      */
-    private void prepareCaptureAndStartPreview(CaptureRequest.Builder previewRequest,
+    protected void prepareCaptureAndStartPreview(CaptureRequest.Builder previewRequest,
             CaptureRequest.Builder stillRequest, Size previewSz, Size captureSz, int format,
             CaptureListener resultListener, int maxNumImages,
             ImageReader.OnImageAvailableListener imageListener) throws Exception {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
index 7d952f6..bd02d7e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBase.java
@@ -21,6 +21,7 @@
 import android.renderscript.Allocation;
 import android.renderscript.Element;
 import android.renderscript.Type;
+import android.renderscript.Script;
 
 public class IntrinsicBase extends RSBaseCompute {
     protected final String TAG = "Img";
@@ -59,12 +60,24 @@
         return e;
     }
 
-    protected Allocation makeAllocation(int w, int h, Element e) {
+    protected Allocation makeAllocation(int w, int h, Element e, boolean clear) {
         Type.Builder tb = new Type.Builder(mRS, e);
         tb.setX(w);
         tb.setY(h);
         Type t = tb.create();
-        return Allocation.createTyped(mRS, t);
+        Allocation a = Allocation.createTyped(mRS, t);
+
+        if (clear) {
+            final int s = a.getBytesSize();
+            byte[] b = new byte[s];
+            a.copyFromUnchecked(b);
+        }
+
+        return a;
+    }
+
+    protected Allocation makeAllocation(int w, int h, Element e) {
+        return makeAllocation(w, h, e, true);
     }
 
     protected void makeSource(int w, int h, Element e) {
@@ -123,4 +136,11 @@
         checkForErrors();
     }
 
+    protected Script.LaunchOptions makeClipper(int x, int y, int x2, int y2) {
+        Script.LaunchOptions lo = new Script.LaunchOptions();
+        lo.setX(x, x2);
+        lo.setY(y, y2);
+        return lo;
+    }
+
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
index 2ac7d6f..ac48783 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicColorMatrix.java
@@ -25,7 +25,8 @@
 
     private void subtest(int w, int h, Matrix4f mat, Float4 add,
                          Element.DataType dtIn, int vsIn,
-                         Element.DataType dtOut, int vsOut) {
+                         Element.DataType dtOut, int vsOut,
+                         boolean clip) {
 
 
         if (mat == null) {
@@ -42,21 +43,34 @@
 
 
         makeSource(w, h, ein);
-        mAllocRef = makeAllocation(w, h, eout);
-        mAllocDst = makeAllocation(w, h, eout);
+        mAllocRef = makeAllocation(w, h, eout, true);
+        mAllocDst = makeAllocation(w, h, eout, true);
+
+        int x1 = 0, y1 = 0, x2 = w, y2 = h;
+        if (clip) {
+            x1 = 11;
+            y1 = 11;
+            x2 = w - 11;
+            y2 = h - 11;
+        }
 
         mSi.setColorMatrix(mat);
         mSi.setAdd(add);
-        mSi.forEach(mAllocSrc, mAllocDst);
-        mSr.invoke_reference(mat, add, mAllocSrc, mAllocRef);
+        if (clip) {
+            mSi.forEach(mAllocSrc, mAllocDst, makeClipper(x1, y1, x2, y2));
+        } else {
+            mSi.forEach(mAllocSrc, mAllocDst);
+        }
+        mSr.invoke_reference(mat, add, mAllocSrc, mAllocRef, x1, y1, x2, y2);
 
-        android.util.Log.e("RSI test", "test ColorMatrix  vsin=" + vsIn + ", vsout=" + vsOut + ",  dim " + w + ", " + h);
+        //android.util.Log.e("RSI test", "test ColorMatrix  vsin=" + vsIn + ", vsout=" + vsOut + ",  dim " + w + ", " + h);
         mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
         mRS.finish();
     }
 
 
-    private void test(Element.DataType dtin, Element.DataType dtout, int subtest) {
+    private void test(Element.DataType dtin, Element.DataType dtout, int subtest,
+                      boolean clip) {
         Float4 add = new Float4();
         Matrix4f mat = new Matrix4f();
         java.util.Random r = new java.util.Random(100);
@@ -99,52 +113,84 @@
                     add.w = r.nextFloat() * (subtest - 1);
                 }
             }
-            android.util.Log.v("rs", "Mat [" + f[0] + ", " + f[4] + ", " + f[8] + ", " + f[12] + "]");
-            android.util.Log.v("rs", "    [" + f[1] + ", " + f[5] + ", " + f[9] + ", " + f[13] + "]");
-            android.util.Log.v("rs", "    [" + f[2] + ", " + f[6] + ", " + f[10] + ", " + f[14] + "]");
-            android.util.Log.v("rs", "    [" + f[3] + ", " + f[7] + ", " + f[11] + ", " + f[15] + "]");
+            //android.util.Log.v("rs", "Mat [" + f[0] + ", " + f[4] + ", " + f[8] + ", " + f[12] + "]");
+            //android.util.Log.v("rs", "    [" + f[1] + ", " + f[5] + ", " + f[9] + ", " + f[13] + "]");
+            //android.util.Log.v("rs", "    [" + f[2] + ", " + f[6] + ", " + f[10] + ", " + f[14] + "]");
+            //android.util.Log.v("rs", "    [" + f[3] + ", " + f[7] + ", " + f[11] + ", " + f[15] + "]");
         }
 
         for (int i=1; i <= 4; i++) {
             for (int j=1; j <=4; j++) {
                 subtest(101, 101, mat, add,
-                        dtin, i,
-                        dtout, j);
+                        dtin, i, dtout, j, clip);
             }
         }
         checkError();
     }
 
     public void test_U8_U8_Ident() {
-        test(Element.DataType.UNSIGNED_8, Element.DataType.UNSIGNED_8, 0);
+        test(Element.DataType.UNSIGNED_8, Element.DataType.UNSIGNED_8, 0, false);
     }
 
     public void test_F32_F32_Ident() {
-        test(Element.DataType.FLOAT_32, Element.DataType.FLOAT_32, 0);
+        test(Element.DataType.FLOAT_32, Element.DataType.FLOAT_32, 0, false);
     }
 
     public void test_U8_F32_Ident() {
-        test(Element.DataType.UNSIGNED_8, Element.DataType.FLOAT_32, 0);
+        test(Element.DataType.UNSIGNED_8, Element.DataType.FLOAT_32, 0, false);
     }
 
     public void test_F32_U8_Ident() {
-        test(Element.DataType.FLOAT_32, Element.DataType.UNSIGNED_8, 0);
+        test(Element.DataType.FLOAT_32, Element.DataType.UNSIGNED_8, 0, false);
     }
 
     public void test_U8_U8_Rand() {
-        test(Element.DataType.UNSIGNED_8, Element.DataType.UNSIGNED_8, 2);
+        test(Element.DataType.UNSIGNED_8, Element.DataType.UNSIGNED_8, 2, false);
     }
 
     public void test_F32_F32_Rand() {
-        test(Element.DataType.FLOAT_32, Element.DataType.FLOAT_32, 10);
+        test(Element.DataType.FLOAT_32, Element.DataType.FLOAT_32, 10, false);
     }
 
     public void test_U8_F32_Rand() {
-        test(Element.DataType.UNSIGNED_8, Element.DataType.FLOAT_32, 10);
+        test(Element.DataType.UNSIGNED_8, Element.DataType.FLOAT_32, 10, false);
     }
 
     public void test_F32_U8_Rand() {
-        test(Element.DataType.FLOAT_32, Element.DataType.UNSIGNED_8, 10);
+        test(Element.DataType.FLOAT_32, Element.DataType.UNSIGNED_8, 10, false);
     }
 
+
+
+    public void test_U8_U8_IdentC() {
+        test(Element.DataType.UNSIGNED_8, Element.DataType.UNSIGNED_8, 0, true);
+    }
+
+    public void test_F32_F32_IdentC() {
+        test(Element.DataType.FLOAT_32, Element.DataType.FLOAT_32, 0, true);
+    }
+
+    public void test_U8_F32_IdentC() {
+        test(Element.DataType.UNSIGNED_8, Element.DataType.FLOAT_32, 0, true);
+    }
+
+    public void test_F32_U8_IdentC() {
+        test(Element.DataType.FLOAT_32, Element.DataType.UNSIGNED_8, 0, true);
+    }
+
+    public void test_U8_U8_RandC() {
+        test(Element.DataType.UNSIGNED_8, Element.DataType.UNSIGNED_8, 2, true);
+    }
+
+    public void test_F32_F32_RandC() {
+        test(Element.DataType.FLOAT_32, Element.DataType.FLOAT_32, 10, true);
+    }
+
+    public void test_U8_F32_RandC() {
+        test(Element.DataType.UNSIGNED_8, Element.DataType.FLOAT_32, 10, true);
+    }
+
+    public void test_F32_U8_RandC() {
+        test(Element.DataType.FLOAT_32, Element.DataType.UNSIGNED_8, 10, true);
+    }
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
index 12eae9a..1880132 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve3x3.java
@@ -20,138 +20,187 @@
 import android.util.Log;
 
 public class IntrinsicConvolve3x3 extends IntrinsicBase {
-    private void testConvolve3(int w, int h, Element.DataType dt, int vecSize) {
+    private void testConvolve3(int w, int h, Element.DataType dt, int vecSize, Script.LaunchOptions sc) {
         float cf1[] = {0.f, 0.f, 0.f,  0.f, 1.f, 0.f,  0.f, 0.f, 0.f};
         float cf2[] = {0.f, -1.f, 0.f,  -1.f, 5.f, -1.f,  0.f, -1.f, 0.f};
 
-
         Element e = makeElement(dt, vecSize);
 
         System.gc();
         makeBuffers(w, h, e);
 
-
         ScriptIntrinsicConvolve3x3 si = ScriptIntrinsicConvolve3x3.create(mRS, e);
         si.setCoefficients(cf1);
         si.setInput(mAllocSrc);
-        si.forEach(mAllocRef);
+        si.forEach(mAllocRef, sc);
 
         ScriptC_intrinsic_convolve3x3 sr = new ScriptC_intrinsic_convolve3x3(mRS);
         sr.set_gCoeffs(cf1);
         sr.set_gIn(mAllocSrc);
         sr.set_gWidth(w);
         sr.set_gHeight(h);
+
+        if (sc != null) {
+            mAllocRef.copyFrom(mAllocSrc);
+            mAllocDst.copyFrom(mAllocSrc);
+        }
+
         if (dt == Element.DataType.UNSIGNED_8) {
             switch(vecSize) {
             case 4:
-                sr.forEach_convolve_U4(mAllocDst);
+                sr.forEach_convolve_U4(mAllocDst, sc);
                 break;
             case 3:
-                sr.forEach_convolve_U3(mAllocDst);
+                sr.forEach_convolve_U3(mAllocDst, sc);
                 break;
             case 2:
-                sr.forEach_convolve_U2(mAllocDst);
+                sr.forEach_convolve_U2(mAllocDst, sc);
                 break;
             case 1:
-                sr.forEach_convolve_U1(mAllocDst);
+                sr.forEach_convolve_U1(mAllocDst, sc);
                 break;
             }
         } else {
             switch(vecSize) {
             case 4:
-                sr.forEach_convolve_F4(mAllocDst);
+                sr.forEach_convolve_F4(mAllocDst, sc);
                 break;
             case 3:
-                sr.forEach_convolve_F3(mAllocDst);
+                sr.forEach_convolve_F3(mAllocDst, sc);
                 break;
             case 2:
-                sr.forEach_convolve_F2(mAllocDst);
+                sr.forEach_convolve_F2(mAllocDst, sc);
                 break;
             case 1:
-                sr.forEach_convolve_F1(mAllocDst);
+                sr.forEach_convolve_F1(mAllocDst, sc);
                 break;
             }
         }
 
-        android.util.Log.e("RSI test", "test convolve U8_" + vecSize + " 1 " + w + ", " + h);
+        //android.util.Log.e("RSI test", "test convolve U8_" + vecSize + " 1 " + w + ", " + h);
         mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
 
         si.setCoefficients(cf2);
         sr.set_gCoeffs(cf2);
-        si.forEach(mAllocRef);
+        si.forEach(mAllocRef, sc);
         if (dt == Element.DataType.UNSIGNED_8) {
             switch(vecSize) {
             case 4:
-                sr.forEach_convolve_U4(mAllocDst);
+                sr.forEach_convolve_U4(mAllocDst, sc);
                 break;
             case 3:
-                sr.forEach_convolve_U3(mAllocDst);
+                sr.forEach_convolve_U3(mAllocDst, sc);
                 break;
             case 2:
-                sr.forEach_convolve_U2(mAllocDst);
+                sr.forEach_convolve_U2(mAllocDst, sc);
                 break;
             case 1:
-                sr.forEach_convolve_U1(mAllocDst);
+                sr.forEach_convolve_U1(mAllocDst, sc);
                 break;
             }
         } else {
             switch(vecSize) {
             case 4:
-                sr.forEach_convolve_F4(mAllocDst);
+                sr.forEach_convolve_F4(mAllocDst, sc);
                 break;
             case 3:
-                sr.forEach_convolve_F3(mAllocDst);
+                sr.forEach_convolve_F3(mAllocDst, sc);
                 break;
             case 2:
-                sr.forEach_convolve_F2(mAllocDst);
+                sr.forEach_convolve_F2(mAllocDst, sc);
                 break;
             case 1:
-                sr.forEach_convolve_F1(mAllocDst);
+                sr.forEach_convolve_F1(mAllocDst, sc);
                 break;
             }
         }
-        android.util.Log.e("RSI test", "test convolve U8_" + vecSize + " 2 " + w + ", " + h);
+        //android.util.Log.e("RSI test", "test convolve U8_" + vecSize + " 2 " + w + ", " + h);
         mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
         mRS.finish();
     }
 
 
     public void test_U8_4() {
-        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 4);
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 4, null);
         checkError();
     }
     public void test_U8_3() {
-        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 3);
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 3, null);
         checkError();
     }
     public void test_U8_2() {
-        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 2);
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 2, null);
         checkError();
     }
     public void test_U8_1() {
-        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 1);
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 1, null);
         checkError();
     }
 
     public void test_F32_4() {
-        testConvolve3(100, 100, Element.DataType.FLOAT_32, 4);
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 4, null);
         checkError();
     }
 
     public void test_F32_3() {
-        testConvolve3(100, 100, Element.DataType.FLOAT_32, 3);
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 3, null);
         checkError();
     }
 
     public void test_F32_2() {
-        testConvolve3(100, 100, Element.DataType.FLOAT_32, 2);
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 2, null);
         checkError();
     }
 
     public void test_F32_1() {
-        testConvolve3(100, 100, Element.DataType.FLOAT_32, 1);
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 1, null);
         checkError();
     }
 
 
+    public void test_U8_4C() {
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 4,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+    public void test_U8_3C() {
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 3,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+    public void test_U8_2C() {
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 2,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+    public void test_U8_1C() {
+        testConvolve3(100, 100, Element.DataType.UNSIGNED_8, 1,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_4C() {
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 4,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_3C() {
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 3,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_2C() {
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 2,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_1C() {
+        testConvolve3(100, 100, Element.DataType.FLOAT_32, 1,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
index 482db59..ee92651 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicConvolve5x5.java
@@ -21,10 +21,16 @@
 
 public class IntrinsicConvolve5x5 extends IntrinsicBase {
     private void test5(ScriptC_intrinsic_convolve5x5 sr, ScriptIntrinsicConvolve5x5 si,
-                        Element e, float cf[], String name, int num, int w, int h) {
+                       Element e, float cf[], String name, int num, int w, int h,
+                       Script.LaunchOptions sc) {
         si.setCoefficients(cf);
         si.setInput(mAllocSrc);
-        si.forEach(mAllocRef);
+
+        if (sc != null) {
+            mAllocRef.copyFrom(mAllocSrc);
+            mAllocDst.copyFrom(mAllocSrc);
+        }
+        si.forEach(mAllocRef, sc);
 
         sr.set_gWidth(w);
         sr.set_gHeight(h);
@@ -33,41 +39,41 @@
         if (e.getDataType() == Element.DataType.UNSIGNED_8) {
             switch(e.getVectorSize()) {
             case 4:
-                sr.forEach_convolve_U4(mAllocDst);
+                sr.forEach_convolve_U4(mAllocDst, sc);
                 break;
             case 3:
-                sr.forEach_convolve_U3(mAllocDst);
+                sr.forEach_convolve_U3(mAllocDst, sc);
                 break;
             case 2:
-                sr.forEach_convolve_U2(mAllocDst);
+                sr.forEach_convolve_U2(mAllocDst, sc);
                 break;
             case 1:
-                sr.forEach_convolve_U1(mAllocDst);
+                sr.forEach_convolve_U1(mAllocDst, sc);
                 break;
             }
         } else {
             switch(e.getVectorSize()) {
             case 4:
-                sr.forEach_convolve_F4(mAllocDst);
+                sr.forEach_convolve_F4(mAllocDst, sc);
                 break;
             case 3:
-                sr.forEach_convolve_F3(mAllocDst);
+                sr.forEach_convolve_F3(mAllocDst, sc);
                 break;
             case 2:
-                sr.forEach_convolve_F2(mAllocDst);
+                sr.forEach_convolve_F2(mAllocDst, sc);
                 break;
             case 1:
-                sr.forEach_convolve_F1(mAllocDst);
+                sr.forEach_convolve_F1(mAllocDst, sc);
                 break;
             }
         }
 
-        android.util.Log.e("RSI test", name + "  " + e.getVectorSize() + " " + num + " " + w + ", " + h);
+        //android.util.Log.e("RSI test", name + "  " + e.getVectorSize() + " " + num + " " + w + ", " + h);
         mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
         mRS.finish();
     }
 
-    private void testConvolve5(int w, int h, Element.DataType dt, int vecSize) {
+    private void testConvolve5(int w, int h, Element.DataType dt, int vecSize, Script.LaunchOptions sc) {
         float cf1[] = { 0.f,  0.f,  0.f,  0.f,  0.f,
                         0.f,  0.f,  0.f,  0.f,  0.f,
                         0.f,  0.f,  1.f,  0.f,  0.f,
@@ -84,43 +90,87 @@
 
         ScriptIntrinsicConvolve5x5 si = ScriptIntrinsicConvolve5x5.create(mRS, e);
         ScriptC_intrinsic_convolve5x5 sr = new ScriptC_intrinsic_convolve5x5(mRS);
-        test5(sr, si, e, cf1, "test convolve", 1, w, h);
-        test5(sr, si, e, cf2, "test convolve", 2, w, h);
+        test5(sr, si, e, cf1, "test convolve", 1, w, h, sc);
+        test5(sr, si, e, cf2, "test convolve", 2, w, h, sc);
     }
 
     public void test_U8_4() {
-        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 4);
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 4, null);
         checkError();
     }
     public void test_U8_3() {
-        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 3);
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 3, null);
         checkError();
     }
     public void test_U8_2() {
-        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 2);
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 2, null);
         checkError();
     }
     public void test_U8_1() {
-        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 1);
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 1, null);
         checkError();
     }
 
     public void test_F32_4() {
-        testConvolve5(100, 100, Element.DataType.FLOAT_32, 4);
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 4, null);
         checkError();
     }
     public void test_F32_3() {
-        testConvolve5(100, 100, Element.DataType.FLOAT_32, 3);
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 3, null);
         checkError();
     }
     public void test_F32_2() {
-        testConvolve5(100, 100, Element.DataType.FLOAT_32, 2);
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 2, null);
         checkError();
     }
     public void test_F32_1() {
-        testConvolve5(100, 100, Element.DataType.FLOAT_32, 1);
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 1, null);
         checkError();
     }
 
+    public void test_U8_4C() {
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 4,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+    public void test_U8_3C() {
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 3,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+    public void test_U8_2C() {
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 2,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+    public void test_U8_1C() {
+        testConvolve5(100, 100, Element.DataType.UNSIGNED_8, 1,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_4C() {
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 4,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_3C() {
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 3,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_2C() {
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 2,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
+
+    public void test_F32_1C() {
+        testConvolve5(100, 100, Element.DataType.FLOAT_32, 1,
+                      makeClipper(11, 11, 90, 90));
+        checkError();
+    }
 
 }
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index de868d1..d90a61e 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -42,6 +42,7 @@
 import com.android.tradefed.testtype.IRemoteTest;
 import com.android.tradefed.testtype.IResumableTest;
 import com.android.tradefed.testtype.IShardableTest;
+import com.android.tradefed.testtype.InstrumentationTest;
 import com.android.tradefed.util.AbiFormatter;
 import com.android.tradefed.util.RunUtil;
 import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
@@ -477,6 +478,11 @@
                 if (test instanceof IBuildReceiver) {
                     ((IBuildReceiver) test).setBuild(mBuildInfo);
                 }
+                // setForceAbi should be exposed on device test.
+                // This is not the best fix, but works.
+                if (test instanceof InstrumentationTest) {
+                    ((InstrumentationTest)test).setForceAbi(mForceAbi);
+                }
 
                 forwardPackageDetails(knownTests.getPackageDef(), listener);
                 test.run(filter);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java
index 35b4998..eab7925 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java
@@ -48,11 +48,6 @@
 
     private CtsBuildHelper mCtsBuild = null;
 
-    @Option(name = AbiFormatter.FORCE_ABI_STRING,
-            description = AbiFormatter.FORCE_ABI_DESCRIPTION,
-            importance = Importance.IF_UNSET)
-    private String mForceAbi = null;
-
     /**
      * {@inheritDoc}
      */
@@ -96,12 +91,14 @@
                 File apkFile = mCtsBuild.getTestApp(apkFileName);
                 String errorCode = null;
                 String[] options = {};
-                if (mForceAbi != null) {
+                String forceAbi = getForceAbi();
+                if (forceAbi != null) {
                     String abi = AbiFormatter.getDefaultAbi(mTestDevice, mForceAbi);
                     if (abi != null) {
                         options = new String[]{String.format("--abi %s ", abi)};
                     }
                 }
+                Log.d(LOG_TAG, "installPackage options: " + options);
                 errorCode = mTestDevice.installPackage(apkFile, true, options);
                 if (errorCode != null) {
                     Log.e(LOG_TAG, String.format("Failed to install %s on %s. Reason: %s",