Commit 31901806 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][Signin] Rename accountName to accountEmail for profile data

This CL renames accountName to accountEmail for profile data related
code.

Bug: 1131344
Change-Id: I8651cd5759c38844444fbbe199391baa3f4f9d5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2552392Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829668}
parent 338f8bb8
...@@ -36,7 +36,7 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer { ...@@ -36,7 +36,7 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer {
private final ProfileDataCache mProfileCache; private final ProfileDataCache mProfileCache;
private final ViewGroup mView; private final ViewGroup mView;
private final ImageView mProfileView; private final ImageView mProfileView;
private final String mSignedInAccountName; private final String mSignedInAccountEmail;
private final ViewHolder mViewHolder; private final ViewHolder mViewHolder;
private final RecyclerView mChipsContainer; private final RecyclerView mChipsContainer;
...@@ -59,7 +59,7 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer { ...@@ -59,7 +59,7 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer {
mProfileView = mView.findViewById(R.id.profile_image); mProfileView = mView.findViewById(R.id.profile_image);
IdentityManager identityManager = IdentityServicesProvider.get().getIdentityManager( IdentityManager identityManager = IdentityServicesProvider.get().getIdentityManager(
AutofillAssistantUiController.getProfile()); AutofillAssistantUiController.getProfile());
mSignedInAccountName = CoreAccountInfo.getEmailFrom( mSignedInAccountEmail = CoreAccountInfo.getEmailFrom(
identityManager.getPrimaryAccountInfo(ConsentLevel.SYNC)); identityManager.getPrimaryAccountInfo(ConsentLevel.SYNC));
setupProfileImage(); setupProfileImage();
...@@ -115,10 +115,10 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer { ...@@ -115,10 +115,10 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer {
@Override @Override
public void onProfileDataUpdated(String accountEmail) { public void onProfileDataUpdated(String accountEmail) {
if (!mSignedInAccountName.equals(accountEmail)) { if (!mSignedInAccountEmail.equals(accountEmail)) {
return; return;
} }
setProfileImageFor(mSignedInAccountName); setProfileImageFor(mSignedInAccountEmail);
} }
/** Return the view associated to this coordinator. */ /** Return the view associated to this coordinator. */
...@@ -135,7 +135,7 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer { ...@@ -135,7 +135,7 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer {
* Cleanup resources when this goes out of scope. * Cleanup resources when this goes out of scope.
*/ */
public void destroy() { public void destroy() {
if (mSignedInAccountName != null) { if (mSignedInAccountEmail != null) {
mProfileCache.removeObserver(this); mProfileCache.removeObserver(this);
} }
} }
...@@ -148,9 +148,9 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer { ...@@ -148,9 +148,9 @@ public class AssistantHeaderCoordinator implements ProfileDataCache.Observer {
// TODO(b/130415092): Use image from AGSA if chrome is not signed in. // TODO(b/130415092): Use image from AGSA if chrome is not signed in.
private void setupProfileImage() { private void setupProfileImage() {
if (mSignedInAccountName != null) { if (mSignedInAccountEmail != null) {
mProfileCache.addObserver(this); mProfileCache.addObserver(this);
mProfileCache.update(Collections.singletonList(mSignedInAccountName)); mProfileCache.update(Collections.singletonList(mSignedInAccountEmail));
} }
} }
private void setProfileImageFor(String signedInAccountName) { private void setProfileImageFor(String signedInAccountName) {
......
...@@ -12,26 +12,26 @@ import androidx.annotation.Nullable; ...@@ -12,26 +12,26 @@ import androidx.annotation.Nullable;
* Immutable holder for displayable profile data. * Immutable holder for displayable profile data.
*/ */
public class DisplayableProfileData { public class DisplayableProfileData {
private final String mAccountName; private final String mAccountEmail;
private final Drawable mImage; private final Drawable mImage;
private final @Nullable String mFullName; private final @Nullable String mFullName;
private final @Nullable String mGivenName; private final @Nullable String mGivenName;
public DisplayableProfileData(String accountName, Drawable image, @Nullable String fullName, public DisplayableProfileData(String accountEmail, Drawable image, @Nullable String fullName,
@Nullable String givenName) { @Nullable String givenName) {
assert accountName != null; assert accountEmail != null;
assert image != null; assert image != null;
mAccountName = accountName; mAccountEmail = accountEmail;
mImage = image; mImage = image;
mFullName = fullName; mFullName = fullName;
mGivenName = givenName; mGivenName = givenName;
} }
/** /**
* @return The account name (i.e. the e-mail address). * @return The account email.
*/ */
public String getAccountName() { public String getAccountEmail() {
return mAccountName; return mAccountEmail;
} }
/** /**
...@@ -60,7 +60,7 @@ public class DisplayableProfileData { ...@@ -60,7 +60,7 @@ public class DisplayableProfileData {
*/ */
public String getFullNameOrEmail() { public String getFullNameOrEmail() {
if (mFullName == null) { if (mFullName == null) {
return mAccountName; return mAccountEmail;
} }
return mFullName; return mFullName;
} }
......
...@@ -186,10 +186,10 @@ public class ProfileDataCache implements ProfileDownloader.Observer, ProfileData ...@@ -186,10 +186,10 @@ public class ProfileDataCache implements ProfileDownloader.Observer, ProfileData
* given account or a {@link DisplayableProfileData} with a placeholder image and null * given account or a {@link DisplayableProfileData} with a placeholder image and null
* full and given name. * full and given name.
*/ */
public DisplayableProfileData getProfileDataOrDefault(String accountName) { public DisplayableProfileData getProfileDataOrDefault(String accountEmail) {
DisplayableProfileData profileData = mCachedProfileData.get(accountName); DisplayableProfileData profileData = mCachedProfileData.get(accountEmail);
if (profileData == null) { if (profileData == null) {
return new DisplayableProfileData(accountName, mPlaceholderImage, null, null); return new DisplayableProfileData(accountEmail, mPlaceholderImage, null, null);
} }
return profileData; return profileData;
} }
...@@ -236,8 +236,8 @@ public class ProfileDataCache implements ProfileDownloader.Observer, ProfileData ...@@ -236,8 +236,8 @@ public class ProfileDataCache implements ProfileDownloader.Observer, ProfileData
private DisplayableProfileData createDisplayableProfileData( private DisplayableProfileData createDisplayableProfileData(
ProfileDataSource.ProfileData profileData) { ProfileDataSource.ProfileData profileData) {
return new DisplayableProfileData(profileData.getAccountName(), return new DisplayableProfileData(profileData.getAccountEmail(),
prepareAvatar(profileData.getAvatar(), profileData.getAccountName()), prepareAvatar(profileData.getAvatar(), profileData.getAccountEmail()),
profileData.getFullName(), profileData.getGivenName()); profileData.getFullName(), profileData.getGivenName());
} }
...@@ -337,8 +337,8 @@ public class ProfileDataCache implements ProfileDownloader.Observer, ProfileData ...@@ -337,8 +337,8 @@ public class ProfileDataCache implements ProfileDownloader.Observer, ProfileData
} }
private void updateCachedProfileDataAndNotifyObservers(DisplayableProfileData profileData) { private void updateCachedProfileDataAndNotifyObservers(DisplayableProfileData profileData) {
mCachedProfileData.put(profileData.getAccountName(), profileData); mCachedProfileData.put(profileData.getAccountEmail(), profileData);
notifyObservers(profileData.getAccountName()); notifyObservers(profileData.getAccountEmail());
} }
private void notifyObservers(String accountEmail) { private void notifyObservers(String accountEmail) {
......
...@@ -336,12 +336,12 @@ public abstract class SigninFragmentBase ...@@ -336,12 +336,12 @@ public abstract class SigninFragmentBase
if (!TextUtils.isEmpty(fullName)) { if (!TextUtils.isEmpty(fullName)) {
mConsentTextTracker.setTextNonRecordable(mView.getAccountTextPrimary(), fullName); mConsentTextTracker.setTextNonRecordable(mView.getAccountTextPrimary(), fullName);
mConsentTextTracker.setTextNonRecordable( mConsentTextTracker.setTextNonRecordable(
mView.getAccountTextSecondary(), profileData.getAccountName()); mView.getAccountTextSecondary(), profileData.getAccountEmail());
mView.getAccountTextSecondary().setVisibility(View.VISIBLE); mView.getAccountTextSecondary().setVisibility(View.VISIBLE);
} else { } else {
// Full name is not available, show the email in the primary TextView. // Full name is not available, show the email in the primary TextView.
mConsentTextTracker.setTextNonRecordable( mConsentTextTracker.setTextNonRecordable(
mView.getAccountTextPrimary(), profileData.getAccountName()); mView.getAccountTextPrimary(), profileData.getAccountEmail());
mView.getAccountTextSecondary().setVisibility(View.GONE); mView.getAccountTextSecondary().setVisibility(View.GONE);
} }
} }
......
...@@ -317,14 +317,14 @@ public class SigninPromoController { ...@@ -317,14 +317,14 @@ public class SigninPromoController {
recordSigninButtonUsed(); recordSigninButtonUsed();
RecordUserAction.record(mSigninWithDefaultUserActionName); RecordUserAction.record(mSigninWithDefaultUserActionName);
SigninActivityLauncherImpl.get().launchActivityForPromoDefaultFlow( SigninActivityLauncherImpl.get().launchActivityForPromoDefaultFlow(
context, mAccessPoint, mProfileData.getAccountName()); context, mAccessPoint, mProfileData.getAccountEmail());
} }
private void signinWithNotDefaultAccount(Context context) { private void signinWithNotDefaultAccount(Context context) {
recordSigninButtonUsed(); recordSigninButtonUsed();
RecordUserAction.record(mSigninNotDefaultUserActionName); RecordUserAction.record(mSigninNotDefaultUserActionName);
SigninActivityLauncherImpl.get().launchActivityForPromoChooseAccountFlow( SigninActivityLauncherImpl.get().launchActivityForPromoChooseAccountFlow(
context, mAccessPoint, mProfileData.getAccountName()); context, mAccessPoint, mProfileData.getAccountEmail());
} }
private void recordSigninButtonUsed() { private void recordSigninButtonUsed() {
......
...@@ -115,9 +115,9 @@ class AccountPickerMediator { ...@@ -115,9 +115,9 @@ class AccountPickerMediator {
DisplayableProfileData profileData, boolean isDefaultAccount) { DisplayableProfileData profileData, boolean isDefaultAccount) {
Callback<DisplayableProfileData> profileDataCallback = profileData1 Callback<DisplayableProfileData> profileDataCallback = profileData1
-> mAccountPickerListener.onAccountSelected( -> mAccountPickerListener.onAccountSelected(
profileData1.getAccountName(), isDefaultAccount); profileData1.getAccountEmail(), isDefaultAccount);
PropertyModel model = ExistingAccountRowProperties.createModel(profileData, PropertyModel model = ExistingAccountRowProperties.createModel(profileData,
profileDataCallback, profileData.getAccountName().equals(mSelectedAccountName)); profileDataCallback, profileData.getAccountEmail().equals(mSelectedAccountName));
return new MVCListAdapter.ListItem(ItemType.EXISTING_ACCOUNT_ROW, model); return new MVCListAdapter.ListItem(ItemType.EXISTING_ACCOUNT_ROW, model);
} }
...@@ -126,7 +126,7 @@ class AccountPickerMediator { ...@@ -126,7 +126,7 @@ class AccountPickerMediator {
if (item.type == AccountPickerProperties.ItemType.EXISTING_ACCOUNT_ROW) { if (item.type == AccountPickerProperties.ItemType.EXISTING_ACCOUNT_ROW) {
PropertyModel model = item.model; PropertyModel model = item.model;
boolean isSelectedAccount = TextUtils.equals(mSelectedAccountName, boolean isSelectedAccount = TextUtils.equals(mSelectedAccountName,
model.get(ExistingAccountRowProperties.PROFILE_DATA).getAccountName()); model.get(ExistingAccountRowProperties.PROFILE_DATA).getAccountEmail());
model.set(ExistingAccountRowProperties.IS_SELECTED_ACCOUNT, isSelectedAccount); model.set(ExistingAccountRowProperties.IS_SELECTED_ACCOUNT, isSelectedAccount);
} }
} }
...@@ -140,7 +140,7 @@ class AccountPickerMediator { ...@@ -140,7 +140,7 @@ class AccountPickerMediator {
if (item.type == AccountPickerProperties.ItemType.EXISTING_ACCOUNT_ROW) { if (item.type == AccountPickerProperties.ItemType.EXISTING_ACCOUNT_ROW) {
PropertyModel model = item.model; PropertyModel model = item.model;
boolean isProfileDataUpdated = TextUtils.equals(accountName, boolean isProfileDataUpdated = TextUtils.equals(accountName,
model.get(ExistingAccountRowProperties.PROFILE_DATA).getAccountName()); model.get(ExistingAccountRowProperties.PROFILE_DATA).getAccountEmail());
if (isProfileDataUpdated) { if (isProfileDataUpdated) {
model.set(ExistingAccountRowProperties.PROFILE_DATA, model.set(ExistingAccountRowProperties.PROFILE_DATA,
mProfileDataCache.getProfileDataOrDefault(accountName)); mProfileDataCache.getProfileDataOrDefault(accountName));
......
...@@ -78,11 +78,11 @@ class ExistingAccountRowViewBinder { ...@@ -78,11 +78,11 @@ class ExistingAccountRowViewBinder {
String fullName = profileData.getFullName(); String fullName = profileData.getFullName();
if (!TextUtils.isEmpty(fullName)) { if (!TextUtils.isEmpty(fullName)) {
accountTextPrimary.setText(fullName); accountTextPrimary.setText(fullName);
accountTextSecondary.setText(profileData.getAccountName()); accountTextSecondary.setText(profileData.getAccountEmail());
accountTextSecondary.setVisibility(View.VISIBLE); accountTextSecondary.setVisibility(View.VISIBLE);
} else { } else {
// Full name is not available, show the email in the primary TextView. // Full name is not available, show the email in the primary TextView.
accountTextPrimary.setText(profileData.getAccountName()); accountTextPrimary.setText(profileData.getAccountEmail());
accountTextSecondary.setVisibility(View.GONE); accountTextSecondary.setVisibility(View.GONE);
} }
} }
......
...@@ -186,7 +186,7 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -186,7 +186,7 @@ public class AccountPickerBottomSheetRenderTest {
throws IOException { throws IOException {
mAccountManagerTestRule.addAccount(PROFILE_DATA1); mAccountManagerTestRule.addAccount(PROFILE_DATA1);
CoreAccountInfo coreAccountInfo = CoreAccountInfo coreAccountInfo =
mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountName()); mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountEmail());
// Throws a connection error during the sign-in action // Throws a connection error during the sign-in action
doAnswer(invocation -> { doAnswer(invocation -> {
Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1); Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1);
...@@ -208,7 +208,7 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -208,7 +208,7 @@ public class AccountPickerBottomSheetRenderTest {
public void testSigninGeneralErrorView(boolean nightModeEnabled) throws IOException { public void testSigninGeneralErrorView(boolean nightModeEnabled) throws IOException {
mAccountManagerTestRule.addAccount(PROFILE_DATA1); mAccountManagerTestRule.addAccount(PROFILE_DATA1);
CoreAccountInfo coreAccountInfo = CoreAccountInfo coreAccountInfo =
mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountName()); mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountEmail());
// Throws a connection error during the sign-in action // Throws a connection error during the sign-in action
doAnswer(invocation -> { doAnswer(invocation -> {
Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1); Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1);
...@@ -230,7 +230,7 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -230,7 +230,7 @@ public class AccountPickerBottomSheetRenderTest {
public void testSigninAuthErrorView(boolean nightModeEnabled) throws IOException { public void testSigninAuthErrorView(boolean nightModeEnabled) throws IOException {
mAccountManagerTestRule.addAccount(PROFILE_DATA1); mAccountManagerTestRule.addAccount(PROFILE_DATA1);
CoreAccountInfo coreAccountInfo = CoreAccountInfo coreAccountInfo =
mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountName()); mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountEmail());
// Throws an authentication error during the sign-in action // Throws an authentication error during the sign-in action
doAnswer(invocation -> { doAnswer(invocation -> {
Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1); Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1);
...@@ -254,7 +254,7 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -254,7 +254,7 @@ public class AccountPickerBottomSheetRenderTest {
throws IOException { throws IOException {
mAccountManagerTestRule.addAccount(PROFILE_DATA1); mAccountManagerTestRule.addAccount(PROFILE_DATA1);
CoreAccountInfo coreAccountInfo = CoreAccountInfo coreAccountInfo =
mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountName()); mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountEmail());
// Throws an auth error during the sign-in action // Throws an auth error during the sign-in action
doAnswer(invocation -> { doAnswer(invocation -> {
Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1); Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1);
...@@ -273,7 +273,7 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -273,7 +273,7 @@ public class AccountPickerBottomSheetRenderTest {
return null; return null;
}) })
.when(mAccountPickerDelegateMock) .when(mAccountPickerDelegateMock)
.updateCredentials(eq(PROFILE_DATA1.getAccountName()), any()); .updateCredentials(eq(PROFILE_DATA1.getAccountEmail()), any());
onView(withText(R.string.auth_error_card_button)).perform(click()); onView(withText(R.string.auth_error_card_button)).perform(click());
mRenderTestRule.render( mRenderTestRule.render(
mCoordinator.getBottomSheetViewForTesting(), "collapsed_sheet_with_account"); mCoordinator.getBottomSheetViewForTesting(), "collapsed_sheet_with_account");
......
...@@ -146,7 +146,7 @@ public class AccountPickerMediatorTest { ...@@ -146,7 +146,7 @@ public class AccountPickerMediatorTest {
Assert.assertEquals(AccountPickerProperties.ItemType.EXISTING_ACCOUNT_ROW, item.type); Assert.assertEquals(AccountPickerProperties.ItemType.EXISTING_ACCOUNT_ROW, item.type);
PropertyModel model = item.model; PropertyModel model = item.model;
DisplayableProfileData profileData = model.get(ExistingAccountRowProperties.PROFILE_DATA); DisplayableProfileData profileData = model.get(ExistingAccountRowProperties.PROFILE_DATA);
Assert.assertEquals(accountEmail, profileData.getAccountName()); Assert.assertEquals(accountEmail, profileData.getAccountEmail());
Assert.assertEquals(fullName, profileData.getFullName()); Assert.assertEquals(fullName, profileData.getFullName());
Assert.assertEquals( Assert.assertEquals(
isSelectedAccount, model.get(ExistingAccountRowProperties.IS_SELECTED_ACCOUNT)); isSelectedAccount, model.get(ExistingAccountRowProperties.IS_SELECTED_ACCOUNT));
......
...@@ -113,8 +113,8 @@ public class AccountManagerTestRule implements TestRule { ...@@ -113,8 +113,8 @@ public class AccountManagerTestRule implements TestRule {
* @return The account added. * @return The account added.
*/ */
public CoreAccountInfo addAccount(ProfileDataSource.ProfileData profileData) { public CoreAccountInfo addAccount(ProfileDataSource.ProfileData profileData) {
CoreAccountInfo coreAccountInfo = addAccount(profileData.getAccountName()); CoreAccountInfo coreAccountInfo = addAccount(profileData.getAccountEmail());
mFakeAccountManagerFacade.setProfileData(profileData.getAccountName(), profileData); mFakeAccountManagerFacade.setProfileData(profileData.getAccountEmail(), profileData);
return coreAccountInfo; return coreAccountInfo;
} }
......
...@@ -18,15 +18,15 @@ public interface ProfileDataSource { ...@@ -18,15 +18,15 @@ public interface ProfileDataSource {
* Immutable holder for profile data. * Immutable holder for profile data.
*/ */
class ProfileData { class ProfileData {
private final String mAccountName; private final String mAccountEmail;
private final @Nullable Bitmap mAvatar; private final @Nullable Bitmap mAvatar;
private final @Nullable String mFullName; private final @Nullable String mFullName;
private final @Nullable String mGivenName; private final @Nullable String mGivenName;
public ProfileData(String accountName, @Nullable Bitmap avatar, @Nullable String fullName, public ProfileData(String accountEmail, @Nullable Bitmap avatar, @Nullable String fullName,
@Nullable String givenName) { @Nullable String givenName) {
assert accountName != null; assert accountEmail != null;
this.mAccountName = accountName; this.mAccountEmail = accountEmail;
this.mAvatar = avatar; this.mAvatar = avatar;
this.mFullName = fullName; this.mFullName = fullName;
this.mGivenName = givenName; this.mGivenName = givenName;
...@@ -34,10 +34,10 @@ public interface ProfileDataSource { ...@@ -34,10 +34,10 @@ public interface ProfileDataSource {
/** /**
* Gets the account email address. * Gets the account email address.
* @return the account name. * @return the account email.
*/ */
public String getAccountName() { public String getAccountEmail() {
return mAccountName; return mAccountEmail;
} }
/** /**
......
...@@ -58,7 +58,7 @@ public class FakeProfileDataSource implements ProfileDataSource { ...@@ -58,7 +58,7 @@ public class FakeProfileDataSource implements ProfileDataSource {
if (profileData == null) { if (profileData == null) {
mProfileDataMap.remove(accountId); mProfileDataMap.remove(accountId);
} else { } else {
assert accountId.equals(profileData.getAccountName()); assert accountId.equals(profileData.getAccountEmail());
mProfileDataMap.put(accountId, profileData); mProfileDataMap.put(accountId, profileData);
} }
fireOnProfileDataUpdatedNotification(accountId); fireOnProfileDataUpdatedNotification(accountId);
......
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