From 72dc40e42ed85f71ab80ca3ae4bfa8ab0ffccf45 Mon Sep 17 00:00:00 2001 From: Becca Hughes Date: Wed, 6 Sep 2023 14:12:20 -0700 Subject: [PATCH] Only update settings UI if data changes The flashing was caused by overzealous reloading which should be fixed by this CL. Test: flash device Bug: 299329723 Change-Id: I7d97da7f3c699ebea280a337bc64b8fe2f351126 --- ...CredentialManagerPreferenceController.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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);