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

Commit f7bbdc81 authored by William Escande's avatar William Escande
Browse files

DatabaseManager: Allow more flexible cleanup

Test: atest SystemAppCheck#system_app_crash
Bug: 328698375
Bug: 332627403
Fix: 332627403
Change-Id: Id4a94c462cdab341dcec7cadcdc6e7861030ec18
parent f2bf4d9a
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1084,12 +1084,11 @@ public class DatabaseManager {
     * @param database the Bluetooth storage {@link MetadataDatabase}
     */
    public void start(MetadataDatabase database) {
        Log.d(TAG, "start()");

        if (database == null) {
            Log.e(TAG, "stat failed, database is null.");
            Log.e(TAG, "start failed, database is null.");
            return;
        }
        Log.d(TAG, "start()");

        synchronized (mDatabaseLock) {
            mDatabase = database;
@@ -1124,6 +1123,12 @@ public class DatabaseManager {

    /** Close and de-init the DatabaseManager */
    public void cleanup() {
        synchronized (mDatabaseLock) {
            if (mDatabase == null) {
                Log.w(TAG, "cleanup called on non started database");
                return;
            }
        }
        removeUnusedMetadata();
        mAdapterService.unregisterReceiver(mReceiver);
        if (mHandlerThread != null) {