Merge "camera2: Add RAW/JPEG comparison test." into lmp-mr1-dev
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index 16f9ec1..e8e7485 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -34,6 +34,7 @@
     CtsSplitApp_arm64-v8a \
     CtsSplitApp_mips64 \
     CtsSplitApp_mips \
+    CtsSplitAppDiffRevision \
     CtsSplitAppDiffVersion \
     CtsSplitAppDiffCert \
     CtsSplitAppFeature \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index e67a5c1..d3f77e3 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1313,6 +1313,14 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".managedprovisioning.WorkNotificationTestActivity">
+            <intent-filter>
+                <action android:name="com.android.cts.verifier.managedprovisioning.WORK_NOTIFICATION" />
+                <action android:name="com.android.cts.verifier.managedprovisioning.CLEAR_WORK_NOTIFICATION" />
+                <category android:name="android.intent.category.DEFAULT"></category>
+            </intent-filter>
+        </activity>
+
         <receiver android:name=".managedprovisioning.DeviceAdminTestReceiver"
                 android:label="@string/provisioning_byod_device_admin"
                 android:permission="android.permission.BIND_DEVICE_ADMIN">
diff --git a/apps/CtsVerifier/res/drawable-hdpi/ic_corp_icon.png b/apps/CtsVerifier/res/drawable-hdpi/ic_corp_icon.png
new file mode 100644
index 0000000..06c5135
--- /dev/null
+++ b/apps/CtsVerifier/res/drawable-hdpi/ic_corp_icon.png
Binary files differ
diff --git a/apps/CtsVerifier/res/drawable-mdpi/ic_corp_icon.png b/apps/CtsVerifier/res/drawable-mdpi/ic_corp_icon.png
new file mode 100644
index 0000000..79372b2
--- /dev/null
+++ b/apps/CtsVerifier/res/drawable-mdpi/ic_corp_icon.png
Binary files differ
diff --git a/apps/CtsVerifier/res/drawable-xhdpi/ic_corp_icon.png b/apps/CtsVerifier/res/drawable-xhdpi/ic_corp_icon.png
new file mode 100644
index 0000000..3626c7d
--- /dev/null
+++ b/apps/CtsVerifier/res/drawable-xhdpi/ic_corp_icon.png
Binary files differ
diff --git a/apps/CtsVerifier/res/drawable-xxhdpi/ic_corp_icon.png b/apps/CtsVerifier/res/drawable-xxhdpi/ic_corp_icon.png
new file mode 100644
index 0000000..d33319f
--- /dev/null
+++ b/apps/CtsVerifier/res/drawable-xxhdpi/ic_corp_icon.png
Binary files differ
diff --git a/apps/CtsVerifier/res/drawable-xxxhdpi/ic_corp_icon.png b/apps/CtsVerifier/res/drawable-xxxhdpi/ic_corp_icon.png
new file mode 100644
index 0000000..359e210
--- /dev/null
+++ b/apps/CtsVerifier/res/drawable-xxxhdpi/ic_corp_icon.png
Binary files differ
diff --git a/apps/CtsVerifier/res/layout/byod_custom_view_badged_icons.xml b/apps/CtsVerifier/res/layout/byod_custom_view.xml
similarity index 89%
rename from apps/CtsVerifier/res/layout/byod_custom_view_badged_icons.xml
rename to apps/CtsVerifier/res/layout/byod_custom_view.xml
index 1a29f65..00c9ad9 100644
--- a/apps/CtsVerifier/res/layout/byod_custom_view_badged_icons.xml
+++ b/apps/CtsVerifier/res/layout/byod_custom_view.xml
@@ -28,12 +28,10 @@
         <TextView android:id="@+id/message"
                 style="@style/InstructionsSmallFont"
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/provisioning_byod_workapps_visible_instruction" />
+                android:layout_height="wrap_content" />
     </ScrollView>
 
     <ImageView android:id="@+id/sample_icon"
-            android:src="@drawable/badged_icon"
             android:layout_width="56dip"
             android:layout_height="56dip"
             android:layout_gravity="center_horizontal" />
diff --git a/apps/CtsVerifier/res/layout/fs_info.xml b/apps/CtsVerifier/res/layout/fs_info.xml
index 3fe6815..ea02fee 100644
--- a/apps/CtsVerifier/res/layout/fs_info.xml
+++ b/apps/CtsVerifier/res/layout/fs_info.xml
@@ -13,62 +13,44 @@
      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="fill_parent" android:layout_height="wrap_content">
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent" android:layout_height="fill_parent">
+    <GridLayout
+        android:columnCount="2"
+        android:orientation="horizontal"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content">
 
-    <ImageView android:id="@+id/fs_legend_good_image"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:src="@drawable/fs_good"
-        android:layout_alignParentTop="true"
-        android:layout_alignParentLeft="true" />
-    <TextView android:id="@+id/fs_legend_good_text"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/fs_legend_good"
-        android:layout_toRightOf="@id/fs_legend_good_image"
-        android:layout_alignTop="@id/fs_legend_good_image"
-        android:layout_marginLeft="3dip" />
+        <ImageView android:id="@+id/fs_legend_good_image"
+            android:src="@drawable/fs_good"
+            android:layout_gravity="top|left" />
+        <TextView android:id="@+id/fs_legend_good_text"
+            android:text="@string/fs_legend_good"
+            android:layout_marginLeft="3dip"
+            android:layout_gravity="top|left" />
 
-    <ImageView android:id="@+id/fs_legend_indeterminate_image"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:src="@drawable/fs_indeterminate"
-        android:layout_alignParentLeft="true"
-        android:layout_below="@id/fs_legend_good_image" />
-    <TextView android:id="@+id/fs_legend_indeterminate_text"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/fs_legend_indeterminate"
-        android:layout_toRightOf="@id/fs_legend_indeterminate_image"
-        android:layout_alignTop="@id/fs_legend_indeterminate_image"
-        android:layout_marginLeft="3dip" />
+        <ImageView android:id="@+id/fs_legend_indeterminate_image"
+            android:src="@drawable/fs_indeterminate"
+            android:layout_gravity="top|left" />
+        <TextView android:id="@+id/fs_legend_indeterminate_text"
+            android:text="@string/fs_legend_indeterminate"
+            android:layout_marginLeft="3dip"
+            android:layout_gravity="top|left" />
 
-    <ImageView android:id="@+id/fs_legend_warning_image"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:src="@drawable/fs_warning"
-        android:layout_alignParentLeft="true"
-        android:layout_below="@id/fs_legend_indeterminate_image" />
-    <TextView android:id="@+id/fs_legend_warning_text"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/fs_legend_warning"
-        android:layout_toRightOf="@id/fs_legend_warning_image"
-        android:layout_alignTop="@id/fs_legend_warning_image"
-        android:layout_marginLeft="3dip" />
+        <ImageView android:id="@+id/fs_legend_warning_image"
+            android:src="@drawable/fs_warning"
+            android:layout_gravity="top|left" />
+        <TextView android:id="@+id/fs_legend_warning_text"
+            android:text="@string/fs_legend_warning"
+            android:layout_marginLeft="3dip"
+            android:layout_gravity="top|left" />
 
-    <ImageView android:id="@+id/fs_legend_error_image"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:src="@drawable/fs_error"
-        android:layout_alignParentLeft="true"
-        android:layout_below="@id/fs_legend_warning_image" />
-    <TextView android:id="@+id/fs_legend_error_text"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/fs_legend_error"
-        android:layout_toRightOf="@id/fs_legend_error_image"
-        android:layout_alignTop="@id/fs_legend_error_image"
-        android:layout_marginLeft="3dip" />
-</RelativeLayout>
+        <ImageView android:id="@+id/fs_legend_error_image"
+            android:src="@drawable/fs_error"
+            android:layout_gravity="top|left" />
+        <TextView android:id="@+id/fs_legend_error_text"
+            android:text="@string/fs_legend_error"
+            android:layout_marginLeft="3dip"
+            android:layout_gravity="top|left" />
+    </GridLayout>
+</ScrollView>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 0724e0f..b92bca9 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1287,6 +1287,13 @@
         \n
         Verify that you are prompted with the above choices and both options work as intended. Then mark this test accordingly.
     </string>
+    <string name="provisioning_byod_work_notification">Work notification is badged</string>
+    <string name="provisioning_byod_work_notification_instruction">
+        Please press the Go button to trigger a notification.\n
+        \n
+        Verify that the notification is badged (see sample badge below). Then mark this test accordingly.
+    </string>
+    <string name="provisioning_byod_work_notification_title">This is a work notification</string>
     <string name="provisioning_byod_profile_visible_instruction">
         Please press the Go button to open the Settings page.
         Navigate to Accounts and confirm that:\n
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
index ebddf4f..6b9316f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
@@ -105,18 +105,20 @@
 
     private String mTestParent;
 
-    public ManifestTestListAdapter(Context context, String testParent) {
+    public ManifestTestListAdapter(Context context, String testParent, String[] disabledTestArray) {
         super(context);
         mContext = context;
         mTestParent = testParent;
-
-        String[] disabledTestArray = context.getResources().getStringArray(R.array.disabled_tests);
         mDisabledTests = new HashSet<>(disabledTestArray.length);
         for (int i = 0; i < disabledTestArray.length; i++) {
             mDisabledTests.add(disabledTestArray[i]);
         }
     }
 
+    public ManifestTestListAdapter(Context context, String testParent) {
+        this(context, testParent, context.getResources().getStringArray(R.array.disabled_tests));
+    }
+
     @Override
     protected List<TestListItem> getRows() {
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java
index a6489c1..bf3484e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerPowerLevelActivity.java
@@ -59,6 +59,7 @@
         setPassFailButtonClickListeners();
         setInfoResources(R.string.ble_power_level_name,
                          R.string.ble_power_level_info, -1);
+        getPassButton().setEnabled(false);
 
         mTimerText = (TextView)findViewById(R.id.ble_timer);
         mTimer = new CountDownTimer(REFRESH_MAC_TIME, 1000) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java
index 9895f02..56d73aa 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BluetoothTestActivity.java
@@ -20,7 +20,12 @@
 import com.android.cts.verifier.PassFailButtons;
 import com.android.cts.verifier.R;
 
+import android.bluetooth.BluetoothAdapter;
 import android.os.Bundle;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.List;
 
 public class BluetoothTestActivity extends PassFailButtons.TestListActivity {
 
@@ -31,6 +36,32 @@
         setPassFailButtonClickListeners();
         setInfoResources(R.string.bluetooth_test, R.string.bluetooth_test_info, -1);
 
-        setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName()));
+        BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (bluetoothAdapter == null) {
+            Toast.makeText(this, "bluetooth not supported", Toast.LENGTH_SHORT);
+            return;
+        }
+
+        List<String> disabledTestArray = new ArrayList<String>();
+        for (String s : this.getResources().getStringArray(R.array.disabled_tests)) {
+            disabledTestArray.add(s);
+        }
+        if (!this.getPackageManager().hasSystemFeature("android.hardware.bluetooth_le")) {
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleAdvertiserTestActivity");
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleScannerTestActivity");
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleClientTestActivity");
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleServerStartActivity");
+        } else if (!bluetoothAdapter.isMultipleAdvertisementSupported()) {
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleAdvertiserTestActivity");
+            disabledTestArray.add(
+                  "com.android.cts.verifier.bluetooth.BleServerStartActivity");
+        }
+        setTestListAdapter(new ManifestTestListAdapter(this, getClass().getName(),
+                disabledTestArray.toArray(new String[disabledTestArray.size()])));
     }
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
index 12aa37b..057d00d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
@@ -77,6 +77,7 @@
     private TestItem mCrossProfileIntentFiltersTest;
     private TestItem mDisableNonMarketTest;
     private TestItem mEnableNonMarketTest;
+    private TestItem mWorkNotificationBadgedTest;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -170,16 +171,17 @@
          * To keep the image in this test up to date, use the instructions in
          * {@link ByodIconSamplerActivity}.
          */
-        mWorkAppVisibleTest = new TestItem(this, R.string.provisioning_byod_workapps_visible,
+        mWorkAppVisibleTest = new TestItemWithIcon(this,
+                R.string.provisioning_byod_workapps_visible,
                 R.string.provisioning_byod_profile_visible_instruction,
-                new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME)) {
-            @Override
-            public View getCustomView() {
-                LayoutInflater layoutInflater = LayoutInflater.from(getApplicationContext());
-                return layoutInflater.inflate(R.layout.byod_custom_view_badged_icons,
-                        null /* root */);
-            }
-        };
+                new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME),
+                R.drawable.badged_icon);
+
+        mWorkNotificationBadgedTest = new TestItemWithIcon(this,
+                R.string.provisioning_byod_work_notification,
+                R.string.provisioning_byod_work_notification_instruction,
+                new Intent(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION),
+                R.drawable.ic_corp_icon);
 
         mDisableNonMarketTest = new TestItem(this, R.string.provisioning_byod_nonmarket_deny,
                 R.string.provisioning_byod_nonmarket_deny_info,
@@ -202,6 +204,7 @@
         mTests.add(mProfileVisibleTest);
         mTests.add(mDeviceAdminVisibleTest);
         mTests.add(mWorkAppVisibleTest);
+        mTests.add(mWorkNotificationBadgedTest);
         mTests.add(mCrossProfileIntentFiltersTest);
         mTests.add(mDisableNonMarketTest);
         mTests.add(mEnableNonMarketTest);
@@ -222,12 +225,14 @@
                 .setPositiveButton(R.string.pass_button_text, new AlertDialog.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
+                        clearRemainingState(test);
                         setTestResult(test, TestResult.Passed);
                     }
                 })
                 .setNegativeButton(R.string.fail_button_text, new AlertDialog.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
+                        clearRemainingState(test);
                         setTestResult(test, TestResult.Failed);
                     }
                 });
@@ -248,6 +253,14 @@
         });
     }
 
+    private void clearRemainingState(final TestItem test) {
+        if (WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION.equals(
+                test.getManualTestIntent().getAction())) {
+            ByodFlowTestActivity.this.startActivity(new Intent(
+                    WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION));
+        }
+    }
+
     private void setTestResult(TestItem test, TestResult result) {
         test.setPassFailState(result);
 
@@ -306,6 +319,10 @@
                 this, ByodHelperActivity.class),
                 PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                 PackageManager.DONT_KILL_APP);
+        getPackageManager().setComponentEnabledSetting(new ComponentName(
+                this, WorkNotificationTestActivity.class),
+                PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+                PackageManager.DONT_KILL_APP);
     }
 
     private void showToast(int messageId) {
@@ -375,6 +392,29 @@
         }
     }
 
+    static class TestItemWithIcon extends TestItem {
+
+        private int mImageResId;
+        private Context mContext;
+
+        public TestItemWithIcon(Context context, int nameResId, int testInstructionResId,
+                Intent testIntent, int imageResId) {
+            super(context, nameResId, testInstructionResId, testIntent);
+            mContext = context;
+            mImageResId = imageResId;
+        }
+
+        @Override
+        public View getCustomView() {
+            LayoutInflater layoutInflater = LayoutInflater.from(mContext);
+            View view = layoutInflater.inflate(R.layout.byod_custom_view,
+                    null /* root */);
+            ((ImageView) view.findViewById(R.id.sample_icon)).setImageResource(mImageResId);
+            ((TextView) view.findViewById(R.id.message)).setText(getManualTestInstruction());
+            return view;
+        }
+    }
+
     static class TestAdapter extends ArrayAdapter<TestItem> {
 
         public TestAdapter(Context context) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
index 1f78daf..fa7bc4c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
@@ -26,8 +26,6 @@
 import android.util.Log;
 import android.widget.Toast;
 
-import com.android.cts.verifier.managedprovisioning.ByodHelperActivity;
-
 /**
  * Profile owner receiver for BYOD flow test.
  * Setup cross-profile intent filter after successful provisioning.
@@ -52,6 +50,8 @@
             filter.addAction(ByodHelperActivity.ACTION_REMOVE_PROFILE_OWNER);
             filter.addAction(ByodHelperActivity.ACTION_INSTALL_APK);
             filter.addAction(CrossProfileTestActivity.ACTION_CROSS_PROFILE);
+            filter.addAction(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION);
+            filter.addAction(WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION);
             dpm.addCrossProfileIntentFilter(getWho(context), filter,
                     DevicePolicyManager.FLAG_MANAGED_CAN_ACCESS_PARENT);
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/WorkNotificationTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/WorkNotificationTestActivity.java
new file mode 100644
index 0000000..c85ccf5
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/WorkNotificationTestActivity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 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.managedprovisioning;
+
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.os.Bundle;
+
+import com.android.cts.verifier.R;
+
+/**
+ * Test activity used to generate a notification.
+ */
+public class WorkNotificationTestActivity extends Activity {
+    public static final String ACTION_WORK_NOTIFICATION =
+            "com.android.cts.verifier.managedprovisioning.WORK_NOTIFICATION";
+    public static final String ACTION_CLEAR_WORK_NOTIFICATION =
+            "com.android.cts.verifier.managedprovisioning.CLEAR_WORK_NOTIFICATION";
+    private static final int NOTIFICATION_ID = 7;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        final String action = getIntent().getAction();
+        final NotificationManager notificationManager = (NotificationManager)
+                getSystemService(Context.NOTIFICATION_SERVICE);
+        if (ACTION_WORK_NOTIFICATION.equals(action)) {
+            final Notification notification = new Notification.Builder(this)
+                .setSmallIcon(R.drawable.icon)
+                .setContentTitle(getString(R.string.provisioning_byod_work_notification_title))
+                .setVisibility(Notification.VISIBILITY_PUBLIC)
+                .setAutoCancel(true)
+                .build();
+            notificationManager.notify(NOTIFICATION_ID, notification);
+        } else if (ACTION_CLEAR_WORK_NOTIFICATION.equals(action)) {
+            notificationManager.cancel(NOTIFICATION_ID);
+        }
+        finish();
+    }
+}
diff --git a/build/test_executable.mk b/build/test_executable.mk
index e0352ba..02b3e4c 100644
--- a/build/test_executable.mk
+++ b/build/test_executable.mk
@@ -43,3 +43,6 @@
 						-b $(CTS_UNSUPPORTED_ABIS) \
 						-a $(CTS_TARGET_ARCH) \
 						-o $@
+
+# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
+$(my_register_name) : $(cts_executable_xml)
diff --git a/build/test_gtest_package.mk b/build/test_gtest_package.mk
index 6868081..dd1269b 100644
--- a/build/test_gtest_package.mk
+++ b/build/test_gtest_package.mk
@@ -52,3 +52,6 @@
 						-b $(CTS_UNSUPPORTED_ABIS) \
 						-a $(CTS_TARGET_ARCH) \
 						-o $@
+
+# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
+$(my_register_name) : $(cts_package_apk) $(cts_package_xml)
diff --git a/build/test_host_java_library.mk b/build/test_host_java_library.mk
index 8e071e4..8ed5670 100644
--- a/build/test_host_java_library.mk
+++ b/build/test_host_java_library.mk
@@ -42,3 +42,6 @@
 						-b $(CTS_UNSUPPORTED_ABIS) \
 						-a $(CTS_TARGET_ARCH) \
 						-o $@
+
+# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
+$(my_register_name) : $(cts_library_xml)
diff --git a/build/test_package.mk b/build/test_package.mk
index 72972b2..7589787 100644
--- a/build/test_package.mk
+++ b/build/test_package.mk
@@ -64,3 +64,6 @@
 						-b $(CTS_UNSUPPORTED_ABIS) \
 						-a $(CTS_TARGET_ARCH) \
 						-o $@
+
+# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
+$(my_register_name) : $(cts_package_apk) $(cts_package_xml)
diff --git a/build/test_target_java_library.mk b/build/test_target_java_library.mk
index c0d7a2a..04fffb9 100644
--- a/build/test_target_java_library.mk
+++ b/build/test_target_java_library.mk
@@ -44,3 +44,6 @@
 						-a $(CTS_TARGET_ARCH) \
 						-x "runtimeArgs->$(PRIVATE_RUNTIME_ARGS)" \
 						-o $@
+
+# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
+$(my_register_name) : $(cts_library_jar) $(cts_library_xml)
diff --git a/build/test_uiautomator.mk b/build/test_uiautomator.mk
index 085d672..cad6e4f 100644
--- a/build/test_uiautomator.mk
+++ b/build/test_uiautomator.mk
@@ -55,3 +55,6 @@
 						-b $(CTS_UNSUPPORTED_ABIS) \
 						-a $(CTS_TARGET_ARCH) \
 						-o $@
+
+# Have the module name depend on the cts files; so the cts files get generated when you run mm/mmm/mma/mmma.
+$(my_register_name) : $(cts_library_jar) $(cts_library_xml)
diff --git a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java
index caa3e46..90cbed9 100644
--- a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java
+++ b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java
@@ -57,6 +57,9 @@
     private static final String APK_mips64 = "CtsSplitApp_mips64.apk";
     private static final String APK_mips = "CtsSplitApp_mips.apk";
 
+    private static final String APK_DIFF_REVISION = "CtsSplitAppDiffRevision.apk";
+    private static final String APK_DIFF_REVISION_v7 = "CtsSplitAppDiffRevision_v7.apk";
+
     private static final String APK_DIFF_VERSION = "CtsSplitAppDiffVersion.apk";
     private static final String APK_DIFF_VERSION_v7 = "CtsSplitAppDiffVersion_v7.apk";
 
@@ -233,6 +236,30 @@
         new InstallMultiple().inheritFrom(PKG).addApk(APK_DIFF_VERSION_v7).runExpectingFailure();
     }
 
+    public void testDiffRevision() throws Exception {
+        new InstallMultiple().addApk(APK).addApk(APK_DIFF_REVISION_v7).run();
+        runDeviceTests(PKG, ".SplitAppTest", "testRevision0_12");
+    }
+
+    public void testDiffRevisionInheritBase() throws Exception {
+        new InstallMultiple().addApk(APK).addApk(APK_v7).run();
+        runDeviceTests(PKG, ".SplitAppTest", "testRevision0_0");
+        new InstallMultiple().inheritFrom(PKG).addApk(APK_DIFF_REVISION_v7).run();
+        runDeviceTests(PKG, ".SplitAppTest", "testRevision0_12");
+    }
+
+    public void testDiffRevisionInheritSplit() throws Exception {
+        new InstallMultiple().addApk(APK).addApk(APK_v7).run();
+        runDeviceTests(PKG, ".SplitAppTest", "testRevision0_0");
+        new InstallMultiple().inheritFrom(PKG).addApk(APK_DIFF_REVISION).run();
+        runDeviceTests(PKG, ".SplitAppTest", "testRevision12_0");
+    }
+
+    public void testDiffRevisionDowngrade() throws Exception {
+        new InstallMultiple().addApk(APK).addApk(APK_DIFF_REVISION_v7).run();
+        new InstallMultiple().inheritFrom(PKG).addApk(APK_v7).runExpectingFailure();
+    }
+
     public void testFeatureBase() throws Exception {
         new InstallMultiple().addApk(APK).addApk(APK_FEATURE).run();
         runDeviceTests(PKG, ".SplitAppTest", "testFeatureBase");
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
index 8b25f4b..bf89576 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/Android.mk
@@ -30,7 +30,31 @@
 LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
 
 LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
-LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundred --replace-version -c mdpi -c hdpi -c xhdpi -c xxhdpi
+LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundred --replace-version
+
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_PACKAGE)
+
+
+#################################################
+# Define a variant with a different revision code
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsSplitAppDiffRevision
+LOCAL_PACKAGE_SPLITS := v7
+
+LOCAL_MANIFEST_FILE := revision/AndroidManifest.xml
+LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
+LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundredRevisionTwelve --replace-version
 
 LOCAL_PROGUARD_ENABLED := disabled
 LOCAL_DEX_PREOPT := false
@@ -53,7 +77,7 @@
 LOCAL_PACKAGE_SPLITS := v7
 
 LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
-LOCAL_AAPT_FLAGS := --version-code 101 --version-name OneHundredOne --replace-version -c mdpi -c hdpi -c xhdpi -c xxhdpi
+LOCAL_AAPT_FLAGS := --version-code 101 --version-name OneHundredOne --replace-version
 
 LOCAL_PROGUARD_ENABLED := disabled
 LOCAL_DEX_PREOPT := false
@@ -76,7 +100,7 @@
 LOCAL_PACKAGE_SPLITS := v7
 
 LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey2
-LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundred --replace-version -c mdpi -c hdpi -c xhdpi -c xxhdpi
+LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundred --replace-version
 
 LOCAL_PROGUARD_ENABLED := disabled
 LOCAL_DEX_PREOPT := false
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk b/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
index e93f6c3..809a6b8 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/feature/Android.mk
@@ -24,7 +24,7 @@
 LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
 
 LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
-LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundred --replace-version -c mdpi -c hdpi -c xhdpi -c xxhdpi
+LOCAL_AAPT_FLAGS := --version-code 100 --version-name OneHundred --replace-version
 
 LOCAL_MODULE_TAGS := tests
 
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/revision/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/SplitApp/revision/AndroidManifest.xml
new file mode 100644
index 0000000..8e053ba
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/revision/AndroidManifest.xml
@@ -0,0 +1,44 @@
+<?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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+        package="com.android.cts.splitapp"
+        android:revisionCode="12">
+
+    <uses-permission android:name="android.permission.CAMERA" />
+
+    <application android:label="SplitApp">
+        <activity android:name=".MyActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            <meta-data android:name="android.service.wallpaper" android:resource="@xml/my_activity_meta" />
+        </activity>
+        <receiver android:name=".MyReceiver"
+                android:enabled="@bool/my_receiver_enabled">
+            <intent-filter>
+                <action android:name="android.intent.action.DATE_CHANGED" />
+            </intent-filter>
+        </receiver>
+
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:targetPackage="com.android.cts.splitapp" />
+
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java b/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
index 5046458..3d6cee7 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
@@ -21,6 +21,7 @@
 
 import android.content.Intent;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ProviderInfo;
 import android.content.pm.ResolveInfo;
@@ -30,6 +31,7 @@
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
 import android.test.AndroidTestCase;
+import android.test.MoreAsserts;
 import android.util.DisplayMetrics;
 import android.util.Log;
 
@@ -319,6 +321,30 @@
         assertFalse(new File(getContext().getCodeCacheDir(), "cache.raw").exists());
     }
 
+    public void testRevision0_0() throws Exception {
+        final PackageInfo info = getContext().getPackageManager()
+                .getPackageInfo(getContext().getPackageName(), 0);
+        assertEquals(0, info.baseRevisionCode);
+        assertEquals(1, info.splitRevisionCodes.length);
+        assertEquals(0, info.splitRevisionCodes[0]);
+    }
+
+    public void testRevision12_0() throws Exception {
+        final PackageInfo info = getContext().getPackageManager()
+                .getPackageInfo(getContext().getPackageName(), 0);
+        assertEquals(12, info.baseRevisionCode);
+        assertEquals(1, info.splitRevisionCodes.length);
+        assertEquals(0, info.splitRevisionCodes[0]);
+    }
+
+    public void testRevision0_12() throws Exception {
+        final PackageInfo info = getContext().getPackageManager()
+                .getPackageInfo(getContext().getPackageName(), 0);
+        assertEquals(0, info.baseRevisionCode);
+        assertEquals(1, info.splitRevisionCodes.length);
+        assertEquals(12, info.splitRevisionCodes[0]);
+    }
+
     private static void updateDpi(Resources r, int densityDpi) {
         final Configuration c = new Configuration(r.getConfiguration());
         c.densityDpi = densityDpi;
diff --git a/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java b/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
index 33e67e5..ba880d7 100644
--- a/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
+++ b/hostsidetests/theme/src/android/theme/cts/ComparisonTask.java
@@ -37,9 +37,7 @@
 
     private static final int IMAGE_THRESHOLD = 2;
 
-    private static final String STORAGE_PATH_DEVICE = "/storage/emulated/legacy/cts-holo-assets/%s.png";
-
-    private static final String STORAGE_PATH_EMULATOR = "/sdcard/cts-holo-assets/%s.png";
+    private static final String STORAGE_PATH_DEVICE = "/sdcard/cts-holo-assets/%s.png";
 
     private final ITestDevice mDevice;
 
@@ -47,18 +45,10 @@
 
     private final String mName;
 
-    private final String mStoragePath;
-
     public ComparisonTask(ITestDevice device, File reference, String name) {
         mDevice = device;
         mReference = reference;
         mName = name;
-
-        if (mDevice.getSerialNumber().startsWith("emulator-")) {
-            mStoragePath = STORAGE_PATH_EMULATOR;
-        } else {
-            mStoragePath = STORAGE_PATH_DEVICE;
-        }
     }
 
     public Boolean call() {
@@ -67,7 +57,7 @@
         try {
             generated = File.createTempFile("gen_" + mName, ".png");
 
-            final String remoteGenerated = String.format(mStoragePath, mName);
+            final String remoteGenerated = String.format(STORAGE_PATH_DEVICE, mName);
             if (!mDevice.doesFileExist(remoteGenerated)) {
                 Log.logAndDisplay(LogLevel.ERROR, TAG, "File " + remoteGenerated + " have not been saved on device");
                 return false;
@@ -84,7 +74,7 @@
                 Log.logAndDisplay(LogLevel.INFO, TAG, "Diff created: " + diff.getPath());
             }
         } catch (Exception e) {
-            Log.logAndDisplay(LogLevel.ERROR, TAG, String.format(mStoragePath, mName));
+            Log.logAndDisplay(LogLevel.ERROR, TAG, String.format(STORAGE_PATH_DEVICE, mName));
             Log.logAndDisplay(LogLevel.ERROR, TAG, e.toString());
             e.printStackTrace();
         } finally {
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 7532fc8..7c500b9 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -133,35 +133,10 @@
 {
   description: "New tests recently added for Android Enterprise. To be moved out of CTS-staging as soon as they show that they are stable",
   names: [
-    "com.android.cts.devicepolicy.DeviceOwnerTest#testApplicationRestrictions",
-    "com.android.cts.devicepolicy.DeviceOwnerTest#testCaCertManagement",
-    "com.android.cts.devicepolicy.DeviceOwnerTest#testDeviceOwnerSetup",
-    "com.android.cts.devicepolicy.DeviceOwnerTest#testPersistentIntentResolving",
-    "com.android.cts.devicepolicy.DeviceOwnerTest#testScreenCaptureDisabled",
-    "com.android.cts.devicepolicy.ManagedProfileTest#testManagedProfileSetup",
-    "com.android.cts.devicepolicy.ManagedProfileTest#testWipeData",
-    "com.android.cts.devicepolicy.ManagedProfileTest#testCrossProfileIntentFilters",
-    "com.android.cts.devicepolicy.ManagedProfileTest#testCrossProfileContent",
-    "com.android.cts.devicepolicy.ManagedProfileTest#testNoDebuggingFeaturesRestriction",
-    "com.android.cts.devicepolicy.ManagedProfileTest#testCrossProfileCopyPaste",
-    "com.android.cts.devicepolicy.DeviceOwnerTest#testLockTask"
+    "com.android.cts.devicepolicy.ManagedProfileTest#testCrossProfileCopyPaste"
   ]
 },
 {
-
-  description: "These tests fail on some devices.",
-  names: [
-    "android.uirendering.cts.testclasses.ExactCanvasTests#testBlueRect",
-    "android.uirendering.cts.testclasses.ExactCanvasTests#testBluePaddedSquare",
-    "android.uirendering.cts.testclasses.ViewClippingTests#testSimplePaddingClip",
-    "android.uirendering.cts.testclasses.ViewClippingTests#testSimpleClipBoundsClip",
-    "android.uirendering.cts.testclasses.ViewClippingTests#testSimpleOutlineClip",
-    "android.uirendering.cts.testclasses.ViewClippingTests#testSimpleBoundsClip",
-    "android.uirendering.cts.testclasses.InfrastructureTests#testViewInitializer"
-  ],
-  bug: 17511118
-},
-{
   description: "This test failed on devices that use effect off loading. In addition it uses hidden apis",
   names: [
     "android.media.cts.AudioEffectTest#test1_1ConstructorFromUuid"
diff --git a/tests/tests/app/src/android/app/cts/AlarmManagerTest.java b/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
index b9caae9..b85c616 100644
--- a/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
@@ -18,14 +18,17 @@
 
 
 import android.app.AlarmManager;
+import android.app.AlarmManager.AlarmClockInfo;
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.cts.util.PollingCheck;
+import android.os.Build;
 import android.os.SystemClock;
 import android.test.AndroidTestCase;
 import android.util.Log;
+import android.test.MoreAsserts;
 
 public class AlarmManagerTest extends AndroidTestCase {
     public static final String MOCKACTION = "android.app.AlarmManagerTest.TEST_ALARMRECEIVER";
@@ -225,8 +228,8 @@
         mWakeupTime = System.currentTimeMillis() + TEST_ALARM_FUTURITY;
         mAm.setRepeating(AlarmManager.RTC_WAKEUP, mWakeupTime, REPEAT_PERIOD, mSender);
 
-        // wait slightly beyond the initial alarm to verify that it fires the first time
-        new PollingCheck(TEST_ALARM_FUTURITY + TIME_DELTA) {
+        // wait beyond the initial alarm's possible delivery window to verify that it fires the first time
+        new PollingCheck(TEST_ALARM_FUTURITY + REPEAT_PERIOD) {
             @Override
             protected boolean check() {
                 return mMockAlarmReceiver.alarmed;
@@ -236,7 +239,7 @@
 
         // Now reset the receiver and wait for the intended repeat alarm to fire as expected
         mMockAlarmReceiver.setAlarmedFalse();
-        new PollingCheck(REPEAT_PERIOD*2 + TIME_DELTA) {
+        new PollingCheck(REPEAT_PERIOD*2) {
             @Override
             protected boolean check() {
                 return mMockAlarmReceiver.alarmed;
@@ -282,4 +285,66 @@
         // " Unable to open alarm driver: Permission denied". But still fail
         // after tried many permission.
     }
+
+    public void testSetAlarmClock() throws Exception {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            mMockAlarmReceiver.setAlarmedFalse();
+            mMockAlarmReceiver2.setAlarmedFalse();
+
+            // Set first alarm clock.
+            final long wakeupTimeFirst = System.currentTimeMillis()
+                    + 2 * TEST_ALARM_FUTURITY;
+            mAm.setAlarmClock(new AlarmClockInfo(wakeupTimeFirst, null), mSender);
+
+            // Verify getNextAlarmClock returns first alarm clock.
+            AlarmClockInfo nextAlarmClock = mAm.getNextAlarmClock();
+            assertEquals(wakeupTimeFirst, nextAlarmClock.getTriggerTime());
+            assertNull(nextAlarmClock.getShowIntent());
+
+            // Set second alarm clock, earlier than first.
+            final long wakeupTimeSecond = System.currentTimeMillis()
+                    + TEST_ALARM_FUTURITY;
+            PendingIntent showIntentSecond = PendingIntent.getBroadcast(getContext(), 0,
+                    new Intent(getContext(), AlarmManagerTest.class).setAction("SHOW_INTENT"), 0);
+            mAm.setAlarmClock(new AlarmClockInfo(wakeupTimeSecond, showIntentSecond),
+                    mSender2);
+
+            // Verify getNextAlarmClock returns second alarm clock now.
+            nextAlarmClock = mAm.getNextAlarmClock();
+            assertEquals(wakeupTimeSecond, nextAlarmClock.getTriggerTime());
+            assertEquals(showIntentSecond, nextAlarmClock.getShowIntent());
+
+            // Cancel second alarm.
+            mAm.cancel(mSender2);
+
+            // Verify getNextAlarmClock returns first alarm clock again.
+            nextAlarmClock = mAm.getNextAlarmClock();
+            assertEquals(wakeupTimeFirst, nextAlarmClock.getTriggerTime());
+            assertNull(nextAlarmClock.getShowIntent());
+
+            // Wait for first alarm to trigger.
+            assertFalse(mMockAlarmReceiver.alarmed);
+            new PollingCheck(2 * TEST_ALARM_FUTURITY + TIME_DELAY) {
+                @Override
+                protected boolean check() {
+                    return mMockAlarmReceiver.alarmed;
+                }
+            }.run();
+
+            // Verify first alarm fired at the right time.
+            assertEquals(mMockAlarmReceiver.rtcTime, wakeupTimeFirst, TIME_DELTA);
+
+            // Verify second alarm didn't fire.
+            assertFalse(mMockAlarmReceiver2.alarmed);
+
+            // Verify the next alarm is not returning neither the first nor the second alarm.
+            nextAlarmClock = mAm.getNextAlarmClock();
+            MoreAsserts.assertNotEqual(wakeupTimeFirst, nextAlarmClock != null
+                    ? nextAlarmClock.getTriggerTime()
+                    : null);
+            MoreAsserts.assertNotEqual(wakeupTimeSecond, nextAlarmClock != null
+                    ? nextAlarmClock.getTriggerTime()
+                    : null);
+        }
+    }
 }
diff --git a/tests/tests/app/src/android/app/cts/DownloadManagerTest.java b/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
index 84faffa..a68d860 100644
--- a/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
@@ -49,7 +49,7 @@
     private static final int MINIMUM_DOWNLOAD_BYTES = 100 * 1024 * 1024;
 
     private static final long SHORT_TIMEOUT = 5 * DateUtils.SECOND_IN_MILLIS;
-    private static final long LONG_TIMEOUT = 2 * DateUtils.MINUTE_IN_MILLIS;
+    private static final long LONG_TIMEOUT = 3 * DateUtils.MINUTE_IN_MILLIS;
 
     private DownloadManager mDownloadManager;
 
diff --git a/tests/tests/app/src/android/app/cts/InstrumentationTest.java b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
index 0c2e9fa..b21148e 100644
--- a/tests/tests/app/src/android/app/cts/InstrumentationTest.java
+++ b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
@@ -196,10 +196,12 @@
 
     public void testInvokeMenuActionSync() throws Exception {
         final int resId = R.id.goto_menu_id;
-        mInstrumentation.invokeMenuActionSync(mActivity, resId, 0);
-        mInstrumentation.waitForIdleSync();
-
-        assertEquals(resId, mActivity.getMenuID());
+        if (mActivity.getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)) {
+            mInstrumentation.invokeMenuActionSync(mActivity, resId, 0);
+            mInstrumentation.waitForIdleSync();
+    
+            assertEquals(resId, mActivity.getMenuID());
+        }
     }
 
     public void testCallActivityOnPostCreate() throws Throwable {
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
index dd17779..872f951 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
@@ -447,22 +447,26 @@
             assertTrue("rowStride " + rowStride + " should be >= width " + w , rowStride >= w);
             for (int row = 0; row < h; row++) {
                 int bytesPerPixel = ImageFormat.getBitsPerPixel(format) / 8;
+                int length;
                 if (pixelStride == bytesPerPixel) {
                     // Special case: optimized read of the entire row
-                    int length = w * bytesPerPixel;
+                    length = w * bytesPerPixel;
                     buffer.get(data, offset, length);
-                    // Advance buffer the remainder of the row stride
-                    buffer.position(buffer.position() + rowStride - length);
                     offset += length;
                 } else {
                     // Generic case: should work for any pixelStride but slower.
                     // Use intermediate buffer to avoid read byte-by-byte from
                     // DirectByteBuffer, which is very bad for performance
-                    buffer.get(rowData, 0, rowStride);
+                    length = (w - 1) * pixelStride + bytesPerPixel;
+                    buffer.get(rowData, 0, length);
                     for (int col = 0; col < w; col++) {
                         data[offset++] = rowData[col * pixelStride];
                     }
                 }
+                // Advance buffer the remainder of the row stride
+                if (row < h - 1) {
+                    buffer.position(buffer.position() + rowStride - length);
+                }
             }
             if (VERBOSE) Log.v(TAG, "Finished reading data from plane " + i);
             buffer.rewind();
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
index c16c135..d606b70 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
@@ -47,6 +47,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 public class SensorTest extends SensorTestCase {
@@ -329,10 +330,10 @@
         Handler handler = new Handler(handlerThread.getLooper());
         TestSensorEventListener listener = new TestSensorEventListener(environment, handler);
 
-        sensorManager.registerListener(listener);
-        listener.waitForEvents(1);
-        sensorManager.requestFlush();
-        listener.waitForFlushComplete();
+        CountDownLatch eventLatch = sensorManager.registerListener(listener, 1);
+        listener.waitForEvents(eventLatch, 1);
+        CountDownLatch flushLatch = sensorManager.requestFlush();
+        listener.waitForFlushComplete(flushLatch);
         listener.assertEventsReceivedInHandler();
     }
 
@@ -341,26 +342,30 @@
     public void testBatchAndFlushWithMutipleSensors() throws Exception {
         final int maxSensors = 3;
         final int maxReportLatencyUs = (int) TimeUnit.SECONDS.toMicros(10);
-        int sensorsCount = mSensorList.size();
-        int numSensors = sensorsCount < maxSensors ? sensorsCount : maxSensors;
+        List<Sensor> sensorsToTest = new ArrayList<Sensor>();
+        for (Sensor sensor : mSensorList) {
+            if (sensor.getReportingMode() == Sensor.REPORTING_MODE_CONTINUOUS) {
+                sensorsToTest.add(sensor);
+                if (sensorsToTest.size()  == maxSensors) break;
+            }
+        }
+        final int numSensorsToTest = sensorsToTest.size();
+        if (numSensorsToTest == 0) {
+            return;
+        }
 
         StringBuilder builder = new StringBuilder();
         ParallelSensorOperation parallelSensorOperation = new ParallelSensorOperation();
-        for (int i = 0; i < sensorsCount && numSensors > 0; ++i) {
-            Sensor sensor = mSensorList.get(i);
-            // skip all non-continuous sensors
-            if (sensor.getReportingMode() == Sensor.REPORTING_MODE_CONTINUOUS) {
-                TestSensorEnvironment environment = new TestSensorEnvironment(
-                        getContext(),
-                        sensor,
-                        shouldEmulateSensorUnderLoad(),
-                        SensorManager.SENSOR_DELAY_FASTEST,
-                        maxReportLatencyUs);
-                FlushExecutor executor = new FlushExecutor(environment, 500 /* eventCount */);
-                parallelSensorOperation.add(new TestSensorOperation(environment, executor));
-                --numSensors;
-                builder.append(sensor.getName()).append(", ");
-            }
+        for (Sensor sensor : sensorsToTest) {
+            TestSensorEnvironment environment = new TestSensorEnvironment(
+                    getContext(),
+                    sensor,
+                    shouldEmulateSensorUnderLoad(),
+                    SensorManager.SENSOR_DELAY_FASTEST,
+                    maxReportLatencyUs);
+            FlushExecutor executor = new FlushExecutor(environment, 500 /* eventCount */);
+            parallelSensorOperation.add(new TestSensorOperation(environment, executor));
+            builder.append(sensor.getName()).append(", ");
         }
 
         Log.i(TAG, "Testing batch/flush for sensors: " + builder);
@@ -523,12 +528,12 @@
                 throws InterruptedException {
             int sensorReportingMode = mEnvironment.getSensor().getReportingMode();
             try {
-                sensorManager.registerListener(listener);
+                CountDownLatch eventLatch = sensorManager.registerListener(listener, mEventCount);
                 if (sensorReportingMode == Sensor.REPORTING_MODE_CONTINUOUS) {
-                    listener.waitForEvents(mEventCount);
+                    listener.waitForEvents(eventLatch, mEventCount);
                 }
-                sensorManager.requestFlush();
-                listener.waitForFlushComplete();
+                CountDownLatch flushLatch = sensorManager.requestFlush();
+                listener.waitForFlushComplete(flushLatch);
             } finally {
                 sensorManager.unregisterListener();
             }
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java
index a60428f..7b1a499 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorEventListener.java
@@ -106,6 +106,31 @@
     }
 
     /**
+     * @param eventCount
+     * @return A CountDownLatch initialzed with eventCount and decremented as sensor events arrive
+     * for this listerner.
+     */
+    public CountDownLatch getLatchForSensorEvents(int eventCount) {
+        CountDownLatch latch = new CountDownLatch(eventCount);
+        synchronized (mEventLatches) {
+            mEventLatches.add(latch);
+        }
+        return latch;
+    }
+
+    /**
+     * @return A CountDownLatch initialzed with 1 and decremented as a flush complete arrives
+     * for this listerner.
+     */
+    public CountDownLatch getLatchForFlushCompleteEvent() {
+        CountDownLatch latch = new CountDownLatch(1);
+        synchronized (mFlushLatches) {
+            mFlushLatches.add(latch);
+        }
+        return latch;
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -182,13 +207,8 @@
      *
      * @throws AssertionError if there was a timeout after {@link #FLUSH_TIMEOUT_US} &micro;s
      */
-    public void waitForFlushComplete() throws InterruptedException {
+    public void waitForFlushComplete(CountDownLatch latch) throws InterruptedException {
         clearEvents();
-        CountDownLatch latch = new CountDownLatch(1);
-        synchronized (mFlushLatches) {
-            mFlushLatches.add(latch);
-        }
-
         try {
             String message = SensorCtsHelper.formatAssertionMessage(
                     "WaitForFlush",
@@ -208,13 +228,8 @@
      *
      * @throws AssertionError if there was a timeout after {@link #FLUSH_TIMEOUT_US} &micro;s
      */
-    public void waitForEvents(int eventCount) throws InterruptedException {
+    public void waitForEvents(CountDownLatch latch, int eventCount) throws InterruptedException {
         clearEvents();
-        CountDownLatch eventLatch = new CountDownLatch(eventCount);
-        synchronized (mEventLatches) {
-            mEventLatches.add(eventLatch);
-        }
-
         try {
             long samplingPeriodUs = mEnvironment.getMaximumExpectedSamplingPeriodUs();
             // timeout is 2 * event count * expected period + batch timeout + default wait
@@ -224,20 +239,20 @@
             long timeoutUs = (2 * eventCount * samplingPeriodUs)
                     + mEnvironment.getMaxReportLatencyUs()
                     + EVENT_TIMEOUT_US;
-            boolean success = eventLatch.await(timeoutUs, TimeUnit.MICROSECONDS);
+            boolean success = latch.await(timeoutUs, TimeUnit.MICROSECONDS);
             if (!success) {
                 String message = SensorCtsHelper.formatAssertionMessage(
                         "WaitForEvents",
                         mEnvironment,
                         "requested=%d, received=%d, timeout=%dus",
                         eventCount,
-                        eventCount - eventLatch.getCount(),
+                        eventCount - latch.getCount(),
                         timeoutUs);
                 Assert.fail(message);
             }
         } finally {
             synchronized (mEventLatches) {
-                mEventLatches.remove(eventLatch);
+                mEventLatches.remove(latch);
             }
         }
     }
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
index fdd851e..2468bd1 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
@@ -23,6 +23,8 @@
 import android.hardware.SensorManager;
 import android.util.Log;
 
+import java.util.concurrent.CountDownLatch;
+
 /**
  * A test class that performs the actions of {@link SensorManager} on a single sensor.
  * This class allows for a single sensor to be registered and unregistered as well as performing
@@ -85,6 +87,33 @@
     }
 
     /**
+     * Register the listener. This method will perform a no-op if the sensor is already registered.
+     *
+     * @return A CountDownLatch initialized with eventCount which is used to wait for sensor
+     * events.
+     * @throws AssertionError if there was an error registering the listener with the
+     * {@link SensorManager}
+     */
+    public CountDownLatch registerListener(TestSensorEventListener listener, int eventCount) {
+        if (mTestSensorEventListener != null) {
+            Log.w(LOG_TAG, "Listener already registered, returning.");
+            return null;
+        }
+
+        CountDownLatch latch = listener.getLatchForSensorEvents(eventCount);
+        mTestSensorEventListener = listener;
+        String message = SensorCtsHelper.formatAssertionMessage("registerListener", mEnvironment);
+        boolean result = mSensorManager.registerListener(
+                mTestSensorEventListener,
+                mEnvironment.getSensor(),
+                mEnvironment.getRequestedSamplingPeriodUs(),
+                mEnvironment.getMaxReportLatencyUs(),
+                mTestSensorEventListener.getHandler());
+        Assert.assertTrue(message, result);
+        return latch;
+    }
+
+    /**
      * Unregister the listener. This method will perform a no-op if the sensor is not registered.
      */
     public void unregisterListener() {
@@ -101,15 +130,18 @@
      * Call {@link SensorManager#flush(SensorEventListener)}. This method will perform a no-op if
      * the sensor is not registered.
      *
+     * @return A CountDownLatch which can be used to wait for a flush complete event.
      * @throws AssertionError if {@link SensorManager#flush(SensorEventListener)} fails.
      */
-    public void requestFlush() {
+    public CountDownLatch requestFlush() {
         if (mTestSensorEventListener == null) {
             Log.w(LOG_TAG, "No listener registered, returning.");
-            return;
+            return null;
         }
+        CountDownLatch latch = mTestSensorEventListener.getLatchForFlushCompleteEvent();
         Assert.assertTrue(
                 SensorCtsHelper.formatAssertionMessage("Flush", mEnvironment),
                 mSensorManager.flush(mTestSensorEventListener));
+        return latch;
     }
 }
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
index 901216a..3b90b15 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
@@ -41,6 +41,7 @@
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -212,8 +213,8 @@
             public void execute(TestSensorManager sensorManager, TestSensorEventListener listener)
                     throws InterruptedException {
                 try {
-                    sensorManager.registerListener(listener);
-                    listener.waitForEvents(eventCount);
+                    CountDownLatch latch = sensorManager.registerListener(listener, eventCount);
+                    listener.waitForEvents(latch, eventCount);
                 } finally {
                     sensorManager.unregisterListener();
                 }
@@ -267,8 +268,8 @@
                 try {
                     sensorManager.registerListener(listener);
                     SensorCtsHelper.sleep(duration, timeUnit);
-                    sensorManager.requestFlush();
-                    listener.waitForFlushComplete();
+                    CountDownLatch latch = sensorManager.requestFlush();
+                    listener.waitForFlushComplete(latch);
                 } finally {
                     sensorManager.unregisterListener();
                 }
diff --git a/tests/tests/media/src/android/media/cts/ImageReaderDecoderTest.java b/tests/tests/media/src/android/media/cts/ImageReaderDecoderTest.java
index 5f326ee..96150ca 100644
--- a/tests/tests/media/src/android/media/cts/ImageReaderDecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/ImageReaderDecoderTest.java
@@ -62,7 +62,8 @@
     private static final long WAIT_FOR_IMAGE_TIMEOUT_MS = 1000;
     private static final String DEBUG_FILE_NAME_BASE = "/sdcard/";
     private static final int NUM_FRAME_DECODED = 100;
-    private static final int MAX_NUM_IMAGES = 3;
+    // video decoders only support a single outstanding image with the consumer
+    private static final int MAX_NUM_IMAGES = 1;
 
     private Resources mResources;
     private MediaCodec.BufferInfo mBufferInfo = new MediaCodec.BufferInfo();
diff --git a/tests/tests/media/src/android/media/cts/PostProcTestBase.java b/tests/tests/media/src/android/media/cts/PostProcTestBase.java
index c31693e..ef87662 100644
--- a/tests/tests/media/src/android/media/cts/PostProcTestBase.java
+++ b/tests/tests/media/src/android/media/cts/PostProcTestBase.java
@@ -31,6 +31,8 @@
     protected Looper mLooper = null;
     protected final Object mLock = new Object();
     protected int mChangedParameter = -1;
+    protected final static String BUNDLE_VOLUME_EFFECT_UUID =
+            "119341a0-8469-11df-81f9-0002a5d5c51b";
 
     protected boolean hasAudioOutput() {
         return getContext().getPackageManager().hasSystemFeature(
diff --git a/tests/tests/media/src/android/media/cts/PresentationSyncTest.java b/tests/tests/media/src/android/media/cts/PresentationSyncTest.java
index ac86f1e..efa2e0a 100644
--- a/tests/tests/media/src/android/media/cts/PresentationSyncTest.java
+++ b/tests/tests/media/src/android/media/cts/PresentationSyncTest.java
@@ -109,7 +109,20 @@
         CpuWaster cpuWaster = new CpuWaster();
         try {
             cpuWaster.start();
-            runThroughputTest(output, refreshNsec, 0.75f);
+            // Tests with mult < 1.0f are flaky, for two reasons:
+            //
+            // (a) They assume that the GPU can render the test scene in less than mult*refreshNsec.
+            //     It's a simple scene, but CTS/CDD don't currently require being able to do more
+            //     than a full-screen clear in refreshNsec.
+            //
+            // (b) More importantly, it assumes that the only rate-limiting happening is
+            //     backpressure from the buffer queue. If the EGL implementation is doing its own
+            //     rate-limiting (to limit the amount of work queued to the GPU at any time), then
+            //     depending on how that's implemented the buffer queue may not have two frames
+            //     pending very often. So the consumer won't be able to drop many frames, and the
+            //     throughput won't be much better than with mult=1.0.
+            //
+            // runThroughputTest(output, refreshNsec, 0.75f);
             cpuWaster.stop();
             runThroughputTest(output, refreshNsec, 1.0f);
             runThroughputTest(output, refreshNsec, 2.0f);
diff --git a/tests/tests/media/src/android/media/cts/VideoEncoderTest.java b/tests/tests/media/src/android/media/cts/VideoEncoderTest.java
index b275232..c3cf9e9 100644
--- a/tests/tests/media/src/android/media/cts/VideoEncoderTest.java
+++ b/tests/tests/media/src/android/media/cts/VideoEncoderTest.java
@@ -746,7 +746,8 @@
 
         final private Map<Size, Set<Size>> mMinMax;     // extreme sizes
         final private Map<Size, Set<Size>> mNearMinMax; // sizes near extreme
-        final private Set<Size> mArbitrary;             // arbitrary sizes in the middle
+        final private Set<Size> mArbitraryW;            // arbitrary widths in the middle
+        final private Set<Size> mArbitraryH;            // arbitrary heights in the middle
         final private Set<Size> mSizes;                 // all non-specifically tested sizes
 
         final private int xAlign;
@@ -760,7 +761,8 @@
             /* calculate min/max sizes */
             mMinMax = new HashMap<Size, Set<Size>>();
             mNearMinMax = new HashMap<Size, Set<Size>>();
-            mArbitrary = new HashSet<Size>();
+            mArbitraryW = new HashSet<Size>();
+            mArbitraryH = new HashSet<Size>();
             mSizes = new HashSet<Size>();
 
             xAlign = mCaps.getWidthAlignment();
@@ -779,18 +781,28 @@
             // initialize arbitrary sizes
             for (int i = 1; i <= 7; ++i) {
                 int j = ((7 * i) % 11) + 1;
-                int width = alignedPointInRange(i * 0.125, xAlign, mCaps.getSupportedWidths());
-                int height = alignedPointInRange(
-                        j * 0.077, yAlign, mCaps.getSupportedHeightsFor(width));
-                mArbitrary.add(new Size(width, height));
+                int width, height;
+                try {
+                    width = alignedPointInRange(i * 0.125, xAlign, mCaps.getSupportedWidths());
+                    height = alignedPointInRange(
+                            j * 0.077, yAlign, mCaps.getSupportedHeightsFor(width));
+                    mArbitraryW.add(new Size(width, height));
+                } catch (IllegalArgumentException e) {
+                }
 
-                height = alignedPointInRange(i * 0.125, yAlign, mCaps.getSupportedHeights());
-                width = alignedPointInRange(j * 0.077, xAlign, mCaps.getSupportedWidthsFor(height));
-                mArbitrary.add(new Size(width, height));
+                try {
+                    height = alignedPointInRange(i * 0.125, yAlign, mCaps.getSupportedHeights());
+                    width = alignedPointInRange(j * 0.077, xAlign, mCaps.getSupportedWidthsFor(height));
+                    mArbitraryH.add(new Size(width, height));
+                } catch (IllegalArgumentException e) {
+                }
             }
-            mArbitrary.removeAll(mSizes);
-            mSizes.addAll(mArbitrary);
-            if (DEBUG) Log.i(TAG, "arbitrary=" + mArbitrary);
+            mArbitraryW.removeAll(mArbitraryH);
+            mArbitraryW.removeAll(mSizes);
+            mSizes.addAll(mArbitraryW);
+            mArbitraryH.removeAll(mSizes);
+            mSizes.addAll(mArbitraryH);
+            if (DEBUG) Log.i(TAG, "arbitrary=" + mArbitraryW + "/" + mArbitraryH);
         }
 
         private void addExtremeSizesFor(int x, int y) {
@@ -892,9 +904,9 @@
             return !skipped;
         }
 
-        public boolean testArbitrary(boolean flexYUV) {
+        public boolean testArbitrary(boolean flexYUV, boolean widths) {
             boolean skipped = true;
-            for (Size s : mArbitrary) {
+            for (Size s : (widths ? mArbitraryW : mArbitraryH)) {
                 if (test(s.getWidth(), s.getHeight(), false /* optional */, flexYUV)) {
                     skipped = false;
                 }
@@ -990,11 +1002,14 @@
                     || info.getName().toLowerCase().startsWith("omx.google.") != goog) {
                 continue;
             }
+            CodecCapabilities caps = null;
             try {
-                CodecCapabilities caps = info.getCapabilitiesForType(mime);
-                result.add(new Encoder(info.getName(), mime, caps));
+                caps = info.getCapabilitiesForType(mime);
             } catch (IllegalArgumentException e) { // mime is not supported
+                continue;
             }
+            assertNotNull(info.getName() + " capabilties for " + mime + " returned null", caps);
+            result.add(new Encoder(info.getName(), mime, caps));
         }
         return result.toArray(new Encoder[result.size()]);
     }
@@ -1207,31 +1222,57 @@
     public void testOtherVP9FlexNearMaxMax()   { nearmaxmax(otherVP9(),   true /* flex */); }
     public void testOtherVP9SurfNearMaxMax()   { nearmaxmax(otherVP9(),   false /* flex */); }
 
-    public void testGoogH265FlexArbitrary()   { arbitrary(googH265(),   true /* flex */); }
-    public void testGoogH265SurfArbitrary()   { arbitrary(googH265(),   false /* flex */); }
-    public void testGoogH264FlexArbitrary()   { arbitrary(googH264(),   true /* flex */); }
-    public void testGoogH264SurfArbitrary()   { arbitrary(googH264(),   false /* flex */); }
-    public void testGoogH263FlexArbitrary()   { arbitrary(googH263(),   true /* flex */); }
-    public void testGoogH263SurfArbitrary()   { arbitrary(googH263(),   false /* flex */); }
-    public void testGoogMpeg4FlexArbitrary()  { arbitrary(googMpeg4(),  true /* flex */); }
-    public void testGoogMpeg4SurfArbitrary()  { arbitrary(googMpeg4(),  false /* flex */); }
-    public void testGoogVP8FlexArbitrary()    { arbitrary(googVP8(),    true /* flex */); }
-    public void testGoogVP8SurfArbitrary()    { arbitrary(googVP8(),    false /* flex */); }
-    public void testGoogVP9FlexArbitrary()    { arbitrary(googVP9(),    true /* flex */); }
-    public void testGoogVP9SurfArbitrary()    { arbitrary(googVP9(),    false /* flex */); }
+    public void testGoogH265FlexArbitraryW()   { arbitraryw(googH265(),   true /* flex */); }
+    public void testGoogH265SurfArbitraryW()   { arbitraryw(googH265(),   false /* flex */); }
+    public void testGoogH264FlexArbitraryW()   { arbitraryw(googH264(),   true /* flex */); }
+    public void testGoogH264SurfArbitraryW()   { arbitraryw(googH264(),   false /* flex */); }
+    public void testGoogH263FlexArbitraryW()   { arbitraryw(googH263(),   true /* flex */); }
+    public void testGoogH263SurfArbitraryW()   { arbitraryw(googH263(),   false /* flex */); }
+    public void testGoogMpeg4FlexArbitraryW()  { arbitraryw(googMpeg4(),  true /* flex */); }
+    public void testGoogMpeg4SurfArbitraryW()  { arbitraryw(googMpeg4(),  false /* flex */); }
+    public void testGoogVP8FlexArbitraryW()    { arbitraryw(googVP8(),    true /* flex */); }
+    public void testGoogVP8SurfArbitraryW()    { arbitraryw(googVP8(),    false /* flex */); }
+    public void testGoogVP9FlexArbitraryW()    { arbitraryw(googVP9(),    true /* flex */); }
+    public void testGoogVP9SurfArbitraryW()    { arbitraryw(googVP9(),    false /* flex */); }
 
-    public void testOtherH265FlexArbitrary()  { arbitrary(otherH265(),  true /* flex */); }
-    public void testOtherH265SurfArbitrary()  { arbitrary(otherH265(),  false /* flex */); }
-    public void testOtherH264FlexArbitrary()  { arbitrary(otherH264(),  true /* flex */); }
-    public void testOtherH264SurfArbitrary()  { arbitrary(otherH264(),  false /* flex */); }
-    public void testOtherH263FlexArbitrary()  { arbitrary(otherH263(),  true /* flex */); }
-    public void testOtherH263SurfArbitrary()  { arbitrary(otherH263(),  false /* flex */); }
-    public void testOtherMpeg4FlexArbitrary() { arbitrary(otherMpeg4(), true /* flex */); }
-    public void testOtherMpeg4SurfArbitrary() { arbitrary(otherMpeg4(), false /* flex */); }
-    public void testOtherVP8FlexArbitrary()   { arbitrary(otherVP8(),   true /* flex */); }
-    public void testOtherVP8SurfArbitrary()   { arbitrary(otherVP8(),   false /* flex */); }
-    public void testOtherVP9FlexArbitrary()   { arbitrary(otherVP9(),   true /* flex */); }
-    public void testOtherVP9SurfArbitrary()   { arbitrary(otherVP9(),   false /* flex */); }
+    public void testOtherH265FlexArbitraryW()  { arbitraryw(otherH265(),  true /* flex */); }
+    public void testOtherH265SurfArbitraryW()  { arbitraryw(otherH265(),  false /* flex */); }
+    public void testOtherH264FlexArbitraryW()  { arbitraryw(otherH264(),  true /* flex */); }
+    public void testOtherH264SurfArbitraryW()  { arbitraryw(otherH264(),  false /* flex */); }
+    public void testOtherH263FlexArbitraryW()  { arbitraryw(otherH263(),  true /* flex */); }
+    public void testOtherH263SurfArbitraryW()  { arbitraryw(otherH263(),  false /* flex */); }
+    public void testOtherMpeg4FlexArbitraryW() { arbitraryw(otherMpeg4(), true /* flex */); }
+    public void testOtherMpeg4SurfArbitraryW() { arbitraryw(otherMpeg4(), false /* flex */); }
+    public void testOtherVP8FlexArbitraryW()   { arbitraryw(otherVP8(),   true /* flex */); }
+    public void testOtherVP8SurfArbitraryW()   { arbitraryw(otherVP8(),   false /* flex */); }
+    public void testOtherVP9FlexArbitraryW()   { arbitraryw(otherVP9(),   true /* flex */); }
+    public void testOtherVP9SurfArbitraryW()   { arbitraryw(otherVP9(),   false /* flex */); }
+
+    public void testGoogH265FlexArbitraryH()   { arbitraryh(googH265(),   true /* flex */); }
+    public void testGoogH265SurfArbitraryH()   { arbitraryh(googH265(),   false /* flex */); }
+    public void testGoogH264FlexArbitraryH()   { arbitraryh(googH264(),   true /* flex */); }
+    public void testGoogH264SurfArbitraryH()   { arbitraryh(googH264(),   false /* flex */); }
+    public void testGoogH263FlexArbitraryH()   { arbitraryh(googH263(),   true /* flex */); }
+    public void testGoogH263SurfArbitraryH()   { arbitraryh(googH263(),   false /* flex */); }
+    public void testGoogMpeg4FlexArbitraryH()  { arbitraryh(googMpeg4(),  true /* flex */); }
+    public void testGoogMpeg4SurfArbitraryH()  { arbitraryh(googMpeg4(),  false /* flex */); }
+    public void testGoogVP8FlexArbitraryH()    { arbitraryh(googVP8(),    true /* flex */); }
+    public void testGoogVP8SurfArbitraryH()    { arbitraryh(googVP8(),    false /* flex */); }
+    public void testGoogVP9FlexArbitraryH()    { arbitraryh(googVP9(),    true /* flex */); }
+    public void testGoogVP9SurfArbitraryH()    { arbitraryh(googVP9(),    false /* flex */); }
+
+    public void testOtherH265FlexArbitraryH()  { arbitraryh(otherH265(),  true /* flex */); }
+    public void testOtherH265SurfArbitraryH()  { arbitraryh(otherH265(),  false /* flex */); }
+    public void testOtherH264FlexArbitraryH()  { arbitraryh(otherH264(),  true /* flex */); }
+    public void testOtherH264SurfArbitraryH()  { arbitraryh(otherH264(),  false /* flex */); }
+    public void testOtherH263FlexArbitraryH()  { arbitraryh(otherH263(),  true /* flex */); }
+    public void testOtherH263SurfArbitraryH()  { arbitraryh(otherH263(),  false /* flex */); }
+    public void testOtherMpeg4FlexArbitraryH() { arbitraryh(otherMpeg4(), true /* flex */); }
+    public void testOtherMpeg4SurfArbitraryH() { arbitraryh(otherMpeg4(), false /* flex */); }
+    public void testOtherVP8FlexArbitraryH()   { arbitraryh(otherVP8(),   true /* flex */); }
+    public void testOtherVP8SurfArbitraryH()   { arbitraryh(otherVP8(),   false /* flex */); }
+    public void testOtherVP9FlexArbitraryH()   { arbitraryh(otherVP9(),   true /* flex */); }
+    public void testOtherVP9SurfArbitraryH()   { arbitraryh(otherVP9(),   false /* flex */); }
 
     public void testGoogH265FlexQCIF()   { specific(googH265(),   176, 144, true /* flex */); }
     public void testGoogH265SurfQCIF()   { specific(googH265(),   176, 144, false /* flex */); }
@@ -1471,14 +1512,14 @@
         }
     }
 
-    private void arbitrary(Encoder[] encoders, boolean flexYUV) {
+    private void arbitrary(Encoder[] encoders, boolean flexYUV, boolean widths) {
         boolean skipped = true;
         if (encoders.length == 0) {
             MediaUtils.skipTest("no such encoder present");
             return;
         }
         for (Encoder encoder: encoders) {
-            if (encoder.testArbitrary(flexYUV)) {
+            if (encoder.testArbitrary(flexYUV, widths)) {
                 skipped = false;
             }
         }
@@ -1487,6 +1528,14 @@
         }
     }
 
+    private void arbitraryw(Encoder[] encoders, boolean flexYUV) {
+        arbitrary(encoders, flexYUV, true /* widths */);
+    }
+
+    private void arbitraryh(Encoder[] encoders, boolean flexYUV) {
+        arbitrary(encoders, flexYUV, false /* widths */);
+    }
+
     /* test specific size */
     private void specific(Encoder[] encoders, int width, int height, boolean flexYUV) {
         boolean skipped = true;
diff --git a/tests/tests/media/src/android/media/cts/VisualizerTest.java b/tests/tests/media/src/android/media/cts/VisualizerTest.java
index 73e48f2..ea7a13f 100644
--- a/tests/tests/media/src/android/media/cts/VisualizerTest.java
+++ b/tests/tests/media/src/android/media/cts/VisualizerTest.java
@@ -27,6 +27,7 @@
 import android.media.audiofx.Visualizer.MeasurementPeakRms;
 import android.os.Looper;
 import android.test.AndroidTestCase;
+import java.util.UUID;
 import android.util.Log;
 
 public class VisualizerTest extends PostProcTestBase {
@@ -281,6 +282,7 @@
 
     //Test case 4.1: test measurement of peak / RMS
     public void test4_1MeasurePeakRms() throws Exception {
+        AudioEffect vc = null;
         try {
             // this test will play a 1kHz sine wave with peaks at -40dB
             MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.sine1khzm40db);
@@ -289,6 +291,15 @@
             final int MAX_MEASUREMENT_ERROR_MB = 2000;
             assertNotNull("null MediaPlayer", mp);
 
+            // creating a volume controller on output mix ensures that ro.audio.silent mutes
+            // audio after the effects and not before
+            vc = new AudioEffect(
+                    AudioEffect.EFFECT_TYPE_NULL,
+                    UUID.fromString(BUNDLE_VOLUME_EFFECT_UUID),
+                    0,
+                    mp.getAudioSessionId());
+            vc.setEnabled(true);
+
             AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
             assertNotNull("null AudioManager", am);
             int originalVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
@@ -308,7 +319,7 @@
             int currentPosition = mp.getCurrentPosition();
             final int maxTry = 100;
             int tryCount = 0;
-            while (currentPosition < 400 && tryCount < maxTry) {
+            while (currentPosition < 200 && tryCount < maxTry) {
                 Thread.sleep(50);
                 currentPosition = mp.getCurrentPosition();
                 tryCount++;
@@ -333,12 +344,15 @@
         } catch (InterruptedException e) {
             fail("sleep() interrupted");
         } finally {
+            if (vc != null)
+                vc.release();
             releaseVisualizer();
         }
     }
 
     //Test case 4.2: test measurement of peak / RMS in Long MP3
     public void test4_2MeasurePeakRmsLongMP3() throws Exception {
+        AudioEffect vc = null;
         try {
             // this test will play a 1kHz sine wave with peaks at -40dB
             MediaPlayer mp = MediaPlayer.create(getContext(), R.raw.sine1khzs40dblong);
@@ -347,6 +361,15 @@
             final int MAX_MEASUREMENT_ERROR_MB = 2000;
             assertNotNull("null MediaPlayer", mp);
 
+            // creating a volume controller on output mix ensures that ro.audio.silent mutes
+            // audio after the effects and not before
+            vc = new AudioEffect(
+                    AudioEffect.EFFECT_TYPE_NULL,
+                    UUID.fromString(BUNDLE_VOLUME_EFFECT_UUID),
+                    0,
+                    mp.getAudioSessionId());
+            vc.setEnabled(true);
+
             AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
             assertNotNull("null AudioManager", am);
             int originalVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
@@ -390,6 +413,8 @@
         } catch (InterruptedException e) {
             fail("sleep() interrupted");
         } finally {
+            if (vc != null)
+                vc.release();
             releaseVisualizer();
         }
     }
diff --git a/tests/tests/uirendering/res/layout/blue_padded_layout.xml b/tests/tests/uirendering/res/layout/blue_padded_layout.xml
index 68c9cd1..2bfd049 100644
--- a/tests/tests/uirendering/res/layout/blue_padded_layout.xml
+++ b/tests/tests/uirendering/res/layout/blue_padded_layout.xml
@@ -14,16 +14,15 @@
        limitations under the License.
   -->
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:id="@+id/test_root"
-        android:layout_width="200px"
-        android:layout_height="200px"
-        android:clipChildren="false">
+    android:layout_width="@dimen/test_width"
+    android:layout_height="@dimen/test_height"
+    android:clipChildren="false">
     <android.uirendering.cts.testclasses.view.UnclippedBlueView
-            android:id="@+id/child"
-            android:layout_width="100px"
-            android:layout_height="100px"
-            android:paddingLeft="15px"
-            android:paddingTop="16px"
-            android:paddingRight="17px"
-            android:paddingBottom="18px"/>
+        android:id="@+id/child"
+        android:layout_width="80px"
+        android:layout_height="80px"
+        android:paddingLeft="15px"
+        android:paddingTop="16px"
+        android:paddingRight="17px"
+        android:paddingBottom="18px"/>
 </FrameLayout>
diff --git a/tests/tests/uirendering/res/layout/blue_padded_square.xml b/tests/tests/uirendering/res/layout/blue_padded_square.xml
index 71f4b0c..7d867d9 100644
--- a/tests/tests/uirendering/res/layout/blue_padded_square.xml
+++ b/tests/tests/uirendering/res/layout/blue_padded_square.xml
@@ -14,7 +14,6 @@
        limitations under the License.
   -->
 <View xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/test_root"
-    android:layout_width="100px"
-    android:layout_height="100px"
+    android:layout_width="@dimen/test_width"
+    android:layout_height="@dimen/test_height"
     android:background="@drawable/blue_padded_square"/>
diff --git a/tests/tests/uirendering/res/layout/draw_activity_view.xml b/tests/tests/uirendering/res/layout/draw_activity_view.xml
deleted file mode 100644
index 54a72e3..0000000
--- a/tests/tests/uirendering/res/layout/draw_activity_view.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?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.
--->
-
-<android.uirendering.cts.CanvasClientView xmlns:android="http://schemas.android.com/apk/res/android"/>
diff --git a/tests/tests/uirendering/res/layout/simple_rect_layout.xml b/tests/tests/uirendering/res/layout/simple_rect_layout.xml
index b570df8..7d6f928 100644
--- a/tests/tests/uirendering/res/layout/simple_rect_layout.xml
+++ b/tests/tests/uirendering/res/layout/simple_rect_layout.xml
@@ -13,14 +13,12 @@
        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:id="@+id/test_root"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-    <View android:layout_width="100px"
-        android:layout_height="100px"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="@dimen/test_width"
+    android:layout_height="@dimen/test_height">
+    <View android:layout_width="80px"
+        android:layout_height="80px"
+        android:translationX="5px"
+        android:translationY="5px"
         android:background="#00f" />
-
-</LinearLayout>
+</FrameLayout>
diff --git a/tests/tests/uirendering/res/layout/simple_red_layout.xml b/tests/tests/uirendering/res/layout/simple_red_layout.xml
index 2d2d189..2af8db6 100644
--- a/tests/tests/uirendering/res/layout/simple_red_layout.xml
+++ b/tests/tests/uirendering/res/layout/simple_red_layout.xml
@@ -14,7 +14,7 @@
        limitations under the License.
   -->
 <View xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="@dimen/test_width"
+    android:layout_height="@dimen/test_height"
     android:id="@+id/test_root"
-    android:layout_width="180px"
-    android:layout_height="180px"
     android:background="#f00" />
diff --git a/tests/tests/uirendering/res/layout/test_container.xml b/tests/tests/uirendering/res/layout/test_container.xml
new file mode 100644
index 0000000..94a8eab
--- /dev/null
+++ b/tests/tests/uirendering/res/layout/test_container.xml
@@ -0,0 +1,24 @@
+<!-- Copyright (C) 2015 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.
+  -->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/test_container"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <ViewStub
+        android:id="@+id/test_content_stub"
+        android:layout_gravity="center"
+        android:layout_width="@dimen/test_width"
+        android:layout_height="@dimen/test_height"/>
+</FrameLayout>
diff --git a/tests/tests/uirendering/res/layout/test_content_canvasclientview.xml b/tests/tests/uirendering/res/layout/test_content_canvasclientview.xml
new file mode 100644
index 0000000..9f8a139
--- /dev/null
+++ b/tests/tests/uirendering/res/layout/test_content_canvasclientview.xml
@@ -0,0 +1,18 @@
+<!-- Copyright (C) 2015 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.
+  -->
+<android.uirendering.cts.testinfrastructure.CanvasClientView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="@dimen/test_width"
+    android:layout_height="@dimen/test_height"/>
\ No newline at end of file
diff --git a/tests/tests/uirendering/res/layout/test_content_webview.xml b/tests/tests/uirendering/res/layout/test_content_webview.xml
new file mode 100644
index 0000000..8b03cab
--- /dev/null
+++ b/tests/tests/uirendering/res/layout/test_content_webview.xml
@@ -0,0 +1,18 @@
+<!-- Copyright (C) 2015 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.
+  -->
+<WebView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="@dimen/test_width"
+    android:layout_height="@dimen/test_height"/>
\ No newline at end of file
diff --git a/tests/tests/uirendering/res/values/dimens.xml b/tests/tests/uirendering/res/values/dimens.xml
new file mode 100644
index 0000000..1c304d3
--- /dev/null
+++ b/tests/tests/uirendering/res/values/dimens.xml
@@ -0,0 +1,18 @@
+<!-- Copyright (C) 2015 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.
+  -->
+<resources>
+    <dimen name="test_width">90px</dimen>
+    <dimen name="test_height">90px</dimen>
+</resources>
diff --git a/tests/tests/uirendering/res/values/themes.xml b/tests/tests/uirendering/res/values/themes.xml
index 751b7cb..f08f029 100644
--- a/tests/tests/uirendering/res/values/themes.xml
+++ b/tests/tests/uirendering/res/values/themes.xml
@@ -17,9 +17,9 @@
     <style name="WhiteBackgroundTheme" parent="@android:style/Theme.Holo.NoActionBar.Fullscreen">
         <item name="android:windowNoTitle">true</item>
         <item name="android:windowFullscreen">true</item>
+        <item name="android:windowOverscan">true</item>
         <item name="android:fadingEdge">none</item>
         <item name="android:windowBackground">@android:color/white</item>
-        <!--This shouldn't be necessary currently a hack for an existing bug with transitions-->
         <item name="android:windowContentTransitions">false</item>
         <item name="android:windowAnimationStyle">@null</item>
     </style>
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/ColorVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/ColorVerifier.java
index ea836ea..7f62b3e 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/ColorVerifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/ColorVerifier.java
@@ -22,11 +22,16 @@
     private int mColor;
 
     public ColorVerifier(int color) {
-        this(color, 20);
+        this(color, DEFAULT_THRESHOLD);
     }
 
-    public ColorVerifier(int color, int threshold) {
-        super(threshold);
+    public ColorVerifier(int color, int colorTolerance) {
+        super(colorTolerance);
+        mColor = color;
+    }
+
+    public ColorVerifier(int color, int colorThreshold, float spatialTolerance) {
+        super(colorThreshold, spatialTolerance);
         mColor = color;
     }
 
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java
index 672b3f6..d4a63de 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/GoldenImageVerifier.java
@@ -18,6 +18,7 @@
 import android.graphics.Bitmap;
 import android.uirendering.cts.bitmapcomparers.BitmapComparer;
 import android.uirendering.cts.differencevisualizers.PassFailVisualizer;
+import android.uirendering.cts.testinfrastructure.ActivityTestBase;
 
 public class GoldenImageVerifier extends BitmapVerifier {
     private BitmapComparer mBitmapComparer;
@@ -26,7 +27,7 @@
     public GoldenImageVerifier(Bitmap goldenBitmap, BitmapComparer bitmapComparer) {
         mGoldenBitmapArray = new int[goldenBitmap.getWidth() * goldenBitmap.getHeight()];
         goldenBitmap.getPixels(mGoldenBitmapArray, 0, goldenBitmap.getWidth(), 0, 0,
-                goldenBitmap.getWidth(), goldenBitmap.getHeight());
+                ActivityTestBase.TEST_WIDTH, ActivityTestBase.TEST_HEIGHT);
         mBitmapComparer = bitmapComparer;
     }
 
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/PerPixelBitmapVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/PerPixelBitmapVerifier.java
index 0bdcc9b..2d00db5 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/PerPixelBitmapVerifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/PerPixelBitmapVerifier.java
@@ -26,38 +26,54 @@
  */
 public abstract class PerPixelBitmapVerifier extends BitmapVerifier {
     private static final String TAG = "PerPixelBitmapVerifer";
-    private int mTolerance;
+    public static final int DEFAULT_THRESHOLD = 48;
 
-    public PerPixelBitmapVerifier(int tolerance) {
-        mTolerance = tolerance;
+    // total color difference tolerated without the pixel failing
+    private int mColorTolerance;
+
+    // portion of bitmap allowed to fail pixel check
+    private float mSpatialTolerance;
+
+    public PerPixelBitmapVerifier() {
+        this(DEFAULT_THRESHOLD, 0);
+    }
+
+    public PerPixelBitmapVerifier(int colorTolerance) {
+        this(colorTolerance, 0);
+    }
+
+    public PerPixelBitmapVerifier(int colorTolerance, float spatialTolerance) {
+        mColorTolerance = colorTolerance;
+        mSpatialTolerance = spatialTolerance;
     }
 
     protected int getExpectedColor(int x, int y) {
         return Color.WHITE;
     }
 
-
     public boolean verify(int[] bitmap, int offset, int stride, int width, int height) {
-        int failCount = 0;
+        int failures = 0;
         int[] differenceMap = new int[bitmap.length];
         for (int y = 0 ; y < height ; y++) {
             for (int x = 0 ; x < width ; x++) {
                 int index = indexFromXAndY(x, y, stride, offset);
-                int expectedColor = getExpectedColor(x, y);
-                if (!verifyPixel(bitmap[index], expectedColor)) {
-                    if (failCount < 50) {
-                        Log.d(TAG, "Expected : " + Integer.toHexString(expectedColor)
+                if (!verifyPixel(x, y, bitmap[index])) {
+                    if (failures < 50) {
+                        Log.d(TAG, "Expected : " + Integer.toHexString(getExpectedColor(x, y))
                                 + " received : " + Integer.toHexString(bitmap[index])
                                 + " at position (" + x + "," + y + ")");
                     }
-                    failCount++;
+                    failures++;
                     differenceMap[index] = FAIL_COLOR;
                 } else {
                     differenceMap[index] = PASS_COLOR;
                 }
             }
         }
-        boolean success = failCount == 0;
+        int toleratedFailures = (int) (mSpatialTolerance * width * height);
+        boolean success = failures <= toleratedFailures;
+        Log.d(TAG, failures + " failures observed out of "
+                + toleratedFailures + " tolerated failures");
         if (!success) {
             mDifferenceBitmap = Bitmap.createBitmap(ActivityTestBase.TEST_WIDTH,
                     ActivityTestBase.TEST_HEIGHT, Bitmap.Config.ARGB_8888);
@@ -67,7 +83,9 @@
         return success;
     }
 
-    protected boolean verifyPixel(int color, int expectedColor) {
-        return CompareUtils.verifyPixelWithThreshold(color, expectedColor, mTolerance);
+
+    protected boolean verifyPixel(int x, int y, int observedColor) {
+        int expectedColor = getExpectedColor(x, y);
+        return CompareUtils.verifyPixelWithThreshold(observedColor, expectedColor, mColorTolerance);
     }
 }
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/RectVerifier.java b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/RectVerifier.java
index 06a430b..f4bece1 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/RectVerifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/bitmapverifiers/RectVerifier.java
@@ -26,7 +26,7 @@
     private Rect mInnerRect;
 
     public RectVerifier(int outerColor, int innerColor, Rect innerRect) {
-        this(outerColor, innerColor, innerRect, 20);
+        this(outerColor, innerColor, innerRect, DEFAULT_THRESHOLD);
     }
 
     public RectVerifier(int outerColor, int innerColor, Rect innerRect, int tolerance) {
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapFilterTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapFilterTests.java
index ddae100..117fe17 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapFilterTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/BitmapFilterTests.java
@@ -28,7 +28,6 @@
 import android.uirendering.cts.testinfrastructure.CanvasClient;
 
 public class BitmapFilterTests extends ActivityTestBase {
-    private static final int THRESHOLD = 20;
     private static final int WHITE_WEIGHT = 255 * 3;
     private enum FilterEnum {
         // Creates Paint object that will have bitmap filtering
@@ -40,72 +39,74 @@
         ADD_FILTER
     }
 
-    /**
-     * Verifies that a Bitmap only contains white and black, within a certain threshold
-     */
-    private static BitmapVerifier mBlackWhiteVerifier = new PerPixelBitmapVerifier(THRESHOLD) {
+    private static final BitmapVerifier BLACK_WHITE_ONLY_VERIFIER
+            = new PerPixelBitmapVerifier(PerPixelBitmapVerifier.DEFAULT_THRESHOLD, 0.99f) {
         @Override
-        protected boolean verifyPixel(int color, int expectedColor) {
+        protected boolean verifyPixel(int x, int y, int color) {
             int weight = Color.red(color) + Color.blue(color) + Color.green(color);
-            return weight < THRESHOLD // is approx Color.BLACK
-                    || weight > WHITE_WEIGHT - THRESHOLD; // is approx Color.WHITE
+            return weight < DEFAULT_THRESHOLD // is approx Color.BLACK
+                    || weight > WHITE_WEIGHT - DEFAULT_THRESHOLD; // is approx Color.WHITE
         }
     };
+    private static final BitmapVerifier GREY_ONLY_VERIFIER
+            = new ColorVerifier(Color.argb(255, 127, 127, 127),
+            PerPixelBitmapVerifier.DEFAULT_THRESHOLD);
+    private static final BitmapVerifier GREY_PARTIAL_VERIFIER
+            = new ColorVerifier(Color.argb(255, 127, 127, 127),
+            300, 0.8f); // content will be mostly grey, for a wide range of grey
+
 
     private static Bitmap createGridBitmap(int width, int height) {
         Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
         for (int i = 0 ; i < width ; i++) {
             for (int j = 0 ; j < height ; j++) {
-                bitmap.setPixel(i, j, ((i + j * width)) % 2 == 0 ?
-                        Color.WHITE : Color.BLACK);
+                boolean isWhite = (i + j * width) % 2 == 0;
+                bitmap.setPixel(i, j, isWhite ? Color.WHITE : Color.BLACK);
             }
         }
         return bitmap;
     }
 
     private static final int SMALL_GRID_SIZE = 5;
-    private static Bitmap mSmallGridBitmap = createGridBitmap(SMALL_GRID_SIZE, SMALL_GRID_SIZE);
+    private Bitmap mSmallGridBitmap = createGridBitmap(SMALL_GRID_SIZE, SMALL_GRID_SIZE);
     private static final int BIG_GRID_SIZE = 360;
-    private static Bitmap mBigGridBitmap = createGridBitmap(BIG_GRID_SIZE, BIG_GRID_SIZE);
-    private static final int HALFWAY_COLOR = Color.argb(255, 127, 127, 127);
+    private Bitmap mBigGridBitmap = createGridBitmap(BIG_GRID_SIZE, BIG_GRID_SIZE);
 
-    /* All of these tests seem to be broken.
-     * TODO: fix in L MR1
     @SmallTest
     public void testPaintFilterScaleUp() {
-        runScaleTest(FilterEnum.PAINT_FILTER, true, mBlackWhiteVerifier);
+        runScaleTest(FilterEnum.PAINT_FILTER, true);
     }
 
     @SmallTest
     public void testPaintFilterScaleDown() {
-        runScaleTest(FilterEnum.PAINT_FILTER, false, new ColorVerifier(HALFWAY_COLOR, 15));
+        runScaleTest(FilterEnum.PAINT_FILTER, false);
     }
 
     @SmallTest
     public void testDrawFilterRemoveFilterScaleUp() {
-        runScaleTest(FilterEnum.REMOVE_FILTER, true, mBlackWhiteVerifier);
+        runScaleTest(FilterEnum.REMOVE_FILTER, true);
     }
 
     @SmallTest
     public void testDrawFilterRemoveFilterScaleDown() {
-        runScaleTest(FilterEnum.REMOVE_FILTER, false, mBlackWhiteVerifier);
+        runScaleTest(FilterEnum.REMOVE_FILTER, false);
     }
 
     @SmallTest
     public void testDrawFilterScaleUp() {
-        runScaleTest(FilterEnum.ADD_FILTER, true, mBlackWhiteVerifier);
+        runScaleTest(FilterEnum.ADD_FILTER, true);
     }
 
     @SmallTest
     public void testDrawFilterScaleDown() {
-        runScaleTest(FilterEnum.ADD_FILTER, false, new ColorVerifier(HALFWAY_COLOR));
+        runScaleTest(FilterEnum.ADD_FILTER, false);
     }
-*/
-    private void runScaleTest(final FilterEnum filterEnum, final boolean scaleUp,
-            BitmapVerifier bitmapVerifier) {
+
+    private void runScaleTest(final FilterEnum filterEnum, final boolean scaleUp) {
         final int gridWidth = scaleUp ? SMALL_GRID_SIZE : BIG_GRID_SIZE;
         final Paint paint = new Paint(filterEnum.equals(FilterEnum.ADD_FILTER) ?
                 0 : Paint.FILTER_BITMAP_FLAG);
+
         CanvasClient canvasClient = new CanvasClient() {
             @Override
             public void draw(Canvas canvas, int width, int height) {
@@ -120,6 +121,16 @@
         };
         createTest()
                 .addCanvasClient(canvasClient)
-                .runWithVerifier(bitmapVerifier);
+                .runWithVerifier(getVerifierForTest(filterEnum, scaleUp));
+    }
+
+    private static BitmapVerifier getVerifierForTest(FilterEnum filterEnum, boolean scaleUp) {
+        if (filterEnum.equals(FilterEnum.REMOVE_FILTER)) {
+            // filtering disabled, so only black and white pixels will come through
+            return BLACK_WHITE_ONLY_VERIFIER;
+        }
+        // if scaling up, output pixels may have single source to sample from,
+        // will only be *mostly* grey.
+        return scaleUp ? GREY_PARTIAL_VERIFIER : GREY_ONLY_VERIFIER;
     }
 }
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java
index afbad65..29755d8 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ExactCanvasTests.java
@@ -36,7 +36,7 @@
 
     @SmallTest
     public void testBlueRect() {
-        final Rect rect = new Rect(10, 10, 100, 100);
+        final Rect rect = new Rect(10, 10, 80, 80);
         createTest()
                 .addCanvasClient(new CanvasClient() {
                     @Override
@@ -58,8 +58,6 @@
                     public void draw(Canvas canvas, int width, int height) {
                         Paint p = new Paint();
                         p.setAntiAlias(false);
-                        p.setColor(Color.WHITE);
-                        canvas.drawRect(0, 0, 100, 100, p);
                         p.setStrokeWidth(1f);
                         p.setColor(Color.BLACK);
                         for (int i = 0; i < 10; i++) {
@@ -81,8 +79,8 @@
                         canvas.drawRect(0, 0, ActivityTestBase.TEST_WIDTH,
                                 ActivityTestBase.TEST_HEIGHT, p);
                         p.setColor(Color.BLACK);
-                        p.setStrokeWidth(10);
-                        canvas.drawRect(10, 10, 20, 20, p);
+                        p.setStrokeWidth(5);
+                        canvas.drawRect(10, 10, 80, 80, p);
                     }
                 })
                 .runWithComparer(mExactComparer);
@@ -94,10 +92,8 @@
                 .addCanvasClient(new CanvasClient() {
                     @Override
                     public void draw(Canvas canvas, int width, int height) {
+                        canvas.drawColor(Color.GREEN);
                         Paint p = new Paint();
-                        p.setColor(Color.GREEN);
-                        canvas.drawRect(0, 0, ActivityTestBase.TEST_WIDTH,
-                                ActivityTestBase.TEST_HEIGHT, p);
                         p.setColor(Color.BLACK);
                         p.setStrokeWidth(10);
                         canvas.drawLine(0, 0, 50, 0, p);
@@ -131,7 +127,7 @@
                         canvas.drawColor(Color.WHITE);
                         p.setColor(Color.BLACK);
                         float[] pts = {
-                                0, 0, 100, 100, 100, 0, 0, 100, 50, 50, 75, 75
+                                0, 0, 80, 80, 80, 0, 0, 80, 40, 50, 60, 50
                         };
                         canvas.drawLines(pts, p);
                     }
@@ -185,10 +181,10 @@
     public void testBluePaddedSquare() {
         final NinePatchDrawable ninePatchDrawable = (NinePatchDrawable)
             getActivity().getResources().getDrawable(R.drawable.blue_padded_square);
-        ninePatchDrawable.setBounds(0, 0, 100, 100);
+        ninePatchDrawable.setBounds(0, 0, 90, 90);
 
         BitmapVerifier verifier = new RectVerifier(Color.WHITE, Color.BLUE,
-                new Rect(10, 10, 90, 90));
+                new Rect(10, 10, 80, 80));
 
         createTest()
                 .addCanvasClient(new CanvasClient() {
@@ -197,7 +193,7 @@
                         canvas.drawColor(Color.WHITE);
                         Paint p = new Paint();
                         p.setColor(Color.BLUE);
-                        canvas.drawRect(10, 10, 90, 90, p);
+                        canvas.drawRect(10, 10, 80, 80, p);
                     }
                 })
                 .addCanvasClient(new CanvasClient() {
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/InfrastructureTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/InfrastructureTests.java
index 6662226..c17e106 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/InfrastructureTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/InfrastructureTests.java
@@ -17,7 +17,6 @@
 
 import com.android.cts.uirendering.R;
 
-import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Rect;
@@ -29,7 +28,6 @@
 import android.uirendering.cts.testinfrastructure.ActivityTestBase;
 import android.uirendering.cts.testinfrastructure.CanvasClient;
 import android.uirendering.cts.testinfrastructure.ViewInitializer;
-import android.util.Log;
 import android.view.View;
 
 public class InfrastructureTests extends ActivityTestBase {
@@ -52,16 +50,17 @@
         CanvasClient canvasClient = new CanvasClient() {
             @Override
             public void draw(Canvas canvas, int width, int height) {
-                canvas.drawColor(canvas.isHardwareAccelerated() ? Color.WHITE : Color.BLACK);
+                canvas.drawColor(canvas.isHardwareAccelerated() ? Color.BLACK : Color.WHITE);
             }
         };
-        // This is considered a very high threshold and as such, the test should still fail because
-        // they are completely different images.
-        final float threshold = 0.1f;
         BitmapComparer inverseComparer = new BitmapComparer() {
             @Override
             public boolean verifySame(int[] ideal, int[] given, int offset, int stride, int width,
                     int height) {
+
+                // Return true if the images aren't even 10% similar. They should be completely
+                // different, since they should both be completely different colors.
+                final float threshold = 0.1f;
                 return !(new MSSIMComparer(threshold)).verifySame(ideal, given, offset, stride,
                         width, height);
             }
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/LayoutTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/LayoutTests.java
index 4667ee9..ff1e9db 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/LayoutTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/LayoutTests.java
@@ -34,7 +34,7 @@
     @SmallTest
     public void testSimpleRectLayout() {
         createTest().addLayout(R.layout.simple_rect_layout, null, false).runWithVerifier(
-                new RectVerifier(Color.WHITE, Color.BLUE, new Rect(0, 0, 100, 100)));
+                new RectVerifier(Color.WHITE, Color.BLUE, new Rect(5, 5, 85, 85)));
     }
 }
 
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java
index 8df8057..6911cf0 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/PathClippingTests.java
@@ -17,7 +17,7 @@
 import com.android.cts.uirendering.R;
 
 public class PathClippingTests extends ActivityTestBase {
-    // draw circle with whole in it, with stroked circle
+    // draw circle with hole in it, with stroked circle
     static final CanvasClient sCircleDrawCanvasClient = new CanvasClient() {
         @Override
         public String getDebugString() {
@@ -31,11 +31,11 @@
             paint.setColor(Color.BLUE);
             paint.setStyle(Paint.Style.STROKE);
             paint.setStrokeWidth(20);
-            canvas.drawCircle(50, 50, 40, paint);
+            canvas.drawCircle(30, 30, 40, paint);
         }
     };
 
-    // draw circle with whole in it, by path operations + path clipping
+    // draw circle with hole in it, by path operations + path clipping
     static final CanvasClient sCircleClipCanvasClient = new CanvasClient() {
         @Override
         public String getDebugString() {
@@ -47,8 +47,8 @@
             canvas.save();
 
             Path path = new Path();
-            path.addCircle(50, 50, 50, Path.Direction.CW);
-            path.addCircle(50, 50, 30, Path.Direction.CCW);
+            path.addCircle(30, 30, 50, Path.Direction.CW);
+            path.addCircle(30, 30, 30, Path.Direction.CCW);
 
             canvas.clipPath(path);
             canvas.drawColor(Color.BLUE);
@@ -72,12 +72,12 @@
                 .runWithVerifier(new SamplePointVerifier(
                         new Point[] {
                                 // inside of circle
-                                new Point(50, 50),
+                                new Point(30, 50),
                                 // on circle
-                                new Point(50 + 32, 50 + 32),
+                                new Point(30 + 32, 30 + 32),
                                 // outside of circle
-                                new Point(50 + 38, 50 + 38),
-                                new Point(100, 100)
+                                new Point(30 + 38, 30 + 38),
+                                new Point(80, 80)
                         },
                         new int[] {
                                 Color.WHITE,
@@ -96,8 +96,8 @@
                         ViewGroup rootView = (ViewGroup) view;
                         rootView.setClipChildren(true);
                         View childView = rootView.getChildAt(0);
-                        childView.setPivotX(50);
-                        childView.setPivotY(50);
+                        childView.setPivotX(40);
+                        childView.setPivotY(40);
                         childView.setRotation(45f);
 
                     }
@@ -105,11 +105,11 @@
                 .runWithVerifier(new SamplePointVerifier(
                         new Point[] {
                                 // inside of rotated rect
-                                new Point(50, 50),
-                                new Point(50 + 32, 50 + 32),
+                                new Point(40, 40),
+                                new Point(40 + 25, 40 + 25),
                                 // outside of rotated rect
-                                new Point(50 + 38, 50 + 38),
-                                new Point(100, 100)
+                                new Point(40 + 31, 40 + 31),
+                                new Point(80, 80)
                         },
                         new int[] {
                                 Color.BLUE,
@@ -128,15 +128,15 @@
                         canvas.save();
 
                         Path path = new Path();
-                        path.addCircle(0, 50, 50, Path.Direction.CW);
-                        path.addCircle(100, 50, 50, Path.Direction.CW);
+                        path.addCircle(0, 45, 45, Path.Direction.CW);
+                        path.addCircle(90, 45, 45, Path.Direction.CW);
                         canvas.clipPath(path);
 
                         Paint paint = new Paint();
                         paint.setAntiAlias(true);
-                        paint.setTextSize(100);
+                        paint.setTextSize(90);
                         paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
-                        canvas.drawText("STRING", 0, 100, paint);
+                        canvas.drawText("STRING", 0, 90, paint);
 
                         canvas.restore();
                     }
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java
index 7947286..32ab0e4 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SweepTests.java
@@ -22,6 +22,7 @@
 import android.graphics.Paint;
 import android.graphics.Point;
 import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.graphics.Shader;
@@ -50,17 +51,11 @@
     public static final int MULTIPLY_COLOR = 0xFF668844;
     public static final int SCREEN_COLOR = 0xFFFFEEFF;
 
-    public static final int FILTER_COLOR = 0xFFBB0000;
-    public static final int RECT0_COLOR = 0x33808080;
-    public static final int RECT1_COLOR = 0x66808080;
-    public static final int RECT2_COLOR = 0x99808080;
-    public static final int RECT3_COLOR = 0xCC808080;
-
     // These points are in pairs, the first being the lower left corner, the second is only in the
     // Destination bitmap, the third is the intersection of the two bitmaps, and the fourth is in
     // the Source bitmap.
     private final static Point[] XFERMODE_TEST_POINTS = new Point[] {
-            new Point(1, 160), new Point(50, 50), new Point(70, 70), new Point(140, 140)
+            new Point(1, 80), new Point(25, 25), new Point(35, 35), new Point(70, 70)
     };
 
     /**
@@ -128,8 +123,8 @@
     };
 
     private final static DisplayModifier XFERMODE_MODIFIER = new DisplayModifier() {
-        private final RectF mSrcRect = new RectF(60, 60, 160, 160);
-        private final RectF mDstRect = new RectF(20, 20, 120, 120);
+        private final RectF mSrcRect = new RectF(30, 30, 80, 80);
+        private final RectF mDstRect = new RectF(10, 10, 60, 60);
         private final Bitmap mSrcBitmap = createSrc();
         private final Bitmap mDstBitmap = createDst();
 
@@ -144,8 +139,7 @@
         }
 
         private Bitmap createSrc() {
-            Bitmap srcB = Bitmap.createBitmap(MODIFIER_WIDTH, MODIFIER_HEIGHT,
-                    Bitmap.Config.ARGB_8888);
+            Bitmap srcB = Bitmap.createBitmap(TEST_WIDTH, TEST_HEIGHT, Bitmap.Config.ARGB_8888);
             Canvas srcCanvas = new Canvas(srcB);
             Paint srcPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
             srcPaint.setColor(SRC_COLOR);
@@ -154,8 +148,7 @@
         }
 
         private Bitmap createDst() {
-            Bitmap dstB = Bitmap.createBitmap(MODIFIER_WIDTH, MODIFIER_HEIGHT,
-                    Bitmap.Config.ARGB_8888);
+            Bitmap dstB = Bitmap.createBitmap(TEST_WIDTH, TEST_HEIGHT, Bitmap.Config.ARGB_8888);
             Canvas dstCanvas = new Canvas(dstB);
             Paint dstPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
             dstPaint.setColor(DST_COLOR);
@@ -164,18 +157,22 @@
         }
     };
 
-
     // We care about one point in each of the four rectangles of different alpha values, as well as
     // the area outside the rectangles
     private final static Point[] COLOR_FILTER_ALPHA_POINTS = new Point[] {
-            new Point(15, 90), new Point(45, 90), new Point(75, 90), new Point(105, 90),
-            new Point(135, 90)
+            new Point(9, 45),
+            new Point(27, 45),
+            new Point(45, 45),
+            new Point(63, 45),
+            new Point(81, 45)
     };
 
-    private final Map<PorterDuff.Mode, int[]> COLOR_FILTER_ALPHA_MAP = new LinkedHashMap<PorterDuff.Mode, int[]>() {
+    public static final int FILTER_COLOR = 0xFFBB0000;
+    private final Map<PorterDuff.Mode, int[]> COLOR_FILTER_ALPHA_MAP
+            = new LinkedHashMap<PorterDuff.Mode, int[]>() {
         {
             put(PorterDuff.Mode.SRC, new int[] {
-                FILTER_COLOR, FILTER_COLOR, FILTER_COLOR, FILTER_COLOR, FILTER_COLOR
+                    FILTER_COLOR, FILTER_COLOR, FILTER_COLOR, FILTER_COLOR, FILTER_COLOR
             });
 
             put(PorterDuff.Mode.DST, new int[] {
@@ -228,10 +225,17 @@
         }
     };
 
+    /**
+     * Draws 5 blocks of different color/opacity to be blended against
+     */
     private final static DisplayModifier COLOR_FILTER_ALPHA_MODIFIER = new DisplayModifier() {
-        private final static int mBlockWidths = 30;
-        private final int[] mColorValues = new int[] {RECT0_COLOR, RECT1_COLOR, RECT2_COLOR,
-                RECT3_COLOR};
+        private final int[] BLOCK_COLORS = new int[] {
+                0x33808080,
+                0x66808080,
+                0x99808080,
+                0xCC808080,
+                0x00000000
+        };
 
         private final Bitmap mBitmap = createQuadRectBitmap();
 
@@ -240,13 +244,15 @@
         }
 
         private Bitmap createQuadRectBitmap() {
-            Bitmap bitmap = Bitmap.createBitmap(MODIFIER_WIDTH, MODIFIER_HEIGHT,
-                    Bitmap.Config.ARGB_8888);
+            Bitmap bitmap = Bitmap.createBitmap(TEST_WIDTH, TEST_HEIGHT, Bitmap.Config.ARGB_8888);
             Canvas canvas = new Canvas(bitmap);
             Paint paint = new Paint();
-            for (int i = 0 ; i < 4 ; i++) {
-                paint.setColor(mColorValues[i]);
-                canvas.drawRect(i * mBlockWidths, 0, (i + 1) * mBlockWidths, MODIFIER_HEIGHT, paint);
+            paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
+            final int blockCount = BLOCK_COLORS.length;
+            final int blockWidth = TEST_WIDTH / blockCount;
+            for (int i = 0 ; i < blockCount; i++) {
+                paint.setColor(BLOCK_COLORS[i]);
+                canvas.drawRect(i * blockWidth, 0, (i + 1) * blockWidth, TEST_HEIGHT, paint);
             }
             return bitmap;
         }
@@ -266,10 +272,9 @@
         }
 
         private Bitmap createGradient() {
-            LinearGradient gradient = new LinearGradient(30, 90, 150, 90, mColors, null,
+            LinearGradient gradient = new LinearGradient(15, 45, 75, 45, mColors, null,
                     Shader.TileMode.REPEAT);
-            Bitmap bitmap = Bitmap.createBitmap(MODIFIER_WIDTH, MODIFIER_HEIGHT,
-                    Bitmap.Config.ARGB_8888);
+            Bitmap bitmap = Bitmap.createBitmap(TEST_WIDTH, TEST_HEIGHT, Bitmap.Config.ARGB_8888);
             Paint p = new Paint();
             p.setShader(gradient);
             Canvas c = new Canvas(bitmap);
@@ -281,9 +286,7 @@
     public static final DisplayModifier mCircleDrawModifier = new DisplayModifier() {
         @Override
         public void modifyDrawing(Paint paint, Canvas canvas) {
-            canvas.drawCircle(ActivityTestBase.TEST_WIDTH / 2,
-                    ActivityTestBase.TEST_HEIGHT / 2,
-                    ActivityTestBase.TEST_HEIGHT / 2, paint);
+            canvas.drawCircle(TEST_WIDTH / 2, TEST_HEIGHT / 2, TEST_HEIGHT / 2, paint);
         }
     };
 
@@ -343,16 +346,15 @@
     }
 
     /*
-     * TODO: fix this test for L MR1
     @SmallTest
     public void testShaderSweeps() {
-        int mask = DisplayModifier.Accessor.AA_MASK |
-                DisplayModifier.Accessor.SHADER_MASK |
-                DisplayModifier.Accessor.XFERMODE_MASK |
-                DisplayModifier.Accessor.SHAPES_MASK;
+        int mask = DisplayModifier.Accessor.AA_MASK
+                | DisplayModifier.Accessor.SHADER_MASK
+                | DisplayModifier.Accessor.XFERMODE_MASK
+                | DisplayModifier.Accessor.SHAPES_MASK;
         sweepModifiersForMask(mask, null, DEFAULT_MSSIM_COMPARER, null);
     }
-     */
+    */
 
     protected void sweepModifiersForMask(int mask, final DisplayModifier drawOp,
             BitmapComparer[] bitmapComparers, BitmapVerifier[] bitmapVerifiers) {
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ViewClippingTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ViewClippingTests.java
index da2db48..343228f 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ViewClippingTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/ViewClippingTests.java
@@ -20,11 +20,11 @@
  * Since the layout is blue on a white background, this is always done with a RectVerifier.
  */
 public class ViewClippingTests extends ActivityTestBase {
-    final Rect FULL_RECT = new Rect(0, 0, 200, 200);
-    final Rect BOUNDS_RECT = new Rect(0, 0, 100, 100);
-    final Rect PADDED_RECT = new Rect(15, 16, 83, 82);
-    final Rect OUTLINE_RECT = new Rect(1, 2, 98, 99);
-    final Rect CLIP_BOUNDS_RECT = new Rect(10, 20, 70, 80);
+    final Rect FULL_RECT = new Rect(0, 0, 90, 90);
+    final Rect BOUNDS_RECT = new Rect(0, 0, 80, 80);
+    final Rect PADDED_RECT = new Rect(15, 16, 63, 62);
+    final Rect OUTLINE_RECT = new Rect(1, 2, 78, 79);
+    final Rect CLIP_BOUNDS_RECT = new Rect(10, 20, 50, 60);
 
     final ViewInitializer BOUNDS_CLIP_INIT = new ViewInitializer() {
         @Override
@@ -61,10 +61,9 @@
         }
     };
 
-    // TODO: attempt to reduce
-    static final int TOLERANCE = 16;
     static BitmapVerifier makeClipVerifier(Rect blueBoundsRect) {
-        return new RectVerifier(Color.WHITE, Color.BLUE, blueBoundsRect, TOLERANCE);
+        // very high error tolerance, since all these tests care about is clip alignment
+        return new RectVerifier(Color.WHITE, Color.BLUE, blueBoundsRect, 75);
     }
 
     public void testSimpleUnclipped() {
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
index 386c015..e3ad5a6 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/ActivityTestBase.java
@@ -41,15 +41,16 @@
     public static final String TAG = "ActivityTestBase";
     public static final boolean DEBUG = false;
     public static final boolean USE_RS = false;
-    public static final int TEST_WIDTH = 180;
-    public static final int TEST_HEIGHT = 180; //The minimum height and width of a device
+
+    //The minimum height and width of a device
+    public static final int TEST_WIDTH = 90;
+    public static final int TEST_HEIGHT = 90;
+
     public static final int MAX_SCREEN_SHOTS = 100;
 
     private int[] mHardwareArray = new int[TEST_HEIGHT * TEST_WIDTH];
     private int[] mSoftwareArray = new int[TEST_HEIGHT * TEST_WIDTH];
     private DifferenceVisualizer mDifferenceVisualizer;
-    private Allocation mIdealAllocation;
-    private Allocation mGivenAllocation;
     private RenderScript mRenderScript;
     private TestCaseBuilder mTestCaseBuilder;
 
@@ -122,16 +123,24 @@
         return pixels;
     }
 
+    private Bitmap takeScreenshotImpl() {
+        Bitmap source = getInstrumentation().getUiAutomation().takeScreenshot();
+        int x = (source.getWidth() - TEST_WIDTH) / 2;
+        int y = (source.getHeight() - TEST_HEIGHT) / 2;
+        return Bitmap.createBitmap(source, x, y, TEST_WIDTH, TEST_HEIGHT);
+    }
+
     public Bitmap takeScreenshot() {
         getInstrumentation().waitForIdleSync();
-        Bitmap bitmap1 = getInstrumentation().getUiAutomation().takeScreenshot();
+        Bitmap bitmap1 = takeScreenshotImpl();
         Bitmap bitmap2;
         int count = 0;
         do  {
             bitmap2 = bitmap1;
-            bitmap1 = getInstrumentation().getUiAutomation().takeScreenshot();
+            bitmap1 = takeScreenshotImpl();
             count++;
-        } while (count < MAX_SCREEN_SHOTS && !Arrays.equals(getBitmapPixels(bitmap2), getBitmapPixels(bitmap1)));
+        } while (count < MAX_SCREEN_SHOTS &&
+                !Arrays.equals(getBitmapPixels(bitmap2), getBitmapPixels(bitmap1)));
         return bitmap1;
     }
 
@@ -161,12 +170,12 @@
         boolean success;
 
         if (USE_RS && comparer.supportsRenderScript()) {
-            mIdealAllocation = Allocation.createFromBitmap(mRenderScript, bitmap1,
+            Allocation idealAllocation = Allocation.createFromBitmap(mRenderScript, bitmap1,
                     Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
-            mGivenAllocation = Allocation.createFromBitmap(mRenderScript, bitmap2,
+            Allocation givenAllocation = Allocation.createFromBitmap(mRenderScript, bitmap2,
                     Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
-            success = comparer.verifySameRS(getActivity().getResources(), mIdealAllocation,
-                    mGivenAllocation, 0, TEST_WIDTH, TEST_WIDTH, TEST_HEIGHT, mRenderScript);
+            success = comparer.verifySameRS(getActivity().getResources(), idealAllocation,
+                    givenAllocation, 0, TEST_WIDTH, TEST_WIDTH, TEST_HEIGHT, mRenderScript);
         } else {
             bitmap1.getPixels(mSoftwareArray, 0, TEST_WIDTH, 0, 0, TEST_WIDTH, TEST_HEIGHT);
             bitmap2.getPixels(mHardwareArray, 0, TEST_WIDTH, 0, 0, TEST_WIDTH, TEST_HEIGHT);
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClientView.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClientView.java
index 92242f0..60127ae 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClientView.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/CanvasClientView.java
@@ -19,6 +19,7 @@
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Paint;
+import android.util.AttributeSet;
 import android.view.View;
 
 /**
@@ -26,14 +27,21 @@
  */
 public class CanvasClientView extends View {
     private CanvasClient mCanvasClient;
-    private int mWidth;
-    private int mHeight;
 
-    public CanvasClientView(Context context, CanvasClient canvasClient, int width, int height) {
+    public CanvasClientView(Context context) {
         super(context);
+    }
+
+    public CanvasClientView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public CanvasClientView(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    public void setCanvasClient(CanvasClient canvasClient) {
         mCanvasClient = canvasClient;
-        mWidth = width;
-        mHeight = height;
     }
 
     @Override
@@ -45,11 +53,11 @@
             paint.setTextSize(20);
             canvas.drawText(s, 200, 200, paint);
         }
-        if (mCanvasClient != null) {
-            canvas.save();
-            canvas.clipRect(0, 0, mWidth, mHeight);
-            mCanvasClient.draw(canvas, mWidth, mHeight);
-            canvas.restore();
-        }
+        if (mCanvasClient == null) throw new IllegalStateException("Canvas client missing");
+
+        canvas.save();
+        canvas.clipRect(0, 0, ActivityTestBase.TEST_WIDTH, ActivityTestBase.TEST_HEIGHT);
+        mCanvasClient.draw(canvas, ActivityTestBase.TEST_WIDTH, ActivityTestBase.TEST_HEIGHT);
+        canvas.restore();
     }
 }
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java
index 684293d..b42ac88 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DisplayModifier.java
@@ -32,17 +32,16 @@
  * Modifies the canvas and paint objects when called.
  */
 public abstract class DisplayModifier {
-    private static final RectF gRect = new RectF(0, 0, 100, 100);
-    private static final float[] gPts = new float[]{
-            0, 100, 100, 0, 100, 200, 200, 100
+    private static final RectF RECT = new RectF(0, 0, 100, 100);
+    private static final float[] POINTS = new float[]{
+            0, 40, 40, 0, 40, 80, 80, 40
     };
-    private static final float[] gTriPts = new float[]{
-            75, 0, 130, 130, 130, 130, 0, 130, 0, 130, 75, 0
+    private static final float[] TRIANGLE_POINTS = new float[]{
+            40, 0, 80, 80, 80, 80, 0, 80, 0, 80, 40, 0
     };
-    private static final int NUM_PARALLEL_LINES = 24;
-    private static final float[] gLinePts = new float[NUM_PARALLEL_LINES * 8 + gTriPts.length];
-    protected static final int MODIFIER_WIDTH = 180;
-    protected static final int MODIFIER_HEIGHT = 180;
+    private static final int NUM_PARALLEL_LINES = 10;
+    private static final float[] LINES = new float[NUM_PARALLEL_LINES * 8
+            + TRIANGLE_POINTS.length];
 
     public static final PorterDuff.Mode[] PORTERDUFF_MODES = new PorterDuff.Mode[] {
         PorterDuff.Mode.SRC, PorterDuff.Mode.DST, PorterDuff.Mode.SRC_OVER,
@@ -53,25 +52,23 @@
     };
 
     static {
-        int index;
-        for (index = 0; index < gTriPts.length; index++) {
-            gLinePts[index] = gTriPts[index];
-        }
+        System.arraycopy(TRIANGLE_POINTS, 0, LINES, 0, TRIANGLE_POINTS.length);
+        int index = TRIANGLE_POINTS.length;
         float val = 0;
         for (int i = 0; i < NUM_PARALLEL_LINES; i++) {
-            gLinePts[index + 0] = 150;
-            gLinePts[index + 1] = val;
-            gLinePts[index + 2] = 300;
-            gLinePts[index + 3] = val;
+            LINES[index + 0] = 40;
+            LINES[index + 1] = val;
+            LINES[index + 2] = 80;
+            LINES[index + 3] = val;
             index += 4;
             val += 8 + (2.0f / NUM_PARALLEL_LINES);
         }
         val = 0;
         for (int i = 0; i < NUM_PARALLEL_LINES; i++) {
-            gLinePts[index + 0] = val;
-            gLinePts[index + 1] = 150;
-            gLinePts[index + 2] = val;
-            gLinePts[index + 3] = 300;
+            LINES[index + 0] = val;
+            LINES[index + 1] = 40;
+            LINES[index + 2] = val;
+            LINES[index + 3] = 80;
             index += 4;
             val += 8 + (2.0f / NUM_PARALLEL_LINES);
         }
@@ -81,7 +78,7 @@
     // paint object, like anti-aliasing or drawing. Within those LinkedHashMaps are the various
     // options for that specific topic, which contains a displaymodifier which will affect the
     // given canvas and paint objects.
-    public static final LinkedHashMap<String, LinkedHashMap<String, DisplayModifier>> sMaps =
+    public static final LinkedHashMap<String, LinkedHashMap<String, DisplayModifier>> MAPS =
             new LinkedHashMap<String, LinkedHashMap<String,DisplayModifier>>() {
                 {
                     put("aa", new LinkedHashMap<String, DisplayModifier>() {
@@ -225,7 +222,7 @@
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
                                     canvas.rotate(90);
-                                    canvas.translate(0, -200);
+                                    canvas.translate(0, -100);
                                 }
                             });
                             put("scale2x2", new DisplayModifier() {
@@ -347,13 +344,13 @@
                             put("roundRect", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    canvas.drawRoundRect(gRect, 20, 20, paint);
+                                    canvas.drawRoundRect(RECT, 20, 20, paint);
                                 }
                             });
                             put("rect", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    canvas.drawRect(gRect, paint);
+                                    canvas.drawRect(RECT, paint);
                                 }
                             });
                             put("circle", new DisplayModifier() {
@@ -365,36 +362,32 @@
                             put("oval", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    canvas.drawOval(gRect, paint);
+                                    canvas.drawOval(RECT, paint);
                                 }
                             });
                             put("lines", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    canvas.drawLines(gLinePts, paint);
+                                    canvas.drawLines(LINES, paint);
                                 }
                             });
-                            /* drawPoints does not work with zero stroke width,
-                             * but it isn't a regression
-                             * TODO: fix hardware canvas so that drawPoints works
                             put("plusPoints", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    canvas.drawPoints(gPts, paint);
+                                    canvas.drawPoints(POINTS, paint);
                                 }
                             });
-                             */
                             put("text", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    paint.setTextSize(36);
+                                    paint.setTextSize(20);
                                     canvas.drawText("TEXTTEST", 0, 50, paint);
                                 }
                             });
                             put("shadowtext", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    paint.setTextSize(36);
+                                    paint.setTextSize(20);
                                     paint.setShadowLayer(3.0f, 0.0f, 3.0f, 0xffff00ff);
                                     canvas.drawText("TEXTTEST", 0, 50, paint);
                                 }
@@ -410,13 +403,13 @@
                             put("arc", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    canvas.drawArc(gRect, 260, 285, false, paint);
+                                    canvas.drawArc(RECT, 260, 285, false, paint);
                                 }
                             });
                             put("arcFromCenter", new DisplayModifier() {
                                 @Override
                                 public void modifyDrawing(Paint paint, Canvas canvas) {
-                                    canvas.drawArc(gRect, 260, 285, true, paint);
+                                    canvas.drawArc(RECT, 260, 285, true, paint);
                                 }
                             });
                         }
@@ -454,9 +447,9 @@
             // Create a Display Map of the valid indices
             mDisplayMap = new LinkedHashMap<String, LinkedHashMap<String, DisplayModifier>>();
             int index = 0;
-            for (String key : DisplayModifier.sMaps.keySet()) {
+            for (String key : DisplayModifier.MAPS.keySet()) {
                 if (validIndex(index)) {
-                    mDisplayMap.put(key, DisplayModifier.sMaps.get(key));
+                    mDisplayMap.put(key, DisplayModifier.MAPS.get(key));
                 }
                 index++;
             }
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
index 166b6ff..65ed7ee 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testinfrastructure/DrawActivity.java
@@ -22,6 +22,7 @@
 import android.os.Handler;
 import android.os.Message;
 import android.view.View;
+import android.view.ViewStub;
 import android.view.ViewTreeObserver;
 import android.webkit.WebView;
 
@@ -41,6 +42,8 @@
 
     public void onCreate(Bundle bundle){
         super.onCreate(bundle);
+        getWindow().getDecorView().setSystemUiVisibility(
+                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
         mHandler = new RenderSpecHandler();
         int uiMode = getResources().getConfiguration().uiMode;
         mOnWatch = (uiMode & Configuration.UI_MODE_TYPE_WATCH) == Configuration.UI_MODE_TYPE_WATCH;
@@ -83,39 +86,40 @@
         }
 
         public void handleMessage(Message message) {
-            int webViewBuffer = 0;
+            int drawCountDelay = 0;
+            setContentView(R.layout.test_container);
+            ViewStub stub = (ViewStub) findViewById(R.id.test_content_stub);
             switch (message.what) {
                 case LAYOUT_MSG: {
-                    setContentView(message.arg1);
-                    mView = findViewById(R.id.test_root);
-                    if (mView == null) {
-                        throw new IllegalStateException("test_root failed to inflate");
-                    }
+                    stub.setLayoutResource(message.arg1);
+                    mView = stub.inflate();
                 } break;
 
                 case CANVAS_MSG: {
-                    mView = new CanvasClientView(getApplicationContext(),
-                            (CanvasClient) (message.obj), ActivityTestBase.TEST_WIDTH,
-                            ActivityTestBase.TEST_HEIGHT);
-                    setContentView(mView);
+                    stub.setLayoutResource(R.layout.test_content_canvasclientview);
+                    mView = stub.inflate();
+                    ((CanvasClientView) mView).setCanvasClient((CanvasClient) (message.obj));
                 } break;
 
                 case WEB_VIEW_MSG: {
-                    mView = new WebView(getApplicationContext());
+                    stub.setLayoutResource(R.layout.test_content_webview);
+                    mView = stub.inflate();
                     ((WebView) mView).loadUrl((String) message.obj);
                     ((WebView) mView).setInitialScale(100);
-                    setContentView(mView);
-                    webViewBuffer = 10;
+                    drawCountDelay = 10;
                 } break;
             }
 
+            if (mView == null) {
+                throw new IllegalStateException("failed to inflate test content");
+            }
+
             if (mViewInitializer != null) {
                 mViewInitializer.intializeView(mView);
             }
-
             mView.setLayerType(message.arg2, null);
 
-            DrawCounterListener onDrawListener = new DrawCounterListener(webViewBuffer);
+            DrawCounterListener onDrawListener = new DrawCounterListener(drawCountDelay);
 
             mView.getViewTreeObserver().addOnPreDrawListener(onDrawListener);
 
diff --git a/tests/tests/view/src/android/view/cts/MenuInflaterTest.java b/tests/tests/view/src/android/view/cts/MenuInflaterTest.java
index 40d1d3d..6007730 100644
--- a/tests/tests/view/src/android/view/cts/MenuInflaterTest.java
+++ b/tests/tests/view/src/android/view/cts/MenuInflaterTest.java
@@ -19,7 +19,6 @@
 import com.android.cts.view.R;
 import com.android.internal.view.menu.MenuBuilder;
 
-
 import android.app.Activity;
 import android.content.Context;
 import android.content.res.Resources;
@@ -28,6 +27,7 @@
 import android.graphics.BitmapFactory;
 import android.graphics.drawable.BitmapDrawable;
 import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.SubMenu;
@@ -48,17 +48,22 @@
     protected void setUp() throws Exception {
         super.setUp();
         mActivity = getActivity();
-        mMenuInflater = mActivity.getMenuInflater();
     }
 
+    @UiThreadTest
     public void testConstructor() {
         new MenuInflater(mActivity);
     }
 
+    @UiThreadTest
     public void testInflate() {
         Menu menu = new MenuBuilder(mActivity);
         assertEquals(0, menu.size());
 
+        if (mMenuInflater == null) {
+            mMenuInflater = mActivity.getMenuInflater();
+        }
+
         mMenuInflater.inflate(com.android.cts.view.R.menu.browser, menu);
         assertNotNull(menu);
         assertEquals(1, menu.size());
@@ -77,7 +82,12 @@
     }
 
     // Check wheher the objects are created correctly from xml files
+    @UiThreadTest
     public void testInflateFromXml(){
+        if (mMenuInflater == null) {
+            mMenuInflater = mActivity.getMenuInflater();
+        }
+
         // the visibility and shortcut
         Menu menu = new MenuBuilder(mActivity);
         mMenuInflater.inflate(R.menu.visible_shortcut, menu);
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index 24b8fdb..480e1a6 100644
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -2845,15 +2845,19 @@
         assertEquals(1, mTextView.getImeActionId());
     }
 
-    @UiThreadTest
     public void testSetTextLong() {
-        final int MAX_COUNT = 1 << 21;
-        char[] longText = new char[MAX_COUNT];
-        for (int n = 0; n < MAX_COUNT; n++) {
-            longText[n] = 'm';
-        }
-        mTextView = findTextView(R.id.textview_text);
-        mTextView.setText(new String(longText));
+        mActivity.runOnUiThread(new Runnable() {
+            public void run() {
+                final int MAX_COUNT = 1 << 21;
+                char[] longText = new char[MAX_COUNT];
+                for (int n = 0; n < MAX_COUNT; n++) {
+                    longText[n] = 'm';
+                }
+                mTextView = findTextView(R.id.textview_text);
+                mTextView.setText(new String(longText));
+            }
+        });
+        mInstrumentation.waitForIdleSync();
     }
 
     @UiThreadTest