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

Commit 7373fc9a authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Add workaround for "Service Changed" indications breaking server-only remotes

am: fb702ee6

Change-Id: Ic0727d12da91674737a0b3300eb4a0aa1e686349
parents d83f1791 fb702ee6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1077,7 +1077,7 @@ void gatts_process_attribute_req(tGATT_TCB& tcb, uint8_t op_code, uint16_t len,
 * Returns          void
 *
 ******************************************************************************/
static void gatts_proc_srv_chg_ind_ack(tGATT_TCB tcb) {
void gatts_proc_srv_chg_ind_ack(tGATT_TCB tcb) {
  tGATTS_SRV_CHG_REQ req;
  tGATTS_SRV_CHG* p_buf = NULL;

+22 −0
Original line number Diff line number Diff line
@@ -597,6 +597,8 @@ void gatt_rsp_timeout(void* data) {
  gatt_disconnect(p_clcb->p_tcb);
}

extern void gatts_proc_srv_chg_ind_ack(tGATT_TCB tcb);

/*******************************************************************************
 *
 * Function         gatt_indication_confirmation_timeout
@@ -609,6 +611,26 @@ void gatt_rsp_timeout(void* data) {
void gatt_indication_confirmation_timeout(void* data) {
  tGATT_TCB* p_tcb = (tGATT_TCB*)data;

  if (p_tcb->indicate_handle == gatt_cb.handle_of_h_r) {
    /* There are some GATT Server only devices, that don't implement GATT client
     * functionalities, and ignore "Service Changed" indication. Android does
     * not have CCC in "Service Changed" characteristic, and sends it to all
     * bonded devices. This leads to situation where remote can ignore the
     * indication, and trigger 30s timeout, then reconnection in a loop.
     *
     * Since chances of healthy Client device keeping connection for 30 seconds
     * and not responding to "Service Changed" indication are very low, assume
     * we are dealing with Server only device, and don't trigger disconnection.
     *
     * TODO: In future, we should properly expose CCC, and send indication only
     * to devices that register for it.
     */
    LOG(WARNING) << " Service Changed notification timed out in 30 "
                    "seconds, assuming server-only remote, not disconnecting";
    gatts_proc_srv_chg_ind_ack(*p_tcb);
    return;
  }

  LOG(WARNING) << __func__ << " disconnecting...";
  gatt_disconnect(p_tcb);
}