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

Commit 45107e0c authored by Marc Blank's avatar Marc Blank
Browse files

AbstractSyncableContentProvider must only call onAccountsChanged with GAIA accounts

Currently, ASCP calls onAccountsChanged with an array of ALL accounts, but
ContactsProvider and CalendarProvider assume these are all GAIA accounts.
This can cause a looping crash in acore, so the code has been changed to
only pass an array of GAIA accounts...
parent 89fe2736
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -165,6 +165,20 @@ public abstract class AbstractSyncableContentProvider extends SyncableContentPro
                        // Some providers override onAccountsChanged(); give them a database to
                        // Some providers override onAccountsChanged(); give them a database to
                        // work with.
                        // work with.
                        mDb = mOpenHelper.getWritableDatabase();
                        mDb = mOpenHelper.getWritableDatabase();
                        // Only call onAccountsChanged on GAIA accounts; otherwise, the contacts and
                        // calendar providers will choke as they try to sync unknown accounts with
                        // AbstractGDataSyncAdapter, which will put acore into a crash loop
                        ArrayList<Account> gaiaAccounts = new ArrayList<Account>();
                        for (Account acct: accounts) {
                            if (acct.mType.equals("com.google.GAIA")) {
                                gaiaAccounts.add(acct);
                            }
                        }
                        accounts = new Account[gaiaAccounts.size()];
                        int i = 0;
                        for (Account acct: gaiaAccounts) {
                            accounts[i++] = acct;
                        }
                        onAccountsChanged(accounts);
                        onAccountsChanged(accounts);
                        TempProviderSyncAdapter syncAdapter = getTempProviderSyncAdapter();
                        TempProviderSyncAdapter syncAdapter = getTempProviderSyncAdapter();
                        if (syncAdapter != null) {
                        if (syncAdapter != null) {
@@ -175,7 +189,6 @@ public abstract class AbstractSyncableContentProvider extends SyncableContentPro


        return true;
        return true;
    }
    }

    /**
    /**
     * Get a non-persistent instance of this content provider.
     * Get a non-persistent instance of this content provider.
     * You must call {@link #close} on the returned
     * You must call {@link #close} on the returned