Commit eb50f888 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

[Android] Signin flow is shown when user signed in but not sync

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: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807880}
parent c50922a2
...@@ -162,7 +162,11 @@ public class AccountManagementFragment extends PreferenceFragmentCompat ...@@ -162,7 +162,11 @@ public class AccountManagementFragment extends PreferenceFragmentCompat
mSignedInAccountName = CoreAccountInfo.getEmailFrom( mSignedInAccountName = CoreAccountInfo.getEmailFrom(
IdentityServicesProvider.get() IdentityServicesProvider.get()
.getIdentityManager(Profile.getLastUsedRegularProfile()) .getIdentityManager(Profile.getLastUsedRegularProfile())
.getPrimaryAccountInfo(ConsentLevel.SYNC)); .getPrimaryAccountInfo(
ChromeFeatureList.isEnabled(
ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
? ConsentLevel.NOT_REQUIRED
: ConsentLevel.SYNC));
if (mSignedInAccountName == null) { if (mSignedInAccountName == null) {
// The AccountManagementFragment can only be shown when the user is signed in. If the // The AccountManagementFragment can only be shown when the user is signed in. If the
// user is signed out, exit the fragment. // user is signed out, exit the fragment.
......
...@@ -82,10 +82,6 @@ public class SignInPreference ...@@ -82,10 +82,6 @@ public class SignInPreference
mProfileDataCache = new ProfileDataCache(context, imageSize); mProfileDataCache = new ProfileDataCache(context, imageSize);
mAccountManagerFacade = AccountManagerFacadeProvider.getInstance(); mAccountManagerFacade = AccountManagerFacadeProvider.getInstance();
setOnPreferenceClickListener(preference
-> SigninUtils.startSigninActivityIfAllowed(
getContext(), SigninAccessPoint.SETTINGS));
// State will be updated in registerForUpdates. // State will be updated in registerForUpdates.
mState = State.SIGNED_IN; mState = State.SIGNED_IN;
} }
...@@ -218,6 +214,10 @@ public class SignInPreference ...@@ -218,6 +214,10 @@ public class SignInPreference
setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId()); setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
setWidgetLayoutResource(0); setWidgetLayoutResource(0);
setViewEnabled(false); setViewEnabled(false);
setOnPreferenceClickListener(pref -> {
ManagedPreferencesUtils.showManagedByAdministratorToast(getContext());
return true;
});
mSigninPromoController = null; mSigninPromoController = null;
mWasGenericSigninPromoDisplayed = false; mWasGenericSigninPromoDisplayed = false;
} }
...@@ -231,6 +231,7 @@ public class SignInPreference ...@@ -231,6 +231,7 @@ public class SignInPreference
setIcon(null); setIcon(null);
setWidgetLayoutResource(0); setWidgetLayoutResource(0);
setViewEnabled(true); setViewEnabled(true);
setOnPreferenceClickListener(null);
if (mSigninPromoController == null) { if (mSigninPromoController == null) {
mSigninPromoController = new SigninPromoController(SigninAccessPoint.SETTINGS); mSigninPromoController = new SigninPromoController(SigninAccessPoint.SETTINGS);
...@@ -251,6 +252,9 @@ public class SignInPreference ...@@ -251,6 +252,9 @@ public class SignInPreference
setIcon(AppCompatResources.getDrawable(getContext(), R.drawable.logo_avatar_anonymous)); setIcon(AppCompatResources.getDrawable(getContext(), R.drawable.logo_avatar_anonymous));
setWidgetLayoutResource(0); setWidgetLayoutResource(0);
setViewEnabled(true); setViewEnabled(true);
setOnPreferenceClickListener(pref
-> SigninUtils.startSigninActivityIfAllowed(
getContext(), SigninAccessPoint.SETTINGS));
mSigninPromoController = null; mSigninPromoController = null;
if (!mWasGenericSigninPromoDisplayed) { if (!mWasGenericSigninPromoDisplayed) {
...@@ -272,6 +276,7 @@ public class SignInPreference ...@@ -272,6 +276,7 @@ public class SignInPreference
setIcon(profileData.getImage()); setIcon(profileData.getImage());
setWidgetLayoutResource(0); setWidgetLayoutResource(0);
setViewEnabled(true); setViewEnabled(true);
setOnPreferenceClickListener(null);
mSigninPromoController = null; mSigninPromoController = null;
mWasGenericSigninPromoDisplayed = false; mWasGenericSigninPromoDisplayed = 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