Snap for 11464157 from f1c1e011b239a9d423da2bf16cd663319d1e5377 to 24Q2-release
Change-Id: Iac59c2fd0dc2d243c1f584957b948ebe0aecced3
diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml
index dfc9596..1e83e22 100644
--- a/res/layout/search_bar.xml
+++ b/res/layout/search_bar.xml
@@ -34,6 +34,9 @@
android:paddingStart="@dimen/search_bar_padding_start"
android:paddingEnd="@dimen/search_bar_padding_end"
android:background="@drawable/search_bar_selected_background"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:nextFocusForward="@+id/homepage_container"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search">
<TextView
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index be0658e..e16219b 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -166,7 +166,7 @@
return CONDITIONALLY_UNAVAILABLE;
}
- if (mServices.isEmpty()) {
+ if (!hasNonPrimaryServices()) {
return CONDITIONALLY_UNAVAILABLE;
}
@@ -428,6 +428,17 @@
}
}
+ @VisibleForTesting
+ public boolean hasNonPrimaryServices() {
+ for (CredentialProviderInfo availableService : mServices) {
+ if (!availableService.isPrimary()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
index 0a04a73..c0023ee 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
@@ -529,6 +529,23 @@
}
@Test
+ public void hasNonPrimaryServices_allServicesArePrimary() {
+ CredentialManagerPreferenceController controller =
+ createControllerWithServices(
+ Lists.newArrayList(createCredentialProviderPrimary()));
+ assertThat(controller.hasNonPrimaryServices()).isFalse();
+ }
+
+ @Test
+ public void hasNonPrimaryServices_mixtureOfServices() {
+ CredentialManagerPreferenceController controller =
+ createControllerWithServices(
+ Lists.newArrayList(createCredentialProviderInfo(),
+ createCredentialProviderPrimary()));
+ assertThat(controller.hasNonPrimaryServices()).isTrue();
+ }
+
+ @Test
public void testProviderLimitReached() {
// The limit is 5 with one slot reserved for primary.
assertThat(CredentialManagerPreferenceController.hasProviderLimitBeenReached(0)).isFalse();
@@ -580,6 +597,13 @@
.build();
}
+ private CredentialProviderInfo createCredentialProviderPrimary() {
+ return createCredentialProviderInfoBuilder(
+ "com.android.primary", "CredManProvider", "Service Label", "App Name")
+ .setPrimary(true)
+ .build();
+ }
+
private CredentialProviderInfo createCredentialProviderInfoWithSubtitle(
String packageName, String className, CharSequence label, CharSequence subtitle) {
ServiceInfo si = new ServiceInfo();