Commit 4aa3e99b authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Disable sign-in controls while sign-in is in progress

This CL disables "Yes, I'm in" button, account picker and Settings link
in the streamlined sign-in screen if either account selection is pending
or sign-in is in progress or account list isn't available because of
a GMS error.

Bug: 814728
Change-Id: Ic5aa09395557268a7264d876b08e5b63197e85ee
Reviewed-on: https://chromium-review.googlesource.com/1062565Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559538}
parent 2dacc374
......@@ -62,12 +62,13 @@ public class SigninFirstRunFragment extends SigninFragmentBase implements FirstR
}
@Override
protected void onSigninAccepted(
String accountName, boolean isDefaultAccount, boolean settingsClicked) {
protected void onSigninAccepted(String accountName, boolean isDefaultAccount,
boolean settingsClicked, Runnable callback) {
getPageDelegate().acceptSignIn(accountName, isDefaultAccount);
if (settingsClicked) {
getPageDelegate().askToOpenSignInSettings();
}
getPageDelegate().advanceToNextPage();
callback.run();
}
}
......@@ -107,8 +107,8 @@ public class SigninFragment extends SigninFragmentBase {
}
@Override
protected void onSigninAccepted(
String accountName, boolean isDefaultAccount, boolean settingsClicked) {
protected void onSigninAccepted(String accountName, boolean isDefaultAccount,
boolean settingsClicked, Runnable callback) {
if (PrefServiceBridge.getInstance().getSyncLastAccountName() != null) {
AccountSigninActivity.recordSwitchAccountSourceHistogram(
AccountSigninActivity.SwitchAccountSource.SIGNOUT_SIGNIN);
......@@ -125,10 +125,13 @@ public class SigninFragment extends SigninFragmentBase {
recordSigninCompletedHistogramAccountInfo();
getActivity().finish();
callback.run();
}
@Override
public void onSignInAborted() {}
public void onSignInAborted() {
callback.run();
}
});
}
......
......@@ -101,7 +101,7 @@ public abstract class SigninFragmentBase
private List<String> mAccountNames;
private boolean mResumed;
private boolean mDestroyed;
// TODO(https://crbug.com/814728): Ignore button clicks if GMS reported an error.
private boolean mIsSigninInProgress;
private boolean mHasGmsError;
private UserRecoverableErrorHandler.ModalDialog mGooglePlayServicesUpdateErrorHandler;
......@@ -186,9 +186,10 @@ public abstract class SigninFragmentBase
* @param accountName The name of the account
* @param isDefaultAccount Whether selected account is a default one (first of all accounts)
* @param settingsClicked Whether the user requested to see their sync settings
* @param callback The callback invoke when sign-in process is finished or aborted
*/
protected abstract void onSigninAccepted(
String accountName, boolean isDefaultAccount, boolean settingsClicked);
protected abstract void onSigninAccepted(String accountName, boolean isDefaultAccount,
boolean settingsClicked, Runnable callback);
/** Returns the access point that initiated the sign-in flow. */
protected @SigninAccessPoint int getSigninAccessPoint() {
......@@ -212,7 +213,6 @@ public abstract class SigninFragmentBase
mSigninFlowType = arguments.getInt(ARGUMENT_SIGNIN_FLOW_TYPE, FLOW_DEFAULT);
// Don't have a selected account now, onResume will trigger the selection.
// TODO(https://crbug.com/814728): Disable controls until an account is selected.
mAccountSelectionPending = true;
if (savedInstanceState == null) {
......@@ -356,17 +356,17 @@ public abstract class SigninFragmentBase
}
private void onAccountPickerClicked() {
// TODO(https://crbug.com/814728): Ignore clicks if GMS reported an error.
if (isForcedSignin() || !areControlsEnabled()) return;
showAccountPicker();
}
private void onRefuseButtonClicked(View button) {
// TODO(https://crbug.com/814728): Disable controls.
onSigninRefused();
}
private void onAcceptButtonClicked(View button) {
// TODO(https://crbug.com/814728): Disable controls.
if (!areControlsEnabled()) return;
mIsSigninInProgress = true;
RecordUserAction.record("Signin_Signin_WithDefaultSyncSettings");
// Record the fact that the user consented to the consent text by clicking on a button
......@@ -375,7 +375,8 @@ public abstract class SigninFragmentBase
}
private void onSettingsLinkClicked(View view) {
// TODO(https://crbug.com/814728): Disable controls.
if (!areControlsEnabled()) return;
mIsSigninInProgress = true;
RecordUserAction.record("Signin_Signin_WithAdvancedSyncSettings");
// Record the fact that the user consented to the consent text by clicking on a link
......@@ -383,6 +384,14 @@ public abstract class SigninFragmentBase
seedAccountsAndSignin(true);
}
/**
* Whether account picker and accept button should react to clicks. This doesn't change the
* visual appearance of these controls. Refuse button is always enabled.
*/
private boolean areControlsEnabled() {
return !mAccountSelectionPending && !mIsSigninInProgress && !mHasGmsError;
}
private void seedAccountsAndSignin(boolean settingsClicked) {
// Ensure that the AccountTrackerService has a fully up to date GAIA id <-> email mapping,
// as this is needed for the previous account check.
......@@ -425,14 +434,14 @@ public abstract class SigninFragmentBase
if (mDestroyed) return;
SigninManager.wipeSyncUserDataIfRequired(wipeData).then((Void v) -> {
onSigninAccepted(mSelectedAccountName, mIsDefaultAccountSelected,
settingsClicked);
settingsClicked, () -> mIsSigninInProgress = false);
});
}
@Override
public void onCancel() {
mConfirmSyncDataStateMachine = null;
// TODO(https://crbug.com/814728): Re-enable controls.
mIsSigninInProgress = false;
}
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment