Merge "Fix "Turn on phone calls" for guest user"

This commit is contained in:
Anna Bauza
2022-06-09 08:46:38 +00:00
committed by Android (Google) Code Review
10 changed files with 286 additions and 100 deletions

View File

@@ -7704,17 +7704,15 @@
<!-- Message of dialog shown when remove_guest_on_exit toggle is ON [CHAR LIMIT=NONE] -->
<string name="remove_guest_on_exit_dialog_message">Apps and data from this guest session will be
deleted now, and all future guest activity will be deleted each time you exit guest mode</string>
<!-- Title of preference to enable guest calling[CHAR LIMIT=40] -->
<string name="enable_guest_calling">Allow guest to use phone</string>
<!-- Summary of preference to enable guest calling [CHAR LIMIT=NONE] -->
<string name="enable_guest_calling_summary">Call history will be shared with guest user</string>
<!-- Title of preference to enable calling[CHAR LIMIT=40] -->
<string name="user_enable_calling">Turn on phone calls</string>
<!-- Title of preference to enable calling and SMS [CHAR LIMIT=45] -->
<string name="user_enable_calling_sms">Turn on phone calls &amp; SMS</string>
<!-- Title of preference to remove the user [CHAR LIMIT=35] -->
<string name="user_remove_user">Delete user</string>
<!-- Title for confirmation of turning on calls [CHAR LIMIT=40] -->
<string name="user_enable_calling_confirm_title">Turn on phone calls?</string>
<!-- Message for confirmation of turning on calls [CHAR LIMIT=none] -->
<string name="user_enable_calling_confirm_message">Call history will be shared with this user.</string>
<!-- Title for confirmation of turning on calls and SMS [CHAR LIMIT=45] -->
<string name="user_enable_calling_and_sms_confirm_title">Turn on phone calls &amp; SMS?</string>
<!-- Message for confirmation of turning on calls and SMS [CHAR LIMIT=none] -->

View File

@@ -78,6 +78,13 @@
android:summary="@string/remove_guest_on_exit_summary"
android:order="60"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="enable_guest_calling"
android:title="@string/enable_guest_calling"
android:summary="@string/enable_guest_calling_summary"
android:singleLineTitle="false"
android:order="65"/>
<com.android.settingslib.RestrictedSwitchPreference
android:key="user_settings_add_users_when_locked"
android:title="@string/user_add_on_lockscreen_menu"

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2022 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.users;
import android.content.Context;
import android.os.Bundle;
import android.os.UserManager;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
/**
* Controls the preference on the user settings screen which determines whether the guest user
* should have access to telephony or not.
*/
public class GuestTelephonyPreferenceController extends TogglePreferenceController {
private final UserManager mUserManager;
private final UserCapabilities mUserCaps;
private Bundle mDefaultGuestRestrictions;
public GuestTelephonyPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mUserManager = context.getSystemService(UserManager.class);
mUserCaps = UserCapabilities.create(context);
mDefaultGuestRestrictions = mUserManager.getDefaultGuestRestrictions();
mDefaultGuestRestrictions.putBoolean(UserManager.DISALLOW_SMS, true);
}
@Override
public int getAvailabilityStatus() {
if (!mUserCaps.isAdmin() || !mUserCaps.mCanAddGuest) {
return DISABLED_FOR_USER;
} else {
return mUserCaps.mUserSwitcherEnabled ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
}
@Override
public boolean isChecked() {
return !mDefaultGuestRestrictions.getBoolean(UserManager.DISALLOW_OUTGOING_CALLS, false);
}
@Override
public boolean setChecked(boolean isChecked) {
mDefaultGuestRestrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS, !isChecked);
mUserManager.setDefaultGuestRestrictions(mDefaultGuestRestrictions);
return true;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_system;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
mUserCaps.updateAddUserCapabilities(mContext);
preference.setVisible(isAvailable() && mUserCaps.mUserSwitcherEnabled);
}
}

View File

@@ -42,7 +42,6 @@ import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -69,11 +68,10 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
static final String EXTRA_USER_ID = "user_id";
private static final int DIALOG_CONFIRM_REMOVE = 1;
private static final int DIALOG_CONFIRM_ENABLE_CALLING = 2;
private static final int DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS = 3;
private static final int DIALOG_SETUP_USER = 4;
private static final int DIALOG_CONFIRM_RESET_GUEST = 5;
private static final int DIALOG_CONFIRM_RESET_GUEST_AND_SWITCH_USER = 6;
private static final int DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS = 2;
private static final int DIALOG_SETUP_USER = 3;
private static final int DIALOG_CONFIRM_RESET_GUEST = 4;
private static final int DIALOG_CONFIRM_RESET_GUEST_AND_SWITCH_USER = 5;
/** Whether to enable the app_copying fragment. */
private static final boolean SHOW_APP_COPYING_PREF = false;
@@ -97,7 +95,6 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
@VisibleForTesting
/** The user being studied (not the user doing the studying). */
UserInfo mUserInfo;
private Bundle mDefaultGuestRestrictions;
@Override
public int getMetricsCategory() {
@@ -165,12 +162,13 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (Boolean.TRUE.equals(newValue)) {
showDialog(mUserInfo.isGuest() ? DIALOG_CONFIRM_ENABLE_CALLING
: DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS);
return false;
if (preference == mPhonePref) {
if (Boolean.TRUE.equals(newValue)) {
showDialog(DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS);
return false;
}
enableCallsAndSms(false);
}
enableCallsAndSms(false);
return true;
}
@@ -181,8 +179,6 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
case DIALOG_CONFIRM_RESET_GUEST:
case DIALOG_CONFIRM_RESET_GUEST_AND_SWITCH_USER:
return SettingsEnums.DIALOG_USER_REMOVE;
case DIALOG_CONFIRM_ENABLE_CALLING:
return SettingsEnums.DIALOG_USER_ENABLE_CALLING;
case DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS:
return SettingsEnums.DIALOG_USER_ENABLE_CALLING_AND_SMS;
case DIALOG_SETUP_USER:
@@ -202,9 +198,6 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
case DIALOG_CONFIRM_REMOVE:
return UserDialogs.createRemoveDialog(getActivity(), mUserInfo.id,
(dialog, which) -> removeUser());
case DIALOG_CONFIRM_ENABLE_CALLING:
return UserDialogs.createEnablePhoneCallsDialog(getActivity(),
(dialog, which) -> enableCallsAndSms(true));
case DIALOG_CONFIRM_ENABLE_CALLING_AND_SMS:
return UserDialogs.createEnablePhoneCallsAndSmsDialog(getActivity(),
(dialog, which) -> enableCallsAndSms(true));
@@ -308,13 +301,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
}
if (mUserInfo.isGuest()) {
// These are not for an existing user, just general Guest settings.
// Default title is for calling and SMS. Change to calling-only here
// TODO(b/191483069): These settings can't be changed unless guest user exists
mPhonePref.setTitle(R.string.user_enable_calling);
mDefaultGuestRestrictions = mUserManager.getDefaultGuestRestrictions();
mPhonePref.setChecked(
!mDefaultGuestRestrictions.getBoolean(UserManager.DISALLOW_OUTGOING_CALLS));
removePreference(KEY_ENABLE_TELEPHONY);
mRemoveUserPref.setTitle(mGuestUserAutoCreated
? com.android.settingslib.R.string.guest_reset_guest
: com.android.settingslib.R.string.guest_exit_guest);
@@ -397,31 +384,9 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
private void enableCallsAndSms(boolean enabled) {
mPhonePref.setChecked(enabled);
if (mUserInfo.isGuest()) {
mDefaultGuestRestrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS, !enabled);
// SMS is always disabled for guest
mDefaultGuestRestrictions.putBoolean(UserManager.DISALLOW_SMS, true);
mUserManager.setDefaultGuestRestrictions(mDefaultGuestRestrictions);
// Update the guest's restrictions, if there is a guest
// TODO: Maybe setDefaultGuestRestrictions() can internally just set the restrictions
// on any existing guest rather than do it here with multiple Binder calls.
List<UserInfo> users = mUserManager.getAliveUsers();
for (UserInfo user : users) {
if (user.isGuest()) {
UserHandle userHandle = UserHandle.of(user.id);
for (String key : mDefaultGuestRestrictions.keySet()) {
mUserManager.setUserRestriction(
key, mDefaultGuestRestrictions.getBoolean(key), userHandle);
}
}
}
} else {
UserHandle userHandle = UserHandle.of(mUserInfo.id);
mUserManager.setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, !enabled,
userHandle);
mUserManager.setUserRestriction(UserManager.DISALLOW_SMS, !enabled, userHandle);
}
UserHandle userHandle = UserHandle.of(mUserInfo.id);
mUserManager.setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, !enabled, userHandle);
mUserManager.setUserRestriction(UserManager.DISALLOW_SMS, !enabled, userHandle);
}
private void removeUser() {

View File

@@ -145,21 +145,6 @@ public final class UserDialogs {
.create();
}
/**
* Creates a dialog to confirm that the user is ok to enable phone calls (no SMS).
*
* @param onConfirmListener Callback object for positive action
*/
public static Dialog createEnablePhoneCallsDialog(Context context,
DialogInterface.OnClickListener onConfirmListener) {
return new AlertDialog.Builder(context)
.setTitle(R.string.user_enable_calling_confirm_title)
.setMessage(R.string.user_enable_calling_confirm_message)
.setPositiveButton(R.string.okay, onConfirmListener)
.setNegativeButton(android.R.string.cancel, null)
.create();
}
/**
* Creates a dialog to confirm that the user is ok to start setting up a new user.
*

View File

@@ -125,6 +125,7 @@ public class UserSettings extends SettingsPreferenceFragment
private static final String KEY_ADD_USER = "user_add";
private static final String KEY_ADD_SUPERVISED_USER = "supervised_user_add";
private static final String KEY_ADD_USER_WHEN_LOCKED = "user_settings_add_users_when_locked";
private static final String KEY_ENABLE_GUEST_TELEPHONY = "enable_guest_calling";
private static final String KEY_MULTIUSER_TOP_INTRO = "multiuser_top_intro";
private static final String KEY_TIMEOUT_TO_USER_ZERO = "timeout_to_user_zero_preference";
private static final String KEY_GUEST_CATEGORY = "guest_category";
@@ -215,6 +216,7 @@ public class UserSettings extends SettingsPreferenceFragment
private EditUserInfoController mEditUserInfoController =
new EditUserInfoController(Utils.FILE_PROVIDER_AUTHORITY);
private AddUserWhenLockedPreferenceController mAddUserWhenLockedPreferenceController;
private GuestTelephonyPreferenceController mGuestTelephonyPreferenceController;
private RemoveGuestOnExitPreferenceController mRemoveGuestOnExitPreferenceController;
private MultiUserTopIntroPreferenceController mMultiUserTopIntroPreferenceController;
private TimeoutToUserZeroPreferenceController mTimeoutToUserZeroPreferenceController;
@@ -310,6 +312,9 @@ public class UserSettings extends SettingsPreferenceFragment
mAddUserWhenLockedPreferenceController = new AddUserWhenLockedPreferenceController(
activity, KEY_ADD_USER_WHEN_LOCKED);
mGuestTelephonyPreferenceController = new GuestTelephonyPreferenceController(
activity, KEY_ENABLE_GUEST_TELEPHONY);
mRemoveGuestOnExitPreferenceController = new RemoveGuestOnExitPreferenceController(
activity, KEY_REMOVE_GUEST_ON_EXIT, this, mHandler);
@@ -321,6 +326,7 @@ public class UserSettings extends SettingsPreferenceFragment
final PreferenceScreen screen = getPreferenceScreen();
mAddUserWhenLockedPreferenceController.displayPreference(screen);
mGuestTelephonyPreferenceController.displayPreference(screen);
mRemoveGuestOnExitPreferenceController.displayPreference(screen);
mMultiUserTopIntroPreferenceController.displayPreference(screen);
mTimeoutToUserZeroPreferenceController.displayPreference(screen);
@@ -328,6 +334,9 @@ public class UserSettings extends SettingsPreferenceFragment
screen.findPreference(mAddUserWhenLockedPreferenceController.getPreferenceKey())
.setOnPreferenceChangeListener(mAddUserWhenLockedPreferenceController);
screen.findPreference(mGuestTelephonyPreferenceController.getPreferenceKey())
.setOnPreferenceChangeListener(mGuestTelephonyPreferenceController);
screen.findPreference(mRemoveGuestOnExitPreferenceController.getPreferenceKey())
.setOnPreferenceChangeListener(mRemoveGuestOnExitPreferenceController);
@@ -397,6 +406,8 @@ public class UserSettings extends SettingsPreferenceFragment
mAddUserWhenLockedPreferenceController.updateState(screen.findPreference(
mAddUserWhenLockedPreferenceController.getPreferenceKey()));
mGuestTelephonyPreferenceController.updateState(screen.findPreference(
mGuestTelephonyPreferenceController.getPreferenceKey()));
mTimeoutToUserZeroPreferenceController.updateState(screen.findPreference(
mTimeoutToUserZeroPreferenceController.getPreferenceKey()));
mRemoveGuestOnExitPreferenceController.updateState(screen.findPreference(
@@ -1302,9 +1313,13 @@ public class UserSettings extends SettingsPreferenceFragment
mAddUserWhenLockedPreferenceController.getPreferenceKey());
mAddUserWhenLockedPreferenceController.updateState(addUserOnLockScreen);
final Preference multiUserTopIntroPrefence = getPreferenceScreen().findPreference(
final Preference guestCallPreference = getPreferenceScreen().findPreference(
mGuestTelephonyPreferenceController.getPreferenceKey());
mGuestTelephonyPreferenceController.updateState(guestCallPreference);
final Preference multiUserTopIntroPreference = getPreferenceScreen().findPreference(
mMultiUserTopIntroPreferenceController.getPreferenceKey());
mMultiUserTopIntroPreferenceController.updateState(multiUserTopIntroPrefence);
mMultiUserTopIntroPreferenceController.updateState(multiUserTopIntroPreference);
mUserListCategory.setVisible(mUserCaps.mUserSwitcherEnabled);
updateGuestPreferences();
updateGuestCategory(context, users);

View File

@@ -47,7 +47,6 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
private static final int PRIMARY_USER_ID = 0;
private final List<String> mBaseRestrictions = new ArrayList<>();
private final List<String> mGuestRestrictions = new ArrayList<>();
private final Map<String, List<EnforcingUser>> mRestrictionSources = new HashMap<>();
private final List<UserInfo> mUserProfileInfos = new ArrayList<>();
private final Set<Integer> mManagedProfiles = new HashSet<>();
@@ -55,6 +54,7 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
private boolean mIsQuietModeEnabled = false;
private int[] profileIdsForUser = new int[0];
private boolean mUserSwitchEnabled;
private Bundle mDefaultGuestUserRestriction = new Bundle();
private @UserManager.UserSwitchabilityResult int mSwitchabilityStatus =
UserManager.SWITCHABILITY_STATUS_OK;
@@ -99,15 +99,24 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
@Implementation
protected Bundle getDefaultGuestRestrictions() {
Bundle bundle = new Bundle();
mGuestRestrictions.forEach(restriction -> bundle.putBoolean(restriction, true));
return bundle;
return mDefaultGuestUserRestriction;
}
@Implementation
protected void setDefaultGuestRestrictions(Bundle restrictions) {
mDefaultGuestUserRestriction = restrictions;
}
public void addGuestUserRestriction(String restriction) {
mGuestRestrictions.add(restriction);
mDefaultGuestUserRestriction.putBoolean(restriction, true);
}
public boolean hasGuestUserRestriction(String restriction, boolean expectedValue) {
return mDefaultGuestUserRestriction.containsKey(restriction)
&& mDefaultGuestUserRestriction.getBoolean(restriction) == expectedValue;
}
@Implementation
protected boolean hasUserRestriction(String restrictionKey) {
return hasUserRestriction(restrictionKey, UserHandle.of(UserHandle.myUserId()));

View File

@@ -0,0 +1,150 @@
/*
* Copyright (C) 2022 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.users;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.os.SystemProperties;
import android.os.UserManager;
import androidx.preference.PreferenceScreen;
import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedSwitchPreference;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
ShadowUserManager.class,
ShadowDevicePolicyManager.class
})
public class GuestTelephonyPreferenceControllerTest {
@Mock(answer = RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen;
@Mock(answer = RETURNS_DEEP_STUBS)
private Context mContext;
private ShadowUserManager mUserManager;
private ShadowDevicePolicyManager mDpm;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mUserManager = ShadowUserManager.getShadow();
mUserManager.setSupportsMultipleUsers(true);
mDpm = ShadowDevicePolicyManager.getShadow();
}
@After
public void tearDown() {
ShadowUserManager.reset();
}
@Test
public void displayPref_NotAdmin_shouldNotDisplay() {
mUserManager.setIsAdminUser(false);
final GuestTelephonyPreferenceController controller =
new GuestTelephonyPreferenceController(mContext, "fake_key");
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
when(preference.getKey()).thenReturn(controller.getPreferenceKey());
when(mScreen.findPreference(preference.getKey())).thenReturn(preference);
controller.displayPreference(mScreen);
verify(preference).setVisible(false);
}
@Test
public void updateState_NotAdmin_shouldNotDisplayPreference() {
mUserManager.setIsAdminUser(false);
final GuestTelephonyPreferenceController controller =
new GuestTelephonyPreferenceController(mContext, "fake_key");
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
controller.updateState(preference);
verify(preference).setVisible(false);
}
@Test
public void updateState_Admin_shouldDisplayPreference() {
SystemProperties.set("fw.max_users", Long.toBinaryString(4));
mDpm.setDeviceOwner(null);
mUserManager.setIsAdminUser(true);
mUserManager.setUserSwitcherEnabled(true);
mUserManager.setSupportsMultipleUsers(true);
mUserManager.setUserTypeEnabled(UserManager.USER_TYPE_FULL_RESTRICTED, true);
mUserManager.setUserTypeEnabled(UserManager.USER_TYPE_FULL_SYSTEM, true);
mUserManager.setUserTypeEnabled(UserManager.USER_TYPE_FULL_GUEST, true);
final GuestTelephonyPreferenceController controller =
new GuestTelephonyPreferenceController(mContext, "fake_key");
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
controller.updateState(preference);
verify(preference).setVisible(true);
}
@Test
public void setChecked_Guest_hasNoCallRestriction() {
mUserManager.setIsAdminUser(true);
final GuestTelephonyPreferenceController controller =
new GuestTelephonyPreferenceController(mContext, "fake_key");
controller.setChecked(true);
assertThat(mUserManager.hasGuestUserRestriction("no_outgoing_calls", false)).isTrue();
assertThat(mUserManager.hasGuestUserRestriction("no_sms", true)).isTrue();
}
@Test
public void setUnchecked_Guest_hasCallRestriction() {
mUserManager.setIsAdminUser(true);
final GuestTelephonyPreferenceController controller =
new GuestTelephonyPreferenceController(mContext, "fake_key");
controller.setChecked(false);
assertThat(mUserManager.hasGuestUserRestriction("no_outgoing_calls", true)).isTrue();
assertThat(mUserManager.hasGuestUserRestriction("no_sms", true)).isTrue();
}
}

View File

@@ -420,29 +420,6 @@ public class UserDetailsSettingsTest {
verify(mPhonePref).setChecked(true);
}
@Test
public void initialize_guestSelected_noCallRestriction_shouldSetPhonePreference() {
setupSelectedGuest();
mUserManager.setIsAdminUser(true);
mFragment.initialize(mActivity, mArguments);
verify(mPhonePref).setTitle(R.string.user_enable_calling);
verify(mPhonePref).setChecked(true);
}
@Test
public void initialize_guestSelected_callRestriction_shouldSetPhonePreference() {
setupSelectedGuest();
mUserManager.setIsAdminUser(true);
mUserManager.addGuestUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
mFragment.initialize(mActivity, mArguments);
verify(mPhonePref).setTitle(R.string.user_enable_calling);
verify(mPhonePref).setChecked(false);
}
@Test
public void initialize_switchUserDisallowed_shouldSetAdminDisabledOnSwitchPreference() {
setupSelectedUser();

View File

@@ -146,6 +146,8 @@ public class UserSettingsTest {
mFragment = spy(new UserSettings());
ReflectionHelpers.setField(mFragment, "mAddUserWhenLockedPreferenceController",
mock(AddUserWhenLockedPreferenceController.class));
ReflectionHelpers.setField(mFragment, "mGuestTelephonyPreferenceController",
mock(GuestTelephonyPreferenceController.class));
ReflectionHelpers.setField(mFragment, "mMultiUserTopIntroPreferenceController",
mock(MultiUserTopIntroPreferenceController.class));
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);