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

Commit fdd6358a authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "GATT: Disable notifications when disconnecting" am: e7c6d4c8 am:...

Merge "GATT: Disable notifications when disconnecting" am: e7c6d4c8 am: 4cbc5b11 am: 1a6703aa am: a3956235 am: d8cda775

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2133662



Change-Id: I25118d72ac59986183ca0cd3d728f446108cc8f9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 54c49700 d8cda775
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -385,6 +385,16 @@ void bta_gattc_open(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
    return;
  }

  tBTA_GATTC_RCB* p_clreg = p_clcb->p_rcb;
  /* Re-enable notification registration for closed connection */
  for (int i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i++) {
    if (p_clreg->notif_reg[i].in_use &&
        p_clreg->notif_reg[i].remote_bda == p_clcb->bda &&
        p_clreg->notif_reg[i].app_disconnected) {
      p_clreg->notif_reg[i].app_disconnected = false;
    }
  }

  /* a connected remote device */
  if (GATT_GetConnIdIfConnected(
          p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda,
@@ -511,6 +521,16 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {

  if (p_clcb->p_srcb->mtu == 0) p_clcb->p_srcb->mtu = GATT_DEF_BLE_MTU_SIZE;

  tBTA_GATTC_RCB* p_clreg = p_clcb->p_rcb;
  /* Re-enable notification registration for closed connection */
  for (int i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i++) {
    if (p_clreg->notif_reg[i].in_use &&
        p_clreg->notif_reg[i].remote_bda == p_clcb->bda &&
        p_clreg->notif_reg[i].app_disconnected) {
      p_clreg->notif_reg[i].app_disconnected = false;
    }
  }

  /* start database cache if needed */
  if (p_clcb->p_srcb->gatt_database.IsEmpty() ||
      p_clcb->p_srcb->state != BTA_GATTC_SERV_IDLE) {
@@ -604,6 +624,14 @@ void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
    bta_sys_conn_close(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
  }

  /* Disable notification registration for closed connection */
  for (int i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i++) {
    if (p_clreg->notif_reg[i].in_use &&
        p_clreg->notif_reg[i].remote_bda == p_clcb->bda) {
      p_clreg->notif_reg[i].app_disconnected = true;
    }
  }

  bta_gattc_clcb_dealloc(p_clcb);

  if (p_data->hdr.event == BTA_GATTC_API_CLOSE_EVT) {
+1 −0
Original line number Diff line number Diff line
@@ -230,6 +230,7 @@ typedef struct {

typedef struct {
  bool in_use;
  bool app_disconnected;
  RawAddress remote_bda;
  uint16_t handle;
} tBTA_GATTC_NOTIF_REG;
+2 −1
Original line number Diff line number Diff line
@@ -352,7 +352,8 @@ bool bta_gattc_check_notif_registry(tBTA_GATTC_RCB* p_clreg,
  for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i++) {
    if (p_clreg->notif_reg[i].in_use &&
        p_clreg->notif_reg[i].remote_bda == p_srcb->server_bda &&
        p_clreg->notif_reg[i].handle == p_notify->handle) {
        p_clreg->notif_reg[i].handle == p_notify->handle &&
        !p_clreg->notif_reg[i].app_disconnected) {
      VLOG(1) << "Notification registered!";
      return true;
    }