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

Commit 6fbc74ed authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Gerrit Code Review
Browse files

Merge "Create metadata after the device is bonded" into main

parents 7f007c1e ecb163aa
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ public class DatabaseManager {
    void bondStateChanged(BluetoothDevice device, int state) {
        synchronized (mMetadataCache) {
            String address = device.getAddress();
            if (!Flags.createMetadataAfterBonding()) {
                if (state != BluetoothDevice.BOND_NONE) {
                    if (mMetadataCache.containsKey(address)) {
                        return;
@@ -213,6 +214,21 @@ public class DatabaseManager {
                        deleteDatabase(metadata);
                    }
                }
                return;
            }

            if (state == BluetoothDevice.BOND_BONDED) {
                if (mMetadataCache.containsKey(address)) {
                    return;
                }
                createMetadata(address, false);
            } else if (state == BluetoothDevice.BOND_NONE) {
                Metadata metadata = mMetadataCache.get(address);
                if (metadata != null) {
                    mMetadataCache.remove(address);
                    deleteDatabase(metadata);
                }
            }
        }
    }