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

Commit 2b1e6779 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 25639 into eclair

* changes:
  do not use transactions for calls that just read the DB
parents 45dfa63a 86bd084c
Loading
Loading
Loading
Loading
+18 −37
Original line number Diff line number Diff line
@@ -287,15 +287,11 @@ public class AccountManagerService

    private String readUserDataFromDatabase(Account account, String key) {
        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        db.beginTransaction();
        try {
            long accountId = getAccountId(db, account);
            if (accountId < 0) {
                return null;
            }
        Cursor cursor = db.query(TABLE_EXTRAS, new String[]{EXTRAS_VALUE},
                    EXTRAS_ACCOUNTS_ID + "=" + accountId + " AND " + EXTRAS_KEY + "=?",
                    new String[]{key}, null, null, null);
                EXTRAS_ACCOUNTS_ID
                        + "=(select _id FROM accounts WHERE name=? AND type=?) AND "
                        + EXTRAS_KEY + "=?",
                new String[]{account.name, account.type, key}, null, null, null);
        try {
            if (cursor.moveToNext()) {
                return cursor.getString(0);
@@ -304,9 +300,6 @@ public class AccountManagerService
        } finally {
            cursor.close();
        }
        } finally {
            db.endTransaction();
        }
    }

    public AuthenticatorDescription[] getAuthenticatorTypes() {
@@ -530,15 +523,18 @@ public class AccountManagerService

    public String readAuthTokenFromDatabase(Account account, String authTokenType) {
        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
        db.beginTransaction();
        Cursor cursor = db.query(TABLE_AUTHTOKENS, new String[]{AUTHTOKENS_AUTHTOKEN},
                AUTHTOKENS_ACCOUNTS_ID + "=(select _id FROM accounts WHERE name=? AND type=?) AND "
                        + AUTHTOKENS_TYPE + "=?",
                new String[]{account.name, account.type, authTokenType},
                null, null, null);
        try {
            long accountId = getAccountId(db, account);
            if (accountId < 0) {
                return null;
            if (cursor.moveToNext()) {
                return cursor.getString(0);
            }
            return getAuthToken(db, accountId, authTokenType);
            return null;
        } finally {
            db.endTransaction();
            cursor.close();
        }
    }

@@ -1069,21 +1065,6 @@ public class AccountManagerService
        }
    }

    private String getAuthToken(SQLiteDatabase db, long accountId, String authTokenType) {
        Cursor cursor = db.query(TABLE_AUTHTOKENS, new String[]{AUTHTOKENS_AUTHTOKEN},
                AUTHTOKENS_ACCOUNTS_ID + "=" + accountId + " AND " + AUTHTOKENS_TYPE + "=?",
                new String[]{authTokenType},
                null, null, null);
        try {
            if (cursor.moveToNext()) {
                return cursor.getString(0);
            }
            return null;
        } finally {
            cursor.close();
        }
    }

    private abstract class Session extends IAccountAuthenticatorResponse.Stub
            implements AuthenticatorBindHelper.Callback, IBinder.DeathRecipient {
        IAccountManagerResponse mResponse;