aboutsummaryrefslogtreecommitdiff
path: root/car-lib
diff options
context:
space:
mode:
authorYing Zheng <yizheng@google.com>2018-06-07 14:08:41 -0700
committerYing Zheng <yizheng@google.com>2018-06-12 11:14:45 -0700
commitcab525e4725e0139a6617d582c93ccd1fe1614f2 (patch)
treed12e364e5868a713c322049e5eb341842481716f /car-lib
parent3883346b3154f82dd57b8e69f3018cfa1b30de16 (diff)
downloadCar-cab525e4725e0139a6617d582c93ccd1fe1614f2.tar.gz
Make default boot into user and last active user settable.
Bug: 79535271 78908507 Test: Build Change-Id: Ie30982b9b34a154faa580fff7a025b1d1be88e2d
Diffstat (limited to 'car-lib')
-rw-r--r--car-lib/src/android/car/settings/CarSettings.java30
-rw-r--r--car-lib/src/android/car/user/CarUserManagerHelper.java48
2 files changed, 63 insertions, 15 deletions
diff --git a/car-lib/src/android/car/settings/CarSettings.java b/car-lib/src/android/car/settings/CarSettings.java
index d7402b2605..f5e10378fa 100644
--- a/car-lib/src/android/car/settings/CarSettings.java
+++ b/car-lib/src/android/car/settings/CarSettings.java
@@ -45,6 +45,22 @@ public class CarSettings {
*/
public static final String KEY_GARAGE_MODE_MAINTENANCE_WINDOW =
"android.car.GARAGE_MODE_MAINTENANCE_WINDOW";
+
+ /**
+ * Key for default user id to boot into.
+ *
+ * @hide
+ */
+ public static final String DEFAULT_USER_ID_TO_BOOT_INTO =
+ "android.car.DEFAULT_BOOT_INTO_USER_ID";
+
+ /**
+ * Key for user id that is last logged in to.
+ *
+ * @hide
+ */
+ public static final String LAST_ACTIVE_USER_ID =
+ "android.car.LAST_ACTIVE_USER_ID";
}
/**
@@ -62,20 +78,6 @@ public class CarSettings {
public static final int DEFAULT_GARAGE_MODE_MAINTENANCE_WINDOW = 10 * 60 * 1000; // 10 mins
/**
- * Id for user that is set as default to boot into.
- *
- * @hide
- */
- public static final int DEFAULT_USER_ID_TO_BOOT_INTO = 10; // Default to first created user.
-
- /**
- * Id for user that is last logged in to.
- *
- * @hide
- */
- public static final int LAST_ACTIVE_USER_ID = 10; // Default to first created user.
-
- /**
* @hide
*/
public static final class Secure {
diff --git a/car-lib/src/android/car/user/CarUserManagerHelper.java b/car-lib/src/android/car/user/CarUserManagerHelper.java
index 4a69f0b738..b5cfa38926 100644
--- a/car-lib/src/android/car/user/CarUserManagerHelper.java
+++ b/car-lib/src/android/car/user/CarUserManagerHelper.java
@@ -29,6 +29,7 @@ import android.graphics.drawable.Drawable;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
+import android.provider.Settings;
import android.util.Log;
import com.android.internal.util.UserIcons;
@@ -91,6 +92,51 @@ public class CarUserManagerHelper {
}
/**
+ * Set default boot into user.
+ *
+ * @param userId default user id to boot into.
+ */
+ public void setDefaultBootUser(int userId) {
+ Settings.Global.putInt(
+ mContext.getContentResolver(),
+ CarSettings.Global.DEFAULT_USER_ID_TO_BOOT_INTO, userId);
+ }
+
+ /**
+ * Set last active user.
+ *
+ * @param userId last active user id.
+ */
+ public void setLastActiveUser(int userId) {
+ Settings.Global.putInt(
+ mContext.getContentResolver(), CarSettings.Global.LAST_ACTIVE_USER_ID, userId);
+ }
+
+ /**
+ * Get user id for the default boot into user.
+ *
+ * @return user id of the default boot into user
+ */
+ public int getDefaultBootUser() {
+ // Make user 10 the original default boot user.
+ return Settings.Global.getInt(
+ mContext.getContentResolver(), CarSettings.Global.DEFAULT_USER_ID_TO_BOOT_INTO,
+ /* default user id= */ 10);
+ }
+
+ /**
+ * Get user id for the last active user.
+ *
+ * @return user id of the last active user
+ */
+ public int getLastActiveUser() {
+ // Make user 10 the original default last active user.
+ return Settings.Global.getInt(
+ mContext.getContentResolver(), CarSettings.Global.LAST_ACTIVE_USER_ID,
+ /* default user id= */ 10);
+ }
+
+ /**
* Returns {@code true} if the system is in the headless user 0 model.
*
* @return {@boolean true} if headless system user.
@@ -234,7 +280,7 @@ public class CarUserManagerHelper {
* @return {@code true} if is default user, {@code false} otherwise.
*/
public boolean isDefaultUser(UserInfo userInfo) {
- return userInfo.id == CarSettings.DEFAULT_USER_ID_TO_BOOT_INTO;
+ return userInfo.id == getDefaultBootUser();
}
/**