Merge "DO NOT MERGE Hide provider from this list if autofill provider" into udc-dev

This commit is contained in:
Becca Hughes
2023-04-27 16:35:18 +00:00
committed by Android (Google) Code Review
2 changed files with 40 additions and 0 deletions

View File

@@ -376,6 +376,10 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl
Map<String, List<CredentialProviderInfo>> groupedInfos = new HashMap<>();
for (CredentialProviderInfo cpi : mServices) {
String packageName = cpi.getServiceInfo().packageName;
if (isProviderHiddenBecauseOfAutofill(packageName)) {
continue;
}
if (!groupedInfos.containsKey(packageName)) {
groupedInfos.put(packageName, new ArrayList<>());
}
@@ -579,6 +583,23 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl
return new NewProviderConfirmationDialogFragment(host, packageName, appName);
}
/** If the provider is also the autofill provider then hide it. */
@VisibleForTesting
public boolean isProviderHiddenBecauseOfAutofill(String packageName) {
final String autofillService = Settings.Secure.getStringForUser(
mContext.getContentResolver(),
Settings.Secure.AUTOFILL_SERVICE,
getUser());
if (autofillService == null || TextUtils.isEmpty(autofillService)) {
return false;
}
if (packageName == null || TextUtils.isEmpty(packageName)) {
return false;
}
return autofillService.startsWith(packageName);
}
@VisibleForTesting
void completeEnableProviderDialogBox(
int whichButton, String packageName, boolean setActivityResult) {