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

Commit de41684c authored by Fred Quintana's avatar Fred Quintana Committed by Android (Google) Code Review
Browse files

Merge "fix a bug where some accounts changed listeners don't see the new...

Merge "fix a bug where some accounts changed listeners don't see the new version of the accounts because the accounts changed broadcast is sent from within the transaction try block, thus before db.endTransaction() is called."
parents 0761cea3 743dfad2
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -399,19 +399,19 @@ public class AccountManagerService

    private boolean insertAccountIntoDatabase(Account account, String password, Bundle extras) {
        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
        db.beginTransaction();
        try {
        if (account == null) {
            return false;
        }
            boolean noBroadcast = false;
            if (account.type.equals(GOOGLE_ACCOUNT_TYPE)) {
                // Look for the 'nobroadcast' flag and remove it since we don't want it to persist
                // in the db.
                noBroadcast = extras.getBoolean(NO_BROADCAST_FLAG, false);
        final boolean noBroadcast = account.type.equals(GOOGLE_ACCOUNT_TYPE)
                && extras != null && extras.getBoolean(NO_BROADCAST_FLAG, false);
        // Remove the 'nobroadcast' flag since we don't want it to persist in the db. It is instead
        // used as a control signal to indicate whether or not this insertion should result in
        // an accounts changed broadcast being sent.
        if (extras != null) {
            extras.remove(NO_BROADCAST_FLAG);
        }

        db.beginTransaction();
        try {
            long numMatches = DatabaseUtils.longForQuery(db,
                    "select count(*) from " + TABLE_ACCOUNTS
                            + " WHERE " + ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
@@ -436,13 +436,13 @@ public class AccountManagerService
                }
            }
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
        if (!noBroadcast) {
            sendAccountsChangedBroadcast();
        }
        return true;
        } finally {
            db.endTransaction();
        }
    }

    private long insertExtra(SQLiteDatabase db, long accountId, String key, String value) {
@@ -1681,11 +1681,11 @@ public class AccountManagerService
                try {
                    db.execSQL("DELETE from " + TABLE_AUTHTOKENS);
                    db.execSQL("UPDATE " + TABLE_ACCOUNTS + " SET " + ACCOUNTS_PASSWORD + " = ''");
                    sendAccountsChangedBroadcast();
                    db.setTransactionSuccessful();
                } finally {
                    db.endTransaction();
                }
                sendAccountsChangedBroadcast();
            }
            setMetaValue("imsi", imsi);
        }