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

Commit 64c99c99 authored by Charles Lin's avatar Charles Lin
Browse files

Set proper scan type before first discovery

Set scan type when start first discover after bt enabled.
And replace adv evt hex code to define code

Test: Enable Bluetooth and then start discovery.
Bug: 146474336
Change-Id: I63c8cda5343de15381c83da4ea3afde6b75aaf6a
parent 11f37fb4
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -1305,6 +1305,7 @@ tBTM_STATUS btm_ble_start_inquiry(uint8_t mode, uint8_t duration) {
    /* enable IRK list */
    btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
#endif
    p_ble_cb->inq_var.scan_type = BTM_BLE_SCAN_MODE_ACTI;
    p_ble_cb->inq_var.scan_duplicate_filter = BTM_BLE_DUPLICATE_DISABLE;
    status = btm_ble_start_scan();
  } else if ((p_ble_cb->inq_var.scan_interval !=
@@ -1892,18 +1893,23 @@ void btm_ble_process_adv_pkt(uint8_t data_len, uint8_t* data) {
    btm_ble_process_adv_addr(bda, &addr_type);

    uint16_t event_type;
    if (legacy_evt_type == 0x00) {  // ADV_IND;
      event_type = 0x0013;
    } else if (legacy_evt_type == 0x01) {  // ADV_DIRECT_IND;
      event_type = 0x0015;
    } else if (legacy_evt_type == 0x02) {  // ADV_SCAN_IND;
      event_type = 0x0012;
    } else if (legacy_evt_type == 0x03) {  // ADV_NONCONN_IND;
      event_type = 0x0010;
    } else if (legacy_evt_type == 0x04) {  // SCAN_RSP;
    event_type = 1 << BLE_EVT_LEGACY_BIT;
    if (legacy_evt_type == BTM_BLE_ADV_IND_EVT) {
      event_type |= (1 << BLE_EVT_CONNECTABLE_BIT)|
                    (1 << BLE_EVT_SCANNABLE_BIT);
    } else if (legacy_evt_type == BTM_BLE_ADV_DIRECT_IND_EVT) {
      event_type |= (1 << BLE_EVT_CONNECTABLE_BIT)|
                    (1 << BLE_EVT_DIRECTED_BIT);
    } else if (legacy_evt_type == BTM_BLE_ADV_SCAN_IND_EVT) {
      event_type |= (1 << BLE_EVT_SCANNABLE_BIT);
    } else if (legacy_evt_type == BTM_BLE_ADV_NONCONN_IND_EVT) {
      event_type = (1 << BLE_EVT_LEGACY_BIT);//0x0010;
    } else if (legacy_evt_type == BTM_BLE_SCAN_RSP_EVT) {  // SCAN_RSP;
      // We can't distinguish between "SCAN_RSP to an ADV_IND", and "SCAN_RSP to
      // an ADV_SCAN_IND", so always return "SCAN_RSP to an ADV_IND"
      event_type = 0x001B;
      event_type |= (1 << BLE_EVT_CONNECTABLE_BIT)|
                    (1 << BLE_EVT_SCANNABLE_BIT)|
                    (1 << BLE_EVT_SCAN_RESPONSE_BIT);
    } else {
      BTM_TRACE_ERROR(
          "Malformed LE Advertising Report Event - unsupported "
+5 −1
Original line number Diff line number Diff line
@@ -36,7 +36,11 @@ typedef uint8_t tBTM_BLE_CHNL_MAP[CHNL_MAP_LEN];
#define BTM_BLE_NON_CONNECT_EVT 0x03
/* Connectable low duty cycle directed advertising  */
#define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04
/* 0x00 - 0x05 can be received on adv event type */
/* 0x00 - 0x04 can be received on adv event type */
#define BTM_BLE_ADV_IND_EVT  0x00
#define BTM_BLE_ADV_DIRECT_IND_EVT  0x01
#define BTM_BLE_ADV_SCAN_IND_EVT  0x02
#define BTM_BLE_ADV_NONCONN_IND_EVT  0x03
#define BTM_BLE_SCAN_RSP_EVT 0x04
#define BTM_BLE_SCAN_REQ_EVT 0x05
#define BTM_BLE_UNKNOWN_EVT 0xff