Switch to new autofillHint API

Test: Ran CTS autofill tests
Bug: 35364993
Change-Id: I75bfd5fa6d8e40347b17a9ec1a92f0025e714263
diff --git a/tests/autofillservice/res/layout/view_attribute_test_activity.xml b/tests/autofillservice/res/layout/view_attribute_test_activity.xml
index 8dde7c4..da27150 100644
--- a/tests/autofillservice/res/layout/view_attribute_test_activity.xml
+++ b/tests/autofillservice/res/layout/view_attribute_test_activity.xml
@@ -49,10 +49,12 @@
 
     <TextView android:id="@+id/textViewNoHint" android:layout_width="wrap_content"
         android:layout_height="wrap_content" />
-    <TextView android:id="@+id/textViewHintNone" android:layout_width="wrap_content"
-        android:layout_height="wrap_content" android:autofillHint="none" />
+    <TextView android:id="@+id/textViewHintCustom" android:layout_width="wrap_content"
+        android:layout_height="wrap_content" android:autofillHint="@string/new_password_label" />
     <TextView android:id="@+id/textViewPassword" android:layout_width="wrap_content"
         android:layout_height="wrap_content" android:autofillHint="password" />
     <TextView android:id="@+id/textViewPhoneName" android:layout_width="wrap_content"
-        android:layout_height="wrap_content" android:autofillHint="phone|username" />
+        android:layout_height="wrap_content" android:autofillHint=" phone, username     " />
+    <TextView android:id="@+id/textViewHintsFromArray" android:layout_width="wrap_content"
+        android:layout_height="wrap_content" android:autofillHint="@array/cc_expiration_values" />
 </LinearLayout>
diff --git a/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java b/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java
index 9ca1929..a1938b3 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/ViewAttributesTest.java
@@ -17,7 +17,6 @@
 package android.autofillservice.cts;
 
 import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilConnected;
-import static android.autofillservice.cts.InstrumentedAutoFillService.waitUntilDisconnected;
 
 import static com.google.common.truth.Truth.assertThat;
 
@@ -274,41 +273,56 @@
 
     @Test
     public void checkTextViewNoHint() {
-        assertThat(mActivity.findViewById(R.id.textViewNoHint).getAutofillHint()).isEqualTo(
-                View.AUTOFILL_HINT_NONE);
+        assertThat(mActivity.findViewById(R.id.textViewNoHint).getAutofillHint()).isNull();
     }
 
     @Test
-    public void checkTextViewHintNone() {
-        assertThat(mActivity.findViewById(R.id.textViewHintNone).getAutofillHint()).isEqualTo(
-                View.AUTOFILL_HINT_NONE);
+    public void checkTextViewHintCustom() {
+        assertThat(mActivity.findViewById(R.id.textViewHintCustom).getAutofillHint()).isEqualTo(
+                new String[]{mActivity.getString(R.string.new_password_label)});
     }
 
     @Test
     public void checkTextViewPassword() {
         assertThat(mActivity.findViewById(R.id.textViewPassword).getAutofillHint()).isEqualTo(
-                View.AUTOFILL_HINT_PASSWORD);
+                new String[]{View.AUTOFILL_HINT_PASSWORD});
     }
 
     @Test
     public void checkTextViewPhoneName() {
         assertThat(mActivity.findViewById(R.id.textViewPhoneName).getAutofillHint()).isEqualTo(
-                View.AUTOFILL_HINT_PHONE | View.AUTOFILL_HINT_USERNAME);
+                new String[]{View.AUTOFILL_HINT_PHONE, View.AUTOFILL_HINT_USERNAME});
+    }
+
+    @Test
+    public void checkTextViewHintsFromArray() {
+        assertThat(mActivity.findViewById(R.id.textViewHintsFromArray).getAutofillHint()).isEqualTo(
+                new String[]{"yesterday", "today", "tomorrow", "never"});
     }
 
     @Test
     public void checkSetAutoFill() {
         View v = mActivity.findViewById(R.id.textViewNoHint);
 
-        v.setAutofillHint(View.AUTOFILL_HINT_NONE);
-        assertThat(v.getAutofillHint()).isEqualTo(View.AUTOFILL_HINT_NONE);
+        v.setAutofillHint(null);
+        assertThat(v.getAutofillHint()).isNull();
 
-        v.setAutofillHint(View.AUTOFILL_HINT_PASSWORD);
-        assertThat(v.getAutofillHint()).isEqualTo(View.AUTOFILL_HINT_PASSWORD);
+        v.setAutofillHint(new String[0]);
+        assertThat(v.getAutofillHint()).isNull();
 
-        v.setAutofillHint(View.AUTOFILL_HINT_PASSWORD | View.AUTOFILL_HINT_EMAIL_ADDRESS);
-        assertThat(v.getAutofillHint()).isEqualTo(View.AUTOFILL_HINT_PASSWORD
-                | View.AUTOFILL_HINT_EMAIL_ADDRESS);
+        v.setAutofillHint(new String[]{View.AUTOFILL_HINT_PASSWORD});
+        assertThat(v.getAutofillHint()).isEqualTo(new String[]{View.AUTOFILL_HINT_PASSWORD});
+
+        v.setAutofillHint(new String[]{"custom", "value"});
+        assertThat(v.getAutofillHint()).isEqualTo(new String[]{"custom", "value"});
+
+        v.setAutofillHint("more", "values");
+        assertThat(v.getAutofillHint()).isEqualTo(new String[]{"more", "values"});
+
+        v.setAutofillHint(
+                new String[]{View.AUTOFILL_HINT_PASSWORD, View.AUTOFILL_HINT_EMAIL_ADDRESS});
+        assertThat(v.getAutofillHint()).isEqualTo(new String[]{View.AUTOFILL_HINT_PASSWORD,
+                View.AUTOFILL_HINT_EMAIL_ADDRESS});
     }
 
     @Test
@@ -395,13 +409,4 @@
             disableService();
         }
     }
-
-    @Test
-    public void checkSetAutoFillUnknown() {
-        View v = mActivity.findViewById(R.id.textViewNoHint);
-
-        // Unknown values are allowed
-        v.setAutofillHint(-1);
-        assertThat(v.getAutofillHint()).isEqualTo(-1);
-    }
 }