Use isPrimary bit to determine top provider

If the cred man provider has the isPrimary
bit set then we should use it as top
provider.

Test: ondevice
Bug: 280454916
Change-Id: I8c5651909d3926f09549c64af68185f1ef633198
This commit is contained in:
Becca Hughes
2023-05-03 19:28:40 +00:00
parent 69fcc2ba5c
commit 3096997718
4 changed files with 52 additions and 24 deletions

View File

@@ -47,7 +47,9 @@ import com.android.settingslib.utils.ThreadUtils;
import com.android.settingslib.widget.CandidateInfo;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class DefaultCombinedPicker extends DefaultAppPickerFragment {
@@ -338,9 +340,9 @@ public class DefaultCombinedPicker extends DefaultAppPickerFragment {
return true;
}
private void setProviders(String autofillProvider, List<String> credManProviders) {
private void setProviders(String autofillProvider, List<String> primaryCredManProviders) {
if (TextUtils.isEmpty(autofillProvider)) {
if (credManProviders.size() > 0) {
if (primaryCredManProviders.size() > 0) {
autofillProvider =
CredentialManagerPreferenceController
.AUTOFILL_CREDMAN_ONLY_PROVIDER_PLACEHOLDER;
@@ -350,13 +352,25 @@ public class DefaultCombinedPicker extends DefaultAppPickerFragment {
Settings.Secure.putStringForUser(
getContext().getContentResolver(), AUTOFILL_SETTING, autofillProvider, mUserId);
CredentialManager service = getCredentialProviderService();
final CredentialManager service = getCredentialProviderService();
if (service == null) {
return;
}
// Get the existing secondary providers since we don't touch them in
// this part of the UI we should just copy them over.
final List<String> credManProviders = new ArrayList<>();
for (CredentialProviderInfo cpi :
service.getCredentialProviderServices(
mUserId, CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY)) {
if (cpi.isEnabled()) {
credManProviders.add(cpi.getServiceInfo().getComponentName().flattenToString());
}
}
service.setEnabledProviders(
new ArrayList<String>(), // TODO(240466271): pass down primary providers.
primaryCredManProviders,
credManProviders,
mUserId,
ContextCompat.getMainExecutor(getContext()),