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

Commit 30bacb0a authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Fix disconnect order and gatt cache

Disconnect was removing the client before trying to access that client
id to send callbacks (hence we were never seeing gatt disconnect
callbacks). Also updates the gatt cache directory to one that is
accessible on ChromeOS/Linux.

Bug: 247605554
Tag: #floss
Test: Manual test on ChromeOS
Change-Id: I932e2ae623b6ef572d18b7af9885799a3ec44810
parent b6e89146
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -33,6 +33,15 @@ using gatt::StoredAttribute;
using std::string;
using std::vector;

#ifdef TARGET_FLOSS
#define GATT_CACHE_PREFIX "/var/lib/bluetooth/gatt/gatt_cache_"
#define GATT_CACHE_VERSION 6

#define GATT_HASH_MAX_SIZE 30
#define GATT_HASH_PATH_PREFIX "/var/lib/bluetooth/gatt/gatt_hash_"
#define GATT_HASH_PATH "/var/lib/bluetooth/gatt"
#define GATT_HASH_FILE_PREFIX "gatt_hash_"
#else
#define GATT_CACHE_PREFIX "/data/misc/bluetooth/gatt_cache_"
#define GATT_CACHE_VERSION 6

@@ -40,6 +49,7 @@ using std::vector;
#define GATT_HASH_PATH_PREFIX "/data/misc/bluetooth/gatt_hash_"
#define GATT_HASH_PATH "/data/misc/bluetooth"
#define GATT_HASH_FILE_PREFIX "gatt_hash_"
#endif

// Default expired time is 7 days
#define GATT_HASH_EXPIRED_TIME 604800
+2 −7
Original line number Diff line number Diff line
@@ -1658,22 +1658,17 @@ impl BtifGattClientCallbacks for BluetoothGatt {
        client_id: i32,
        addr: RawAddress,
    ) {
        self.context_map.remove_connection(client_id, conn_id);
        let client = self.context_map.get_by_client_id(client_id);
        if let Some(c) = client {
            let cbid = c.cbid;
            self.context_map.get_callback_from_callback_id(cbid).and_then(
                |cb: &mut GattClientCallback| {
                    cb.on_client_connection_state(
                        status,
                        client_id,
                        status == GattStatus::Success,
                        addr.to_string(),
                    );
                    cb.on_client_connection_state(status, client_id, false, addr.to_string());
                    Some(())
                },
            );
        }
        self.context_map.remove_connection(client_id, conn_id);
    }

    fn search_complete_cb(&mut self, conn_id: i32, _status: GattStatus) {