Merge "Introduce concept of DockUser"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2c45688a13
@@ -1305,15 +1305,15 @@
|
|||||||
<item>1</item>
|
<item>1</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Setting entries for timing out to user 0 when docked. -->
|
<!-- Setting entries for timing out to the Dock User when docked. -->
|
||||||
<string-array name="switch_to_user_zero_when_docked_timeout_entries">
|
<string-array name="switch_to_dock_user_when_docked_timeout_entries">
|
||||||
<item>Never</item>
|
<item>Never</item>
|
||||||
<item>After 1 minute</item>
|
<item>After 1 minute</item>
|
||||||
<item>After 5 minutes</item>
|
<item>After 5 minutes</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Setting values for timing out to user 0 when docked. [DO NOT TRANSLATE] -->
|
<!-- Setting values for timing out to the Dock User when docked. [DO NOT TRANSLATE] -->
|
||||||
<string-array name="switch_to_user_zero_when_docked_timeout_values" translatable="false">
|
<string-array name="switch_to_dock_user_when_docked_timeout_values" translatable="false">
|
||||||
<!-- Never -->
|
<!-- Never -->
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<!-- 1 minute -->
|
<!-- 1 minute -->
|
||||||
|
@@ -5818,9 +5818,10 @@
|
|||||||
<string name="user_lockscreen_settings">Lock screen settings</string>
|
<string name="user_lockscreen_settings">Lock screen settings</string>
|
||||||
<!-- User settings item to allow creating new users from locks screen [CHAR LIMIT=50] -->
|
<!-- User settings item to allow creating new users from locks screen [CHAR LIMIT=50] -->
|
||||||
<string name="user_add_on_lockscreen_menu">Add users from lock screen</string>
|
<string name="user_add_on_lockscreen_menu">Add users from lock screen</string>
|
||||||
<!-- User settings item to allow the system to automatically switch back to the admin user when
|
<!-- TODO(b/257333623): HSUM has no 1:1 admin:dream relationship. There can even be >1 admin -->
|
||||||
|
<!-- User settings item to allow the system to automatically switch back to the Dock User when
|
||||||
the device is docked. [CHAR LIMIT=50] -->
|
the device is docked. [CHAR LIMIT=50] -->
|
||||||
<string name="switch_to_user_zero_when_docked">Switch to admin user when docked</string>
|
<string name="switch_to_dock_user_when_docked">Switch to admin user when docked</string>
|
||||||
|
|
||||||
<!-- User (self) removal confirmation title [CHAR LIMIT=30] -->
|
<!-- User (self) removal confirmation title [CHAR LIMIT=30] -->
|
||||||
<string name="user_confirm_remove_self_title">Delete yourself?</string>
|
<string name="user_confirm_remove_self_title">Delete yourself?</string>
|
||||||
|
@@ -94,10 +94,10 @@
|
|||||||
settings:allowDividerAbove="true"/>
|
settings:allowDividerAbove="true"/>
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="timeout_to_user_zero_preference"
|
android:key="timeout_to_dock_user_preference"
|
||||||
android:title="@string/switch_to_user_zero_when_docked"
|
android:title="@string/switch_to_dock_user_when_docked"
|
||||||
android:order="106"
|
android:order="106"
|
||||||
android:fragment="com.android.settings.users.TimeoutToUserZeroSettings"
|
android:fragment="com.android.settings.users.TimeoutToDockUserSettings"
|
||||||
settings:controller="com.android.settings.users.TimeoutToUserZeroPreferenceController"/>
|
settings:controller="com.android.settings.users.TimeoutToDockUserPreferenceController"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -17,4 +17,4 @@
|
|||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:title="@string/switch_to_user_zero_when_docked"/>
|
android:title="@string/switch_to_dock_user_when_docked"/>
|
@@ -39,9 +39,10 @@ public class ScreenSaverPreferenceController extends AbstractPreferenceControlle
|
|||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
final boolean dreamsSupported = mContext.getResources().getBoolean(
|
final boolean dreamsSupported = mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsSupported);
|
com.android.internal.R.bool.config_dreamsSupported);
|
||||||
final boolean dreamsOnlyEnabledForSystemUser = mContext.getResources().getBoolean(
|
final boolean dreamsOnlyEnabledForDockUser = mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForSystemUser);
|
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser);
|
||||||
return dreamsSupported && (!dreamsOnlyEnabledForSystemUser || isSystemUser());
|
// TODO(b/257333623): Allow the Dock User to be non-SystemUser user in HSUM.
|
||||||
|
return dreamsSupported && (!dreamsOnlyEnabledForDockUser || isSystemUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.users;
|
package com.android.settings.users;
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.TIMEOUT_TO_USER_ZERO;
|
import static android.provider.Settings.Secure.TIMEOUT_TO_DOCK_USER;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -30,20 +30,20 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the preference which launches a settings screen for user to configure whether to
|
* Controls the preference which launches a settings screen for user to configure whether to
|
||||||
* automatically switch to the admin user when the device is docked.
|
* automatically switch to the designated Dock User when the device is docked.
|
||||||
*/
|
*/
|
||||||
public class TimeoutToUserZeroPreferenceController extends BasePreferenceController {
|
public class TimeoutToDockUserPreferenceController extends BasePreferenceController {
|
||||||
private final String[] mEntries;
|
private final String[] mEntries;
|
||||||
private final String[] mValues;
|
private final String[] mValues;
|
||||||
|
|
||||||
public TimeoutToUserZeroPreferenceController(Context context,
|
public TimeoutToDockUserPreferenceController(Context context,
|
||||||
String preferenceKey) {
|
String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
|
|
||||||
mEntries = mContext.getResources().getStringArray(
|
mEntries = mContext.getResources().getStringArray(
|
||||||
com.android.settings.R.array.switch_to_user_zero_when_docked_timeout_entries);
|
com.android.settings.R.array.switch_to_dock_user_when_docked_timeout_entries);
|
||||||
mValues = mContext.getResources().getStringArray(
|
mValues = mContext.getResources().getStringArray(
|
||||||
com.android.settings.R.array.switch_to_user_zero_when_docked_timeout_values);
|
com.android.settings.R.array.switch_to_dock_user_when_docked_timeout_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,7 +57,7 @@ public class TimeoutToUserZeroPreferenceController extends BasePreferenceControl
|
|||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
// Feature not available on device.
|
// Feature not available on device.
|
||||||
if (!mContext.getResources().getBoolean(
|
if (!mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_enableTimeoutToUserZeroWhenDocked)) {
|
com.android.internal.R.bool.config_enableTimeoutToDockUserWhenDocked)) {
|
||||||
return UNSUPPORTED_ON_DEVICE;
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +68,7 @@ public class TimeoutToUserZeroPreferenceController extends BasePreferenceControl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is currently user zero. Only non user zero can have this setting.
|
// Is currently user zero. Only non user zero can have this setting.
|
||||||
|
// TODO(b/257333623): Allow the Dock User to be non-SystemUser user in HSUM.
|
||||||
if (UserHandle.myUserId() == UserHandle.USER_SYSTEM) {
|
if (UserHandle.myUserId() == UserHandle.USER_SYSTEM) {
|
||||||
return DISABLED_FOR_USER;
|
return DISABLED_FOR_USER;
|
||||||
}
|
}
|
||||||
@@ -78,9 +79,9 @@ public class TimeoutToUserZeroPreferenceController extends BasePreferenceControl
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
final String key = Settings.Secure.getStringForUser(mContext.getContentResolver(),
|
final String key = Settings.Secure.getStringForUser(mContext.getContentResolver(),
|
||||||
TIMEOUT_TO_USER_ZERO, UserHandle.myUserId());
|
TIMEOUT_TO_DOCK_USER, UserHandle.myUserId());
|
||||||
final int index = Arrays.asList(mValues).indexOf(key != null ? key :
|
final int index = Arrays.asList(mValues).indexOf(key != null ? key :
|
||||||
mValues[TimeoutToUserZeroSettings.DEFAULT_TIMEOUT_SETTING_VALUE_INDEX]);
|
mValues[TimeoutToDockUserSettings.DEFAULT_TIMEOUT_SETTING_VALUE_INDEX]);
|
||||||
|
|
||||||
return mEntries[index];
|
return mEntries[index];
|
||||||
}
|
}
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.users;
|
package com.android.settings.users;
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.TIMEOUT_TO_USER_ZERO;
|
import static android.provider.Settings.Secure.TIMEOUT_TO_DOCK_USER;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -33,9 +33,9 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting screen that lists options for users to configure whether to automatically switch to the
|
* Setting screen that lists options for users to configure whether to automatically switch to the
|
||||||
* admin user when the device is docked, and if so duration of the timeout.
|
* Dock User when the device is docked, and if so duration of the timeout.
|
||||||
*/
|
*/
|
||||||
public class TimeoutToUserZeroSettings extends RadioButtonPickerFragment {
|
public class TimeoutToDockUserSettings extends RadioButtonPickerFragment {
|
||||||
// Index of the default key of the timeout setting if it hasn't been changed by the user.
|
// Index of the default key of the timeout setting if it hasn't been changed by the user.
|
||||||
public static final int DEFAULT_TIMEOUT_SETTING_VALUE_INDEX = 0;
|
public static final int DEFAULT_TIMEOUT_SETTING_VALUE_INDEX = 0;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class TimeoutToUserZeroSettings extends RadioButtonPickerFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return R.xml.user_timeout_to_user_zero_settings;
|
return R.xml.user_timeout_to_dock_user_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,9 +60,9 @@ public class TimeoutToUserZeroSettings extends RadioButtonPickerFragment {
|
|||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
mEntries = getContext().getResources().getStringArray(
|
mEntries = getContext().getResources().getStringArray(
|
||||||
R.array.switch_to_user_zero_when_docked_timeout_entries);
|
R.array.switch_to_dock_user_when_docked_timeout_entries);
|
||||||
mValues = getContext().getResources().getStringArray(
|
mValues = getContext().getResources().getStringArray(
|
||||||
R.array.switch_to_user_zero_when_docked_timeout_values);
|
R.array.switch_to_dock_user_when_docked_timeout_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -83,13 +83,13 @@ public class TimeoutToUserZeroSettings extends RadioButtonPickerFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected String getDefaultKey() {
|
protected String getDefaultKey() {
|
||||||
final String defaultKey = Settings.Secure.getStringForUser(
|
final String defaultKey = Settings.Secure.getStringForUser(
|
||||||
getContext().getContentResolver(), TIMEOUT_TO_USER_ZERO, UserHandle.myUserId());
|
getContext().getContentResolver(), TIMEOUT_TO_DOCK_USER, UserHandle.myUserId());
|
||||||
return defaultKey != null ? defaultKey : mValues[DEFAULT_TIMEOUT_SETTING_VALUE_INDEX];
|
return defaultKey != null ? defaultKey : mValues[DEFAULT_TIMEOUT_SETTING_VALUE_INDEX];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean setDefaultKey(String key) {
|
protected boolean setDefaultKey(String key) {
|
||||||
Settings.Secure.putStringForUser(getContext().getContentResolver(), TIMEOUT_TO_USER_ZERO,
|
Settings.Secure.putStringForUser(getContext().getContentResolver(), TIMEOUT_TO_DOCK_USER,
|
||||||
key, UserHandle.myUserId());
|
key, UserHandle.myUserId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@@ -127,7 +127,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_ADD_USER_WHEN_LOCKED = "user_settings_add_users_when_locked";
|
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_ENABLE_GUEST_TELEPHONY = "enable_guest_calling";
|
||||||
private static final String KEY_MULTIUSER_TOP_INTRO = "multiuser_top_intro";
|
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_TIMEOUT_TO_DOCK_USER = "timeout_to_dock_user_preference";
|
||||||
private static final String KEY_GUEST_CATEGORY = "guest_category";
|
private static final String KEY_GUEST_CATEGORY = "guest_category";
|
||||||
private static final String KEY_GUEST_RESET = "guest_reset";
|
private static final String KEY_GUEST_RESET = "guest_reset";
|
||||||
private static final String KEY_GUEST_EXIT = "guest_exit";
|
private static final String KEY_GUEST_EXIT = "guest_exit";
|
||||||
@@ -220,7 +220,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
private GuestTelephonyPreferenceController mGuestTelephonyPreferenceController;
|
private GuestTelephonyPreferenceController mGuestTelephonyPreferenceController;
|
||||||
private RemoveGuestOnExitPreferenceController mRemoveGuestOnExitPreferenceController;
|
private RemoveGuestOnExitPreferenceController mRemoveGuestOnExitPreferenceController;
|
||||||
private MultiUserTopIntroPreferenceController mMultiUserTopIntroPreferenceController;
|
private MultiUserTopIntroPreferenceController mMultiUserTopIntroPreferenceController;
|
||||||
private TimeoutToUserZeroPreferenceController mTimeoutToUserZeroPreferenceController;
|
private TimeoutToDockUserPreferenceController mTimeoutToDockUserPreferenceController;
|
||||||
private UserCreatingDialog mUserCreatingDialog;
|
private UserCreatingDialog mUserCreatingDialog;
|
||||||
private final AtomicBoolean mGuestCreationScheduled = new AtomicBoolean();
|
private final AtomicBoolean mGuestCreationScheduled = new AtomicBoolean();
|
||||||
private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
|
private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
|
||||||
@@ -322,15 +322,15 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
mMultiUserTopIntroPreferenceController = new MultiUserTopIntroPreferenceController(activity,
|
mMultiUserTopIntroPreferenceController = new MultiUserTopIntroPreferenceController(activity,
|
||||||
KEY_MULTIUSER_TOP_INTRO);
|
KEY_MULTIUSER_TOP_INTRO);
|
||||||
|
|
||||||
mTimeoutToUserZeroPreferenceController = new TimeoutToUserZeroPreferenceController(activity,
|
mTimeoutToDockUserPreferenceController = new TimeoutToDockUserPreferenceController(
|
||||||
KEY_TIMEOUT_TO_USER_ZERO);
|
activity, KEY_TIMEOUT_TO_DOCK_USER);
|
||||||
|
|
||||||
final PreferenceScreen screen = getPreferenceScreen();
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
mAddUserWhenLockedPreferenceController.displayPreference(screen);
|
mAddUserWhenLockedPreferenceController.displayPreference(screen);
|
||||||
mGuestTelephonyPreferenceController.displayPreference(screen);
|
mGuestTelephonyPreferenceController.displayPreference(screen);
|
||||||
mRemoveGuestOnExitPreferenceController.displayPreference(screen);
|
mRemoveGuestOnExitPreferenceController.displayPreference(screen);
|
||||||
mMultiUserTopIntroPreferenceController.displayPreference(screen);
|
mMultiUserTopIntroPreferenceController.displayPreference(screen);
|
||||||
mTimeoutToUserZeroPreferenceController.displayPreference(screen);
|
mTimeoutToDockUserPreferenceController.displayPreference(screen);
|
||||||
|
|
||||||
screen.findPreference(mAddUserWhenLockedPreferenceController.getPreferenceKey())
|
screen.findPreference(mAddUserWhenLockedPreferenceController.getPreferenceKey())
|
||||||
.setOnPreferenceChangeListener(mAddUserWhenLockedPreferenceController);
|
.setOnPreferenceChangeListener(mAddUserWhenLockedPreferenceController);
|
||||||
@@ -409,8 +409,8 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
mAddUserWhenLockedPreferenceController.getPreferenceKey()));
|
mAddUserWhenLockedPreferenceController.getPreferenceKey()));
|
||||||
mGuestTelephonyPreferenceController.updateState(screen.findPreference(
|
mGuestTelephonyPreferenceController.updateState(screen.findPreference(
|
||||||
mGuestTelephonyPreferenceController.getPreferenceKey()));
|
mGuestTelephonyPreferenceController.getPreferenceKey()));
|
||||||
mTimeoutToUserZeroPreferenceController.updateState(screen.findPreference(
|
mTimeoutToDockUserPreferenceController.updateState(screen.findPreference(
|
||||||
mTimeoutToUserZeroPreferenceController.getPreferenceKey()));
|
mTimeoutToDockUserPreferenceController.getPreferenceKey()));
|
||||||
mRemoveGuestOnExitPreferenceController.updateState(screen.findPreference(
|
mRemoveGuestOnExitPreferenceController.updateState(screen.findPreference(
|
||||||
mRemoveGuestOnExitPreferenceController.getPreferenceKey()));
|
mRemoveGuestOnExitPreferenceController.getPreferenceKey()));
|
||||||
if (mShouldUpdateUserList) {
|
if (mShouldUpdateUserList) {
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.users;
|
package com.android.settings.users;
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.TIMEOUT_TO_USER_ZERO;
|
import static android.provider.Settings.Secure.TIMEOUT_TO_DOCK_USER;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -45,12 +45,12 @@ import org.robolectric.annotation.Config;
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowSecureSettings.class, ShadowUserHandle.class})
|
@Config(shadows = {ShadowSecureSettings.class, ShadowUserHandle.class})
|
||||||
public class TimeoutToUserZeroPreferenceControllerTest {
|
public class TimeoutToDockUserPreferenceControllerTest {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Resources mResources;
|
private Resources mResources;
|
||||||
private TimeoutToUserZeroPreferenceController mController;
|
private TimeoutToDockUserPreferenceController mController;
|
||||||
|
|
||||||
private static final String FAKE_PREFERENCE_KEY = "timeout_to_user_zero_preference";
|
private static final String FAKE_PREFERENCE_KEY = "timeout_to_dock_user_preference";
|
||||||
|
|
||||||
private String[] mEntries;
|
private String[] mEntries;
|
||||||
private String[] mValues;
|
private String[] mValues;
|
||||||
@@ -62,15 +62,15 @@ public class TimeoutToUserZeroPreferenceControllerTest {
|
|||||||
doReturn(mResources).when(mContext).getResources();
|
doReturn(mResources).when(mContext).getResources();
|
||||||
|
|
||||||
mEntries = mResources.getStringArray(
|
mEntries = mResources.getStringArray(
|
||||||
R.array.switch_to_user_zero_when_docked_timeout_entries);
|
R.array.switch_to_dock_user_when_docked_timeout_entries);
|
||||||
mValues = mResources.getStringArray(
|
mValues = mResources.getStringArray(
|
||||||
R.array.switch_to_user_zero_when_docked_timeout_values);
|
R.array.switch_to_dock_user_when_docked_timeout_values);
|
||||||
|
|
||||||
mController = new TimeoutToUserZeroPreferenceController(mContext, FAKE_PREFERENCE_KEY);
|
mController = new TimeoutToDockUserPreferenceController(mContext, FAKE_PREFERENCE_KEY);
|
||||||
|
|
||||||
// Feature enabled.
|
// Feature enabled.
|
||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_enableTimeoutToUserZeroWhenDocked)).thenReturn(
|
com.android.internal.R.bool.config_enableTimeoutToDockUserWhenDocked)).thenReturn(
|
||||||
true);
|
true);
|
||||||
|
|
||||||
// Multi-user feature enabled.
|
// Multi-user feature enabled.
|
||||||
@@ -89,7 +89,7 @@ public class TimeoutToUserZeroPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_featureFlagDisabled_returnUnsupportedOnDevice() {
|
public void getAvailabilityStatus_featureFlagDisabled_returnUnsupportedOnDevice() {
|
||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_enableTimeoutToUserZeroWhenDocked)).thenReturn(
|
com.android.internal.R.bool.config_enableTimeoutToDockUserWhenDocked)).thenReturn(
|
||||||
false);
|
false);
|
||||||
|
|
||||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
@@ -121,7 +121,7 @@ public class TimeoutToUserZeroPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_settingNotSet() {
|
public void getSummary_settingNotSet() {
|
||||||
Settings.Secure.putStringForUser(mContext.getContentResolver(), TIMEOUT_TO_USER_ZERO,
|
Settings.Secure.putStringForUser(mContext.getContentResolver(), TIMEOUT_TO_DOCK_USER,
|
||||||
null, UserHandle.myUserId());
|
null, UserHandle.myUserId());
|
||||||
|
|
||||||
assertThat(mController.getSummary().toString()).isEqualTo(mEntries[0]);
|
assertThat(mController.getSummary().toString()).isEqualTo(mEntries[0]);
|
||||||
@@ -129,7 +129,7 @@ public class TimeoutToUserZeroPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_setToNever() {
|
public void getSummary_setToNever() {
|
||||||
Settings.Secure.putStringForUser(mContext.getContentResolver(), TIMEOUT_TO_USER_ZERO,
|
Settings.Secure.putStringForUser(mContext.getContentResolver(), TIMEOUT_TO_DOCK_USER,
|
||||||
mValues[0], UserHandle.myUserId());
|
mValues[0], UserHandle.myUserId());
|
||||||
|
|
||||||
assertThat(mController.getSummary().toString()).isEqualTo(mEntries[0]);
|
assertThat(mController.getSummary().toString()).isEqualTo(mEntries[0]);
|
||||||
@@ -137,7 +137,7 @@ public class TimeoutToUserZeroPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSummary_setToOneMinute() {
|
public void getSummary_setToOneMinute() {
|
||||||
Settings.Secure.putStringForUser(mContext.getContentResolver(), TIMEOUT_TO_USER_ZERO,
|
Settings.Secure.putStringForUser(mContext.getContentResolver(), TIMEOUT_TO_DOCK_USER,
|
||||||
mValues[1], UserHandle.myUserId());
|
mValues[1], UserHandle.myUserId());
|
||||||
|
|
||||||
assertThat(mController.getSummary().toString()).isEqualTo(mEntries[1]);
|
assertThat(mController.getSummary().toString()).isEqualTo(mEntries[1]);
|
@@ -42,11 +42,11 @@ import java.util.List;
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowFragment.class})
|
@Config(shadows = {ShadowFragment.class})
|
||||||
public class TimeoutToUserZeroSettingsTest {
|
public class TimeoutToDockUserSettingsTest {
|
||||||
@Mock
|
@Mock
|
||||||
private FragmentActivity mActivity;
|
private FragmentActivity mActivity;
|
||||||
|
|
||||||
private TimeoutToUserZeroSettings mSettings;
|
private TimeoutToDockUserSettings mSettings;
|
||||||
|
|
||||||
private String[] mEntries;
|
private String[] mEntries;
|
||||||
private String[] mValues;
|
private String[] mValues;
|
||||||
@@ -57,10 +57,10 @@ public class TimeoutToUserZeroSettingsTest {
|
|||||||
|
|
||||||
final Context context = spy(ApplicationProvider.getApplicationContext());
|
final Context context = spy(ApplicationProvider.getApplicationContext());
|
||||||
mEntries = context.getResources().getStringArray(
|
mEntries = context.getResources().getStringArray(
|
||||||
R.array.switch_to_user_zero_when_docked_timeout_entries);
|
R.array.switch_to_dock_user_when_docked_timeout_entries);
|
||||||
mValues = context.getResources().getStringArray(
|
mValues = context.getResources().getStringArray(
|
||||||
R.array.switch_to_user_zero_when_docked_timeout_values);
|
R.array.switch_to_dock_user_when_docked_timeout_values);
|
||||||
mSettings = spy(new TimeoutToUserZeroSettings());
|
mSettings = spy(new TimeoutToDockUserSettings());
|
||||||
|
|
||||||
doReturn(context).when(mSettings).getContext();
|
doReturn(context).when(mSettings).getContext();
|
||||||
doReturn(mActivity).when(mSettings).getActivity();
|
doReturn(mActivity).when(mSettings).getActivity();
|
@@ -60,7 +60,7 @@ public class ScreenSaverPreferenceControllerTest {
|
|||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForSystemUser))
|
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
when(mUserManager.isSystemUser()).thenReturn(true);
|
when(mUserManager.isSystemUser()).thenReturn(true);
|
||||||
assertTrue(mController.isAvailable());
|
assertTrue(mController.isAvailable());
|
||||||
@@ -71,7 +71,7 @@ public class ScreenSaverPreferenceControllerTest {
|
|||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForSystemUser))
|
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
when(mUserManager.isSystemUser()).thenReturn(false);
|
when(mUserManager.isSystemUser()).thenReturn(false);
|
||||||
assertTrue(mController.isAvailable());
|
assertTrue(mController.isAvailable());
|
||||||
@@ -82,7 +82,7 @@ public class ScreenSaverPreferenceControllerTest {
|
|||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(false);
|
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(false);
|
||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForSystemUser))
|
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser))
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
when(mUserManager.isSystemUser()).thenReturn(true);
|
when(mUserManager.isSystemUser()).thenReturn(true);
|
||||||
assertFalse(mController.isAvailable());
|
assertFalse(mController.isAvailable());
|
||||||
@@ -93,7 +93,7 @@ public class ScreenSaverPreferenceControllerTest {
|
|||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForSystemUser))
|
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
when(mUserManager.isSystemUser()).thenReturn(true);
|
when(mUserManager.isSystemUser()).thenReturn(true);
|
||||||
assertTrue(mController.isAvailable());
|
assertTrue(mController.isAvailable());
|
||||||
@@ -104,7 +104,7 @@ public class ScreenSaverPreferenceControllerTest {
|
|||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
com.android.internal.R.bool.config_dreamsSupported)).thenReturn(true);
|
||||||
when(mResources.getBoolean(
|
when(mResources.getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForSystemUser))
|
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
when(mUserManager.isSystemUser()).thenReturn(false);
|
when(mUserManager.isSystemUser()).thenReturn(false);
|
||||||
assertFalse(mController.isAvailable());
|
assertFalse(mController.isAvailable());
|
||||||
|
Reference in New Issue
Block a user