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

Commit 7a7fa568 authored by Stanley Tng's avatar Stanley Tng
Browse files

Delete Database before removing from list

Fixed the Bluetooth crash when forgetting a device due to a null object
access. The fix is to delete the database before removing it from the
list.

Test: Manual test with pairing and forgetting a LE device
Bug: 123312624
Change-Id: I3d531371d64f2dedaea299d5f74a99bbf935c71a
parent dc239973
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -151,9 +151,10 @@ public class DatabaseManager {
                }
                createMetadata(address);
            } else {
                if (mMetadataCache.containsKey(address)) {
                Metadata metadata = mMetadataCache.get(address);
                if (metadata != null) {
                    mMetadataCache.remove(address);
                    deleteDatabase(mMetadataCache.get(address));
                    deleteDatabase(metadata);
                }
            }
        }
@@ -707,9 +708,6 @@ public class DatabaseManager {
    }

    private void updateDatabase(Metadata data) {
        if (data == null) {
            Log.e(TAG, "updateDatabase: data is null");
        }
        if (data.getAddress() == null) {
            Log.e(TAG, "updateDatabase: address is null");
            return;
@@ -723,9 +721,6 @@ public class DatabaseManager {
    }

    private void deleteDatabase(Metadata data) {
        if (data == null) {
            Log.e(TAG, "deleteDatabase: data is null");
        }
        if (data.getAddress() == null) {
            Log.e(TAG, "deleteDatabase: address is null");
            return;