diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index c50eca4761c..c8627e7e9e7 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -46,33 +46,27 @@
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
-
+
-
+
-
-
-
-
+
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
index 3d88cf9ec12..e0ba71bbef3 100644
--- a/res/xml/accounts_personal_dashboard_settings.xml
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -47,26 +47,20 @@
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
-
+
-
-
-
-
+
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
index 29e71e28258..1c4c6aa3f3d 100644
--- a/res/xml/accounts_work_dashboard_settings.xml
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -33,7 +33,7 @@
+ android:title="@string/autofill_app">
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
-
+
-
-
-
-
+
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 036df276877..42b2334f232 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -80,7 +80,6 @@ public class AccountPreferenceController extends AbstractPreferenceController
private static final int ORDER_NEXT_TO_LAST = 1001;
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
- private static final String PREF_KEY_ACCOUNTS = "accounts_category";
private static final String PREF_KEY_ADD_ACCOUNT = "add_account";
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
@@ -324,6 +323,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
mHelper.createAccessiblePreferenceCategory(
mFragment.getPreferenceManager().getContext());
preferenceGroup.setOrder(mAccountProfileOrder++);
+ preferenceGroup.setTitle(R.string.account_settings); // default title; may be modified below
if (isSingleProfile()) {
final String title = context.getString(R.string.account_for_section_header,
BidiFormatter.getInstance().unicodeWrap(userInfo.name));
@@ -349,10 +349,8 @@ public class AccountPreferenceController extends AbstractPreferenceController
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
- final PreferenceGroup accounts =
- screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
- if (accounts != null) {
- accounts.addPreference(preferenceGroup);
+ if (screen != null) {
+ screen.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index 4b6a6a8d702..b22b1562be2 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -39,7 +39,6 @@ import android.os.UserManager;
import android.text.TextUtils;
import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
@@ -73,13 +72,9 @@ import java.util.List;
ShadowSettingsLibUtils.class})
public class AccountPreferenceControllerTest {
- private static final String PREF_KEY_ACCOUNTS = "accounts_category";
-
@Mock(answer = RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen;
@Mock(answer = RETURNS_DEEP_STUBS)
- private PreferenceCategory mAccountsCategory;
- @Mock(answer = RETURNS_DEEP_STUBS)
private UserManager mUserManager;
@Mock(answer = RETURNS_DEEP_STUBS)
private SettingsPreferenceFragment mFragment;
@@ -100,9 +95,6 @@ public class AccountPreferenceControllerTest {
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
- // This is a bit ugly, but hard to avoid because of how the mocks are used in these tests.
- // TODO: Refactor these tests to not use RETURNS_DEEP_STUBS.
- when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
.thenReturn(new AuthenticatorDescription[0]);
@@ -174,7 +166,6 @@ public class AccountPreferenceControllerTest {
// First time resume will build the UI
mController.onResume();
reset(mScreen);
- when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
mController.onResume();
verify(mScreen, never()).addPreference(any(PreferenceGroup.class));
@@ -193,7 +184,6 @@ public class AccountPreferenceControllerTest {
// add a new profile
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
reset(mScreen);
- when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
mController.onResume();
verify(mScreen, times(1)).addPreference(any(PreferenceGroup.class));