Add tests for guest user events

Also, move ACTION_USER_GUEST_EXIT_CONFIRMED so it is only logged after
safety-check

Test: ROBOTEST_FILTER="com.android.settings.users.UserSettingsTest" m RunSettingsRoboTests
Test: ROBOTEST_FILTER="com.android.settings.users.UserDetailsSettingsTest" m RunSettingsRoboTests
Bug: 184200796
Change-Id: Id18aa914bbb262984d7c7cf4b8a4ffdde278fd23
This commit is contained in:
Peter Kalauskas
2021-05-10 20:28:53 -07:00
parent 4523f9200f
commit c24234c301
3 changed files with 43 additions and 3 deletions

View File

@@ -829,13 +829,14 @@ public class UserSettings extends SettingsPreferenceFragment
/**
* Erase the current user (guest) and switch to another user.
*/
private void exitGuest() {
@VisibleForTesting
void exitGuest() {
// Just to be safe
mMetricsFeatureProvider.action(getActivity(),
SettingsEnums.ACTION_USER_GUEST_EXIT_CONFIRMED);
if (!isCurrentUserGuest()) {
return;
}
mMetricsFeatureProvider.action(getActivity(),
SettingsEnums.ACTION_USER_GUEST_EXIT_CONFIRMED);
removeThisUser();
}