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

Commit 800286dc authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Prevents the OOB data generation procedure from getting stuck because

the SMP state machine is busy

This makes the smp state machine return whether an event is successfully
executed.

Bug: 266006098
Test: Manual
Change-Id: If70c930e1586d03f5125dcfb3897c37f9eb2c87f
(cherry picked from commit 4319fc82)
Merged-In: If70c930e1586d03f5125dcfb3897c37f9eb2c87f
parent 682be609
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2803,7 +2803,11 @@ void btif_dm_generate_local_oob_data(tBT_TRANSPORT transport) {
        stop_oob_advertiser();
      }
      waiting_on_oob_advertiser_start = true;
      SMP_CrLocScOobData();
      if (!SMP_CrLocScOobData()) {
        waiting_on_oob_advertiser_start = false;
        invoke_oob_data_request_cb(transport, false, Octet16{}, Octet16{},
                                 RawAddress{}, 0x00);
      }
    } else {
      invoke_oob_data_request_cb(transport, false, Octet16{}, Octet16{},
                                 RawAddress{}, 0x00);
+4 −1
Original line number Diff line number Diff line
@@ -187,8 +187,11 @@ extern void SMP_SecureConnectionOobDataReply(uint8_t* p_data);
 * Description      This function is called to generate a public key to be
 *                  passed to a remote device via an Out of Band transport
 *
 * Returns          true if the request is successfully sent and executed by the
 *                  state machine, false otherwise
 *
 ******************************************************************************/
extern void SMP_CrLocScOobData();
extern bool SMP_CrLocScOobData();

/*******************************************************************************
 *
+5 −2
Original line number Diff line number Diff line
@@ -567,10 +567,13 @@ void SMP_SecureConnectionOobDataReply(uint8_t* p_data) {
 * Description      This function is called to generate a public key to be
 *                  passed to a remote device via Out of Band transport.
 *
 * Returns          true if the request is successfully sent and executed by the
 *                  state machine, false otherwise
 *
 ******************************************************************************/
void SMP_CrLocScOobData() {
bool SMP_CrLocScOobData() {
  tSMP_INT_DATA smp_int_data;
  smp_sm_event(&smp_cb, SMP_CR_LOC_SC_OOB_DATA_EVT, &smp_int_data);
  return smp_sm_event(&smp_cb, SMP_CR_LOC_SC_OOB_DATA_EVT, &smp_int_data);
}

/*******************************************************************************
+1 −1
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ extern tSMP_CB smp_cb;
extern void smp_init(void);

/* smp main */
extern void smp_sm_event(tSMP_CB* p_cb, tSMP_EVENT event,
extern bool smp_sm_event(tSMP_CB* p_cb, tSMP_EVENT event,
                         tSMP_INT_DATA* p_data);

extern tSMP_STATE smp_get_state(void);
+8 −5
Original line number Diff line number Diff line
@@ -973,17 +973,19 @@ tSMP_STATE smp_get_state(void) { return smp_cb.state; }
 *              not NULL state, adjust the new state to the returned state. If
 *              (api_evt != MAX), call callback function.
 *
 * Returns      void.
 * Returns      true if the event is executed and a state transition can be
 *              expected, false if the event is ignored, state is invalid, or
 *              the role is invalid for the control block.
 *
 ******************************************************************************/
void smp_sm_event(tSMP_CB* p_cb, tSMP_EVENT event, tSMP_INT_DATA* p_data) {
bool smp_sm_event(tSMP_CB* p_cb, tSMP_EVENT event, tSMP_INT_DATA* p_data) {
  uint8_t curr_state = p_cb->state;
  tSMP_SM_TBL state_table;
  uint8_t action, entry, i;

  if (p_cb->role >= 2) {
    SMP_TRACE_DEBUG("Invalid role: %d", p_cb->role);
    return;
    return false;
  }

  tSMP_ENTRY_TBL entry_table = smp_entry_table[p_cb->role];
@@ -991,7 +993,7 @@ void smp_sm_event(tSMP_CB* p_cb, tSMP_EVENT event, tSMP_INT_DATA* p_data) {
  SMP_TRACE_EVENT("main smp_sm_event");
  if (curr_state >= SMP_STATE_MAX) {
    SMP_TRACE_DEBUG("Invalid state: %d", curr_state);
    return;
    return false;
  }

  SMP_TRACE_DEBUG("SMP Role: %s State: [%s (%d)], Event: [%s (%d)]",
@@ -1014,7 +1016,7 @@ void smp_sm_event(tSMP_CB* p_cb, tSMP_EVENT event, tSMP_INT_DATA* p_data) {
    SMP_TRACE_DEBUG("Ignore event [%s (%d)] in state [%s (%d)]",
                    smp_get_event_name(event), event,
                    smp_get_state_name(curr_state), curr_state);
    return;
    return false;
  }

  /* Get possible next state from state table. */
@@ -1035,6 +1037,7 @@ void smp_sm_event(tSMP_CB* p_cb, tSMP_EVENT event, tSMP_INT_DATA* p_data) {
    }
  }
  SMP_TRACE_DEBUG("result state = %s", smp_get_state_name(p_cb->state));
  return true;
}

/*******************************************************************************
Loading