Fix creating multiple users from same alert dialog
Disable the button listeners after the first click to avoid the creation of more than one user per dialog. Bug: 252831574 Test: Manually tested by calling the API from a regular app Change-Id: I6d343ae0a2a4d81d35a85f51a60c88c0c18dba21
This commit is contained in:
@@ -49,6 +49,7 @@ public class ConfirmUserCreationActivity extends AlertActivity
|
||||
private String mAccountType;
|
||||
private PersistableBundle mAccountOptions;
|
||||
private boolean mCanProceed;
|
||||
private boolean mIsFirstClick;
|
||||
private UserManager mUserManager;
|
||||
|
||||
@Override
|
||||
@@ -82,6 +83,7 @@ public class ConfirmUserCreationActivity extends AlertActivity
|
||||
ap.mNegativeButtonText = getString(android.R.string.cancel);
|
||||
ap.mNegativeButtonListener = this;
|
||||
}
|
||||
mIsFirstClick = true;
|
||||
setupAlert();
|
||||
}
|
||||
|
||||
@@ -128,7 +130,8 @@ public class ConfirmUserCreationActivity extends AlertActivity
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
setResult(RESULT_CANCELED);
|
||||
if (which == BUTTON_POSITIVE && mCanProceed) {
|
||||
if (which == BUTTON_POSITIVE && mCanProceed && mIsFirstClick) {
|
||||
mIsFirstClick = false;
|
||||
Log.i(TAG, "Ok, creating user");
|
||||
UserInfo user = mUserManager.createUser(mUserName, USER_TYPE, 0);
|
||||
if (user == null) {
|
||||
|
||||
Reference in New Issue
Block a user