Merge Autofill settings into Account settings.
Autofill settings are removed from Language and Input.
They are now in a new top-level Passwords and Accounts page.
Some polish work is left to match the new design.
Bug: 169455298
Test: manual - check settings page and some search keywords
Test: manual - add work profile and check the above again
Test: make RunSettingsRoboTests
Change-Id: I3981ce73fef63f06a40e61e894481d24284614ba
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7c2cc67..e78761a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7764,8 +7764,8 @@
<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 account settings [CHAR LIMIT=40]-->
- <string name="account_dashboard_title">Accounts</string>
+ <!-- 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>
<!-- Title for setting tile leading to setting UI which allows user set default app to
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index d2affc7..c8627e7 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -22,14 +22,38 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
+
+ <PreferenceCategory
+ android:key="default_service_category"
+ android:order="20"
+ android:title="@string/autofill_app">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_main"
+ android:title="@string/autofill_app"
+ settings:keywords="@string/autofill_keywords">
+ <extra
+ android:name="for_work"
+ android:value="false" />
+ </com.android.settings.widget.GearPreference>
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:order="130"/>
<SwitchPreference
android:key="auto_sync_account_data"
android:title="@string/auto_sync_account_title"
android:summary="@string/auto_sync_account_summary"
- android:order="102"
+ android:order="202"
settings:allowDividerAbove="true"/>
<SwitchPreference
@@ -37,12 +61,12 @@
android:title="@string/account_settings_menu_auto_sync_work"
android:summary="@string/auto_sync_account_summary"
settings:forWork="true"
- android:order="103"/>
+ android:order="203"/>
<SwitchPreference
android:key="auto_sync_personal_account_data"
android:title="@string/account_settings_menu_auto_sync_personal"
android:summary="@string/auto_sync_account_summary"
- android:order="104"/>
+ android:order="204"/>
</PreferenceScreen>
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
index db57e3d..3d88cf9 100644
--- a/res/xml/accounts_personal_dashboard_settings.xml
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
+ <PreferenceCategory
+ android:key="default_service_category"
+ android:order="20"
+ android:title="@string/autofill_app">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_main"
+ android:title="@string/autofill_app"
+ settings:keywords="@string/autofill_keywords">
+ <extra
+ android:name="for_work"
+ android:value="false" />
+ </com.android.settings.widget.GearPreference>
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="accounts_category"
android:order="100"
- settings:allowDividerAbove="true"/>
+ android:title="@string/account_settings">
- <SwitchPreference
- android:key="auto_sync_personal_account_data"
- android:title="@string/account_settings_menu_auto_sync_personal"
- android:summary="@string/auto_sync_account_summary"
- android:order="110"/>
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="200"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_personal_account_data"
+ android:title="@string/account_settings_menu_auto_sync_personal"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="210"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
index b27357d..29e71e2 100644
--- a/res/xml/accounts_work_dashboard_settings.xml
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
+ <com.android.settings.widget.WorkOnlyCategory
+ android:key="autofill_work_app_defaults"
+ android:order="30"
+ android:title="@string/default_for_work">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_work"
+ android:title="@string/autofill_app"
+ settings:searchable="false">
+ <extra
+ android:name="for_work"
+ android:value="true" />
+ </com.android.settings.widget.GearPreference>
+ </com.android.settings.widget.WorkOnlyCategory>
+
+ <PreferenceCategory
+ android:key="accounts_category"
android:order="100"
- settings:allowDividerAbove="true"/>
+ android:title="@string/account_settings">
- <SwitchPreference
- android:key="auto_sync_work_account_data"
- android:title="@string/account_settings_menu_auto_sync_work"
- android:summary="@string/auto_sync_account_summary"
- android:order="110"/>
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="200"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_work_account_data"
+ android:title="@string/account_settings_menu_auto_sync_work"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="210"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/default_autofill_picker_settings.xml b/res/xml/default_autofill_picker_settings.xml
deleted file mode 100644
index 392f733..0000000
--- a/res/xml/default_autofill_picker_settings.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="default_autofill_picker"
- android:title="@string/autofill_app"
- settings:keywords="@string/autofill_keywords">
-
- <PreferenceCategory
- android:key="passwords_category"
- android:persistent="false"
- android:title="@string/autofill_passwords"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController" >
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="default_service_category"
- android:title="@string/autofill_app">
-
- <!-- TODO(b/169455298): Fix the redundant title. -->
- <com.android.settings.widget.GearPreference
- android:key="default_autofill_main"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:searchable="false"
- settings:keywords="@string/autofill_keywords">
- <extra android:name="for_work" android:value="false" />
- </com.android.settings.widget.GearPreference>
- </PreferenceCategory>
-
-
- <com.android.settings.widget.WorkOnlyCategory
- android:key="autofill_work_app_defaults"
- android:title="@string/default_for_work">
-
- <com.android.settings.widget.GearPreference
- android:key="default_autofill_work"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:searchable="false"
- settings:keywords="@string/autofill_keywords">
- <extra android:name="for_work" android:value="true" />
- </com.android.settings.widget.GearPreference>
- </com.android.settings.widget.WorkOnlyCategory>
-</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 50968d9..d7b8364 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -54,12 +54,6 @@
android:persistent="false"
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings" />
- <Preference
- android:key="default_autofill"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.AutofillPicker"
- settings:keywords="@string/autofill_keywords" />
-
<!-- User dictionary preference title and fragment will be set programmatically. -->
<Preference
android:key="key_user_dictionary_settings"
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 7b50b46..9e232f4 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -27,6 +27,8 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
+import com.android.settings.applications.defaultapps.DefaultWorkAutofillPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -68,14 +70,22 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ static void buildAutofillPreferenceControllers(
+ Context context, List<AbstractPreferenceController> controllers) {
+ controllers.add(new DefaultAutofillPreferenceController(context));
+ controllers.add(new DefaultWorkAutofillPreferenceController(context));
+ }
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.ALL);
@@ -86,7 +96,6 @@
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
- return controllers;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -95,8 +104,11 @@
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(
- context, null /* parent */, null /* authorities*/);
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAccountPreferenceControllers(
+ context, null /* parent */, null /* authorities*/, controllers);
+ buildAutofillPreferenceControllers(context, controllers);
+ return controllers;
}
@Override
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index f29326e..c97c886 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -18,6 +18,8 @@
import static android.provider.Settings.EXTRA_AUTHORITIES;
+import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
-
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.PERSONAL);
@@ -78,7 +82,6 @@
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
- return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
+// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index ff5bc78..64c2d13 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -75,11 +75,12 @@
private static final String TAG = "AccountPrefController";
- private static final int ORDER_ACCOUNT_PROFILES = 1;
+ private static final int ORDER_ACCOUNT_PROFILES = 101;
private static final int ORDER_LAST = 1002;
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";
@@ -348,8 +349,10 @@
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
- if (screen != null) {
- screen.addPreference(preferenceGroup);
+ final PreferenceGroup accounts =
+ screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
+ if (accounts != null) {
+ accounts.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index 853c66b..4e6515b 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -18,6 +18,8 @@
import static android.provider.Settings.EXTRA_AUTHORITIES;
+import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
-
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.WORK);
@@ -78,7 +82,6 @@
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
- return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
+// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }
diff --git a/src/com/android/settings/applications/defaultapps/AutofillPicker.java b/src/com/android/settings/applications/defaultapps/AutofillPicker.java
deleted file mode 100644
index 62a478f..0000000
--- a/src/com/android/settings/applications/defaultapps/AutofillPicker.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.defaultapps;
-
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.search.SearchIndexable;
-
-import java.util.Arrays;
-import java.util.List;
-
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
-public class AutofillPicker extends DashboardFragment {
- private static final String TAG = "AutofillPicker";
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.DEFAULT_AUTOFILL_PICKER;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.default_autofill_picker_settings;
- }
-
- @Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context);
- }
-
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.default_autofill_picker_settings) {
-
- @Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context
- context) {
- return buildPreferenceControllers(context);
- }
- };
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
- return Arrays.asList(
- new DefaultAutofillPreferenceController(context),
- new DefaultWorkAutofillPreferenceController(context));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index b22b156..4b6a6a8 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -39,6 +39,7 @@
import android.text.TextUtils;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
@@ -72,9 +73,13 @@
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;
@@ -95,6 +100,9 @@
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]);
@@ -166,6 +174,7 @@
// 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));
@@ -184,6 +193,7 @@
// 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));