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

Commit f0f1a1e9 authored by Jack He's avatar Jack He Committed by Myles Watson
Browse files

LE-COC: Free LE-COC server resource when BluetoothServerSocket is closed

* When BluetoothServerSocket is closed in the Java layer, the native
  layer should respond by freeing all resources used by the server
  including file descriptors, structs, PSMs, and security IDs
* We did this correctly for BR_EDR L2CAP COC channels after
  I4e37dcd858af258fbd64fbfb2fbf0083bd743e06, but the same fix did not
  apply to LE COC
* This CL make sure LE COC server resources are freed propertly upon
  server fd closure

Test: open and close LE COC server repeatedly on an Android phone
Fixes: 144148429
Change-Id: I16fa10e77612105d23848f71925ff6efc95bc75a
(cherry picked from commit 71a497ed)
parent 53822e21
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -254,6 +254,11 @@ static void btsock_l2cap_free_l(l2cap_socket* sock) {
    }
    if ((sock->channel >= 0) && (sock->server)) {
      BTA_JvFreeChannel(sock->channel, BTA_JV_CONN_TYPE_L2CAP_LE);
      if (!sock->fixed_chan) {
        VLOG(2) << __func__ << ": stopping L2CAP LE COC server channel "
                << sock->channel;
        BTA_JvL2capStopServer(sock->channel, sock->id);
      }
    }
  } else {
    // Only call if we are non server connections