Merge "Default to timing out to dock user in 1 minute" into tm-qpr-dev am: 0be191aeb7 am: 26343e8926

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20683709

Change-Id: I63dedfa49ec3d7c64c156d6a5da33772abfcc4b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/settings/users/TimeoutToDockUserSettings.java b/src/com/android/settings/users/TimeoutToDockUserSettings.java
index bb61b67..60bbdbb 100644
--- a/src/com/android/settings/users/TimeoutToDockUserSettings.java
+++ b/src/com/android/settings/users/TimeoutToDockUserSettings.java
@@ -37,7 +37,8 @@
  */
 public class TimeoutToDockUserSettings extends RadioButtonPickerFragment {
     // 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;
+    // Default to the smallest non-zero option (which is currently 1 minute).
+    public static final int DEFAULT_TIMEOUT_SETTING_VALUE_INDEX = 1;
 
     // Labels of the options, for example, "never", "after 5 minutes".
     private String[] mEntries;
diff --git a/tests/robotests/src/com/android/settings/users/TimeoutToDockUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/users/TimeoutToDockUserPreferenceControllerTest.java
index 2c93e94..774117f 100644
--- a/tests/robotests/src/com/android/settings/users/TimeoutToDockUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/users/TimeoutToDockUserPreferenceControllerTest.java
@@ -124,7 +124,8 @@
         Settings.Secure.putStringForUser(mContext.getContentResolver(), TIMEOUT_TO_DOCK_USER,
                 null, UserHandle.myUserId());
 
-        assertThat(mController.getSummary().toString()).isEqualTo(mEntries[0]);
+        assertThat(mController.getSummary().toString()).isEqualTo(
+                mEntries[TimeoutToDockUserSettings.DEFAULT_TIMEOUT_SETTING_VALUE_INDEX]);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/users/TimeoutToDockUserSettingsTest.java b/tests/robotests/src/com/android/settings/users/TimeoutToDockUserSettingsTest.java
index 55b630d..6c95fce 100644
--- a/tests/robotests/src/com/android/settings/users/TimeoutToDockUserSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/users/TimeoutToDockUserSettingsTest.java
@@ -78,8 +78,9 @@
     }
 
     @Test
-    public void defaultKey_settingNotSet_shouldReturnFirstValueAsDefault() {
-        assertThat(mSettings.getDefaultKey()).isEqualTo(mValues[0]);
+    public void defaultKey_settingNotSet_shouldReturnSecondValueAsDefault() {
+        assertThat(mSettings.getDefaultKey()).isEqualTo(
+                mValues[TimeoutToDockUserSettings.DEFAULT_TIMEOUT_SETTING_VALUE_INDEX]);
     }
 
     @Test
@@ -95,4 +96,11 @@
         mSettings.setDefaultKey(expectedKey);
         assertThat(mSettings.getDefaultKey()).isEqualTo(expectedKey);
     }
+
+    @Test
+    public void defaultKey_setToThirdValue_shouldSaveToSettings() {
+        final String expectedKey = mValues[2];
+        mSettings.setDefaultKey(expectedKey);
+        assertThat(mSettings.getDefaultKey()).isEqualTo(expectedKey);
+    }
 }