Loading system/bta/vc/device.cc +2 −4 Original line number Diff line number Diff line Loading @@ -415,10 +415,8 @@ bool VolumeControlDevice::IsEncryptionEnabled() { return BTM_IsEncrypted(address, BT_TRANSPORT_LE); } bool VolumeControlDevice::EnableEncryption(tBTM_SEC_CALLBACK* callback) { int result = BTM_SetEncryption(address, BT_TRANSPORT_LE, callback, nullptr, void VolumeControlDevice::EnableEncryption() { int result = BTM_SetEncryption(address, BT_TRANSPORT_LE, nullptr, nullptr, BTM_BLE_SEC_ENCRYPT); LOG(INFO) << __func__ << ": result=" << +result; // TODO: should we care about the result?? return true; } system/bta/vc/devices.h +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ class VolumeControlDevice { GATT_WRITE_OP_CB cb, void* cb_data); bool IsEncryptionEnabled(); bool EnableEncryption(tBTM_SEC_CALLBACK* callback); void EnableEncryption(); bool EnqueueInitialRequests(tGATT_IF gatt_if, GATT_READ_OP_CB chrc_read_cb, GATT_WRITE_OP_CB cccd_write_cb); Loading system/bta/vc/vc.cc +1 −8 Original line number Diff line number Diff line Loading @@ -145,9 +145,7 @@ class VolumeControlImpl : public VolumeControl { return; } if (!device->EnableEncryption(enc_callback_static)) { device_cleanup_helper(device, device->connecting_actively); } device->EnableEncryption(); } void OnEncryptionComplete(const RawAddress& address, uint8_t success) { Loading Loading @@ -1120,11 +1118,6 @@ class VolumeControlImpl : public VolumeControl { if (instance) instance->gattc_callback(event, p_data); } static void enc_callback_static(const RawAddress* address, tBT_TRANSPORT, void*, tBTM_STATUS status) { if (instance) instance->OnEncryptionComplete(*address, status); } static void chrc_read_callback_static(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, uint16_t len, uint8_t* value, void* data) { Loading system/bta/vc/vc_test.cc +21 −8 Original line number Diff line number Diff line Loading @@ -441,19 +441,32 @@ class VolumeControlTest : public ::testing::Test { gatt_callback(BTA_GATTC_SEARCH_CMPL_EVT, (tBTA_GATTC*)&event_data); } void GetEncryptionCompleteEvt(const RawAddress& bda) { tBTA_GATTC cb_data{}; cb_data.enc_cmpl.client_if = gatt_if; cb_data.enc_cmpl.remote_bda = bda; gatt_callback(BTA_GATTC_ENC_CMPL_CB_EVT, &cb_data); } void SetEncryptionResult(const RawAddress& address, bool success) { ON_CALL(btm_interface, BTM_IsEncrypted(address, _)) .WillByDefault(DoAll(Return(false))); EXPECT_CALL(btm_interface, SetEncryption(address, _, NotNull(), _, BTM_BLE_SEC_ENCRYPT)) .WillOnce(Invoke( [&success](const RawAddress& bd_addr, tBT_TRANSPORT transport, ON_CALL(btm_interface, SetEncryption(address, _, _, _, BTM_BLE_SEC_ENCRYPT)) .WillByDefault(Invoke( [&success, this](const RawAddress& bd_addr, tBT_TRANSPORT transport, tBTM_SEC_CALLBACK* p_callback, void* p_ref_data, tBTM_BLE_SEC_ACT sec_act) -> tBTM_STATUS { if (p_callback) { p_callback(&bd_addr, transport, p_ref_data, success ? BTM_SUCCESS : BTM_FAILED_ON_SECURITY); } GetEncryptionCompleteEvt(bd_addr); return BTM_SUCCESS; })); EXPECT_CALL(btm_interface, SetEncryption(address, _, _, _, BTM_BLE_SEC_ENCRYPT)) .Times(1); } void SetSampleDatabaseVCS(uint16_t conn_id) { Loading system/test/mock/mock_bta_vc_device.cc +1 −3 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ extern std::map<std::string, int> mock_function_count_map; #include <vector> #include "bta/vc/devices.h" #include "stack/btm/btm_sec.h" using namespace bluetooth::vc::internal; Loading @@ -36,9 +35,8 @@ using namespace bluetooth::vc::internal; #define UNUSED_ATTR #endif bool VolumeControlDevice::EnableEncryption(tBTM_SEC_CALLBACK* callback) { void VolumeControlDevice::EnableEncryption() { mock_function_count_map[__func__]++; return false; } bool VolumeControlDevice::EnqueueInitialRequests( tGATT_IF gatt_if, GATT_READ_OP_CB chrc_read_cb, Loading Loading
system/bta/vc/device.cc +2 −4 Original line number Diff line number Diff line Loading @@ -415,10 +415,8 @@ bool VolumeControlDevice::IsEncryptionEnabled() { return BTM_IsEncrypted(address, BT_TRANSPORT_LE); } bool VolumeControlDevice::EnableEncryption(tBTM_SEC_CALLBACK* callback) { int result = BTM_SetEncryption(address, BT_TRANSPORT_LE, callback, nullptr, void VolumeControlDevice::EnableEncryption() { int result = BTM_SetEncryption(address, BT_TRANSPORT_LE, nullptr, nullptr, BTM_BLE_SEC_ENCRYPT); LOG(INFO) << __func__ << ": result=" << +result; // TODO: should we care about the result?? return true; }
system/bta/vc/devices.h +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ class VolumeControlDevice { GATT_WRITE_OP_CB cb, void* cb_data); bool IsEncryptionEnabled(); bool EnableEncryption(tBTM_SEC_CALLBACK* callback); void EnableEncryption(); bool EnqueueInitialRequests(tGATT_IF gatt_if, GATT_READ_OP_CB chrc_read_cb, GATT_WRITE_OP_CB cccd_write_cb); Loading
system/bta/vc/vc.cc +1 −8 Original line number Diff line number Diff line Loading @@ -145,9 +145,7 @@ class VolumeControlImpl : public VolumeControl { return; } if (!device->EnableEncryption(enc_callback_static)) { device_cleanup_helper(device, device->connecting_actively); } device->EnableEncryption(); } void OnEncryptionComplete(const RawAddress& address, uint8_t success) { Loading Loading @@ -1120,11 +1118,6 @@ class VolumeControlImpl : public VolumeControl { if (instance) instance->gattc_callback(event, p_data); } static void enc_callback_static(const RawAddress* address, tBT_TRANSPORT, void*, tBTM_STATUS status) { if (instance) instance->OnEncryptionComplete(*address, status); } static void chrc_read_callback_static(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, uint16_t len, uint8_t* value, void* data) { Loading
system/bta/vc/vc_test.cc +21 −8 Original line number Diff line number Diff line Loading @@ -441,19 +441,32 @@ class VolumeControlTest : public ::testing::Test { gatt_callback(BTA_GATTC_SEARCH_CMPL_EVT, (tBTA_GATTC*)&event_data); } void GetEncryptionCompleteEvt(const RawAddress& bda) { tBTA_GATTC cb_data{}; cb_data.enc_cmpl.client_if = gatt_if; cb_data.enc_cmpl.remote_bda = bda; gatt_callback(BTA_GATTC_ENC_CMPL_CB_EVT, &cb_data); } void SetEncryptionResult(const RawAddress& address, bool success) { ON_CALL(btm_interface, BTM_IsEncrypted(address, _)) .WillByDefault(DoAll(Return(false))); EXPECT_CALL(btm_interface, SetEncryption(address, _, NotNull(), _, BTM_BLE_SEC_ENCRYPT)) .WillOnce(Invoke( [&success](const RawAddress& bd_addr, tBT_TRANSPORT transport, ON_CALL(btm_interface, SetEncryption(address, _, _, _, BTM_BLE_SEC_ENCRYPT)) .WillByDefault(Invoke( [&success, this](const RawAddress& bd_addr, tBT_TRANSPORT transport, tBTM_SEC_CALLBACK* p_callback, void* p_ref_data, tBTM_BLE_SEC_ACT sec_act) -> tBTM_STATUS { if (p_callback) { p_callback(&bd_addr, transport, p_ref_data, success ? BTM_SUCCESS : BTM_FAILED_ON_SECURITY); } GetEncryptionCompleteEvt(bd_addr); return BTM_SUCCESS; })); EXPECT_CALL(btm_interface, SetEncryption(address, _, _, _, BTM_BLE_SEC_ENCRYPT)) .Times(1); } void SetSampleDatabaseVCS(uint16_t conn_id) { Loading
system/test/mock/mock_bta_vc_device.cc +1 −3 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ extern std::map<std::string, int> mock_function_count_map; #include <vector> #include "bta/vc/devices.h" #include "stack/btm/btm_sec.h" using namespace bluetooth::vc::internal; Loading @@ -36,9 +35,8 @@ using namespace bluetooth::vc::internal; #define UNUSED_ATTR #endif bool VolumeControlDevice::EnableEncryption(tBTM_SEC_CALLBACK* callback) { void VolumeControlDevice::EnableEncryption() { mock_function_count_map[__func__]++; return false; } bool VolumeControlDevice::EnqueueInitialRequests( tGATT_IF gatt_if, GATT_READ_OP_CB chrc_read_cb, Loading