Merge "Revert "Test Fix SettingRobolectricTest Fail"" into main
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index 4ba634c..182e5ae 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -302,8 +302,36 @@
                 null);
     }
 
+    private Set<ComponentName> buildComponentNameSet(List<CredentialProviderInfo> providers) {
+        Set<ComponentName> 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<CredentialProviderInfo> newProviders =
+                mCredentialManager.getCredentialProviderServices(
+                        getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY);
+        Set<ComponentName> newComponents = buildComponentNameSet(newProviders);
+
+        // Get the list of old components
+        Set<ComponentName> 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);