15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 2009-2012 Broadcom Corporation 45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * you may not use this file except in compliance with the License. 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * You may obtain a copy of the License at: 85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * See the License for the specific language governing permissions and 155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * limitations under the License. 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/************************************************************************************ 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Filename: btif_dm.c 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Description: Contains Device Management (DM) related functionality 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ***********************************************************************************/ 275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <stdio.h> 285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <stdlib.h> 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <unistd.h> 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <hardware/bluetooth.h> 325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <utils/Log.h> 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <cutils/properties.h> 355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "gki.h" 365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btu.h" 375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bd.h" 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_api.h" 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btif_api.h" 405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btif_util.h" 41ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "btif_dm.h" 425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btif_storage.h" 435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btif_hh.h" 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btif_config.h" 455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 46ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "bta_gatt_api.h" 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Constants & Macros 495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define COD_UNCLASSIFIED ((0x1F) << 8) 52ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_HID_KEYBOARD 0x0540 53ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_HID_POINTING 0x0580 54ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_HID_COMBO 0x05C0 55ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_HID_MAJOR 0x0500 56ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_AV_HEADSETS 0x0404 57ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_AV_HANDSFREE 0x0408 58ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_AV_HEADPHONES 0x0418 59ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_AV_PORTABLE_AUDIO 0x041C 60ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera#define COD_AV_HIFI_AUDIO 0x0428 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTIF_DM_DEFAULT_INQ_MAX_RESULTS 0 645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTIF_DM_DEFAULT_INQ_MAX_DURATION 10 65ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta#define BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING 2 66ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 671e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie#define PROPERTY_PRODUCT_MODEL "ro.product.model" 68a30d95acf60f04531923e8ab06d976744697bf51Matthew Xie#define DEFAULT_LOCAL_NAME_MAX 31 691e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie#if (DEFAULT_LOCAL_NAME_MAX > BTM_MAX_LOC_BD_NAME_LEN) 701e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie #error "default btif local name size exceeds stack supported length" 711e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie#endif 72ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 737f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE) 747f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#define BTIF_DM_INTERLEAVE_DURATION_BR_ONE 2 757f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#define BTIF_DM_INTERLEAVE_DURATION_LE_ONE 2 767f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#define BTIF_DM_INTERLEAVE_DURATION_BR_TWO 3 777f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#define BTIF_DM_INTERLEAVE_DURATION_LE_TWO 4 787f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#endif 797f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie 80ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 81ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bond_state_t state; 835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BD_ADDR bd_addr; 845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 is_temp; 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 pin_code_len; 865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 is_ssp; 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 autopair_attempts; 885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 is_local_initiated; 89ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta UINT8 sdp_attempts; 90ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 91ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BOOLEAN is_le_only; 92ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_ble_cb_t ble; 93ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} btif_dm_pairing_cb_t; 955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 96ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 97ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 98ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 99ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT8 ir[BT_OCTET16_LEN]; 100ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT8 irk[BT_OCTET16_LEN]; 101ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT8 dhk[BT_OCTET16_LEN]; 102ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta}btif_dm_local_key_id_t; 103ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 104ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 105ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 106ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BOOLEAN is_er_rcvd; 107ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT8 er[BT_OCTET16_LEN]; 108ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BOOLEAN is_id_keys_rcvd; 109ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_local_key_id_t id_keys; /* ID kyes */ 110ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 111ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta}btif_dm_local_key_cb_t; 112ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 113ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battatypedef struct 114ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BD_ADDR bd_addr; 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BD_NAME bd_name; 1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} btif_dm_remote_name_t; 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projecttypedef struct 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_OCTET16 sp_c; 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_OCTET16 sp_r; 1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BD_ADDR oob_bdaddr; /* peer bdaddr*/ 1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} btif_dm_oob_cb_t; 1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id)) 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* This flag will be true if HCI_Inquiry is in progress */ 1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BOOLEAN btif_dm_inquiry_in_progress = FALSE; 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1301e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie/************************************************************************************ 1311e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie** Static variables 1321e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie************************************************************************************/ 1331e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xiestatic char btif_default_local_name[DEFAULT_LOCAL_NAME_MAX+1] = {'\0'}; 1341e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie 1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Static functions 1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic btif_dm_pairing_cb_t pairing_cb; 1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic btif_dm_oob_cb_t oob_cb; 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_generic_evt(UINT16 event, char* p_param); 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_cb_create_bond(bt_bdaddr_t *bd_addr); 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_cb_hid_remote_name(tBTM_REMOTE_DEV_NAME *p_remote_name); 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_update_remote_properties(BD_ADDR bd_addr, BD_NAME bd_name, 1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type); 145ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 146ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic btif_dm_local_key_cb_t ble_local_key_cb; 147ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_ssp_key_notif); 148ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl); 149ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_passkey_req_evt(tBTA_DM_PIN_REQ *p_pin_req); 150ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 1511e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xiestatic char* btif_get_default_local_name(); 1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Externs 1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern UINT16 bta_service_id_to_uuid_lkup_tbl [BTA_MAX_SERVICE_ID]; 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern bt_status_t btif_hf_execute_service(BOOLEAN b_enable); 1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern bt_status_t btif_av_execute_service(BOOLEAN b_enable); 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern bt_status_t btif_hh_execute_service(BOOLEAN b_enable); 1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectextern int btif_hh_connect(bt_bdaddr_t *bd_addr); 1602e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbachextern void bta_gatt_convert_uuid16_to_uuid128(UINT8 uuid_128[LEN_UUID_128], UINT16 uuid_16); 1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Functions 1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id, 1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN b_enable) 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Check the service_ID and invoke the profile's BT state changed API */ 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (service_id) 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_HFP_SERVICE_ID: 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_HSP_SERVICE_ID: 1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_hf_execute_service(b_enable); 1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project }break; 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_A2DP_SERVICE_ID: 1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_av_execute_service(b_enable); 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project }break; 1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_HID_SERVICE_ID: 1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_hh_execute_service(b_enable); 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project }break; 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR1("%s: Unknown service being enabled", __FUNCTION__); 1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_FAIL; 1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function check_eir_remote_name 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Check if remote name is in the EIR data 1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns TRUE if remote name found 2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Populate p_remote_name, if provided and remote name found 2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BOOLEAN check_eir_remote_name(tBTA_DM_SEARCH *p_search_data, 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_remote_name, UINT8 *p_remote_name_len) 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_eir_remote_name = NULL; 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 remote_name_len = 0; 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Check EIR for remote name and services */ 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_search_data->inq_res.p_eir) 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_eir_remote_name = BTA_CheckEirData(p_search_data->inq_res.p_eir, 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &remote_name_len); 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!p_eir_remote_name) 2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_eir_remote_name = BTA_CheckEirData(p_search_data->inq_res.p_eir, 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTM_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len); 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_eir_remote_name) 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (remote_name_len > BD_NAME_LEN) 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project remote_name_len = BD_NAME_LEN; 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_remote_name && p_remote_name_len) 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_remote_name, p_eir_remote_name, remote_name_len); 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *(p_remote_name + remote_name_len) = 0; 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_remote_name_len = remote_name_len; 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return FALSE; 2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function check_cached_remote_name 2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Check if remote name is in the NVRAM cache 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns TRUE if remote name found 2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Populate p_remote_name, if provided and remote name found 2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BOOLEAN check_cached_remote_name(tBTA_DM_SEARCH *p_search_data, 2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_remote_name, UINT8 *p_remote_name_len) 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdname_t bdname; 2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t remote_bdaddr; 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t prop_name; 2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check if we already have it in our btif_storage cache */ 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(remote_bdaddr.address, p_search_data->inq_res.bd_addr); 2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&prop_name, BT_PROPERTY_BDNAME, 2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sizeof(bt_bdname_t), &bdname); 2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btif_storage_get_remote_device_property( 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project &remote_bdaddr, &prop_name) == BT_STATUS_SUCCESS) 2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_remote_name && p_remote_name_len) 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project strcpy((char *)p_remote_name, (char *)bdname.name); 2685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_remote_name_len = strlen((char *)p_remote_name); 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return FALSE; 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBOOLEAN check_cod(const bt_bdaddr_t *remote_bdaddr, uint32_t cod) 2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t remote_cod; 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t prop_name; 2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check if we already have it in our btif_storage cache */ 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&prop_name, BT_PROPERTY_CLASS_OF_DEVICE, 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sizeof(uint32_t), &remote_cod); 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btif_storage_get_remote_device_property((bt_bdaddr_t *)remote_bdaddr, &prop_name) == BT_STATUS_SUCCESS) 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((remote_cod & 0x7ff) == cod) 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return FALSE; 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 293ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti AgheraBOOLEAN check_cod_hid(const bt_bdaddr_t *remote_bdaddr, uint32_t cod) 294ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera{ 295ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera uint32_t remote_cod; 296ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera bt_property_t prop_name; 297ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera 298ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera /* check if we already have it in our btif_storage cache */ 299ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera BTIF_STORAGE_FILL_PROPERTY(&prop_name, BT_PROPERTY_CLASS_OF_DEVICE, 300ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera sizeof(uint32_t), &remote_cod); 301ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera if (btif_storage_get_remote_device_property((bt_bdaddr_t *)remote_bdaddr, 302ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera &prop_name) == BT_STATUS_SUCCESS) 303ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera { 304ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera if ((remote_cod & 0x700) == cod) 305ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera return TRUE; 306ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera } 3072e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach return FALSE; 3082e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach} 3092e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 3102e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre EisenbachBOOLEAN check_hid_le(const bt_bdaddr_t *remote_bdaddr) 3112e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach{ 3122e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach uint32_t remote_dev_type; 3132e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bt_property_t prop_name; 314ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera 3152e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach /* check if we already have it in our btif_storage cache */ 3162e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach BTIF_STORAGE_FILL_PROPERTY(&prop_name,BT_PROPERTY_TYPE_OF_DEVICE, 3172e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach sizeof(uint32_t), &remote_dev_type); 3182e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach if (btif_storage_get_remote_device_property((bt_bdaddr_t *)remote_bdaddr, 3192e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach &prop_name) == BT_STATUS_SUCCESS) 3202e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach { 3212e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach if (remote_dev_type == BT_DEVICE_DEVTYPE_BLE) 3222e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach { 3232e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bdstr_t bdstr; 3242e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bd2str(remote_bdaddr, &bdstr); 3252e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach if(btif_config_exist("Remote", bdstr, "HidAppId")) 3262e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach return TRUE; 3272e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach } 3282e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach } 329ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera return FALSE; 330ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera} 331ebb1d755818704a662f7ea8ae3cc1b5593d582d8Priti Aghera 3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_bond_state_t state) 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Send bonding state only once - based on outgoing/incoming we may receive duplicates */ 3355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( (pairing_cb.state == state) && (state == BT_BOND_STATE_BONDING) ) 3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.is_temp) 3395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project state = BT_BOND_STATE_NONE; 3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s: state=%d prev_state=%d", __FUNCTION__, state, pairing_cb.state); 3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state); 3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (state == BT_BOND_STATE_BONDING) 3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.state = state; 3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(pairing_cb.bd_addr, bd_addr->address); 3505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(&pairing_cb, 0, sizeof(pairing_cb)); 3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 358ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/* store remote version in bt config to always have access 359ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta to it post pairing*/ 360ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_update_remote_version_property(bt_bdaddr_t *p_bd) 361ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 362ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_property_t property; 363ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT8 lmp_ver = 0; 364ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT16 lmp_subver = 0; 365ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT16 mfct_set = 0; 366ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBTM_STATUS btm_status; 367ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_remote_version_t info; 368ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_status_t status; 369ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdstr_t bdstr; 370ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 371ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btm_status = BTM_ReadRemoteVersion(*(BD_ADDR*)p_bd, &lmp_ver, 372ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &mfct_set, &lmp_subver); 373ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 374ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ALOGD("remote version info [%s]: %x, %x, %x", bd2str(p_bd, &bdstr), 375ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta lmp_ver, mfct_set, lmp_subver); 376ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 377ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (btm_status == BTM_SUCCESS) 378ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 379ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* always update cache to ensure we have availability whenever BTM API 380ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta is not populated */ 381ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta info.manufacturer = mfct_set; 382ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta info.sub_ver = lmp_subver; 383ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta info.version = lmp_ver; 384ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_STORAGE_FILL_PROPERTY(&property, 385ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_PROPERTY_REMOTE_VERSION_INFO, sizeof(bt_remote_version_t), 386ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &info); 387ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta status = btif_storage_set_remote_device_property(p_bd, &property); 388ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote version", status); 389ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 390ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 391ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_update_remote_properties(BD_ADDR bd_addr, BD_NAME bd_name, 3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project DEV_CLASS dev_class, tBT_DEVICE_TYPE device_type) 3955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int num_properties = 0; 3975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t properties[3]; 3985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bdaddr; 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status; 4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT32 cod; 4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_device_type_t dev_type; 4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(properties, 0, sizeof(properties)); 4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bdaddr.address, bd_addr); 4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* remote name */ 4075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (strlen((const char *) bd_name)) 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_BDNAME, strlen((char *)bd_name), bd_name); 4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_storage_set_remote_device_property(&bdaddr, &properties[num_properties]); 4125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device name", status); 4135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* class of device */ 4175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = devclass2uint(dev_class); 4185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( cod == 0) { 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s():cod is 0, set as unclassified", __FUNCTION__); 4205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = COD_UNCLASSIFIED; 4215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 4245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_CLASS_OF_DEVICE, sizeof(cod), &cod); 4255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_storage_set_remote_device_property(&bdaddr, &properties[num_properties]); 4265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device class", status); 4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 4285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* device type */ 4305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project dev_type = device_type; 4315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 4325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type), &dev_type); 4335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_storage_set_remote_device_property(&bdaddr, &properties[num_properties]); 4345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device type", status); 4355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 4365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb, 4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status, &bdaddr, num_properties, properties); 4395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function hid_remote_name_cback 4435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Remote name callback for HID device. Called in stack context 4455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Special handling for HID devices 4465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 4485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void hid_remote_name_cback(void *p_param) 4515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s", __FUNCTION__); 4535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_HID_REMOTE_NAME, 4555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (char *)p_param, sizeof(tBTM_REMOTE_DEV_NAME), NULL); 4565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_cb_hid_remote_name 4615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Remote name callback for HID device. Called in btif context 4635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Special handling for HID devices 4645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 4665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_cb_hid_remote_name(tBTM_REMOTE_DEV_NAME *p_remote_name) 4695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s: status=%d pairing_cb.state=%d", __FUNCTION__, p_remote_name->status, pairing_cb.state); 4715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.state == BT_BOND_STATE_BONDING) 4725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t remote_bd; 4745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(remote_bd.address, pairing_cb.bd_addr); 4765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_remote_name->status == BTM_SUCCESS) 4785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, &remote_bd, BT_BOND_STATE_BONDED); 4805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 4825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_FAIL, &remote_bd, BT_BOND_STATE_NONE); 4835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_cb_create_bond 4895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Create bond initiated from the BTIF thread context 4915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Special handling for HID devices 4925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 4945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_cb_create_bond(bt_bdaddr_t *bd_addr) 4975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 498ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BOOLEAN is_hid = check_cod(bd_addr, COD_HID_POINTING); 499ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 500ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 5015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING); 502ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 503ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (is_hid){ 504ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 5055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int status; 5065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_hh_connect(bd_addr); 5075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(status != BT_STATUS_SUCCESS) 5085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(status, bd_addr, BT_BOND_STATE_NONE); 5095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 511ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 512fc4b2f1953dbe60464d0f5ef7daaa10001fbc62fMatthew Xie#if BLE_INCLUDED == TRUE 513ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int device_type; 514ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int addr_type; 515ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdstr_t bdstr; 516ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bd2str(bd_addr, &bdstr); 517ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if(btif_config_get_int("Remote", (char const *)&bdstr,"DevType", &device_type) && 518ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (btif_storage_get_remote_addr_type(bd_addr, &addr_type) == BT_STATUS_SUCCESS) && 519ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (device_type == BT_DEVICE_TYPE_BLE)) 520ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 521ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmAddBleDevice(bd_addr->address, addr_type, BT_DEVICE_TYPE_BLE); 522ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 523fc4b2f1953dbe60464d0f5ef7daaa10001fbc62fMatthew Xie#endif 5245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmBond ((UINT8 *)bd_addr->address); 525ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 526ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Track originator of bond creation */ 527ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.is_local_initiated = TRUE; 5285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_cb_remove_bond 5345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description remove bond initiated from the BTIF thread context 5365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Special handling for HID devices 5375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 5395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_dm_cb_remove_bond(bt_bdaddr_t *bd_addr) 5425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdstr_t bdstr; 5445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /*special handling for HID devices */ 545390c94dc0f9deee917f52caaf3f8bb9f79aa98b4Ganesh Ganapathi Batta /* VUP needs to be sent if its a HID Device. The HID HOST module will check if there 546390c94dc0f9deee917f52caaf3f8bb9f79aa98b4Ganesh Ganapathi Batta is a valid hid connection with this bd_addr. If yes VUP will be issued.*/ 547390c94dc0f9deee917f52caaf3f8bb9f79aa98b4Ganesh Ganapathi Batta#if (defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)) 548390c94dc0f9deee917f52caaf3f8bb9f79aa98b4Ganesh Ganapathi Batta if (btif_hh_virtual_unplug(bd_addr) != BT_STATUS_SUCCESS) 549390c94dc0f9deee917f52caaf3f8bb9f79aa98b4Ganesh Ganapathi Batta#endif 5505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 551390c94dc0f9deee917f52caaf3f8bb9f79aa98b4Ganesh Ganapathi Batta BTA_DmRemoveDevice((UINT8 *)bd_addr->address); 5525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function search_devices_copy_cb 5585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Deep copy callback for search devices event 5605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 5625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void search_devices_copy_cb(UINT16 event, char *p_dest, char *p_src) 5655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest; 5675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src; 5685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!p_src) 5705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 5715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG2("%s: event=%s", __FUNCTION__, dump_dm_search_event(event)); 5735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_dest_data, p_src_data, sizeof(tBTA_DM_SEARCH)); 5745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 5755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_INQ_RES_EVT: 5775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_src_data->inq_res.p_eir) 5795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_dest_data->inq_res.p_eir = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH)); 5815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_dest_data->inq_res.p_eir, p_src_data->inq_res.p_eir, HCI_EXT_INQ_RESPONSE_LEN); 5825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 5855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_RES_EVT: 5875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_src_data->disc_res.raw_data_size && p_src_data->disc_res.p_raw_data) 5895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_dest_data->disc_res.p_raw_data = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH)); 5915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_dest_data->disc_res.p_raw_data, 5925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_src_data->disc_res.p_raw_data, p_src_data->disc_res.raw_data_size); 5935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 5965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void search_services_copy_cb(UINT16 event, char *p_dest, char *p_src) 6005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest; 6025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src; 6035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!p_src) 6055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 6065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_dest_data, p_src_data, sizeof(tBTA_DM_SEARCH)); 6075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 6085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_RES_EVT: 6105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 61195664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy if (p_src_data->disc_res.result == BTA_SUCCESS) 6125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 61395664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy if (p_src_data->disc_res.num_uuids > 0) 61495664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy { 61595664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy p_dest_data->disc_res.p_uuid_list = 61695664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy (UINT8*)(p_dest + sizeof(tBTA_DM_SEARCH)); 61795664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy memcpy(p_dest_data->disc_res.p_uuid_list, p_src_data->disc_res.p_uuid_list, 61895664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy p_src_data->disc_res.num_uuids*MAX_UUID_SIZE); 61995664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy GKI_freebuf(p_src_data->disc_res.p_uuid_list); 62095664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy } 62195664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy if (p_src_data->disc_res.p_raw_data != NULL) 62295664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy { 62395664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy GKI_freebuf(p_src_data->disc_res.p_raw_data); 62495664a9acc57b5e51365454f26d2fac0f2e1ecd4Kausik Sinnaswamy } 6255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } break; 6275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 6305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** BTIF DM callback events 6325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 6345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_pin_req_evt 6385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes pin request event in btif context 6405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req) 6455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 6475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdname_t bd_name; 6485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT32 cod; 6495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_pin_code_t pin_code; 6505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Remote properties update */ 6525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_update_remote_properties(p_pin_req->bd_addr, p_pin_req->bd_name, 6535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_pin_req->dev_class, BT_DEVICE_TYPE_BREDR); 6545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_pin_req->bd_addr); 6565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(bd_name.name, p_pin_req->bd_name, BD_NAME_LEN); 6575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); 6595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = devclass2uint(p_pin_req->dev_class); 6615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( cod == 0) { 6635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s():cod is 0, set as unclassified", __FUNCTION__); 6645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = COD_UNCLASSIFIED; 6655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check for auto pair possiblity only if bond was initiated by local device */ 6685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.is_local_initiated) 6695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (check_cod(&bd_addr, COD_AV_HEADSETS) || 6715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_HANDSFREE) || 6725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_HEADPHONES) || 6735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_PORTABLE_AUDIO) || 6745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_HIFI_AUDIO) || 6755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_HID_POINTING)) 6765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s()cod matches for auto pair", __FUNCTION__); 6785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Check if this device can be auto paired */ 6795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((btif_storage_is_device_autopair_blacklisted(&bd_addr) == FALSE) && 6805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (pairing_cb.autopair_attempts == 0)) 6815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s() Attempting auto pair", __FUNCTION__); 6835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[0] = 0x30; 6845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[1] = 0x30; 6855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[2] = 0x30; 6865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[3] = 0x30; 6875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.autopair_attempts++; 6895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmPinReply( (UINT8*)bd_addr.address, TRUE, 4, pin_code.pin); 6905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 6915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (check_cod(&bd_addr, COD_HID_KEYBOARD) || 6945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_HID_COMBO)) 6955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(( btif_storage_is_fixed_pin_zeros_keyboard (&bd_addr) == TRUE) && 6975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (pairing_cb.autopair_attempts == 0)) 6985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s() Attempting auto pair", __FUNCTION__); 7005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[0] = 0x30; 7015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[1] = 0x30; 7025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[2] = 0x30; 7035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pin_code.pin[3] = 0x30; 7045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.autopair_attempts++; 7065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmPinReply( (UINT8*)bd_addr.address, TRUE, 4, pin_code.pin); 7075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 7085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, pin_request_cb, 7125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project &bd_addr, &bd_name, cod); 7135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 7145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 7165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_ssp_cfm_req_evt 7185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes SSP confirm request event in btif context 7205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 7225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 7245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_ssp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_ssp_cfm_req) 7255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 7275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdname_t bd_name; 7285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT32 cod; 7295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN is_incoming = !(pairing_cb.state == BT_BOND_STATE_BONDING); 7305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s", __FUNCTION__); 7325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Remote properties update */ 7345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_update_remote_properties(p_ssp_cfm_req->bd_addr, p_ssp_cfm_req->bd_name, 7355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ssp_cfm_req->dev_class, BT_DEVICE_TYPE_BREDR); 7365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_ssp_cfm_req->bd_addr); 7385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(bd_name.name, p_ssp_cfm_req->bd_name, BD_NAME_LEN); 7395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Set the pairing_cb based on the local & remote authentication requirements */ 7415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); 7425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if just_works and bonding bit is not set treat this as temporary */ 7445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ssp_cfm_req->just_works && !(p_ssp_cfm_req->loc_auth_req & BTM_AUTH_BONDS) && 745ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta !(p_ssp_cfm_req->rmt_auth_req & BTM_AUTH_BONDS) && 746ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta !(check_cod((bt_bdaddr_t*)&p_ssp_cfm_req->bd_addr, COD_HID_POINTING))) 7475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.is_temp = TRUE; 7485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.is_temp = FALSE; 7505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.is_ssp = TRUE; 7525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* If JustWorks auto-accept */ 7545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ssp_cfm_req->just_works) 7555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Pairing consent for JustWorks needed if: 7575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 1. Incoming pairing is detected AND 7585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 2. local IO capabilities are DisplayYesNo AND 7595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 3. remote IO capabiltiies are DisplayOnly or NoInputNoOutput; 7605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 7615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((is_incoming) && ((p_ssp_cfm_req->loc_io_caps == 0x01) && 7625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_ssp_cfm_req->rmt_io_caps == 0x00 || p_ssp_cfm_req->rmt_io_caps == 0x03))) 7635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT3("%s: User consent needed for incoming pairing request. loc_io_caps: %d, rmt_io_caps: %d", 7655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__, p_ssp_cfm_req->loc_io_caps, p_ssp_cfm_req->rmt_io_caps); 7665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT1("%s: Auto-accept JustWorks pairing", __FUNCTION__); 7705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_ssp_reply(&bd_addr, BT_SSP_VARIANT_CONSENT, TRUE, 0); 7715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 7725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = devclass2uint(p_ssp_cfm_req->dev_class); 7765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( cod == 0) { 7785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ALOGD("cod is 0, set as unclassified"); 7795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = COD_UNCLASSIFIED; 7805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 782ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta pairing_cb.sdp_attempts = 0; 7835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, cod, 7845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_ssp_cfm_req->just_works ? BT_SSP_VARIANT_CONSENT : BT_SSP_VARIANT_PASSKEY_CONFIRMATION), 7855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ssp_cfm_req->num_val); 7865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 7875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_ssp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_ssp_key_notif) 7895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 7915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdname_t bd_name; 7925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT32 cod; 7935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s", __FUNCTION__); 7955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Remote properties update */ 7975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_update_remote_properties(p_ssp_key_notif->bd_addr, p_ssp_key_notif->bd_name, 7985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ssp_key_notif->dev_class, BT_DEVICE_TYPE_BREDR); 7995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_ssp_key_notif->bd_addr); 8015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(bd_name.name, p_ssp_key_notif->bd_name, BD_NAME_LEN); 8025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); 8045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.is_ssp = TRUE; 8055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = devclass2uint(p_ssp_key_notif->dev_class); 8065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( cod == 0) { 8085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ALOGD("cod is 0, set as unclassified"); 8095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = COD_UNCLASSIFIED; 8105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, 8135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod, BT_SSP_VARIANT_PASSKEY_NOTIFICATION, 8145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ssp_key_notif->passkey); 8155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 8165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 8175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_auth_cmpl_evt 8195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes authentication complete event in btif context 8215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 8235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 8255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) 8265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 8275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Save link key, if not temporary */ 8285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 8295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status = BT_STATUS_FAIL; 8305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bond_state_t state = BT_BOND_STATE_NONE; 8315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_auth_cmpl->bd_addr); 8335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( (p_auth_cmpl->success == TRUE) && (p_auth_cmpl->key_present) ) 8345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_auth_cmpl->key_type < HCI_LKEY_TYPE_DEBUG_COMB) || (p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB) || 8365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_auth_cmpl->key_type == HCI_LKEY_TYPE_CHANGED_COMB) || (!pairing_cb.is_temp)) 8375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t ret; 8395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s: Storing link key. key_type=0x%x, is_temp=%d", 8405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__, p_auth_cmpl->key_type, pairing_cb.is_temp); 8415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ret = btif_storage_add_bonded_device(&bd_addr, 8425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_auth_cmpl->key, p_auth_cmpl->key_type, 8435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.pin_code_len); 8445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret); 8455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s: Temporary key. Not storing. key_type=0x%x, is_temp=%d", 8495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__, p_auth_cmpl->key_type, pairing_cb.is_temp); 8505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_auth_cmpl->success) 8535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = BT_STATUS_SUCCESS; 8555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project state = BT_BOND_STATE_BONDED; 8565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Trigger SDP on the device */ 858ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta pairing_cb.sdp_attempts = 1;; 859e17bf003d4eefdc8525e55894210e9ee494972b8Ganesh Ganapathi Batta 860e17bf003d4eefdc8525e55894210e9ee494972b8Ganesh Ganapathi Batta if(btif_dm_inquiry_in_progress) 861e17bf003d4eefdc8525e55894210e9ee494972b8Ganesh Ganapathi Batta btif_dm_cancel_discovery(); 862e17bf003d4eefdc8525e55894210e9ee494972b8Ganesh Ganapathi Batta 8635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_get_remote_services(&bd_addr); 8645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Do not call bond_state_changed_cb yet. Wait till fetch remote service is complete */ 8655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /*Map the HCI fail reason to bt status */ 8695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch(p_auth_cmpl->fail_reason) 8705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_PAGE_TIMEOUT: 8725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_CONNECTION_TOUT: 8735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = BT_STATUS_RMT_DEV_DOWN; 8745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 8755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* map the auth failure codes, so we can retry pairing if necessary */ 8775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_AUTH_FAILURE: 8785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_HOST_REJECT_SECURITY: 8795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE: 8805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_UNIT_KEY_USED: 8815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED: 8825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case HCI_ERR_INSUFFCIENT_SECURITY: 8835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1(" %s() Authentication fail ", __FUNCTION__); 8845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.autopair_attempts == 1) 8855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s(): Adding device to blacklist ", __FUNCTION__); 8875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Add the device to dynamic black list only if this device belongs to Audio/pointing dev class */ 8895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (check_cod(&bd_addr, COD_AV_HEADSETS) || 8905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_HANDSFREE) || 8915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_HEADPHONES) || 8925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_PORTABLE_AUDIO) || 8935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_AV_HIFI_AUDIO) || 8945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cod(&bd_addr, COD_HID_POINTING)) 8955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_storage_add_device_to_autopair_blacklist (&bd_addr); 8975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.autopair_attempts++; 8995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Create the Bond once again */ 9015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s() auto pair failed. Reinitiate Bond", __FUNCTION__); 9025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_cb_create_bond (&bd_addr); 9035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 9045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 9065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if autopair attempts are more than 1, or not attempted */ 9085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = BT_STATUS_AUTH_FAILURE; 9095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 9115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 9135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = BT_STATUS_FAIL; 9145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(status, &bd_addr, state); 9165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 9185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 9205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_search_devices_evt 9225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes search devices callback events in btif context 9245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 9265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 9275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/ 9285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_search_devices_evt (UINT16 event, char *p_param) 9295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 9305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEARCH *p_search_data; 9315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s event=%s", __FUNCTION__, dump_dm_search_event(event)); 9325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 9345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_RES_EVT: 9365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_search_data = (tBTA_DM_SEARCH *)p_param; 9385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Remote name update */ 9395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (strlen((const char *) p_search_data->disc_res.bd_name)) 9405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t properties[1]; 9425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bdaddr; 9435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status; 9445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project properties[0].type = BT_PROPERTY_BDNAME; 9465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project properties[0].val = p_search_data->disc_res.bd_name; 9475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project properties[0].len = strlen((char *)p_search_data->disc_res.bd_name); 9485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bdaddr.address, p_search_data->disc_res.bd_addr); 9495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_storage_set_remote_device_property(&bdaddr, &properties[0]); 9515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device property", status); 9525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb, 9535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status, &bdaddr, 1, properties); 9545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: Services? */ 9565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 9585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_INQ_RES_EVT: 9605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* inquiry result */ 9625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT32 cod; 9635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_eir_remote_name = NULL; 9645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdname_t bdname; 9655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bdaddr; 9665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 remote_name_len; 9675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_cached_name = NULL; 9685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_SERVICE_MASK services = 0; 9695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdstr_t bdstr; 9705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_search_data = (tBTA_DM_SEARCH *)p_param; 9725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bdaddr.address, p_search_data->inq_res.bd_addr); 9735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s() %s device_type = 0x%x\n", __FUNCTION__, bd2str(&bdaddr, &bdstr), 9755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BLE_INCLUDED == TRUE) 9765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_search_data->inq_res.device_type); 9775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 9785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_DEVICE_TYPE_BREDR); 9795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 9805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdname.name[0] = 0; 9815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = devclass2uint (p_search_data->inq_res.dev_class); 9835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( cod == 0) { 9855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ALOGD("cod is 0, set as unclassified"); 9865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod = COD_UNCLASSIFIED; 9875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!check_eir_remote_name(p_search_data, bdname.name, &remote_name_len)) 9905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project check_cached_remote_name(p_search_data, bdname.name, &remote_name_len); 9915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Check EIR for remote name and services */ 9935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_search_data->inq_res.p_eir) 9945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_GetEirService(p_search_data->inq_res.p_eir, &services); 9965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG2("%s()EIR BTA services = %08X", __FUNCTION__, (UINT32)services); 9975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: Get the service list and check to see which uuids we got and send it back to the client. */ 9985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t properties[5]; 10035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_device_type_t dev_type; 10045c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach UINT8 addr_type; 10055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t num_properties = 0; 10065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status; 10075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(properties, 0, sizeof(properties)); 10095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* BD_ADDR */ 10105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 10115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_BDADDR, sizeof(bdaddr), &bdaddr); 10125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 10135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* BD_NAME */ 10145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Don't send BDNAME if it is empty */ 10155c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach if (bdname.name[0]) 10165c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach { 10175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 10185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_BDNAME, 10195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project strlen((char *)bdname.name), &bdname); 10205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 10215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* DEV_CLASS */ 10245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 10255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_CLASS_OF_DEVICE, sizeof(cod), &cod); 10265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 10275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* DEV_TYPE */ 10285c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 10295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* FixMe: Assumption is that bluetooth.h and BTE enums match */ 10305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project dev_type = p_search_data->inq_res.device_type; 10315c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach addr_type = p_search_data->inq_res.ble_addr_type; 10325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 10335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project dev_type = BT_DEVICE_TYPE_BREDR; 10345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 10355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 10365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type), &dev_type); 10375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 10385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* RSSI */ 10395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], 10405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_PROPERTY_REMOTE_RSSI, sizeof(int8_t), 10415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project &(p_search_data->inq_res.rssi)); 10425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties++; 10435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_storage_add_remote_device(&bdaddr, num_properties, properties); 10455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device (inquiry)", status); 10465c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 10475c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach status = btif_storage_set_remote_addr_type(&bdaddr, addr_type); 10485c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote addr type (inquiry)", status); 10495c44e45473e5fc2fa89411ab1add7dbfc979f1f8Andre Eisenbach#endif 10505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Callback to notify upper layer of device */ 10515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, device_found_cb, 10525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project num_properties, properties); 10535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 10565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_INQ_CMPL_EVT: 10585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 10615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_CMPL_EVT: 10625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED); 10645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 10665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_SEARCH_CANCEL_CMPL_EVT: 10675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if inquiry is not in progress and we get a cancel event, then 10695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * it means we are done with inquiry, but remote_name fetches are in 10705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * progress 10715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 10725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * if inquiry is in progress, then we don't want to act on this cancel_cmpl_evt 10735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * but instead wait for the cancel_cmpl_evt via the Busy Level 10745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 10755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 10765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btif_dm_inquiry_in_progress == FALSE) 10775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED); 10795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 10825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 10845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 10865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_search_services_evt 10885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes search services event in btif context 10905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 10925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_search_services_evt(UINT16 event, char *p_param) 10955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 10965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEARCH *p_data = (tBTA_DM_SEARCH*)p_param; 10975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: event = %d", __FUNCTION__, event); 10995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 11005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_RES_EVT: 11025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_uuid_t uuid_arr[BT_MAX_NUM_UUIDS]; /* Max 32 services */ 11045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t prop; 11055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t i = 0, j = 0; 11065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 11075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t ret; 11085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_data->disc_res.bd_addr); 11105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s:(result=0x%x, services 0x%x)", __FUNCTION__, 11125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->disc_res.result, p_data->disc_res.services); 1113ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta if ((p_data->disc_res.result != BTA_SUCCESS) && 1114ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta (pairing_cb.state == BT_BOND_STATE_BONDING ) && 1115ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING)) 1116ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta { 1117ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta BTIF_TRACE_WARNING1("%s:SDP failed after bonding re-attempting", __FUNCTION__); 1118ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta pairing_cb.sdp_attempts++; 1119ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta btif_dm_get_remote_services(&bd_addr); 1120ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta return; 1121ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta } 11225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.type = BT_PROPERTY_UUIDS; 11235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.len = 0; 11245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_data->disc_res.result == BTA_SUCCESS) && (p_data->disc_res.num_uuids > 0)) 11255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.val = p_data->disc_res.p_uuid_list; 11275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.len = p_data->disc_res.num_uuids * MAX_UUID_SIZE; 11285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i < p_data->disc_res.num_uuids; i++) 11295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char temp[256]; 11315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uuid_to_string((bt_uuid_t*)(p_data->disc_res.p_uuid_list + (i*MAX_UUID_SIZE)), temp); 11325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR2("Index: %d uuid:%s", i, temp); 11335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* onUuidChanged requires getBondedDevices to be populated. 11375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** bond_state_changed needs to be sent prior to remote_device_property 11385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 11395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((pairing_cb.state == BT_BOND_STATE_BONDING) && 11405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (bdcmp(p_data->disc_res.bd_addr, pairing_cb.bd_addr) == 0)&& 1141ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta pairing_cb.sdp_attempts > 0) 11425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s Remote Service SDP done. Call bond_state_changed_cb BONDED", 11445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project __FUNCTION__); 1145ec7e2c8e06396101c6b26187995db7c105ed3c3fGanesh Ganapathi Batta pairing_cb.sdp_attempts = 0; 11465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED); 11475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11492e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach if(p_data->disc_res.num_uuids != 0) 11502e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach { 11512e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach /* Also write this to the NVRAM */ 11522e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach ret = btif_storage_set_remote_device_property(&bd_addr, &prop); 11532e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach ASSERTC(ret == BT_STATUS_SUCCESS, "storing remote services failed", ret); 11542e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach /* Send the event to the BTIF */ 11552e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb, 11562e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach BT_STATUS_SUCCESS, &bd_addr, 1, &prop); 11572e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach } 11585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 11605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_CMPL_EVT: 11625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* fixme */ 11635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 11645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1165607e3b79f1731de0d08a2c03d38ae17874bc282dMatthew Xie#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 11662e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach case BTA_DM_DISC_BLE_RES_EVT: 11672e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach BTIF_TRACE_DEBUG2("%s:, services 0x%x)", __FUNCTION__, 11682e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach p_data->disc_ble_res.service.uu.uuid16); 11692e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bt_uuid_t uuid; 11702e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach int i = 0; 11712e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach int j = 15; 11722e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach if (p_data->disc_ble_res.service.uu.uuid16 == UUID_SERVCLASS_LE_HID) 11732e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach { 11742e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach BTIF_TRACE_DEBUG1("%s: Found HOGP UUID",__FUNCTION__); 11752e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bt_property_t prop; 11762e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bt_bdaddr_t bd_addr; 11772e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach char temp[256]; 1178d7ee77bf8bb7f009b8088c15dcf5458b6f1fd05dZhihai Xu bt_status_t ret; 11792e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 11802e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bta_gatt_convert_uuid16_to_uuid128(uuid.uu,p_data->disc_ble_res.service.uu.uuid16); 11812e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 11822e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach while(i < j ) 11832e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach { 11842e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach unsigned char c = uuid.uu[j]; 11852e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach uuid.uu[j] = uuid.uu[i]; 11862e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach uuid.uu[i] = c; 11872e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach i++; 11882e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach j--; 11892e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach } 11902e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 11912e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach uuid_to_string(&uuid, temp); 11922e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach BTIF_TRACE_ERROR1(" uuid:%s", temp); 11932e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 11942e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach bdcpy(bd_addr.address, p_data->disc_ble_res.bd_addr); 11952e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach prop.type = BT_PROPERTY_UUIDS; 11962e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach prop.val = uuid.uu; 11972e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach prop.len = MAX_UUID_SIZE; 11982e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 1199d7ee77bf8bb7f009b8088c15dcf5458b6f1fd05dZhihai Xu /* Also write this to the NVRAM */ 1200d7ee77bf8bb7f009b8088c15dcf5458b6f1fd05dZhihai Xu ret = btif_storage_set_remote_device_property(&bd_addr, &prop); 1201d7ee77bf8bb7f009b8088c15dcf5458b6f1fd05dZhihai Xu ASSERTC(ret == BT_STATUS_SUCCESS, "storing remote services failed", ret); 1202d7ee77bf8bb7f009b8088c15dcf5458b6f1fd05dZhihai Xu 12032e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach /* Send the event to the BTIF */ 12042e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb, 12052e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach BT_STATUS_SUCCESS, &bd_addr, 1, &prop); 12062e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 12072e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach } 12082e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach break; 1209607e3b79f1731de0d08a2c03d38ae17874bc282dMatthew Xie#endif /* BLE_INCLUDED */ 12102e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach 12115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 12125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(0, "unhandled search services event", event); 12145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 12165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 12185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 12205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_remote_service_record_evt 12225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes search service record event in btif context 12245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 12265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 12285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_remote_service_record_evt(UINT16 event, char *p_param) 12295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 12305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEARCH *p_data = (tBTA_DM_SEARCH*)p_param; 12315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: event = %d", __FUNCTION__, event); 12335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 12345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_RES_EVT: 12365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_service_record_t rec; 12385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t prop; 12395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t i = 0; 12405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 12415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(&rec, 0, sizeof(bt_service_record_t)); 12435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_data->disc_res.bd_addr); 12445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s:(result=0x%x, services 0x%x)", __FUNCTION__, 12465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->disc_res.result, p_data->disc_res.services); 12475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.type = BT_PROPERTY_SERVICE_RECORD; 12485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.val = (void*)&rec; 12495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.len = sizeof(rec); 12505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* disc_res.result is overloaded with SCN. Cannot check result */ 12525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->disc_res.services &= ~BTA_USER_SERVICE_MASK; 12535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: Get the UUID as well */ 12545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rec.channel = p_data->disc_res.result - 3; 12555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: Need to get the service name using p_raw_data */ 12565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rec.name[0] = 0; 12575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb, 12595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_STATUS_SUCCESS, &bd_addr, 1, &prop); 12605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 12625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 12645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(0, "unhandled remote service record event", event); 12665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 12685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 12705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 12725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_upstreams_cback 12745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes UPSTREAMS events in btif context 12765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 12785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 12795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 12805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_upstreams_evt(UINT16 event, char* p_param) 12815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 12825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEC_EVT dm_event = (tBTA_DM_SEC_EVT)event; 12835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_SEC *p_data = (tBTA_DM_SEC*)p_param; 12845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_SERVICE_MASK service_mask; 12855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t i; 12865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 12875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT1("btif_dm_upstreams_cback ev: %s", dump_dm_event(event)); 12895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 12915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_ENABLE_EVT: 12935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BD_NAME bdname; 12955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status; 12965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t prop; 12975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.type = BT_PROPERTY_BDNAME; 12985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.len = BD_NAME_LEN; 12995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop.val = (void*)bdname; 13005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_storage_get_adapter_property(&prop); 13021e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie if (status == BT_STATUS_SUCCESS) 13035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13041e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie /* A name exists in the storage. Make this the device name */ 13051e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie BTA_DmSetDeviceName((char*)prop.val); 13065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 13085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13091e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie /* Storage does not have a name yet. 13101e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie * Use the default name and write it to the chip 13111e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie */ 13121e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie BTA_DmSetDeviceName(btif_get_default_local_name()); 13135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* for each of the enabled services in the mask, trigger the profile 13165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * enable */ 13175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project service_mask = btif_get_enabled_services_mask(); 13185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i <= BTA_MAX_SERVICE_ID; i++) 13195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (service_mask & 13215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(i))) 13225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_in_execute_service_request(i, TRUE); 13245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* clear control blocks */ 13275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(&pairing_cb, 0, sizeof(btif_dm_pairing_cb_t)); 13285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* This function will also trigger the adapter_properties_cb 13305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** and bonded_devices_info_cb 13315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 13325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_storage_load_bonded_devices(); 13335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_storage_load_autopair_device_list(); 13355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_enable_bluetooth_evt(p_data->enable.status, p_data->enable.bd_addr); 13375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISABLE_EVT: 13415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* for each of the enabled services in the mask, trigger the profile 13425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * disable */ 13435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project service_mask = btif_get_enabled_services_mask(); 13445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i <= BTA_MAX_SERVICE_ID; i++) 13455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (service_mask & 13475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(i))) 13485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_in_execute_service_request(i, FALSE); 13505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_disable_bluetooth_evt(); 13535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_PIN_REQ_EVT: 13565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_pin_req_evt(&p_data->pin_req); 13575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_AUTH_CMPL_EVT: 13605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_auth_cmpl_evt(&p_data->auth_cmpl); 13615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BOND_CANCEL_CMPL_EVT: 13645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.state == BT_BOND_STATE_BONDING) 13655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, pairing_cb.bd_addr); 13675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(p_data->bond_cancel_cmpl.result, &bd_addr, BT_BOND_STATE_NONE); 13685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_SP_CFM_REQ_EVT: 13725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_ssp_cfm_req_evt(&p_data->cfm_req); 13735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_SP_KEY_NOTIF_EVT: 13755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_ssp_key_notif_evt(&p_data->key_notif); 13765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DEV_UNPAIRED_EVT: 13795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_data->link_down.bd_addr); 13805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /*special handling for HID devices */ 13825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project #if (defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)) 1383390c94dc0f9deee917f52caaf3f8bb9f79aa98b4Ganesh Ganapathi Batta btif_hh_remove_device(bd_addr); 13845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project #endif 13852e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 13862e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach btif_storage_remove_ble_bonding_keys(&bd_addr); 13872e7fa68bfd9723b7ec7b6b0b128d89f31a2e06eeAndre Eisenbach #endif 13885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_storage_remove_bonded_device(&bd_addr); 13895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_NONE); 13905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BUSY_LEVEL_EVT: 13935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1394ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1395ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_data->busy_level.level_flags & BTM_BL_INQUIRY_PAGING_MASK) 13965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1397ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_data->busy_level.level_flags == BTM_BL_INQUIRY_STARTED) 13985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, 14005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_DISCOVERY_STARTED); 14015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_inquiry_in_progress = TRUE; 14025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1403ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else if (p_data->busy_level.level_flags == BTM_BL_INQUIRY_CANCELLED) 14045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, 14065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_DISCOVERY_STOPPED); 14075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_inquiry_in_progress = FALSE; 14085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1409ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else if (p_data->busy_level.level_flags == BTM_BL_INQUIRY_COMPLETE) 14105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_inquiry_in_progress = FALSE; 14125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project }break; 14155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_LINK_UP_EVT: 14175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_data->link_up.bd_addr); 14185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG0("BTA_DM_LINK_UP_EVT. Sending BT_ACL_STATE_CONNECTED"); 1419ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1420ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_update_remote_version_property(&bd_addr); 1421ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 14225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, acl_state_changed_cb, BT_STATUS_SUCCESS, 14235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project &bd_addr, BT_ACL_STATE_CONNECTED); 14245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 14255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_LINK_DOWN_EVT: 14275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, p_data->link_down.bd_addr); 14285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG0("BTA_DM_LINK_DOWN_EVT. Sending BT_ACL_STATE_DISCONNECTED"); 14295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, acl_state_changed_cb, BT_STATUS_SUCCESS, 14305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project &bd_addr, BT_ACL_STATE_DISCONNECTED); 14315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 14325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_HW_ERROR_EVT: 14345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR0("Received H/W Error. "); 14355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Flush storage data */ 14365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_config_flush(); 14375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project usleep(100000); /* 100milliseconds */ 14385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Killing the process to force a restart as part of fault tolerance */ 14395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project kill(getpid(), SIGKILL); 14405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 14415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1442ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 14435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_KEY_EVT: 1444ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("BTA_DM_BLE_KEY_EVT key_type=0x%02x ", p_data->ble_key.key_type); 1445ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1446ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* If this pairing is by-product of local initiated GATT client Read or Write, 1447ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA would not have sent BTA_DM_BLE_SEC_REQ_EVT event and Bond state would not 1448ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta have setup properly. Setup pairing_cb and notify App about Bonding state now*/ 1449ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.state != BT_BOND_STATE_BONDING) 1450ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1451ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("Bond state not sent to App so far.Notify the app now"); 1452ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bond_state_changed(BT_STATUS_SUCCESS, (bt_bdaddr_t*)p_data->ble_key.bd_addr, 1453ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_BOND_STATE_BONDING); 1454ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1455ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else if (memcmp (pairing_cb.bd_addr, p_data->ble_key.bd_addr, BD_ADDR_LEN)!=0) 1456ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1457ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_ERROR1("BD mismatch discard BLE key_type=%d ",p_data->ble_key.key_type); 1458ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1459ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1460ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1461ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta switch (p_data->ble_key.key_type) 1462ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1463ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_LE_KEY_PENC: 1464ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("Rcv BTA_LE_KEY_PENC"); 1465ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.is_penc_key_rcvd = TRUE; 1466ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(pairing_cb.ble.penc_key.ltk,p_data->ble_key.key_value.penc_key.ltk, 16); 1467ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(pairing_cb.ble.penc_key.rand, p_data->ble_key.key_value.penc_key.rand,8); 1468ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.penc_key.ediv = p_data->ble_key.key_value.penc_key.ediv; 1469ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.penc_key.sec_level = p_data->ble_key.key_value.penc_key.sec_level; 1470ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1471ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta for (i=0; i<16; i++) 1472ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1473ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG2("pairing_cb.ble.penc_key.ltk[%d]=0x%02x",i,pairing_cb.ble.penc_key.ltk[i]); 1474ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1475ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta for (i=0; i<8; i++) 1476ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1477ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG2("pairing_cb.ble.penc_key.rand[%d]=0x%02x",i,pairing_cb.ble.penc_key.rand[i]); 1478ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1479ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.penc_key.ediv=0x%04x",pairing_cb.ble.penc_key.ediv); 1480ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.penc_key.sec_level=0x%02x",pairing_cb.ble.penc_key.sec_level); 1481ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.penc_key.key_size=0x%02x",pairing_cb.ble.penc_key.key_size); 1482ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1483ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1484ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_LE_KEY_PID: 1485ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("Rcv BTA_LE_KEY_PID"); 1486ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.is_pid_key_rcvd = TRUE; 1487ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(pairing_cb.ble.pid_key, p_data->ble_key.key_value.pid_key.irk, 16); 1488ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta for (i=0; i<16; i++) 1489ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1490ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG2("pairing_cb.ble.pid_key[%d]=0x%02x",i,pairing_cb.ble.pid_key[i]); 1491ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1492ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1493ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1494ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_LE_KEY_PCSRK: 1495ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("Rcv BTA_LE_KEY_PCSRK"); 1496ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.is_pcsrk_key_rcvd = TRUE; 1497ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.pcsrk_key.counter = p_data->ble_key.key_value.pcsrk_key.counter; 1498ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.pcsrk_key.sec_level = p_data->ble_key.key_value.pcsrk_key.sec_level; 1499ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(pairing_cb.ble.pcsrk_key.csrk,p_data->ble_key.key_value.pcsrk_key.csrk,16); 1500ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1501ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta for (i=0; i<16; i++) 1502ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1503ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG2("pairing_cb.ble.pcsrk_key.csrk[%d]=0x%02x",i,pairing_cb.ble.pcsrk_key.csrk[i]); 1504ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1505ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.pcsrk_key.counter=0x%08x",pairing_cb.ble.pcsrk_key.counter); 1506ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.pcsrk_key.sec_level=0x%02x",pairing_cb.ble.pcsrk_key.sec_level); 1507ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1508ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1509ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_LE_KEY_LENC: 1510ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("Rcv BTA_LE_KEY_LENC"); 1511ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.is_lenc_key_rcvd = TRUE; 1512ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.lenc_key.div = p_data->ble_key.key_value.lenc_key.div; 1513ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.lenc_key.key_size = p_data->ble_key.key_value.lenc_key.key_size; 1514ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.lenc_key.sec_level = p_data->ble_key.key_value.lenc_key.sec_level; 1515ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1516ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.lenc_key.div=0x%04x",pairing_cb.ble.lenc_key.div); 1517ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.lenc_key.key_size=0x%02x",pairing_cb.ble.lenc_key.key_size); 1518ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.lenc_key.sec_level=0x%02x",pairing_cb.ble.lenc_key.sec_level); 1519ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1520ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1521ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1522ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1523ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_LE_KEY_LCSRK: 1524ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("Rcv BTA_LE_KEY_LCSRK"); 1525ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.is_lcsrk_key_rcvd = TRUE; 1526ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.lcsrk_key.counter = p_data->ble_key.key_value.lcsrk_key.counter; 1527ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.lcsrk_key.div = p_data->ble_key.key_value.lcsrk_key.div; 1528ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.ble.lcsrk_key.sec_level = p_data->ble_key.key_value.lcsrk_key.sec_level; 1529ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1530ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.lcsrk_key.div=0x%04x",pairing_cb.ble.lcsrk_key.div); 1531ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.lcsrk_key.counter=0x%08x",pairing_cb.ble.lcsrk_key.counter); 1532ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("pairing_cb.ble.lcsrk_key.sec_level=0x%02x",pairing_cb.ble.lcsrk_key.sec_level); 1533ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1534ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1535ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1536ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta default: 1537ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_ERROR1("unknown BLE key type (0x%02x)", p_data->ble_key.key_type); 1538ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1539ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1540ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1541ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 15425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_SEC_REQ_EVT: 1543ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("BTA_DM_BLE_SEC_REQ_EVT. "); 1544ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_ble_sec_req_evt(&p_data->ble_req); 1545ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 15465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_PASSKEY_NOTIF_EVT: 1547ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("BTA_DM_BLE_PASSKEY_NOTIF_EVT. "); 1548ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_ble_key_notif_evt(&p_data->key_notif); 1549ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 15505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_PASSKEY_REQ_EVT: 1551ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("BTA_DM_BLE_PASSKEY_REQ_EVT. "); 1552ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_ble_passkey_req_evt(&p_data->pin_req); 1553ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 15545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_OOB_REQ_EVT: 1555ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("BTA_DM_BLE_OOB_REQ_EVT. "); 1556ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 15575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_LOCAL_IR_EVT: 1558ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("BTA_DM_BLE_LOCAL_IR_EVT. "); 1559ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ble_local_key_cb.is_id_keys_rcvd = TRUE; 1560ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&ble_local_key_cb.id_keys.irk[0], &p_data->ble_id_keys.irk[0], sizeof(BT_OCTET16)); 1561ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&ble_local_key_cb.id_keys.ir[0], &p_data->ble_id_keys.ir[0], sizeof(BT_OCTET16)); 1562ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&ble_local_key_cb.id_keys.dhk[0], &p_data->ble_id_keys.dhk[0], sizeof(BT_OCTET16)); 1563ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_local_key( (char *)&ble_local_key_cb.id_keys.irk[0], 1564ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_LOCAL_KEY_IR, 1565ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN); 1566ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_local_key( (char *)&ble_local_key_cb.id_keys.ir[0], 1567ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_LOCAL_KEY_IRK, 1568ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN); 1569ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_local_key( (char *)&ble_local_key_cb.id_keys.dhk[0], 1570ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_LOCAL_KEY_DHK, 1571ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN); 1572ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 15735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_LOCAL_ER_EVT: 1574ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("BTA_DM_BLE_LOCAL_ER_EVT. "); 1575ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ble_local_key_cb.is_er_rcvd = TRUE; 1576ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&ble_local_key_cb.er[0], &p_data->ble_er[0], sizeof(BT_OCTET16)); 1577ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_local_key( (char *)&ble_local_key_cb.er[0], 1578ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_LOCAL_KEY_ER, 1579ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN); 1580ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1581ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 15825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_BLE_AUTH_CMPL_EVT: 1583ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("BTA_DM_BLE_KEY_EVT. "); 1584ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_ble_auth_cmpl_evt(&p_data->auth_cmpl); 1585ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1586ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 1587ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1588ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_DM_AUTHORIZE_EVT: 1589ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_DM_SIG_STRENGTH_EVT: 1590ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_DM_SP_RMT_OOB_EVT: 1591ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_DM_SP_KEYPRESS_EVT: 1592ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTA_DM_ROLE_CHG_EVT: 1593ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 15945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 15955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_WARNING1( "btif_dm_cback : unhandled event (%d)", event ); 15965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 15975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} /* btui_security_cback() */ 15995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 16025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_generic_evt 16045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Executes non-BTA upstream events in BTIF context 16065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 16085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 16105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btif_dm_generic_evt(UINT16 event, char* p_param) 16115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 16125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: event=%d", __FUNCTION__, event); 16135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch(event) 16145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTIF_DM_CB_DISCOVERY_STARTED: 16165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STARTED); 16185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 16205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTIF_DM_CB_CREATE_BOND: 16225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_cb_create_bond((bt_bdaddr_t *)p_param); 16245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 16265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTIF_DM_CB_REMOVE_BOND: 16285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_cb_remove_bond((bt_bdaddr_t *)p_param); 16305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 16325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTIF_DM_CB_HID_REMOTE_NAME: 16345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_cb_hid_remote_name((tBTM_REMOTE_DEV_NAME *)p_param); 16365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 16385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTIF_DM_CB_BOND_STATE_BONDING: 16405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bond_state_changed(BT_STATUS_SUCCESS, (bt_bdaddr_t *)p_param, BT_BOND_STATE_BONDING); 16425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 1644ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_DM_CB_LE_TX_TEST: 1645ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_DM_CB_LE_RX_TEST: 1646ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1647ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t status; 1648ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta STREAM_TO_UINT8(status, p_param); 1649ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_hal_cbacks, le_test_mode_cb, 1650ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (status == 0) ? BT_STATUS_SUCCESS : BT_STATUS_FAIL, 0); 1651ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1652ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 1653ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case BTIF_DM_CB_LE_TEST_END: 1654ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1655ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint8_t status; 1656ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta uint16_t count = 0; 1657ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta STREAM_TO_UINT8(status, p_param); 1658ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (status == 0) 1659ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta STREAM_TO_UINT16(count, p_param); 1660ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_hal_cbacks, le_test_mode_cb, 1661ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (status == 0) ? BT_STATUS_SUCCESS : BT_STATUS_FAIL, count); 1662ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1663ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 16645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 16655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_WARNING2("%s : Unknown event 0x%x", __FUNCTION__, event); 16675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 16695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 16715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 16735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bte_dm_evt 16755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Switches context from BTE to BTIF for all DM events 16775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 16795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 16815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data) 16835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 16845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status; 16855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* switch context to btif task context (copy full union size for convenience) */ 16875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_transfer_context(btif_dm_upstreams_evt, (uint16_t)event, (void*)p_data, sizeof(tBTA_DM_SEC), NULL); 16885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* catch any failed context transfers */ 16905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed", status); 16915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 16925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 16945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bte_search_devices_evt 16965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Switches context from BTE to BTIF for DM search events 16985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 17005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 17025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bte_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data) 17035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 17045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 param_len = 0; 17055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data) 17075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project param_len += sizeof(tBTA_DM_SEARCH); 17085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Allocate buffer to hold the pointers (deep copy). The pointers will point to the end of the tBTA_DM_SEARCH */ 17095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 17105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_INQ_RES_EVT: 17125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data->inq_res.p_eir) 17145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project param_len += HCI_EXT_INQ_RESPONSE_LEN; 17155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 17175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_RES_EVT: 17195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data->disc_res.raw_data_size && p_data->disc_res.p_raw_data) 17215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project param_len += p_data->disc_res.raw_data_size; 17225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 17245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG3("%s event=%s param_len=%d", __FUNCTION__, dump_dm_search_event(event), param_len); 17265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if remote name is available in EIR, set teh flag so that stack doesnt trigger RNR */ 17285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (event == BTA_DM_INQ_RES_EVT) 17295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->inq_res.remt_name_not_required = check_eir_remote_name(p_data, NULL, NULL); 17305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_transfer_context (btif_dm_search_devices_evt , (UINT16) event, (void *)p_data, param_len, 17325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (param_len > sizeof(tBTA_DM_SEARCH)) ? search_devices_copy_cb : NULL); 17335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 17345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 17365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bte_dm_search_services_evt 17385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Switches context from BTE to BTIF for DM search services 17405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** event 17415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 17435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 17455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bte_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data) 17465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 17475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 param_len = 0; 17485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data) 17495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project param_len += sizeof(tBTA_DM_SEARCH); 17505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (event) 17515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BTA_DM_DISC_RES_EVT: 17535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_data->disc_res.result == BTA_SUCCESS) && (p_data->disc_res.num_uuids > 0)) { 17555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project param_len += (p_data->disc_res.num_uuids * MAX_UUID_SIZE); 17565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } break; 17585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: The only other member that needs a deep copy is the p_raw_data. But not sure 17605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * if raw_data is needed. */ 17615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_transfer_context(btif_dm_search_services_evt, event, (char*)p_data, param_len, 17625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (param_len > sizeof(tBTA_DM_SEARCH)) ? search_services_copy_cb : NULL); 17635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 17645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 17665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bte_dm_remote_service_record_evt 17685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Switches context from BTE to BTIF for DM search service 17705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** record event 17715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 17735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 17755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bte_dm_remote_service_record_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data) 17765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 17775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: The only member that needs a deep copy is the p_raw_data. But not sure yet if this is needed. */ 17785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_transfer_context(btif_dm_remote_service_record_evt, event, (char*)p_data, sizeof(tBTA_DM_SEARCH), NULL); 17795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 17805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 17825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** btif api functions (no context switch) 17845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 17865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 17885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_start_discovery 17905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Start device discovery/inquiry 17925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 17945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 17965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_start_discovery(void) 17975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 17985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_DM_INQ inq_params; 17995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_SERVICE_MASK services = 0; 18005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT1("%s", __FUNCTION__); 18025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: Do we need to handle multiple inquiries at the same time? */ 18035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Set inquiry params and call API */ 1805ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 18065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project inq_params.mode = BTA_DM_GENERAL_INQUIRY|BTA_BLE_GENERAL_INQUIRY; 18077f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE) 18087f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie inq_params.intl_duration[0]= BTIF_DM_INTERLEAVE_DURATION_BR_ONE; 18097f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie inq_params.intl_duration[1]= BTIF_DM_INTERLEAVE_DURATION_LE_ONE; 18107f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie inq_params.intl_duration[2]= BTIF_DM_INTERLEAVE_DURATION_BR_TWO; 18117f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie inq_params.intl_duration[3]= BTIF_DM_INTERLEAVE_DURATION_LE_TWO; 18127f3e42943b834ff0f556cd5c063a896f54d53167Matthew Xie#endif 18135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 18145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project inq_params.mode = BTA_DM_GENERAL_INQUIRY; 18155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 18165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project inq_params.duration = BTIF_DM_DEFAULT_INQ_MAX_DURATION; 18175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project inq_params.max_resps = BTIF_DM_DEFAULT_INQ_MAX_RESULTS; 18195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project inq_params.report_dup = TRUE; 18205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project inq_params.filter_type = BTA_DM_INQ_CLR; 18225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: Filter device by BDA needs to be implemented here */ 18235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Will be enabled to TRUE once inquiry busy level has been received */ 18255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_inquiry_in_progress = FALSE; 18265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* find nearby devices */ 18275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmSearch(&inq_params, services, bte_search_devices_evt); 18285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 18305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 18315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 18335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_cancel_discovery 18355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Cancels search 18375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 18395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 18415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_cancel_discovery(void) 18425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 18435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT1("%s", __FUNCTION__); 18445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmSearchCancel(); 18455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 18465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 18475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 18495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_create_bond 18515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Initiate bonding with the specified device 18535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 18555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 18575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_create_bond(const bt_bdaddr_t *bd_addr) 18585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 18595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdstr_t bdstr; 18605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: bd_addr=%s", __FUNCTION__, bd2str((bt_bdaddr_t *) bd_addr, &bdstr)); 18625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.state != BT_BOND_STATE_NONE) 18635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_BUSY; 18645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_CREATE_BOND, 18665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (char *)bd_addr, sizeof(bt_bdaddr_t), NULL); 18675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 18695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 18705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 18725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_cancel_bond 18745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Initiate bonding with the specified device 18765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 18785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 18805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr) 18825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 18835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdstr_t bdstr; 18845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: bd_addr=%s", __FUNCTION__, bd2str((bt_bdaddr_t *)bd_addr, &bdstr)); 18865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* TODO: 18885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 1. Restore scan modes 18895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ** 2. special handling for HID devices 18905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 18915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.state == BT_BOND_STATE_BONDING) 18925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1893ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1894ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 1895ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1896ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.is_ssp) 1897ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1898ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.is_le_only) 1899ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1900ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmBleSecurityGrant((UINT8 *)bd_addr->address,BTA_DM_SEC_PAIR_NOT_SPT); 1901ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1902ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 1903ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmConfirm( (UINT8 *)bd_addr->address, FALSE); 1904ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1905ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 1906ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1907ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.is_le_only) 1908ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1909ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmBondCancel ((UINT8 *)bd_addr->address); 1910ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1911ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 1912ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1913ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmPinReply( (UINT8 *)bd_addr->address, FALSE, 0, NULL); 1914ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1915ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Cancel bonding, in case it is in ACL connection setup state */ 1916ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmBondCancel ((UINT8 *)bd_addr->address); 1917ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1918ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1919ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#else 19205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.is_ssp) 19215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmConfirm( (UINT8 *)bd_addr->address, FALSE); 19235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 19255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmPinReply( (UINT8 *)bd_addr->address, FALSE, 0, NULL); 19275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Cancel bonding, in case it is in ACL connection setup state */ 19295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmBondCancel ((UINT8 *)bd_addr->address); 19305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_storage_remove_bonded_device((bt_bdaddr_t *)bd_addr); 1931ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 19325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 19355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 19365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 19385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_remove_bond 19405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Removes bonding with the specified device 19425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 19445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 19465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_remove_bond(const bt_bdaddr_t *bd_addr) 19485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 19495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdstr_t bdstr; 19505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: bd_addr=%s", __FUNCTION__, bd2str((bt_bdaddr_t *)bd_addr, &bdstr)); 19525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_REMOVE_BOND, 19535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (char *)bd_addr, sizeof(bt_bdaddr_t), NULL); 19545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 19565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 19575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 19595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_pin_reply 19615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description BT legacy pairing - PIN code reply 19635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 19655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 19675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_pin_reply( const bt_bdaddr_t *bd_addr, uint8_t accept, 19695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint8_t pin_len, bt_pin_code_t *pin_code) 19705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 19715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: accept=%d", __FUNCTION__, accept); 1972ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 1973ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1974ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.is_le_only) 1975ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1976ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int i; 1977ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT32 passkey = 0; 1978ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta int multi[] = {100000, 10000, 1000, 100, 10,1}; 1979ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BD_ADDR remote_bd_addr; 1980ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(remote_bd_addr, bd_addr->address); 1981ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta for (i = 0; i < 6; i++) 1982ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1983ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta passkey += (multi[i] * (pin_code->pin[i] - '0')); 1984ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1985ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("btif_dm_pin_reply: passkey: %d", passkey); 1986ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmBlePasskeyReply(remote_bd_addr, accept, passkey); 19875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1988ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1989ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 1990ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1991ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmPinReply( (UINT8 *)bd_addr->address, accept, pin_len, pin_code->pin); 1992ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (accept) 1993ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.pin_code_len = pin_len; 1994ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 1995ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#else 19965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmPinReply( (UINT8 *)bd_addr->address, accept, pin_len, pin_code->pin); 19975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (accept) 19995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pairing_cb.pin_code_len = pin_len; 2000ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 20015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 20025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 20035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 20055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_ssp_reply 20075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description BT SSP Reply - Just Works, Numeric Comparison & Passkey Entry 20095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 20115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 20135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_ssp_reply(const bt_bdaddr_t *bd_addr, 20155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_ssp_variant_t variant, uint8_t accept, 20165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t passkey) 20175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 20185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (variant == BT_SSP_VARIANT_PASSKEY_ENTRY) 20195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 20205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* This is not implemented in the stack. 20215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * For devices with display, this is not needed 20225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 20235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_WARNING1("%s: Not implemented", __FUNCTION__); 20245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_FAIL; 20255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* BT_SSP_VARIANT_CONSENT & BT_SSP_VARIANT_PASSKEY_CONFIRMATION supported */ 20275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: accept=%d", __FUNCTION__, accept); 2028ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 2029ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.is_le_only) 2030ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2031ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (accept) 2032ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmBleSecurityGrant((UINT8 *)bd_addr->address,BTA_DM_SEC_GRANTED); 2033ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 2034ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmBleSecurityGrant((UINT8 *)bd_addr->address,BTA_DM_SEC_PAIR_NOT_SPT); 2035ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2036ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 2037ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmConfirm( (UINT8 *)bd_addr->address, accept); 20385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2039ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#else 2040ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_DmConfirm( (UINT8 *)bd_addr->address, accept); 2041ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 20425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 20435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 20445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 20465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_get_adapter_property 20485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Queries the BTA for the adapter property 20505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 20525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 20545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_get_adapter_property(bt_property_t *prop) 20555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 20565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status; 20575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: type=0x%x", __FUNCTION__, prop->type); 20595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (prop->type) 20605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 20615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BT_PROPERTY_BDNAME: 20625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 20635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdname_t *bd_name = (bt_bdname_t*)prop->val; 20641e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie strcpy((char *)bd_name->name, btif_get_default_local_name()); 20655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop->len = strlen((char *)bd_name->name); 20665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 20685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BT_PROPERTY_ADAPTER_SCAN_MODE: 20705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 20715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if the storage does not have it. Most likely app never set it. Default is NONE */ 20725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_scan_mode_t *mode = (bt_scan_mode_t*)prop->val; 20735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *mode = BT_SCAN_MODE_NONE; 20745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop->len = sizeof(bt_scan_mode_t); 20755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 20775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT: 20795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 20805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project uint32_t *tmt = (uint32_t*)prop->val; 20815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *tmt = 120; /* default to 120s, if not found in NV */ 20825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop->len = sizeof(uint32_t); 20835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 20855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project default: 20875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project prop->len = 0; 20885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_FAIL; 20895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 20915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 20925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 20945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_get_remote_services 20965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Start SDP to get remote services 20985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 20995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 21005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 21015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 21025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr) 21035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 21045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdstr_t bdstr; 21055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: remote_addr=%s", __FUNCTION__, bd2str(remote_addr, &bdstr)); 21075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmDiscover(remote_addr->address, BTA_ALL_SERVICE_MASK, 21095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bte_dm_search_services_evt, TRUE); 21105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 21125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 21135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 21155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 21165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btif_dm_get_remote_service_record 21175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 21185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Start SDP to get remote service record 21195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 21205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 21215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns bt_status_t 21225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 21235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectbt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr, 21245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_uuid_t *uuid) 21255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 21265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tSDP_UUID sdp_uuid; 21275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdstr_t bdstr; 21285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_EVENT2("%s: remote_addr=%s", __FUNCTION__, bd2str(remote_addr, &bdstr)); 21305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sdp_uuid.len = MAX_UUID_SIZE; 21325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(sdp_uuid.uu.uuid128, uuid->uu, MAX_UUID_SIZE); 21335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmDiscoverUUID(remote_addr->address, &sdp_uuid, 21355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bte_dm_remote_service_record_evt, TRUE); 21365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BT_STATUS_SUCCESS; 21385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 21395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_dm_execute_service_request(UINT16 event, char *p_param) 21415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 21425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN b_enable = FALSE; 21435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_status_t status; 21445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (event == BTIF_DM_ENABLE_SERVICE) 21455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 21465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project b_enable = TRUE; 21475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 21485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = btif_in_execute_service_request(*((tBTA_SERVICE_ID*)p_param), b_enable); 21495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (status == BT_STATUS_SUCCESS) 21505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 21515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_property_t property; 21525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_uuid_t local_uuids[BT_MAX_NUM_UUIDS]; 21535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Now send the UUID_PROPERTY_CHANGED event to the upper layer */ 21555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_STORAGE_FILL_PROPERTY(&property, BT_PROPERTY_UUIDS, 21565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sizeof(local_uuids), local_uuids); 21575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_storage_get_adapter_property(&property); 21585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, 21595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_STATUS_SUCCESS, 1, &property); 21605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 21615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 21625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 21635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTM_OOB_INCLUDED == TRUE) 21655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_dm_set_oob_for_io_req(tBTA_OOB_DATA *p_oob_data) 21665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 21675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (oob_cb.sp_c[0] == 0 && oob_cb.sp_c[1] == 0 && 21685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project oob_cb.sp_c[2] == 0 && oob_cb.sp_c[3] == 0 ) 21695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 21705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_oob_data = FALSE; 21715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 21725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 21735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 21745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_oob_data = TRUE; 21755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 21765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_set_oob_for_io_req *p_oob_data=%d", *p_oob_data); 21775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 21785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif /* BTM_OOB_INCLUDED */ 21795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 21805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#ifdef BTIF_DM_OOB_TEST 21815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_dm_load_local_oob(void) 21825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2183d70b7a8ebce5a9646b8baf16a24a6eda88b1a4f6Nick Kralevich char prop_oob[PROPERTY_VALUE_MAX]; 21845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project property_get("service.brcm.bt.oob", prop_oob, "3"); 21855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_load_local_oob prop_oob = %s",prop_oob); 21865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (prop_oob[0] != '3') 21875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 21885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTM_OOB_INCLUDED == TRUE) 21895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (oob_cb.sp_c[0] == 0 && oob_cb.sp_c[1] == 0 && 21905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project oob_cb.sp_c[2] == 0 && oob_cb.sp_c[3] == 0 ) 21915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 21925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG0("btif_dm_load_local_oob: read OOB, call BTA_DmLocalOob()"); 21935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_DmLocalOob(); 21945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 21955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 21965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR0("BTM_OOB_INCLUDED is FALSE!!(btif_dm_load_local_oob)"); 21975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 21985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 21995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 22005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 22015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_dm_proc_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r) 22025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 22035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project FILE *fp; 22045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char *path_a = "/data/misc/bluedroid/LOCAL/a.key"; 22055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char *path_b = "/data/misc/bluedroid/LOCAL/b.key"; 22065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char *path = NULL; 2207d70b7a8ebce5a9646b8baf16a24a6eda88b1a4f6Nick Kralevich char prop_oob[PROPERTY_VALUE_MAX]; 22085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_proc_loc_oob: valid=%d", valid); 22095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (oob_cb.sp_c[0] == 0 && oob_cb.sp_c[1] == 0 && 22105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project oob_cb.sp_c[2] == 0 && oob_cb.sp_c[3] == 0 && 22115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project valid) 22125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 22135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG0("save local OOB data in memory"); 22145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(oob_cb.sp_c, c, BT_OCTET16_LEN); 22155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(oob_cb.sp_r, r, BT_OCTET16_LEN); 22165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project property_get("service.brcm.bt.oob", prop_oob, "3"); 22175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_proc_loc_oob prop_oob = %s",prop_oob); 22185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (prop_oob[0] == '1') 22195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project path = path_a; 22205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (prop_oob[0] == '2') 22215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project path = path_b; 22225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (path) 22235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 22245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fp = fopen(path, "wb+"); 22255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (fp == NULL) 22265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 22275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_proc_loc_oob: failed to save local OOB data to %s", path); 22285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 22295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 22305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 22315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_proc_loc_oob: save local OOB data into file %s",path); 22325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fwrite (c , 1 , BT_OCTET16_LEN , fp ); 22335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fwrite (r , 1 , BT_OCTET16_LEN , fp ); 22345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fclose(fp); 22355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 22365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 22375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 22385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 22395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBOOLEAN btif_dm_proc_rmt_oob(BD_ADDR bd_addr, BT_OCTET16 p_c, BT_OCTET16 p_r) 22405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 22415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char t[128]; 22425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project FILE *fp; 22435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char *path_a = "/data/misc/bluedroid/LOCAL/a.key"; 22445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char *path_b = "/data/misc/bluedroid/LOCAL/b.key"; 22455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char *path = NULL; 2246d70b7a8ebce5a9646b8baf16a24a6eda88b1a4f6Nick Kralevich char prop_oob[PROPERTY_VALUE_MAX]; 22475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN result = FALSE; 22485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bt_bd_addr; 22495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(oob_cb.oob_bdaddr, bd_addr); 22505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project property_get("service.brcm.bt.oob", prop_oob, "3"); 22515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_proc_rmt_oob prop_oob = %s",prop_oob); 22525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (prop_oob[0] == '1') 22535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project path = path_b; 22545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (prop_oob[0] == '2') 22555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project path = path_a; 22565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (path) 22575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 22585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fp = fopen(path, "rb"); 22595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (fp == NULL) 22605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 22615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btapp_dm_rmt_oob_reply: failed to read OOB keys from %s",path); 22625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return FALSE; 22635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 22645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 22655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 22665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_proc_rmt_oob: read OOB data from %s",path); 22675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fread (p_c , 1 , BT_OCTET16_LEN , fp ); 22685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fread (p_r , 1 , BT_OCTET16_LEN , fp ); 22695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project fclose(fp); 22705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 22715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG0("----btif_dm_proc_rmt_oob: TRUE"); 22725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sprintf(t, "%02x:%02x:%02x:%02x:%02x:%02x", 22735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project oob_cb.oob_bdaddr[0], oob_cb.oob_bdaddr[1], oob_cb.oob_bdaddr[2], 22745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project oob_cb.oob_bdaddr[3], oob_cb.oob_bdaddr[4], oob_cb.oob_bdaddr[5]); 22755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("----btif_dm_proc_rmt_oob: peer_bdaddr = %s", t); 22765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sprintf(t, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", 22775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_c[0], p_c[1], p_c[2], p_c[3], p_c[4], p_c[5], p_c[6], p_c[7], 22785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_c[8], p_c[9], p_c[10], p_c[11], p_c[12], p_c[13], p_c[14], p_c[15]); 22795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("----btif_dm_proc_rmt_oob: c = %s",t); 22805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sprintf(t, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", 22815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_r[0], p_r[1], p_r[2], p_r[3], p_r[4], p_r[5], p_r[6], p_r[7], 22825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_r[8], p_r[9], p_r[10], p_r[11], p_r[12], p_r[13], p_r[14], p_r[15]); 22835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("----btif_dm_proc_rmt_oob: r = %s",t); 22845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bt_bd_addr.address, bd_addr); 22855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_BOND_STATE_BONDING, 22865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (char *)&bt_bd_addr, sizeof(bt_bdaddr_t), NULL); 22875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = TRUE; 22885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 22895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("btif_dm_proc_rmt_oob result=%d",result); 22905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return result; 22915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 22925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif /* BTIF_DM_OOB_TEST */ 2293ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) 2294ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2295ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_ssp_key_notif) 2296ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2297ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 2298ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdname_t bd_name; 2299ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT32 cod; 2300ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2301ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("%s", __FUNCTION__); 2302ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2303ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Remote name update */ 2304ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_update_remote_properties(p_ssp_key_notif->bd_addr , p_ssp_key_notif->bd_name, 2305ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta NULL, BT_DEVICE_TYPE_BLE); 2306ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bd_addr.address, p_ssp_key_notif->bd_addr); 2307ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(bd_name.name, p_ssp_key_notif->bd_name, BD_NAME_LEN); 2308ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2309ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); 2310ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.is_ssp = FALSE; 2311ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta cod = COD_UNCLASSIFIED; 2312ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2313ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, 2314ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta cod, BT_SSP_VARIANT_PASSKEY_NOTIFICATION, 2315ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_ssp_key_notif->passkey); 2316ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2317ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2318ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 2319ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2320ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Function btif_dm_ble_auth_cmpl_evt 2321ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2322ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Description Executes authentication complete event in btif context 2323ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2324ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Returns void 2325ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2326ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta*******************************************************************************/ 2327ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) 2328ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2329ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Save link key, if not temporary */ 2330ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 2331ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_status_t status = BT_STATUS_FAIL; 2332ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bond_state_t state = BT_BOND_STATE_NONE; 2333ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2334ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bd_addr.address, p_auth_cmpl->bd_addr); 2335ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if ( (p_auth_cmpl->success == TRUE) && (p_auth_cmpl->key_present) ) 2336ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2337ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* store keys */ 2338ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2339ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_auth_cmpl->success) 2340ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2341ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta status = BT_STATUS_SUCCESS; 2342ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta state = BT_BOND_STATE_BONDED; 2343ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2344ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_save_ble_bonding_keys(); 2345ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTA_GATTC_Refresh(bd_addr.address); 2346ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_get_remote_services(&bd_addr); 2347ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2348ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 2349ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2350ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /*Map the HCI fail reason to bt status */ 2351ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta switch (p_auth_cmpl->fail_reason) 2352ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2353ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta default: 2354ca22ac493ab777199084d87b3c7627e7f27555afAndre Eisenbach btif_dm_remove_ble_bonding_keys(); 2355ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta status = BT_STATUS_FAIL; 2356ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 2357ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2358ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2359ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bond_state_changed(status, &bd_addr, state); 2360ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2361ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2362ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2363ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2364ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid btif_dm_load_ble_local_keys(void) 2365ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2366ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_status_t bt_status; 2367ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2368ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memset(&ble_local_key_cb, 0, sizeof(btif_dm_local_key_cb_t)); 2369ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2370ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (btif_storage_get_ble_local_key(BTIF_DM_LE_LOCAL_KEY_ER,(char*)&ble_local_key_cb.er[0], 2371ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN)== BT_STATUS_SUCCESS) 2372ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2373ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ble_local_key_cb.is_er_rcvd = TRUE; 2374ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("%s BLE ER key loaded",__FUNCTION__ ); 2375ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2376ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2377ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if ((btif_storage_get_ble_local_key(BTIF_DM_LE_LOCAL_KEY_IR,(char*)&ble_local_key_cb.id_keys.ir[0], 2378ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN)== BT_STATUS_SUCCESS )&& 2379ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (btif_storage_get_ble_local_key(BTIF_DM_LE_LOCAL_KEY_IRK, (char*)&ble_local_key_cb.id_keys.irk[0], 2380ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN)== BT_STATUS_SUCCESS)&& 2381ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (btif_storage_get_ble_local_key(BTIF_DM_LE_LOCAL_KEY_DHK,(char*)&ble_local_key_cb.id_keys.dhk[0], 2382ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN)== BT_STATUS_SUCCESS)) 2383ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2384ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ble_local_key_cb.is_id_keys_rcvd = TRUE; 2385ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("%s BLE ID keys loaded",__FUNCTION__ ); 2386ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2387ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2388ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2389ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er, 2390ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBTA_BLE_LOCAL_ID_KEYS *p_id_keys) 2391ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2392ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (ble_local_key_cb.is_er_rcvd ) 2393ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2394ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&er[0], &ble_local_key_cb.er[0], sizeof(BT_OCTET16)); 2395ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta *p_key_mask |= BTA_BLE_LOCAL_KEY_TYPE_ER; 2396ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2397ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2398ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (ble_local_key_cb.is_id_keys_rcvd) 2399ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2400ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&p_id_keys->ir[0], &ble_local_key_cb.id_keys.ir[0], sizeof(BT_OCTET16)); 2401ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&p_id_keys->irk[0], &ble_local_key_cb.id_keys.irk[0], sizeof(BT_OCTET16)); 2402ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(&p_id_keys->dhk[0], &ble_local_key_cb.id_keys.dhk[0], sizeof(BT_OCTET16)); 2403ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta *p_key_mask |= BTA_BLE_LOCAL_KEY_TYPE_ID; 2404ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2405ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG2("%s *p_key_mask=0x%02x",__FUNCTION__, *p_key_mask); 2406ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2407ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2408ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid btif_dm_save_ble_bonding_keys(void) 2409ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2410ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2411ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 2412ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2413ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("%s",__FUNCTION__ ); 2414ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2415ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bd_addr.address, pairing_cb.bd_addr); 2416ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2417ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.ble.is_penc_key_rcvd) 2418ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2419ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_bonding_key(&bd_addr, 2420ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *) &pairing_cb.ble.penc_key, 2421ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_KEY_PENC, 2422ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta sizeof(btif_dm_ble_penc_keys_t)); 2423ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2424ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2425ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.ble.is_pid_key_rcvd) 2426ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2427ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_bonding_key(&bd_addr, 2428ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *) &pairing_cb.ble.pid_key[0], 2429ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_KEY_PID, 2430ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_OCTET16_LEN); 2431ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2432ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2433ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2434ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.ble.is_pcsrk_key_rcvd) 2435ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2436ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_bonding_key(&bd_addr, 2437ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *) &pairing_cb.ble.pcsrk_key, 2438ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_KEY_PCSRK, 2439ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta sizeof(btif_dm_ble_pcsrk_keys_t)); 2440ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2441ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2442ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2443ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.ble.is_lenc_key_rcvd) 2444ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2445ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_bonding_key(&bd_addr, 2446ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *) &pairing_cb.ble.lenc_key, 2447ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_KEY_LENC, 2448ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta sizeof(btif_dm_ble_lenc_keys_t)); 2449ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2450ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2451ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.ble.is_lcsrk_key_rcvd) 2452ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2453ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_add_ble_bonding_key(&bd_addr, 2454ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *) &pairing_cb.ble.lcsrk_key, 2455ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_DM_LE_KEY_LCSRK, 2456ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta sizeof(btif_dm_ble_lcsrk_keys_t)); 2457ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2458ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2459ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2460ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2461ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2462ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid btif_dm_remove_ble_bonding_keys(void) 2463ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2464ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 2465ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2466ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("%s",__FUNCTION__ ); 2467ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2468ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bd_addr.address, pairing_cb.bd_addr); 2469ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_storage_remove_ble_bonding_keys(&bd_addr); 2470ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2471ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2472ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2473ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 2474ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2475ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Function btif_dm_ble_sec_req_evt 2476ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2477ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Description Eprocess security request event in btif context 2478ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2479ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Returns void 2480ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2481ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta*******************************************************************************/ 2482ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid btif_dm_ble_sec_req_evt(tBTA_DM_BLE_SEC_REQ *p_ble_req) 2483ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2484ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 2485ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdname_t bd_name; 2486ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT32 cod; 2487ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("%s", __FUNCTION__); 2488ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2489ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (pairing_cb.state == BT_BOND_STATE_BONDING) 2490ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 2491ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG1("%s Discard security request", __FUNCTION__); 2492ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return; 2493ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2494ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2495ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Remote name update */ 2496ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_update_remote_properties(p_ble_req->bd_addr,p_ble_req->bd_name,NULL,BT_DEVICE_TYPE_BLE); 2497ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2498ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bd_addr.address, p_ble_req->bd_addr); 2499ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(bd_name.name, p_ble_req->bd_name, BD_NAME_LEN); 2500ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2501ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); 2502ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2503ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.is_temp = FALSE; 2504ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.is_le_only = TRUE; 2505ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.is_ssp = TRUE; 2506ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2507ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta cod = COD_UNCLASSIFIED; 2508ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2509ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, cod, 2510ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BT_SSP_VARIANT_CONSENT, 0); 2511ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2512ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2513ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2514ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2515ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 2516ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2517ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Function btif_dm_ble_passkey_req_evt 2518ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2519ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Description Executes pin request event in btif context 2520ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2521ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Returns void 2522ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2523ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta*******************************************************************************/ 2524ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_passkey_req_evt(tBTA_DM_PIN_REQ *p_pin_req) 2525ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2526ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdaddr_t bd_addr; 2527ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bt_bdname_t bd_name; 2528ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta UINT32 cod; 2529ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2530ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Remote name update */ 2531ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_update_remote_properties(p_pin_req->bd_addr,p_pin_req->bd_name,NULL,BT_DEVICE_TYPE_BLE); 2532ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2533ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bdcpy(bd_addr.address, p_pin_req->bd_addr); 2534ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta memcpy(bd_name.name, p_pin_req->bd_name, BD_NAME_LEN); 2535ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2536ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING); 2537ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta pairing_cb.is_le_only = TRUE; 2538ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2539ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta cod = COD_UNCLASSIFIED; 2540ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2541ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta HAL_CBACK(bt_hal_cbacks, pin_request_cb, 2542ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta &bd_addr, &bd_name, cod); 2543ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2544ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2545ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2546ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid btif_dm_update_ble_remote_properties( BD_ADDR bd_addr, BD_NAME bd_name, 2547ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta tBT_DEVICE_TYPE dev_type) 2548ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2549ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_update_remote_properties(bd_addr,bd_name,NULL,dev_type); 2550ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2551ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2552ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_tx_test_cback(void *p) 2553ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2554ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_LE_TX_TEST, 2555ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *)p, 1, NULL); 2556ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2557ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2558ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_rx_test_cback(void *p) 2559ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2560ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_LE_RX_TEST, 2561ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *)p, 1, NULL); 2562ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2563ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2564ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic void btif_dm_ble_test_end_cback(void *p) 2565ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2566ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_LE_TEST_END, 2567ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (char *)p, 3, NULL); 2568ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2569ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 2570ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2571ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Function btif_le_test_mode 2572ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2573ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Description Sends a HCI BLE Test command to the Controller 2574ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2575ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Returns BT_STATUS_SUCCESS on success 2576ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 2577ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta*******************************************************************************/ 2578ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battabt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len) 2579ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 2580ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta switch (opcode) { 2581ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case HCI_BLE_TRANSMITTER_TEST: 2582ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (len != 3) return BT_STATUS_PARM_INVALID; 2583ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTM_BleTransmitterTest(buf[0],buf[1],buf[2], btif_dm_ble_tx_test_cback); 2584ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 2585ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case HCI_BLE_RECEIVER_TEST: 2586ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (len != 1) return BT_STATUS_PARM_INVALID; 2587ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTM_BleReceiverTest(buf[0], btif_dm_ble_rx_test_cback); 2588ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 2589ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta case HCI_BLE_TEST_END: 2590ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTM_BleTestEnd((tBTM_CMPL_CB*) btif_dm_ble_test_end_cback); 2591ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta break; 2592ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta default: 2593ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_ERROR2("%s: Unknown LE Test Mode Command 0x%x", __FUNCTION__, opcode); 2594ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return BT_STATUS_UNSUPPORTED; 2595ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 2596ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return BT_STATUS_SUCCESS; 2597ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 2598ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 2599ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif 26005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 26015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid btif_dm_on_disable() 26025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 26035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* cancel any pending pairing requests */ 26045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (pairing_cb.state == BT_BOND_STATE_BONDING) 26055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 26065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bt_bdaddr_t bd_addr; 26075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 26085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("%s: Cancel pending pairing request", __FUNCTION__); 26095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(bd_addr.address, pairing_cb.bd_addr); 26105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_cancel_bond(&bd_addr); 26115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 26125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 26131e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie 26141e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xiestatic char* btif_get_default_local_name() { 26151e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie if (btif_default_local_name[0] == '\0') 26161e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie { 26171e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie int max_len = sizeof(btif_default_local_name) - 1; 26181e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie if (BTM_DEF_LOCAL_NAME[0] != '\0') 26191e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie { 26201e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie strncpy(btif_default_local_name, BTM_DEF_LOCAL_NAME, max_len); 26211e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie } 26221e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie else 26231e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie { 26241e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie char prop_model[PROPERTY_VALUE_MAX]; 26251e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie property_get(PROPERTY_PRODUCT_MODEL, prop_model, ""); 26261e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie strncpy(btif_default_local_name, prop_model, max_len); 26271e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie } 26281e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie btif_default_local_name[max_len] = '\0'; 26291e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie } 26301e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie return btif_default_local_name; 26311e5109b5cbf49810abd0c94c413ce07db52caacaMatthew Xie} 2632