diff options
author | Ying Zheng <yizheng@google.com> | 2018-06-12 20:47:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-06-12 20:47:56 +0000 |
commit | 7fe1d624cf3150fb6520cb7f7e6f13bcbe083401 (patch) | |
tree | b1adb18244e94b6188f70a9a1e4c61994efc60fd /car-lib/src/android | |
parent | 31682e5b8f34363372f390e2a75173ff59084126 (diff) | |
parent | cab525e4725e0139a6617d582c93ccd1fe1614f2 (diff) | |
download | Car-7fe1d624cf3150fb6520cb7f7e6f13bcbe083401.tar.gz |
Merge "Make default boot into user and last active user settable." into pi-dev
Diffstat (limited to 'car-lib/src/android')
-rw-r--r-- | car-lib/src/android/car/settings/CarSettings.java | 30 | ||||
-rw-r--r-- | car-lib/src/android/car/user/CarUserManagerHelper.java | 48 |
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 05a238e639..423223913f 100644 --- a/car-lib/src/android/car/user/CarUserManagerHelper.java +++ b/car-lib/src/android/car/user/CarUserManagerHelper.java @@ -31,6 +31,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; @@ -93,6 +94,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. @@ -237,7 +283,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(); } /** |