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

Commit be2d96a7 authored by Tetsutoki Shiozawa's avatar Tetsutoki Shiozawa Committed by Shunta Sato
Browse files

Fix: AccountManagerService crashed by accessing closed db

Symptom:
When a current user was switched, AccountManagerService crashed with
IllegalStateException.

Root cause:
accountsDb was closed when user was stopped. AccountManagerService
tried to insert a log record to the closed db and it failed.

Solution:
It catches the exception if it's failed to insert a log record.

Bug: 68233592
Change-Id: I97b63e4777bf7f8a1d38d96e494f6a21847d374b
parent 26817938
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -5082,10 +5082,18 @@ public class AccountManagerService
                logStatement.bindLong(4, callingUid);
                logStatement.bindString(5, tableName);
                logStatement.bindLong(6, userDebugDbInsertionPoint);
                try {
                    logStatement.execute();
                } catch (IllegalStateException e) {
                    // Guard against crash, DB can already be closed
                    // since this statement is executed on a handler thread
                    Slog.w(TAG, "Failed to insert a log record. accountId=" + accountId
                            + " action=" + action + " tableName=" + tableName + " Error: " + e);
                } finally {
                    logStatement.clearBindings();
                }
            }
        }

        LogRecordTask logTask = new LogRecordTask(action, tableName, accountId, userAccount,
                callingUid, userAccount.debugDbInsertionPoint);