Merge "DO NOT MERGE: Change the way that find UI elements" into oreo-mr1-cts-dev
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index d895ca7..19fd445 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -2099,7 +2099,7 @@
             </intent-filter>
             <meta-data android:name="test_category" android:value="@string/test_category_deskclock" />
             <meta-data android:name="test_excluded_features"
-                    android:value="android.hardware.type.television:android.software.leanback" />
+                    android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.automotive" />
         </activity>
 
 <!-- TODO: enable when not requiring to tap the screen and timeouts are tuned -->
diff --git a/apps/CtsVerifier/res/layout/voicemail_broadcast.xml b/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
index 163da23..0cf1d39 100644
--- a/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
+++ b/apps/CtsVerifier/res/layout/voicemail_broadcast.xml
@@ -58,6 +58,12 @@
       android:layout_height="wrap_content"
       android:text="@string/voicemail_set_default_dialer_button"/>
 
+    <Button
+      android:id="@+id/call_settings_check_not_applicable"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:text="@string/visual_voicemail_service_remove_sim_not_applicable"/>
+
     <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java
index 2661d42..95c99b7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/companion/CompanionDeviceTestActivity.java
@@ -31,10 +31,13 @@
 
 import java.util.List;
 
+import com.android.compatibility.common.util.CddTest;
+
 
 /**
  * Test that checks that the {@link CompanionDeviceManager} API is functional
  */
+@CddTest(requirement="3.16/C-1-2,C-1-3,H-1-1")
 public class CompanionDeviceTestActivity extends PassFailButtons.Activity {
 
     private static final String LOG_TAG = "CompanionDeviceTestActi";
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
index 3cf34fa..b54637b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/voicemail/VoicemailBroadcastActivity.java
@@ -29,6 +29,8 @@
 import com.android.cts.verifier.R;
 import com.android.cts.verifier.voicemail.VoicemailBroadcastReceiver.ReceivedListener;
 
+import android.view.View.OnClickListener;
+import android.widget.Button;
 /**
  * This test ask the tester to set the CTS verifier as the default dialer and leave a voicemail. The
  * test will pass if the verifier is able to receive a broadcast for the incoming voicemail. This
@@ -38,7 +40,9 @@
 public class VoicemailBroadcastActivity extends PassFailButtons.Activity {
 
     private ImageView mLeaveVoicemailImage;
+    private ImageView mRestoreDefaultDialerImage;
     private TextView mLeaveVoicemailText;
+    private Button mNotApplicableButton;
 
     private DefaultDialerChanger mDefaultDialerChanger;
 
@@ -53,10 +57,23 @@
         getPassButton().setEnabled(false);
 
         mLeaveVoicemailImage = (ImageView) findViewById(R.id.leave_voicemail_image);
+        mRestoreDefaultDialerImage = (ImageView) findViewById(R.id.restore_default_dialer_image);
         mLeaveVoicemailText = (TextView) findViewById(R.id.leave_voicemail_text);
 
         mDefaultDialerChanger = new DefaultDialerChanger(this);
 
+        mNotApplicableButton = findViewById(R.id.call_settings_check_not_applicable);
+        mNotApplicableButton.setOnClickListener(
+                new OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        getPassButton().setEnabled(true);
+                        mLeaveVoicemailImage.setImageDrawable(getDrawable(R.drawable.fs_warning));
+                        mRestoreDefaultDialerImage.setImageDrawable(getDrawable(R.drawable.fs_warning));
+                    }
+                }
+        );
+
         VoicemailBroadcastReceiver.setListener(new ReceivedListener() {
             @Override
             public void onReceived() {
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
old mode 100644
new mode 100755
index 51c2348..437a43c
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/AssistantVoiceInteractionService.java
@@ -29,10 +29,14 @@
 
     private boolean mReady;
 
+    private boolean mStarted;
+    private Bundle mExtras;
+
     @Override
     public void onReady() {
         super.onReady();
         mReady = true;
+        showSessionIfReady();
     }
 
     @Override
@@ -43,13 +47,18 @@
             stopSelf();
             return START_NOT_STICKY;
         }
-        if (mReady) {
-            Bundle extras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
-            showSession(extras, 0);
-        }
+        mExtras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
+        mStarted = true;
+        showSessionIfReady();
         return START_NOT_STICKY;
     }
 
+    private void showSessionIfReady() {
+        if (mReady && mStarted) {
+            showSession(mExtras, 0);
+        }
+    };
+
     /**
      * Starts the assistant voice interaction service, which initiates a new session that starts
      * the assistant activity.
diff --git a/tests/app/src/android/app/cts/SystemFeaturesTest.java b/tests/app/src/android/app/cts/SystemFeaturesTest.java
index 53b1bf2..9b95c28 100644
--- a/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -42,6 +42,8 @@
 import android.telephony.TelephonyManager;
 import android.test.InstrumentationTestCase;
 
+import com.android.compatibility.common.util.CddTest;
+
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -231,6 +233,7 @@
         }
     }
 
+    @CddTest(requirement="3.8.7/C-1-1")
     public void testLiveWallpaperFeature() {
         try {
             Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
@@ -283,6 +286,7 @@
         }
     }
 
+    @CddTest(requirement="7.1.3/C-0-1")
     public void testScreenFeatures() {
         assertTrue(mPackageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)
                 || mPackageManager.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT));
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
index 0d70947..f0d5cb8 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
@@ -51,6 +51,8 @@
 
 import java.util.Locale;
 
+import com.android.compatibility.common.util.CddTest;
+
 @SmallTest
 @RunWith(AndroidJUnit4.class)
 public class PaintTest {
@@ -1226,6 +1228,7 @@
         new Paint().getTextPath("HIJKLMN", 3, 9, 0, 0, new Path());
     }
 
+    @CddTest(requirement="3.8.13/C-1-2")
     @Test
     public void testHasGlyph() {
         Paint p = new Paint();
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
index eccb16d..ed0e02f 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
@@ -56,7 +56,7 @@
      * Color may be slightly off-spec when resources are resized for lower densities. Use this error
      * margin to accommodate for that when comparing colors.
      */
-    private static final int COLOR_COMPONENT_ERROR_MARGIN = 10;
+    private static final int COLOR_COMPONENT_ERROR_MARGIN = 20;
 
     private final String NOTIFICATION_TAG = "TEST_TAG";
     private final String NOTIFICATION_CHANNEL_ID = "test_channel";
@@ -261,7 +261,7 @@
         float eps = 0.005f;
 
         for (int c : pixels) {
-            if (c == background) {
+            if (isColorSame(c, background)) {
                 s.backgroundPixels++;
                 continue;
             }
diff --git a/tests/tests/text/src/android/text/cts/FontCoverageTest.java b/tests/tests/text/src/android/text/cts/FontCoverageTest.java
index 4f66ee7..837c209 100644
--- a/tests/tests/text/src/android/text/cts/FontCoverageTest.java
+++ b/tests/tests/text/src/android/text/cts/FontCoverageTest.java
@@ -26,12 +26,15 @@
 import android.support.test.filters.LargeTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.compatibility.common.util.CddTest;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.util.HashMap;
 import java.util.Locale;
 
+@CddTest(requirement="3.8.13/C-1-1")
 @LargeTest
 @RunWith(AndroidJUnit4.class)
 public class FontCoverageTest {