Loading core/res/res/values/config.xml +6 −0 Original line number Diff line number Diff line Loading @@ -3529,6 +3529,12 @@ <!-- If true, all guest users created on the device will be ephemeral. --> <bool name="config_guestUserEphemeral">false</bool> <!-- Whether device should always have a guest user available. If true, guest user will be created on boot, and a new guest user will be created in the background anytime the current guest user is removed. Instead of showing "Add guest" and "Remove guest", the UI will show "Guest" and "Reset guest". --> <bool name="config_guestUserAutoCreated">false</bool> <!-- Enforce strong auth on boot. Setting this to false represents a security risk and should not be ordinarily done. The only case in which this might be permissible is in a car head unit where there are hardware mechanisms to protect the device (physical keys) and not Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,7 @@ <java-symbol type="bool" name="config_supportsSystemDecorsOnSecondaryDisplays" /> <java-symbol type="bool" name="config_supportsInsecureLockScreen" /> <java-symbol type="bool" name="config_guestUserEphemeral" /> <java-symbol type="bool" name="config_guestUserAutoCreated" /> <java-symbol type="bool" name="config_localDisplaysMirrorContent" /> <java-symbol type="array" name="config_localPrivateDisplayPorts" /> <java-symbol type="integer" name="config_defaultDisplayDefaultColorMode" /> Loading packages/SettingsLib/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1422,6 +1422,8 @@ <string name="guest_new_guest">Add guest</string> <!-- Label for exiting and removing the guest session in the user switcher [CHAR LIMIT=35] --> <string name="guest_exit_guest">Remove guest</string> <!-- Label for resetting guest session in the user switcher, which will remove all data from the current guest session [CHAR LIMIT=35] --> <string name="guest_reset_guest">Reset guest</string> <!-- Name for the guest user [CHAR LIMIT=35] --> <string name="guest_nickname">Guest</string> Loading packages/SystemUI/res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -1148,12 +1148,18 @@ <!-- Title of the confirmation dialog when exiting guest session [CHAR LIMIT=NONE] --> <string name="guest_exit_guest_dialog_title">Remove guest?</string> <!-- Title of the confirmation dialog when resetting guest session [CHAR LIMIT=NONE] --> <string name="guest_reset_guest_dialog_title">Reset guest?</string> <!-- Message of the confirmation dialog when exiting guest session [CHAR LIMIT=NONE] --> <string name="guest_exit_guest_dialog_message">All apps and data in this session will be deleted.</string> <!-- Label for button in confirmation dialog when exiting guest session [CHAR LIMIT=35] --> <string name="guest_exit_guest_dialog_remove">Remove</string> <!-- Label for button in confirmation dialog when resetting guest session [CHAR LIMIT=35] --> <string name="guest_reset_guest_dialog_remove">Reset</string> <!-- Title of the notification when resuming an existing guest session [CHAR LIMIT=NONE] --> <string name="guest_wipe_session_title">Welcome back, guest!</string> Loading packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java +12 −54 Original line number Diff line number Diff line Loading @@ -27,15 +27,14 @@ import android.content.IntentFilter; import android.content.pm.UserInfo; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.util.Log; import android.view.WindowManagerGlobal; import com.android.internal.logging.UiEventLogger; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.qs.QSUserSwitcherEvent; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.statusbar.policy.UserSwitcherController; /** * Manages notification when a guest session is resumed. Loading @@ -47,9 +46,12 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { private static final String SETTING_GUEST_HAS_LOGGED_IN = "systemui.guest_has_logged_in"; private Dialog mNewSessionDialog; private final UserSwitcherController mUserSwitcherController; private final UiEventLogger mUiEventLogger; public GuestResumeSessionReceiver(UiEventLogger uiEventLogger) { public GuestResumeSessionReceiver(UserSwitcherController userSwitcherController, UiEventLogger uiEventLogger) { mUserSwitcherController = userSwitcherController; mUiEventLogger = uiEventLogger; } Loading Loading @@ -90,7 +92,8 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { int notFirstLogin = Settings.System.getIntForUser( cr, SETTING_GUEST_HAS_LOGGED_IN, 0, userId); if (notFirstLogin != 0) { mNewSessionDialog = new ResetSessionDialog(context, mUiEventLogger, userId); mNewSessionDialog = new ResetSessionDialog(context, mUserSwitcherController, mUiEventLogger, userId); mNewSessionDialog.show(); } else { Settings.System.putIntForUser( Loading @@ -99,54 +102,6 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { } } /** * Wipes the guest session. * * The guest must be the current user and its id must be {@param userId}. */ private static void wipeGuestSession(Context context, int userId) { UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); UserInfo currentUser; try { currentUser = ActivityManager.getService().getCurrentUser(); } catch (RemoteException e) { Log.e(TAG, "Couldn't wipe session because ActivityManager is dead"); return; } if (currentUser.id != userId) { Log.w(TAG, "User requesting to start a new session (" + userId + ")" + " is not current user (" + currentUser.id + ")"); return; } if (!currentUser.isGuest()) { Log.w(TAG, "User requesting to start a new session (" + userId + ")" + " is not a guest"); return; } boolean marked = userManager.markGuestForDeletion(currentUser.id); if (!marked) { Log.w(TAG, "Couldn't mark the guest for deletion for user " + userId); return; } UserInfo newGuest = userManager.createGuest(context, currentUser.name); try { if (newGuest == null) { Log.e(TAG, "Could not create new guest, switching back to system user"); ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM); userManager.removeUser(currentUser.id); WindowManagerGlobal.getWindowManagerService().lockNow(null /* options */); return; } ActivityManager.getService().switchUser(newGuest.id); userManager.removeUser(currentUser.id); } catch (RemoteException e) { Log.e(TAG, "Couldn't wipe session because ActivityManager or WindowManager is dead"); return; } } private void cancelDialog() { if (mNewSessionDialog != null && mNewSessionDialog.isShowing()) { mNewSessionDialog.cancel(); Loading @@ -160,10 +115,12 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { private static final int BUTTON_WIPE = BUTTON_NEGATIVE; private static final int BUTTON_DONTWIPE = BUTTON_POSITIVE; private final UserSwitcherController mUserSwitcherController; private final UiEventLogger mUiEventLogger; private final int mUserId; ResetSessionDialog(Context context, UiEventLogger uiEventLogger, int userId) { ResetSessionDialog(Context context, UserSwitcherController userSwitcherController, UiEventLogger uiEventLogger, int userId) { super(context); setTitle(context.getString(R.string.guest_wipe_session_title)); Loading @@ -175,6 +132,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { setButton(BUTTON_DONTWIPE, context.getString(R.string.guest_wipe_session_dontwipe), this); mUserSwitcherController = userSwitcherController; mUiEventLogger = uiEventLogger; mUserId = userId; } Loading @@ -183,7 +141,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { public void onClick(DialogInterface dialog, int which) { if (which == BUTTON_WIPE) { mUiEventLogger.log(QSUserSwitcherEvent.QS_USER_GUEST_WIPE); wipeGuestSession(getContext(), mUserId); mUserSwitcherController.removeGuestUser(mUserId, UserHandle.USER_NULL); dismiss(); } else if (which == BUTTON_DONTWIPE) { mUiEventLogger.log(QSUserSwitcherEvent.QS_USER_GUEST_CONTINUE); Loading Loading
core/res/res/values/config.xml +6 −0 Original line number Diff line number Diff line Loading @@ -3529,6 +3529,12 @@ <!-- If true, all guest users created on the device will be ephemeral. --> <bool name="config_guestUserEphemeral">false</bool> <!-- Whether device should always have a guest user available. If true, guest user will be created on boot, and a new guest user will be created in the background anytime the current guest user is removed. Instead of showing "Add guest" and "Remove guest", the UI will show "Guest" and "Reset guest". --> <bool name="config_guestUserAutoCreated">false</bool> <!-- Enforce strong auth on boot. Setting this to false represents a security risk and should not be ordinarily done. The only case in which this might be permissible is in a car head unit where there are hardware mechanisms to protect the device (physical keys) and not Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,7 @@ <java-symbol type="bool" name="config_supportsSystemDecorsOnSecondaryDisplays" /> <java-symbol type="bool" name="config_supportsInsecureLockScreen" /> <java-symbol type="bool" name="config_guestUserEphemeral" /> <java-symbol type="bool" name="config_guestUserAutoCreated" /> <java-symbol type="bool" name="config_localDisplaysMirrorContent" /> <java-symbol type="array" name="config_localPrivateDisplayPorts" /> <java-symbol type="integer" name="config_defaultDisplayDefaultColorMode" /> Loading
packages/SettingsLib/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1422,6 +1422,8 @@ <string name="guest_new_guest">Add guest</string> <!-- Label for exiting and removing the guest session in the user switcher [CHAR LIMIT=35] --> <string name="guest_exit_guest">Remove guest</string> <!-- Label for resetting guest session in the user switcher, which will remove all data from the current guest session [CHAR LIMIT=35] --> <string name="guest_reset_guest">Reset guest</string> <!-- Name for the guest user [CHAR LIMIT=35] --> <string name="guest_nickname">Guest</string> Loading
packages/SystemUI/res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -1148,12 +1148,18 @@ <!-- Title of the confirmation dialog when exiting guest session [CHAR LIMIT=NONE] --> <string name="guest_exit_guest_dialog_title">Remove guest?</string> <!-- Title of the confirmation dialog when resetting guest session [CHAR LIMIT=NONE] --> <string name="guest_reset_guest_dialog_title">Reset guest?</string> <!-- Message of the confirmation dialog when exiting guest session [CHAR LIMIT=NONE] --> <string name="guest_exit_guest_dialog_message">All apps and data in this session will be deleted.</string> <!-- Label for button in confirmation dialog when exiting guest session [CHAR LIMIT=35] --> <string name="guest_exit_guest_dialog_remove">Remove</string> <!-- Label for button in confirmation dialog when resetting guest session [CHAR LIMIT=35] --> <string name="guest_reset_guest_dialog_remove">Reset</string> <!-- Title of the notification when resuming an existing guest session [CHAR LIMIT=NONE] --> <string name="guest_wipe_session_title">Welcome back, guest!</string> Loading
packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java +12 −54 Original line number Diff line number Diff line Loading @@ -27,15 +27,14 @@ import android.content.IntentFilter; import android.content.pm.UserInfo; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.util.Log; import android.view.WindowManagerGlobal; import com.android.internal.logging.UiEventLogger; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.qs.QSUserSwitcherEvent; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.statusbar.policy.UserSwitcherController; /** * Manages notification when a guest session is resumed. Loading @@ -47,9 +46,12 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { private static final String SETTING_GUEST_HAS_LOGGED_IN = "systemui.guest_has_logged_in"; private Dialog mNewSessionDialog; private final UserSwitcherController mUserSwitcherController; private final UiEventLogger mUiEventLogger; public GuestResumeSessionReceiver(UiEventLogger uiEventLogger) { public GuestResumeSessionReceiver(UserSwitcherController userSwitcherController, UiEventLogger uiEventLogger) { mUserSwitcherController = userSwitcherController; mUiEventLogger = uiEventLogger; } Loading Loading @@ -90,7 +92,8 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { int notFirstLogin = Settings.System.getIntForUser( cr, SETTING_GUEST_HAS_LOGGED_IN, 0, userId); if (notFirstLogin != 0) { mNewSessionDialog = new ResetSessionDialog(context, mUiEventLogger, userId); mNewSessionDialog = new ResetSessionDialog(context, mUserSwitcherController, mUiEventLogger, userId); mNewSessionDialog.show(); } else { Settings.System.putIntForUser( Loading @@ -99,54 +102,6 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { } } /** * Wipes the guest session. * * The guest must be the current user and its id must be {@param userId}. */ private static void wipeGuestSession(Context context, int userId) { UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); UserInfo currentUser; try { currentUser = ActivityManager.getService().getCurrentUser(); } catch (RemoteException e) { Log.e(TAG, "Couldn't wipe session because ActivityManager is dead"); return; } if (currentUser.id != userId) { Log.w(TAG, "User requesting to start a new session (" + userId + ")" + " is not current user (" + currentUser.id + ")"); return; } if (!currentUser.isGuest()) { Log.w(TAG, "User requesting to start a new session (" + userId + ")" + " is not a guest"); return; } boolean marked = userManager.markGuestForDeletion(currentUser.id); if (!marked) { Log.w(TAG, "Couldn't mark the guest for deletion for user " + userId); return; } UserInfo newGuest = userManager.createGuest(context, currentUser.name); try { if (newGuest == null) { Log.e(TAG, "Could not create new guest, switching back to system user"); ActivityManager.getService().switchUser(UserHandle.USER_SYSTEM); userManager.removeUser(currentUser.id); WindowManagerGlobal.getWindowManagerService().lockNow(null /* options */); return; } ActivityManager.getService().switchUser(newGuest.id); userManager.removeUser(currentUser.id); } catch (RemoteException e) { Log.e(TAG, "Couldn't wipe session because ActivityManager or WindowManager is dead"); return; } } private void cancelDialog() { if (mNewSessionDialog != null && mNewSessionDialog.isShowing()) { mNewSessionDialog.cancel(); Loading @@ -160,10 +115,12 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { private static final int BUTTON_WIPE = BUTTON_NEGATIVE; private static final int BUTTON_DONTWIPE = BUTTON_POSITIVE; private final UserSwitcherController mUserSwitcherController; private final UiEventLogger mUiEventLogger; private final int mUserId; ResetSessionDialog(Context context, UiEventLogger uiEventLogger, int userId) { ResetSessionDialog(Context context, UserSwitcherController userSwitcherController, UiEventLogger uiEventLogger, int userId) { super(context); setTitle(context.getString(R.string.guest_wipe_session_title)); Loading @@ -175,6 +132,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { setButton(BUTTON_DONTWIPE, context.getString(R.string.guest_wipe_session_dontwipe), this); mUserSwitcherController = userSwitcherController; mUiEventLogger = uiEventLogger; mUserId = userId; } Loading @@ -183,7 +141,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { public void onClick(DialogInterface dialog, int which) { if (which == BUTTON_WIPE) { mUiEventLogger.log(QSUserSwitcherEvent.QS_USER_GUEST_WIPE); wipeGuestSession(getContext(), mUserId); mUserSwitcherController.removeGuestUser(mUserId, UserHandle.USER_NULL); dismiss(); } else if (which == BUTTON_DONTWIPE) { mUiEventLogger.log(QSUserSwitcherEvent.QS_USER_GUEST_CONTINUE); Loading