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

Commit e232c44c authored by Dmitry Dementyev's avatar Dmitry Dementyev Committed by Android Build Coastguard Worker
Browse files

Ignore SQL exceptions in getAccountsAsUserForPackage and syncSharedAccounts.

In rare cases API is called for removed user and crashes system server.

Bug: 354148797
Test: manual
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2403b49b56970221a7bfc31bd811a5cf9e094046)
Merged-In: I9f1aef6f8e131ad1df11f68eda4c0db189b45b05
Change-Id: I9f1aef6f8e131ad1df11f68eda4c0db189b45b05
parent cd4d3a5d
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -4612,6 +4612,9 @@ public class AccountManagerService
                    opPackageName,
                    visibleAccountTypes,
                    includeUserManagedNotVisible);
        } catch (SQLiteException e) {
            Log.w(TAG, "Could not get accounts for user " + userId, e);
            return new Account[]{};
        } finally {
            restoreCallingIdentity(identityToken);
        }
@@ -4699,6 +4702,7 @@ public class AccountManagerService

    public Account[] getSharedAccountsAsUser(int userId) {
        userId = handleIncomingUser(userId);
        try {
            UserAccounts accounts = getUserAccounts(userId);
            synchronized (accounts.dbLock) {
                List<Account> accountList = accounts.accountsDb.getSharedAccounts();
@@ -4706,6 +4710,10 @@ public class AccountManagerService
                accountList.toArray(accountArray);
                return accountArray;
            }
        } catch (SQLiteException e) {
            Log.w(TAG, "Could not get shared accounts for user " + userId, e);
            return new Account[]{};
        }
    }

    @Override