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

Commit 5d8bf4a1 authored by Nicklas Shamlo's avatar Nicklas Shamlo Committed by Steve Kondik
Browse files

Make sure unmatched autenticator/account-types doesn't crash Contacts.

If the Contacts-app didn't find a valid authenticator for a specific
account-type, it would previously throw an exception and crash.
Now the account-type is silently ignored.

Installing an app with unmatching authenticator/accounts like, e.g:

<account-authenticator
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="com.abc.def"
    android:icon="@drawable/icon"
    android:smallIcon="@drawable/icon"
    android:label="@string/label"
/>

<sync-adapter
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:contentAuthority="com.android.contacts"
    android:accountType="com.abc.ghi"
    android:supportsUploading="true"
/>

would otherwise crash Contacts.

Change-Id: Idefa3266e1624246de97d1eae6612747b52f8c60
parent 3a399872
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -203,6 +203,10 @@ public class Sources extends BroadcastReceiver implements OnAccountsUpdateListen
                // adapter, using the authenticator to find general resources.
                final String accountType = sync.accountType;
                final AuthenticatorDescription auth = findAuthenticator(auths, accountType);
                if (auth == null) {
                    // no authenticator found for this account type, ignore it.
                    continue;
                }

                ContactsSource source;
                if (GoogleSource.ACCOUNT_TYPE.equals(accountType)) {
@@ -239,7 +243,7 @@ public class Sources extends BroadcastReceiver implements OnAccountsUpdateListen
                return auth;
            }
        }
        throw new IllegalStateException("Couldn't find authenticator for specific account type");
        return null;
    }

    /**