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

Commit 4fbcd194 authored by Marcus Hagerott's avatar Marcus Hagerott
Browse files

Fix crash when viewing or editing contacts without account

QuickContact and editor would crash when opening contacts with an
account_name and account_type from an invalid account or an account
without a contacts sync adapter.

Test: manually verify that a contact with a bogus account can be opened
in QuickContact and editor.

Bug 36782218

Change-Id: I943581be036dff07838ca630c0b771b370f9e2c7
parent 6d2e4427
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -580,9 +580,9 @@ class AccountTypeManagerImpl extends AccountTypeManager
        if (account == null) {
            return null;
        }
        final AccountType type = mTypeProvider.getTypeForAccount(account);
        AccountType type = mTypeProvider.getTypeForAccount(account);
        if (type == null) {
            return null;
            type = mFallbackAccountType;
        }
        return type.wrapAccount(mContext, account);
    }
@@ -703,7 +703,8 @@ class AccountTypeManagerImpl extends AccountTypeManager
     */
    @Override
    public AccountType getAccountType(AccountTypeWithDataSet accountTypeWithDataSet) {
        return mTypeProvider.getType(
        final AccountType type = mTypeProvider.getType(
                accountTypeWithDataSet.accountType, accountTypeWithDataSet.dataSet);
        return type != null ? type : mFallbackAccountType;
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -93,4 +93,18 @@ public class FallbackAccountType extends BaseAccountType {
    public boolean areContactsWritable() {
        return true;
    }


    /**
     * {@inheritDoc}
     *
     * <p>This is overriden because the base class validates that the account.type matches
     * {@link #accountType} but for the fallback case we want to be more permissive</p>
     */
    @Override
    public AccountInfo wrapAccount(Context context, AccountWithDataSet account) {
        return new AccountInfo(
                new AccountDisplayInfo(account, account.name,
                        getDisplayLabel(context), getDisplayIcon(context), false), this);
    }
}