[automerger] CTS test for Android Security Bug-139806216 am: 053c3e96b7

Change-Id: I73f5faf7e313e833ae1bdabfd8fde692a5a00c20
diff --git a/apps/CtsVerifier/res/layout/js_charging.xml b/apps/CtsVerifier/res/layout/js_charging.xml
index 061d796..feee16e 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:id="@+id/charger_prompt"
                 android:layout_width="match_parent"
@@ -43,9 +28,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"
@@ -72,14 +57,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"
@@ -97,21 +82,21 @@
                 android:id="@+id/unplug_test_description"
                 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/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
index 496414f..0b0be81 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/ConditionProviderVerifierActivity.java
@@ -399,6 +399,11 @@
                                 // Now that it's subscribed, remove the rule and verify that it
                                 // unsubscribes.
                                 mNm.removeAutomaticZenRule(id);
+                                try {
+                                    Thread.sleep(3000);
+                                } catch (InterruptedException e) {
+                                    logFail("unexpected InterruptedException");
+                                }
                                 MockConditionProvider.probeSubscribe(mContext,
                                         new MockConditionProvider.ParcelableListResultCatcher() {
                                             @Override
diff --git a/hostsidetests/securitybulletin/res/cve_2018_9497.m2v b/hostsidetests/securitybulletin/res/cve_2018_9497.m2v
new file mode 100644
index 0000000..b8b2fb2
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2018_9497.m2v
Binary files differ
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/TestMediaCodec.java b/hostsidetests/securitybulletin/src/android/security/cts/TestMediaCodec.java
index f58c533..2e196e5 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/TestMediaCodec.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/TestMediaCodec.java
@@ -164,6 +164,15 @@
                 getDevice(), null);
     }
 
+    @SecurityTest(minPatchLevel = "2018-10")
+    public void testPocCVE_2018_9497() throws Exception {
+        String inputFiles[] = {"cve_2018_9497.m2v"};
+        runMpeg2DecodeTest(inputFiles, "--input " + TMP_FILE_PATH
+                + "cve_2018_9497.m2v --save_output 0"
+                + " --num_frames -1 --loopback 0 --display 0 --save_chksum 0",
+                getDevice(), null);
+    }
+
     @SecurityTest
     public void testPocBug_34203195() throws Exception {
         String inputFiles[] = {"bug_34203195.m2v"};
diff --git a/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java b/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java
index e09e0d6..181bdd3 100644
--- a/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java
@@ -56,13 +56,22 @@
             + "    <script>\n"
             + "      navigator.serviceWorker.register('sw.js').then(function(reg) {\n"
             + "         " + JS_INTERFACE_NAME + ".registrationSuccess();\n"
-            + "      }).catch(function(err) { \n"
+            + "      }).catch(function(err) {\n"
             + "         console.error(err);\n"
             + "      });\n"
             + "    </script>\n"
             + "  </body>\n"
             + "</html>\n";
     private static final String SW_RAW_HTML = "fetch('fetch.html');";
+    private static final String SW_UNREGISTER_RAW_JS =
+            "navigator.serviceWorker.getRegistration().then(function(r) {"
+            + "  r.unregister().then(function(success) {"
+            + "    if (success) " + JS_INTERFACE_NAME + ".unregisterSuccess();"
+            + "    else console.error('unregister() was not successful');"
+            + "  });"
+            + "}).catch(function(err) {"
+            + "   console.error(err);"
+            + "});";
 
     private JavascriptStatusReceiver mJavascriptStatusReceiver;
     private WebViewOnUiThread mOnUiThread;
@@ -170,17 +179,34 @@
         assertEquals(2, requests.size());
         assertEquals(SW_URL, requests.get(0).getUrl().toString());
         assertEquals(FETCH_URL, requests.get(1).getUrl().toString());
+
+        // Clean-up, make sure to unregister the Service Worker.
+        mOnUiThread.evaluateJavascript(SW_UNREGISTER_RAW_JS, null);
+        Callable<Boolean> unregisterSuccess = new Callable<Boolean>() {
+            @Override
+            public Boolean call() {
+                return mJavascriptStatusReceiver.mUnregisterSuccess;
+            }
+        };
+        PollingCheck.check("JS could not unregister Service Worker", POLLING_TIMEOUT,
+                unregisterSuccess);
     }
 
     // Object added to the page via AddJavascriptInterface() that is used by the test Javascript to
     // notify back to Java if the Service Worker registration was successful.
     public final static class JavascriptStatusReceiver {
         public volatile boolean mRegistrationSuccess = false;
+        public volatile boolean mUnregisterSuccess = false;
 
         @JavascriptInterface
         public void registrationSuccess() {
             mRegistrationSuccess = true;
         }
+
+        @JavascriptInterface
+        public void unregisterSuccess() {
+            mUnregisterSuccess = true;
+        }
     }
 }
 
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