Merge "Update summary for Passwords and Accounts." into sc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fd2300c..fee92e7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7814,10 +7814,10 @@
     <string name="app_and_notification_dashboard_summary">Recent apps, default apps</string>
     <!-- Toast shown when an app in the work profile attempts to open notification settings. The apps in the work profile cannot access notification settings. [CHAR LIMIT=NONE] -->
     <string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string>
-    <!-- Title for setting tile leading to saved autofill passwords, autofill , and account settings [CHAR LIMIT=40]-->
+    <!-- Title for setting tile leading to saved autofill passwords, autofill, and account settings [CHAR LIMIT=40]-->
     <string name="account_dashboard_title">Passwords and accounts</string>
-    <!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]-->
-    <string name="account_dashboard_default_summary">No accounts added</string>
+    <!-- Summary for setting tile leading to saved autofill passwords, autofill, and account settings [CHAR LIMIT=NONE]-->
+    <string name="account_dashboard_default_summary">Saved passwords, autofill, synced accounts</string>
     <!-- Title for setting tile leading to setting UI which allows user set default app to
     handle actions such as open web page, making phone calls, default SMS apps [CHAR  LIMIT=40]-->
     <string name="app_default_dashboard_title">Default apps</string>
diff --git a/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
index 7cd746f..174ef0f 100644
--- a/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
+++ b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
@@ -17,19 +17,11 @@
 package com.android.settings.accounts;
 
 import android.content.Context;
-import android.icu.text.ListFormatter;
-import android.os.UserHandle;
-import android.text.BidiFormatter;
-import android.text.TextUtils;
 import android.util.FeatureFlagUtils;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.core.FeatureFlags;
-import com.android.settingslib.accounts.AuthenticatorHelper;
-
-import java.util.ArrayList;
-import java.util.List;
 
 public class TopLevelAccountEntryPreferenceController extends BasePreferenceController {
     public TopLevelAccountEntryPreferenceController(Context context, String preferenceKey) {
@@ -47,29 +39,6 @@
         if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) {
             return null;
         }
-
-        final AuthenticatorHelper authHelper = new AuthenticatorHelper(mContext,
-                UserHandle.of(UserHandle.myUserId()), null /* OnAccountsUpdateListener */);
-        final String[] types = authHelper.getEnabledAccountTypes();
-        final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
-        final List<CharSequence> summaries = new ArrayList<>();
-
-        if (types == null || types.length == 0) {
-            summaries.add(mContext.getString(R.string.account_dashboard_default_summary));
-        } else {
-            // Show up to 3 account types, ignore any null value
-            int accountToAdd = Math.min(3, types.length);
-
-            for (int i = 0; i < types.length && accountToAdd > 0; i++) {
-                final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
-                if (TextUtils.isEmpty(label)) {
-                    continue;
-                }
-
-                summaries.add(bidiFormatter.unicodeWrap(label));
-                accountToAdd--;
-            }
-        }
-        return ListFormatter.getInstance().format(summaries);
+        return mContext.getString(R.string.account_dashboard_default_summary);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
index 3a67d7f..1d63cd1 100644
--- a/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java
@@ -23,64 +23,33 @@
 
 import com.android.settings.R;
 import com.android.settings.core.FeatureFlags;
-import com.android.settings.testutils.shadow.ShadowAuthenticationHelper;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowAuthenticationHelper.class})
 public class TopLevelAccountEntryPreferenceControllerTest {
 
     private TopLevelAccountEntryPreferenceController mController;
     private Context mContext;
-    private String[] LABELS;
-    private String[] TYPES;
 
     @Before
     public void setUp() {
         mContext = RuntimeEnvironment.application;
         mController = new TopLevelAccountEntryPreferenceController(mContext, "test_key");
-        LABELS = ShadowAuthenticationHelper.getLabels();
-        TYPES = ShadowAuthenticationHelper.getTypes();
         FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false);
     }
 
-    @After
-    public void tearDown() {
-        ShadowAuthenticationHelper.reset();
-    }
-
-    @Test
-    public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
-        assertThat(mController.getSummary())
-                .isEqualTo(LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]);
-    }
-
     @Test
     public void updateSummary_noAccount_shouldDisplayDefaultSummary() {
-        ShadowAuthenticationHelper.setEnabledAccount(null);
-
         assertThat(mController.getSummary()).isEqualTo(
                 mContext.getText(R.string.account_dashboard_default_summary));
     }
 
     @Test
-    public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() {
-        final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]};
-        ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts);
-
-
-        // should only show the 2 accounts with labels
-        assertThat(mController.getSummary()).isEqualTo(LABELS[0] + " and " + LABELS[1]);
-    }
-
-    @Test
     public void getSummary_silkyHomeEnabled_shouldBeNull() {
         FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, true);