Skip to content

Commit

Permalink
[Android] Signin flow is shown when user signed in but not sync
Browse files Browse the repository at this point in the history
This cl makes two key changes that should fix this bug.

1. The onPreferenceClickListener in the SignInPreference is too generic.
It should only be invoked for managed accounts and generic promos.
The code is moved to the setup of the specific states.

2. AccountManagementFragment should check for signed in accounts, not
syncing accounts, when MOBILE_IDENTITY_CONSISTENCY is on.

Bug: 1128931
Change-Id: Ifbd0fbef5acfdca7412b9ae5056f7208ff59c366
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414233
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807880}
  • Loading branch information
Tanmoy Mollik authored and Commit Bot committed Sep 17, 2020
1 parent c50922a commit eb50f88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ public void update() {
mSignedInAccountName = CoreAccountInfo.getEmailFrom(
IdentityServicesProvider.get()
.getIdentityManager(Profile.getLastUsedRegularProfile())
.getPrimaryAccountInfo(ConsentLevel.SYNC));
.getPrimaryAccountInfo(
ChromeFeatureList.isEnabled(
ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
? ConsentLevel.NOT_REQUIRED
: ConsentLevel.SYNC));
if (mSignedInAccountName == null) {
// The AccountManagementFragment can only be shown when the user is signed in. If the
// user is signed out, exit the fragment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public SignInPreference(Context context, AttributeSet attrs) {
mProfileDataCache = new ProfileDataCache(context, imageSize);
mAccountManagerFacade = AccountManagerFacadeProvider.getInstance();

setOnPreferenceClickListener(preference
-> SigninUtils.startSigninActivityIfAllowed(
getContext(), SigninAccessPoint.SETTINGS));

// State will be updated in registerForUpdates.
mState = State.SIGNED_IN;
}
Expand Down Expand Up @@ -218,6 +214,10 @@ private void setupSigninDisabled() {
setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
setWidgetLayoutResource(0);
setViewEnabled(false);
setOnPreferenceClickListener(pref -> {
ManagedPreferencesUtils.showManagedByAdministratorToast(getContext());
return true;
});
mSigninPromoController = null;
mWasGenericSigninPromoDisplayed = false;
}
Expand All @@ -231,6 +231,7 @@ private void setupPersonalizedPromo() {
setIcon(null);
setWidgetLayoutResource(0);
setViewEnabled(true);
setOnPreferenceClickListener(null);

if (mSigninPromoController == null) {
mSigninPromoController = new SigninPromoController(SigninAccessPoint.SETTINGS);
Expand All @@ -251,6 +252,9 @@ private void setupGenericPromo() {
setIcon(AppCompatResources.getDrawable(getContext(), R.drawable.logo_avatar_anonymous));
setWidgetLayoutResource(0);
setViewEnabled(true);
setOnPreferenceClickListener(pref
-> SigninUtils.startSigninActivityIfAllowed(
getContext(), SigninAccessPoint.SETTINGS));
mSigninPromoController = null;

if (!mWasGenericSigninPromoDisplayed) {
Expand All @@ -272,6 +276,7 @@ private void setupSignedIn(String accountName) {
setIcon(profileData.getImage());
setWidgetLayoutResource(0);
setViewEnabled(true);
setOnPreferenceClickListener(null);

mSigninPromoController = null;
mWasGenericSigninPromoDisplayed = false;
Expand Down

0 comments on commit eb50f88

Please sign in to comment.