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 ...@@ -62,12 +62,13 @@ public class SigninFirstRunFragment extends SigninFragmentBase implements FirstR
} }
@Override @Override
protected void onSigninAccepted( protected void onSigninAccepted(String accountName, boolean isDefaultAccount,
String accountName, boolean isDefaultAccount, boolean settingsClicked) { boolean settingsClicked, Runnable callback) {
getPageDelegate().acceptSignIn(accountName, isDefaultAccount); getPageDelegate().acceptSignIn(accountName, isDefaultAccount);
if (settingsClicked) { if (settingsClicked) {
getPageDelegate().askToOpenSignInSettings(); getPageDelegate().askToOpenSignInSettings();
} }
getPageDelegate().advanceToNextPage(); getPageDelegate().advanceToNextPage();
callback.run();
} }
} }
...@@ -107,8 +107,8 @@ public class SigninFragment extends SigninFragmentBase { ...@@ -107,8 +107,8 @@ public class SigninFragment extends SigninFragmentBase {
} }
@Override @Override
protected void onSigninAccepted( protected void onSigninAccepted(String accountName, boolean isDefaultAccount,
String accountName, boolean isDefaultAccount, boolean settingsClicked) { boolean settingsClicked, Runnable callback) {
if (PrefServiceBridge.getInstance().getSyncLastAccountName() != null) { if (PrefServiceBridge.getInstance().getSyncLastAccountName() != null) {
AccountSigninActivity.recordSwitchAccountSourceHistogram( AccountSigninActivity.recordSwitchAccountSourceHistogram(
AccountSigninActivity.SwitchAccountSource.SIGNOUT_SIGNIN); AccountSigninActivity.SwitchAccountSource.SIGNOUT_SIGNIN);
...@@ -125,10 +125,13 @@ public class SigninFragment extends SigninFragmentBase { ...@@ -125,10 +125,13 @@ public class SigninFragment extends SigninFragmentBase {
recordSigninCompletedHistogramAccountInfo(); recordSigninCompletedHistogramAccountInfo();
getActivity().finish(); getActivity().finish();
callback.run();
} }
@Override @Override
public void onSignInAborted() {} public void onSignInAborted() {
callback.run();
}
}); });
} }
......
...@@ -101,7 +101,7 @@ public abstract class SigninFragmentBase ...@@ -101,7 +101,7 @@ public abstract class SigninFragmentBase
private List<String> mAccountNames; private List<String> mAccountNames;
private boolean mResumed; private boolean mResumed;
private boolean mDestroyed; private boolean mDestroyed;
// TODO(https://crbug.com/814728): Ignore button clicks if GMS reported an error. private boolean mIsSigninInProgress;
private boolean mHasGmsError; private boolean mHasGmsError;
private UserRecoverableErrorHandler.ModalDialog mGooglePlayServicesUpdateErrorHandler; private UserRecoverableErrorHandler.ModalDialog mGooglePlayServicesUpdateErrorHandler;
...@@ -186,9 +186,10 @@ public abstract class SigninFragmentBase ...@@ -186,9 +186,10 @@ public abstract class SigninFragmentBase
* @param accountName The name of the account * @param accountName The name of the account
* @param isDefaultAccount Whether selected account is a default one (first of all accounts) * @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 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( protected abstract void onSigninAccepted(String accountName, boolean isDefaultAccount,
String accountName, boolean isDefaultAccount, boolean settingsClicked); boolean settingsClicked, Runnable callback);
/** Returns the access point that initiated the sign-in flow. */ /** Returns the access point that initiated the sign-in flow. */
protected @SigninAccessPoint int getSigninAccessPoint() { protected @SigninAccessPoint int getSigninAccessPoint() {
...@@ -212,7 +213,6 @@ public abstract class SigninFragmentBase ...@@ -212,7 +213,6 @@ public abstract class SigninFragmentBase
mSigninFlowType = arguments.getInt(ARGUMENT_SIGNIN_FLOW_TYPE, FLOW_DEFAULT); mSigninFlowType = arguments.getInt(ARGUMENT_SIGNIN_FLOW_TYPE, FLOW_DEFAULT);
// Don't have a selected account now, onResume will trigger the selection. // 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; mAccountSelectionPending = true;
if (savedInstanceState == null) { if (savedInstanceState == null) {
...@@ -356,17 +356,17 @@ public abstract class SigninFragmentBase ...@@ -356,17 +356,17 @@ public abstract class SigninFragmentBase
} }
private void onAccountPickerClicked() { private void onAccountPickerClicked() {
// TODO(https://crbug.com/814728): Ignore clicks if GMS reported an error. if (isForcedSignin() || !areControlsEnabled()) return;
showAccountPicker(); showAccountPicker();
} }
private void onRefuseButtonClicked(View button) { private void onRefuseButtonClicked(View button) {
// TODO(https://crbug.com/814728): Disable controls.
onSigninRefused(); onSigninRefused();
} }
private void onAcceptButtonClicked(View button) { private void onAcceptButtonClicked(View button) {
// TODO(https://crbug.com/814728): Disable controls. if (!areControlsEnabled()) return;
mIsSigninInProgress = true;
RecordUserAction.record("Signin_Signin_WithDefaultSyncSettings"); RecordUserAction.record("Signin_Signin_WithDefaultSyncSettings");
// Record the fact that the user consented to the consent text by clicking on a button // Record the fact that the user consented to the consent text by clicking on a button
...@@ -375,7 +375,8 @@ public abstract class SigninFragmentBase ...@@ -375,7 +375,8 @@ public abstract class SigninFragmentBase
} }
private void onSettingsLinkClicked(View view) { private void onSettingsLinkClicked(View view) {
// TODO(https://crbug.com/814728): Disable controls. if (!areControlsEnabled()) return;
mIsSigninInProgress = true;
RecordUserAction.record("Signin_Signin_WithAdvancedSyncSettings"); RecordUserAction.record("Signin_Signin_WithAdvancedSyncSettings");
// Record the fact that the user consented to the consent text by clicking on a link // Record the fact that the user consented to the consent text by clicking on a link
...@@ -383,6 +384,14 @@ public abstract class SigninFragmentBase ...@@ -383,6 +384,14 @@ public abstract class SigninFragmentBase
seedAccountsAndSignin(true); 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) { private void seedAccountsAndSignin(boolean settingsClicked) {
// Ensure that the AccountTrackerService has a fully up to date GAIA id <-> email mapping, // Ensure that the AccountTrackerService has a fully up to date GAIA id <-> email mapping,
// as this is needed for the previous account check. // as this is needed for the previous account check.
...@@ -425,14 +434,14 @@ public abstract class SigninFragmentBase ...@@ -425,14 +434,14 @@ public abstract class SigninFragmentBase
if (mDestroyed) return; if (mDestroyed) return;
SigninManager.wipeSyncUserDataIfRequired(wipeData).then((Void v) -> { SigninManager.wipeSyncUserDataIfRequired(wipeData).then((Void v) -> {
onSigninAccepted(mSelectedAccountName, mIsDefaultAccountSelected, onSigninAccepted(mSelectedAccountName, mIsDefaultAccountSelected,
settingsClicked); settingsClicked, () -> mIsSigninInProgress = false);
}); });
} }
@Override @Override
public void onCancel() { public void onCancel() {
mConfirmSyncDataStateMachine = null; 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