Fix multi user crash when Add guest was tapped multiple times
When "Add guest" got tapped multiple times then the first click starts
the guest creation process which blocks the UI thread for around 2-3
seconds, then triggers the open guest details intent, and the second
tap event starts another guest creation, but it fails (since there
can't be more than 1 guest on the device) and returns null, and in the
openUserDetails we get NullPointerException.
Test: manual test
Video: http://shortn/_i4Dce33yhl
Bug: 160267016
Change-Id: I9a4f0a91295e336d246abe5f5470682a14cb510f
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 910917a..9669190 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -1064,6 +1064,7 @@
}
return true;
} else if (pref == mAddGuest) {
+ mAddGuest.setEnabled(false); // prevent multiple tap issue
UserInfo guest = mUserManager.createGuest(
getContext(), getString(com.android.settingslib.R.string.user_guest));
openUserDetails(guest, true);