Verify cred proxy service not showing in settings
Verify that credman proxy service is not visible in settings.
Bug: 315867620
Test: atest CtsAutoFillServiceTestCases:android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest
Change-Id: I78af433a89ca520ce3bdba406ba97a589d194369
diff --git a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginMixedCredentialActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginMixedCredentialActivityTest.java
index d0b4771..b6ade72 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginMixedCredentialActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/inline/InlineLoginMixedCredentialActivityTest.java
@@ -43,7 +43,9 @@
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.DeviceConfig;
+import android.provider.Settings;
import android.text.TextUtils;
+import android.util.ArraySet;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -150,6 +152,29 @@
}
@Test
+ public void testCredmanProxyServiceIsNotPublic() throws Exception {
+ // Set service.
+ enableService();
+
+ // Verify during initial setup.
+ assertThat(readServiceNameList())
+ .asList()
+ .containsExactly("android.autofillservice.cts/.testcore."
+ + "InstrumentedAutoFillServiceInlineEnabled");
+
+ // Trigger auto-fill.
+ mUiBot.selectByRelativeId(ID_USERNAME);
+ mUiBot.waitForIdleSync();
+ CtsCredentialProviderService.onReceivedResponse();
+
+ // Verify after credman service is invoked.
+ assertThat(readServiceNameList())
+ .asList()
+ .containsExactly("android.autofillservice.cts/.testcore."
+ + "InstrumentedAutoFillServiceInlineEnabled");
+ }
+
+ @Test
@RequiresFlagsEnabled("android.service.autofill.autofill_credman_integration")
public void testAutofill_selectNonCredentialView() throws Exception {
// Set service.
@@ -506,4 +531,28 @@
.collect(Collectors.toMap(c -> c.getComponentName().flattenToString(), c -> c));
}
+ private String[] readServiceNameList() {
+ return parseColonDelimitedServiceNames(
+ Settings.Secure.getString(
+ mContext.getContentResolver(), Settings.Secure.AUTOFILL_SERVICE));
+ }
+
+ private String[] parseColonDelimitedServiceNames(String serviceNames) {
+ final Set<String> delimitedServices = new ArraySet<>();
+ if (!TextUtils.isEmpty(serviceNames)) {
+ final TextUtils.SimpleStringSplitter splitter =
+ new TextUtils.SimpleStringSplitter(':');
+ splitter.setString(serviceNames);
+ while (splitter.hasNext()) {
+ final String str = splitter.next();
+ if (TextUtils.isEmpty(str)) {
+ continue;
+ }
+ delimitedServices.add(str);
+ }
+ }
+ String[] delimitedServicesArray = new String[delimitedServices.size()];
+ return delimitedServices.toArray(delimitedServicesArray);
+ }
+
}