Merge "[DO NOT MERGE] Let voicemail broadcast test pass if it is not applicable." into oreo-mr1-cts-dev
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index b2eba4d..8286f1b 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -2566,7 +2566,9 @@
         Please do the following:\n
         1) Open and fully expand Quick Settings.\n
         2) Verify that at the bottom of Quick Settings, you are not told the device is managed.\n
-        3) Close Quick Settings.
+        3) Close Quick Settings.\n
+        \n
+        If this device does not have quick settings, please skip this test and mark it passing
     </string>
     <string name="enterprise_privacy_keyguard_negative">Keyguard disclosure</string>
     <string name="enterprise_privacy_keyguard_negative_info">
@@ -3304,7 +3306,7 @@
         10) Tap the \"Learn more\" link.\n
         11) Verify that a screen informing you what your managing organization can do is shown.\n
         \n
-        Use the Back button to return to this page.
+        Use the Back button to return to this page. If this device does not have quick settings, please skip this test and mark it passing.
     </string>
     <string name="enterprise_privacy_keyguard">Keyguard disclosure</string>
     <string name="enterprise_privacy_keyguard_info">
@@ -3352,6 +3354,8 @@
         9) Close the dialog.\n
         10) Tap the right button below to disable network logging.\n
         11) Verify that the notification disappeared.\n
+        \n
+        If this device does not have quick settings, please skip this test and mark it passing.
     </string>
     <string name="device_owner_enable_network_logging_button">Enable Network Logging</string>
     <string name="device_owner_disable_network_logging_button">Disable Network Logging</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
index 269f4fd..7f3bfc7 100755
--- a/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/notifications/NotificationListenerVerifierActivity.java
@@ -32,6 +32,8 @@
 
 import com.android.cts.verifier.R;
 
+import com.android.compatibility.common.util.CddTest;
+
 import org.json.JSONException;
 import org.json.JSONObject;
 
@@ -45,6 +47,7 @@
 
 import static junit.framework.Assert.assertNotNull;
 
+@CddTest(requirement="3.8.3.2/C-1-1,C-1-2,C-2-1")
 public class NotificationListenerVerifierActivity extends InteractiveVerifierActivity
         implements Runnable {
     private static final String TAG = "NoListenerVerifier";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
index 9c60737..2f89ec6 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/vr/VrListenerVerifierActivity.java
@@ -31,6 +31,8 @@
 import android.widget.TextView;
 
 
+import com.android.compatibility.common.util.CddTest;
+
 import com.android.cts.verifier.PassFailButtons;
 import com.android.cts.verifier.R;
 
@@ -41,6 +43,7 @@
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
+@CddTest(requirement="7.9.1/H-2-1")
 public class VrListenerVerifierActivity extends PassFailButtons.Activity {
 
     private static final String TAG = "VrListenerActivity";
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
index 6c139aa..321f3d6 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/VrTemperatureTest.java
@@ -21,6 +21,8 @@
 import android.test.AndroidTestCase;
 import android.util.Log;
 
+import com.android.compatibility.common.util.CddTest;
+
 import java.lang.Math;
 
 public class VrTemperatureTest extends BaseDeviceOwnerTest {
@@ -78,6 +80,7 @@
     /**
      * Tests that temperature sensors return valid values.
      */
+    @CddTest(requirement="7.9.2/C-1-13")
     public void testVrTemperatures() throws InterruptedException, SecurityException {
         if (!supportsVrHighPerformance())
             return;
diff --git a/tests/app/src/android/app/cts/NotificationChannelTest.java b/tests/app/src/android/app/cts/NotificationChannelTest.java
index 70ec9cf..c54df84 100644
--- a/tests/app/src/android/app/cts/NotificationChannelTest.java
+++ b/tests/app/src/android/app/cts/NotificationChannelTest.java
@@ -28,6 +28,9 @@
 import android.provider.Settings;
 import android.test.AndroidTestCase;
 
+import com.android.compatibility.common.util.CddTest;
+
+@CddTest(requirement="3.8.3.1/C-1-1,C-1-4")
 public class NotificationChannelTest extends AndroidTestCase {
 
     @Override
diff --git a/tests/app/src/android/app/cts/NotificationManagerTest.java b/tests/app/src/android/app/cts/NotificationManagerTest.java
index b6077ca..4ee7eaf 100644
--- a/tests/app/src/android/app/cts/NotificationManagerTest.java
+++ b/tests/app/src/android/app/cts/NotificationManagerTest.java
@@ -36,6 +36,8 @@
 import android.test.AndroidTestCase;
 import android.util.Log;
 
+import com.android.compatibility.common.util.CddTest;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -43,6 +45,7 @@
 import java.util.Map;
 import java.util.UUID;
 
+@CddTest(requirement="3.8.3.1/C-1-3,C-1-4")
 public class NotificationManagerTest extends AndroidTestCase {
     final String TAG = NotificationManagerTest.class.getSimpleName();
     final boolean DEBUG = false;
@@ -173,6 +176,7 @@
         compareChannels(channel, mNotificationManager.getNotificationChannel(channel.getId()));
     }
 
+    @CddTest(requirement="3.8.3.1/C-1-3")
     public void testCreateChannelWithGroup() throws Exception {
         NotificationChannelGroup ncg = new NotificationChannelGroup("g", "n");
         mNotificationManager.createNotificationChannelGroup(ncg);
@@ -387,6 +391,7 @@
         checkNotificationExistence(id, false);
     }
 
+    @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
     public void testMediaStyle() throws Exception {
         mNotificationManager.cancelAll();
         final int id = 99;
@@ -438,6 +443,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
     public void testBigTextStyle() throws Exception {
         final int id = 101;
 
@@ -464,6 +470,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.3/H-0-2,3.8.3.1/C-2-1")
     public void testBigPictureStyle() throws Exception {
         final int id = 102;
 
@@ -491,6 +498,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.3.1/C-1-3")
     public void testAutogrouping() throws Exception {
         sendNotification(1, R.drawable.black);
         sendNotification(2, R.drawable.blue);
@@ -501,6 +509,7 @@
         assertAllPostedNotificationsAutogrouped();
     }
 
+    @CddTest(requirement="3.8.3.1/C-1-3")
     public void testAutogrouping_autogroupStaysUntilAllNotificationsCanceled() throws Exception {
         sendNotification(1, R.drawable.black);
         sendNotification(2, R.drawable.blue);
diff --git a/tests/app/src/android/app/cts/NotificationTest.java b/tests/app/src/android/app/cts/NotificationTest.java
index 25c25e3..47ab3a1 100644
--- a/tests/app/src/android/app/cts/NotificationTest.java
+++ b/tests/app/src/android/app/cts/NotificationTest.java
@@ -29,8 +29,11 @@
 import android.test.AndroidTestCase;
 import android.widget.RemoteViews;
 
+import com.android.compatibility.common.util.CddTest;
+
 import org.mockito.internal.matchers.Not;
 
+@CddTest(requirement="3.8.3/H-0-1,3.8.3.1/C-1-4")
 public class NotificationTest extends AndroidTestCase {
     private static final String TEXT_RESULT_KEY = "text";
     private static final String DATA_RESULT_KEY = "data";
diff --git a/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java b/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
index fa233dd..5317d89 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/MyWebView.java
@@ -21,7 +21,9 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.util.SparseArray;
+import android.view.autofill.AutofillManager;
 import android.view.autofill.AutofillValue;
 import android.webkit.WebView;
 
@@ -33,10 +35,12 @@
  */
 public class MyWebView extends WebView {
 
+    private static final String TAG = "MyWebView";
     private FillExpectation mExpectation;
 
     public MyWebView(Context context, AttributeSet attrs) {
         super(context, attrs);
+        Log.d(TAG, "isAutofillEnabled() on constructor? " + isAutofillEnabled());
     }
 
     public void expectAutofill(String username, String password) {
@@ -80,6 +84,10 @@
         }
     }
 
+    boolean isAutofillEnabled() {
+        return getContext().getSystemService(AutofillManager.class).isEnabled();
+    }
+
     private class FillExpectation {
         private final CountDownLatch mLatch = new CountDownLatch(1);
         private final String mExpectedUsername;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
index d3b2d82..cf2ecfc 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/WebViewActivityTest.java
@@ -25,6 +25,7 @@
 import android.autofillservice.cts.InstrumentedAutoFillService.FillRequest;
 import android.autofillservice.cts.InstrumentedAutoFillService.SaveRequest;
 import android.support.test.uiautomator.UiObject2;
+import android.util.Log;
 import android.view.ViewStructure.HtmlInfo;
 
 import org.junit.AfterClass;
@@ -35,19 +36,34 @@
 
 public class WebViewActivityTest extends AutoFillServiceTestCase {
 
+    private static final String TAG = "WebViewActivityTest";
+
     // TODO(b/64951517): WebView currently does not trigger the autofill callbacks when values are
     // set using accessibility.
     private static final boolean INJECT_EVENTS = true;
 
     @Rule
     public final AutofillActivityTestRule<WebViewActivity> mActivityRule =
-            new AutofillActivityTestRule<WebViewActivity>(WebViewActivity.class);
+            new AutofillActivityTestRule<WebViewActivity>(WebViewActivity.class) {
+    // TODO(b/111838239): latest WebView implementation calls AutofillManager.isEnabled() to
+    // disable autofill for optimization when it returns false, and unfortunately the value
+    // returned by that method does not change when the service is enabled / disabled, so we
+    // need to start enable the service before launching the activity.
+    // Once that's fixed, remove this overridden method.
+                @Override
+                protected void beforeActivityLaunched() {
+                    super.beforeActivityLaunched();
+                    Log.i(TAG, "Setting service before launching the activity");
+                    enableService();
+                }
+            };
 
     private WebViewActivity mActivity;
 
     @Before
     public void setActivity() {
         mActivity = mActivityRule.getActivity();
+        assertAutofillEnabledOnWebView();
     }
 
     @BeforeClass
@@ -276,4 +292,8 @@
             Helper.assertTextAndValue(passwordNode2, "SWEET");
         }
     }
+
+    private void assertAutofillEnabledOnWebView() {
+        assertThat(mActivity.mWebView.isAutofillEnabled()).isTrue();
+    }
 }
diff --git a/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java b/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
index 94b25fb..aa6275f 100644
--- a/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
+++ b/tests/tests/nativehardware/src/android/hardware/cts/AHardwareBufferNativeTest.java
@@ -19,11 +19,14 @@
 import android.content.pm.PackageManager;
 import android.test.AndroidTestCase;
 
+import com.android.compatibility.common.util.CddTest;
+
 /**
  * Check AHardwareBuffer functionality.
  *
  * This is the place to implement AHardwareBuffer NDK CTS tests.
  */
+@CddTest(requirement="7.9.2/C-1-10")
 public class AHardwareBufferNativeTest extends AndroidTestCase {
     protected native long nativeSetUp();
     protected native void nativeTearDown(long instance);
diff --git a/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java b/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
index a27633a..e7dafa2 100644
--- a/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
+++ b/tests/vr/src/android/vr/cts/VrExtensionBehaviorTest.java
@@ -20,6 +20,8 @@
 import android.opengl.GLES32;
 import android.test.ActivityInstrumentationTestCase2;
 
+import com.android.compatibility.common.util.CddTest;
+
 public class VrExtensionBehaviorTest extends ActivityInstrumentationTestCase2<OpenGLESActivity> {
     static {
         System.loadLibrary("ctsvrextensions_jni");
@@ -53,6 +55,7 @@
     /**
      * Tests that protected content contexts and surfaces can be created.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testProtectedContent() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 1, 0, 0);
         if (!mActivity.supportsVrHighPerformance())
@@ -77,6 +80,7 @@
     /**
      * Tests that textures can be marked as protected.
      */
+    @CddTest(requirement="7.9.2/C-1-8")
     public void testProtectedTextures() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_PROTECTEDTEXTURES, 1, 0, 0);
         if (!mActivity.supportsVrHighPerformance())
@@ -104,6 +108,7 @@
     /**
      * Tests that context priority can be set to high.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testContextPriorityHigh() throws Throwable {
         runContextPriorityTest(EGL_CONTEXT_PRIORITY_HIGH_IMG);
     }
@@ -111,6 +116,7 @@
     /**
      * Tests that context priority can be set to medium.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testContextPriorityMedium() throws Throwable {
         runContextPriorityTest(EGL_CONTEXT_PRIORITY_MEDIUM_IMG);
     }
@@ -118,6 +124,7 @@
     /**
      * Tests that context priority can be set to low.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testContextPriorityLow() throws Throwable {
         runContextPriorityTest(EGL_CONTEXT_PRIORITY_LOW_IMG);
     }
@@ -125,6 +132,7 @@
     /**
      * Tests that context priority can be set to low.
      */
+    @CddTest(requirement="7.9.2/C-1-6")
     public void testMutableRenderBuffer() throws Throwable {
 
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 1);
@@ -160,6 +168,7 @@
      * For more information, see the EGL_image_array spec:
      * https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_EGL_image_array.txt
      */
+    @CddTest(requirement="7.9.2/C-1-8,C-1-10")
     public void testEglImageArray() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 0);
         if (!mActivity.supportsVrHighPerformance())
@@ -179,6 +188,7 @@
      * For more information, see the GL_EXT_external_buffer spec:
      * https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_external_buffer.txt
      */
+    @CddTest(requirement="7.9.2/C-1-8")
     public void testExternalBuffer() throws Throwable {
         mActivity = getGlEsActivity(OpenGLESActivity.RENDERER_BASIC, 0, 0, 0);
         if (!mActivity.supportsVrHighPerformance())