diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java index 4ba634c56c8..182e5ae93bd 100644 --- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java +++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java @@ -302,8 +302,36 @@ public class CredentialManagerPreferenceController extends BasePreferenceControl null); } + private Set buildComponentNameSet(List providers) { + Set output = new HashSet<>(); + + for (CredentialProviderInfo cpi : providers) { + output.add(cpi.getComponentName()); + } + + return output; + } + private void updateFromExternal() { - update(); + if (mCredentialManager == null) { + return; + } + + // Get the list of new providers and components. + List newProviders = + mCredentialManager.getCredentialProviderServices( + getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY); + Set newComponents = buildComponentNameSet(newProviders); + + // Get the list of old components + Set oldComponents = buildComponentNameSet(mServices); + + // If the sets are equal then don't update the UI. + if (oldComponents.equals(newComponents)) { + return; + } + + setAvailableServices(newProviders, null); if (mPreferenceScreen != null) { displayPreference(mPreferenceScreen);