Make use of config for auto-created guest users

If frameworks config config_guestUserAutoCreated=true, then Settings
will:

 - Create a new guest user any time the current guest user is removed

 - Show "Guest" instead of "Add guest"

 - Show "Reset guest" instead of "Remove guest"

Bug: 188542158
Test: With config_guestUserAutoCreated=true, delete current guest user
      using adb (`adb shell cmd user list -v --all` to find the user
      ids, then remove each guest user with `adb shell pm remove-user
      <id>`), then as owner, open multi-users settings page. Check that
      there is a item for "Guest" instead of "Add guest". Select
      "Guest", then confirm there is an item for "Reset guest" (it
      should be disabled). Select "Switch to guest", then switch back to
      owner. Open the multi-users settings page again. Check that "Reset
      guest" is now enabled. Tap "Reset guest", and press confirmation
      button, named "Reset". You should be take back to the main
      multi-user settings page and still see "Guest". Wait a few
      seconds, then use adb to confirm there is a guest user present.
Test: With config_guestUserAutoCreated=true, switch to guest user, open
      multi-users settings page, check that there is an option to "Reset
      guest". Select "Reset guest", and press confirmation button, named
      "Reset". Phone should switch back to last active user, and QS tile
      should now show "Guest" instead of "Add guest". Run `adb shell cmd
      user list -v --all` to confirm guest has a new user id.
Test: With config_guestUserAutoCreated=false, confirm that "Add guest"
      and "Remove guest" features remain unchanged
Change-Id: I7d5b81bd2e5c6b999ae18cd6b1280ae0496db94b
This commit is contained in:
Peter Kalauskas
2021-06-15 17:11:24 -07:00
parent dda37a3500
commit 8d37a2bb85
3 changed files with 162 additions and 9 deletions

View File

@@ -154,4 +154,24 @@ public final class UserDialogs {
null)
.create();
}
/**
* Creates a dialog to confirm with the user if it's ok to reset the guest user, which will
* delete all the guest user's data.
*
* @param context a Context object
* @param onConfirmListener Callback object for positive action
* @return the created Dialog
*/
public static Dialog createResetGuestDialog(Context context,
DialogInterface.OnClickListener onConfirmListener) {
return new AlertDialog.Builder(context)
.setTitle(com.android.settingslib.R.string.guest_reset_guest_dialog_title)
.setMessage(R.string.user_exit_guest_confirm_message)
.setPositiveButton(
com.android.settingslib.R.string.guest_reset_guest_confirm_button,
onConfirmListener)
.setNegativeButton(android.R.string.cancel, null)
.create();
}
}