From 41bf90c94f6bcd4a921f1f1f5767967647171730 Mon Sep 17 00:00:00 2001 From: althafvly Date: Fri, 27 Dec 2024 12:04:58 +0530 Subject: [PATCH] mail: Fix yahoo login for existing users --- .../accountmanager/EeloAccountCreator.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java index 2b001f7a98..f1f9071962 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/accountmanager/EeloAccountCreator.java @@ -98,8 +98,8 @@ public class EeloAccountCreator { android.accounts.Account[] openIdAccounts = accountManager.getAccountsByType(accountType); for (android.accounts.Account openIdAccount : openIdAccounts) { - String emailId = - accountManager.getUserData(openIdAccount, AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY); + final String emailId = getEmailId(accountManager, openIdAccount); + if (isInvalidEmail(emailId)) { continue; } @@ -149,7 +149,8 @@ public class EeloAccountCreator { android.accounts.Account[] eeloAccounts = accountManager.getAccountsByType(AccountManagerConstants.EELO_ACCOUNT_TYPE); for (android.accounts.Account eeloAccount : eeloAccounts) { - String emailId = accountManager.getUserData(eeloAccount, AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY); + final String emailId = getEmailId(accountManager, eeloAccount); + if (isInvalidEmail(emailId)) { continue; } @@ -176,6 +177,16 @@ public class EeloAccountCreator { } } + private static String getEmailId(AccountManager accountManager, android.accounts.Account account) { + String emailId = accountManager.getUserData(account, AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY); + + if (emailId == null || emailId.equals("null") || emailId.isBlank()) { + return account.name; + } + + return emailId; + } + @RequiresApi(api = VERSION_CODES.N) private static void deleteIncompleteAccounts(List accounts, BackgroundAccountRemover accountRemover) { accounts.stream().filter(account -> !account.isFinishedSetup()) -- GitLab