Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e30caf20 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '3378-main-mail_crash' into 'main'

mail: Fix crash when accessing server settings for unfinished accounts

See merge request !173
parents d6b474d9 61241d36
Loading
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.fsck.k9.activity.setup.accountmanager;


import java.util.List;
import java.util.stream.Collectors;

import android.accounts.AccountManager;
import android.content.ContentResolver;
@@ -65,11 +66,17 @@ public class EeloAccountCreator {

            List<Account> accounts = preferences.getAccounts();
            deleteIncompleteAccounts(accounts, accountRemover);
            // deleteIncompleteAccounts is asynchronous.
            // The second time we call preferences.getAccounts()
            // The accounts might not yet be removed
            List<Account> finalAccounts = accounts.stream()
                .filter(Account::isFinishedSetup)
                .collect(Collectors.toList());

            loadEeloAccounts(context, accounts, accountManager, jobManager);
            loadEeloAccounts(context, finalAccounts, accountManager, jobManager);

            AccountManagerConstants.INSTANCE.getOPENID_ACCOUNT_TYPES()
                .forEach(accountType -> loadOpenIdAccounts(context, accountType, accounts, accountManager, jobManager));
                .forEach(accountType -> loadOpenIdAccounts(context, accountType, finalAccounts, accountManager, jobManager));
        } catch (SecurityException e) {
            Timber.e(e, "Failed to load accounts from accountManager because of security violation");
        }