Loading system/gd/security/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ filegroup { "security_module.cc", ":BluetoothSecurityChannelSources", ":BluetoothSecurityPairingSources", ":BluetoothSecurityRecordSources", ], } Loading @@ -27,6 +28,7 @@ filegroup { "test/pairing_handler_le_pair_test.cc", ":BluetoothSecurityChannelTestSources", ":BluetoothSecurityPairingTestSources", ":BluetoothSecurityRecordTestSources", ], } Loading system/gd/security/internal/security_manager_impl.cc +18 −7 Original line number Diff line number Diff line Loading @@ -37,13 +37,13 @@ void SecurityManagerImpl::DispatchPairingHandler( std::shared_ptr<record::SecurityRecord> record, bool locally_initiated) { common::OnceCallback<void(hci::Address, PairingResultOrFailure)> callback = common::BindOnce(&SecurityManagerImpl::OnPairingHandlerComplete, common::Unretained(this)); auto entry = pairing_handler_map_.find(record->GetPseudoAddress().GetAddress()); auto entry = pairing_handler_map_.find(record->GetPseudoAddress()->GetAddress()); if (entry != pairing_handler_map_.end()) { LOG_WARN("Device already has a pairing handler, and is in the middle of pairing!"); return; } std::shared_ptr<pairing::PairingHandler> pairing_handler = nullptr; switch (record->GetPseudoAddress().GetAddressType()) { switch (record->GetPseudoAddress()->GetAddressType()) { case hci::AddressType::PUBLIC_DEVICE_ADDRESS: { pairing_handler = std::make_shared<security::pairing::ClassicPairingHandler>( security_manager_channel_, Loading @@ -56,10 +56,10 @@ void SecurityManagerImpl::DispatchPairingHandler( break; } default: ASSERT_LOG(false, "Pairing type %hhu not implemented!", record->GetPseudoAddress().GetAddressType()); ASSERT_LOG(false, "Pairing type %hhu not implemented!", record->GetPseudoAddress()->GetAddressType()); } auto new_entry = std::pair<hci::Address, std::shared_ptr<pairing::PairingHandler>>( record->GetPseudoAddress().GetAddress(), pairing_handler); record->GetPseudoAddress()->GetAddress(), pairing_handler); pairing_handler_map_.insert(std::move(new_entry)); pairing_handler->Initiate(locally_initiated, this->local_io_capability_, this->local_oob_data_present_, this->local_authentication_requirements_); Loading @@ -69,8 +69,9 @@ void SecurityManagerImpl::Init() { security_manager_channel_->SetChannelListener(this); security_manager_channel_->SendCommand(hci::WriteSimplePairingModeBuilder::Create(hci::Enable::ENABLED)); security_manager_channel_->SendCommand(hci::WriteSecureConnectionsHostSupportBuilder::Create(hci::Enable::ENABLED)); ASSERT_LOG(storage_module_ != nullptr, "Storage module must not be null!"); // TODO(optedoblivion): Populate security record memory map from disk security_database_.LoadRecordsFromStorage(); // TODO(b/161543441): read the privacy policy from device-specific configuration, and IRK from config file. hci::LeAddressManager::AddressPolicy address_policy = hci::LeAddressManager::AddressPolicy::USE_RESOLVABLE_ADDRESS; Loading Loading @@ -102,7 +103,7 @@ void SecurityManagerImpl::CreateBond(hci::AddressWithType device) { void SecurityManagerImpl::CreateBondLe(hci::AddressWithType address) { auto record = security_database_.FindOrCreate(address); if (record->IsBonded()) { if (record->IsPaired()) { NotifyDeviceBondFailed(address, PairingFailure("Already bonded")); return; } Loading Loading @@ -229,6 +230,8 @@ void SecurityManagerImpl::HandleEvent(T packet) { return; } auto device = storage_module_->GetDeviceByClassicMacAddress(bd_addr); auto record = security_database_.FindOrCreate(hci::AddressWithType{bd_addr, hci::AddressType::PUBLIC_DEVICE_ADDRESS}); LOG_WARN("Dispatch #2"); Loading Loading @@ -306,6 +309,10 @@ void SecurityManagerImpl::OnConnectionClosed(hci::Address address) { LOG_DEBUG("Cancelling pairing handler for '%s'", address.ToString().c_str()); entry->second->Cancel(); } auto record = security_database_.FindOrCreate(hci::AddressWithType(address, hci::AddressType::PUBLIC_DEVICE_ADDRESS)); if (record->IsTemporary()) { security_database_.Remove(hci::AddressWithType(address, hci::AddressType::PUBLIC_DEVICE_ADDRESS)); } } void SecurityManagerImpl::OnHciLeEvent(hci::LeMetaEventView event) { Loading Loading @@ -367,6 +374,7 @@ void SecurityManagerImpl::OnPairingHandlerComplete(hci::Address address, Pairing } auto record = this->security_database_.FindOrCreate(remote); record->CancelPairing(); security_database_.SaveRecordsToStorage(); } void SecurityManagerImpl::OnL2capRegistrationCompleteLe( Loading Loading @@ -591,7 +599,9 @@ SecurityManagerImpl::SecurityManagerImpl( hci_layer->GetLeSecurityInterface(security_handler_->BindOn(this, &SecurityManagerImpl::OnHciLeEvent))), security_manager_channel_(security_manager_channel), acl_manager_(acl_manager), storage_module_(storage_module) { storage_module_(storage_module), security_record_storage_(storage_module, security_handler), security_database_(security_record_storage_) { Init(); l2cap_manager_le_->RegisterService( Loading Loading @@ -620,6 +630,7 @@ void SecurityManagerImpl::OnPairingFinished(security::PairingResultOrFailure pai NotifyDeviceBonded(result.connection_address); security_handler_->CallOn(this, &SecurityManagerImpl::WipeLePairingHandler); security_database_.SaveRecordsToStorage(); } void SecurityManagerImpl::WipeLePairingHandler() { Loading system/gd/security/internal/security_manager_impl.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener, pub channel::SecurityManagerChannel* security_manager_channel_; hci::AclManager* acl_manager_; storage::StorageModule* storage_module_ __attribute__((unused)); record::SecurityRecordStorage security_record_storage_; record::SecurityRecordDatabase security_database_; std::unordered_map<hci::Address, std::shared_ptr<pairing::PairingHandler>> pairing_handler_map_; hci::IoCapability local_io_capability_ = kDefaultIoCapability; Loading system/gd/security/pairing/classic_pairing_handler.cc +50 −43 Original line number Diff line number Diff line Loading @@ -25,32 +25,31 @@ namespace pairing { void ClassicPairingHandler::NotifyUiDisplayYesNo(uint32_t numeric_value) { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayConfirmValue, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_, numeric_value)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayConfirmValue, *GetRecord()->GetPseudoAddress(), device_name_, numeric_value); } void ClassicPairingHandler::NotifyUiDisplayYesNo() { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayYesNoDialog, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayYesNoDialog, *GetRecord()->GetPseudoAddress(), device_name_); } void ClassicPairingHandler::NotifyUiDisplayPasskey(uint32_t passkey) { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayPasskey, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_, passkey)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayPasskey, *GetRecord()->GetPseudoAddress(), device_name_, passkey); } void ClassicPairingHandler::NotifyUiDisplayPasskeyInput() { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayEnterPasskeyDialog, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayEnterPasskeyDialog, *GetRecord()->GetPseudoAddress(), device_name_); } void ClassicPairingHandler::NotifyUiDisplayCancel() { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post( common::BindOnce(&UI::Cancel, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress())); user_interface_handler_->CallOn(user_interface_, &UI::Cancel, *GetRecord()->GetPseudoAddress()); } void ClassicPairingHandler::OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) { Loading @@ -60,10 +59,10 @@ void ClassicPairingHandler::OnPairingPromptAccepted(const bluetooth::hci::Addres void ClassicPairingHandler::OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) { if (confirmed) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } else { GetChannel()->SendCommand( hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } } Loading @@ -82,7 +81,7 @@ void ClassicPairingHandler::Initiate(bool locally_initiated, hci::IoCapability i // TODO(optedoblivion): Read OOB data // if host and controller support secure connections used HCIREADLOCALOOBEXTENDEDDATA vs HCIREADLOCALOOBDATA GetChannel()->Connect(GetRecord()->GetPseudoAddress().GetAddress()); GetChannel()->Connect(GetRecord()->GetPseudoAddress()->GetAddress()); } void ClassicPairingHandler::Cancel() { Loading @@ -92,7 +91,7 @@ void ClassicPairingHandler::Cancel() { if (last_status_ != hci::ErrorCode::SUCCESS) { result = PairingFailure(hci::ErrorCodeText(last_status_)); } std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress().GetAddress(), result); std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress()->GetAddress(), result); } void ClassicPairingHandler::OnReceive(hci::ChangeConnectionLinkKeyCompleteView packet) { Loading @@ -108,25 +107,27 @@ void ClassicPairingHandler::OnReceive(hci::MasterLinkKeyCompleteView packet) { void ClassicPairingHandler::OnReceive(hci::PinCodeRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnReceive(hci::LinkKeyRequestView packet) { ASSERT(packet.IsValid()); if (already_link_key_replied_) return; if (already_link_key_replied_) { LOG_WARN("Pairing is already in progress..."); return; } already_link_key_replied_ = true; // TODO(optedoblivion): Add collision detection here LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); if (GetRecord()->IsBonded() || GetRecord()->IsPaired()) { auto packet = hci::LinkKeyRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress(), GetRecord()->GetLinkKey()); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); if (GetRecord()->IsPaired()) { auto packet = hci::LinkKeyRequestReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress(), GetRecord()->GetLinkKey()); LOG_INFO("Sending: LINK_KEY_REQUEST_REPLY"); this->GetChannel()->SendCommand(std::move(packet)); last_status_ = hci::ErrorCode::SUCCESS; Cancel(); } else { auto packet = hci::LinkKeyRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress()); auto packet = hci::LinkKeyRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress()); LOG_INFO("Sending: LINK_KEY_REQUEST_NEGATIVE_REPLY"); this->GetChannel()->SendCommand(std::move(packet)); } Loading @@ -135,7 +136,7 @@ void ClassicPairingHandler::OnReceive(hci::LinkKeyRequestView packet) { void ClassicPairingHandler::OnReceive(hci::LinkKeyNotificationView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); GetRecord()->SetLinkKey(packet.GetLinkKey(), packet.GetKeyType()); Cancel(); } Loading @@ -143,19 +144,19 @@ void ClassicPairingHandler::OnReceive(hci::LinkKeyNotificationView packet) { void ClassicPairingHandler::OnReceive(hci::IoCapabilityRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); hci::IoCapability io_capability = local_io_capability_; hci::OobDataPresent oob_present = hci::OobDataPresent::NOT_PRESENT; hci::AuthenticationRequirements authentication_requirements = local_authentication_requirements_; auto reply_packet = hci::IoCapabilityRequestReplyBuilder::Create( GetRecord()->GetPseudoAddress().GetAddress(), io_capability, oob_present, authentication_requirements); GetRecord()->GetPseudoAddress()->GetAddress(), io_capability, oob_present, authentication_requirements); this->GetChannel()->SendCommand(std::move(reply_packet)); } void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); // Using local variable until device database pointer is ready remote_io_capability_ = packet.GetIoCapability(); Loading @@ -165,10 +166,17 @@ void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { case hci::AuthenticationRequirements::NO_BONDING: GetRecord()->SetIsEncryptionRequired(false); GetRecord()->SetRequiresMitmProtection(false); // TODO(optedoblivion): check for HID device and if HID don't make temporary GetRecord()->SetIsTemporary( local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING || local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING_MITM_PROTECTION); break; case hci::AuthenticationRequirements::NO_BONDING_MITM_PROTECTION: GetRecord()->SetIsEncryptionRequired(false); GetRecord()->SetRequiresMitmProtection(true); GetRecord()->SetIsTemporary( local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING || local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING_MITM_PROTECTION); break; case hci::AuthenticationRequirements::DEDICATED_BONDING: GetRecord()->SetIsEncryptionRequired(true); Loading @@ -195,7 +203,7 @@ void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { void ClassicPairingHandler::OnReceive(hci::SimplePairingCompleteView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); last_status_ = packet.GetStatus(); if (last_status_ != hci::ErrorCode::SUCCESS) { LOG_INFO("Failed SimplePairingComplete: %s", hci::ErrorCodeText(last_status_).c_str()); Loading @@ -222,13 +230,13 @@ void ClassicPairingHandler::OnReceive(hci::EncryptionKeyRefreshCompleteView pack void ClassicPairingHandler::OnReceive(hci::RemoteOobDataRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnReceive(hci::UserPasskeyNotificationView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnReceive(hci::KeypressNotificationView packet) { Loading Loading @@ -262,11 +270,10 @@ void ClassicPairingHandler::OnReceive(hci::KeypressNotificationView packet) { void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); // if locally_initialized, use default, otherwise us remote io caps hci::IoCapability initiator_io_capability = (locally_initiated_) ? local_io_capability_ : remote_io_capability_; hci::IoCapability responder_io_capability = (!locally_initiated_) ? local_io_capability_ : remote_io_capability_; // TODO(optedoblivion): Check for TEMPORARY pairing case switch (initiator_io_capability) { case hci::IoCapability::DISPLAY_ONLY: switch (responder_io_capability) { Loading @@ -274,14 +281,14 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, Both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; case hci::IoCapability::DISPLAY_YES_NO: // NumericComparison, Initiator auto confirm, Responder display GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); LOG_INFO("Numeric Comparison: A auto confirm"); // Unauthenticated GetRecord()->SetAuthenticated(true); Loading @@ -297,7 +304,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, Both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(true); break; Loading Loading @@ -328,8 +335,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { break; case hci::IoCapability::NO_INPUT_NO_OUTPUT: // NumericComparison, auto confirm Responder, Yes/No confirm Initiator. Don't show confirmation value NotifyUiDisplayYesNo(); LOG_INFO("Numeric Comparison: A DisplayYesNo, B auto confirm, no show value"); NotifyUiDisplayYesNo(); // Unauthenticated GetRecord()->SetAuthenticated(true); break; Loading Loading @@ -362,7 +369,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -374,7 +381,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -382,7 +389,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, Initiator auto confirm, Responder Yes/No confirm, no show conf val LOG_INFO("Numeric Comparison: A auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -390,7 +397,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -398,7 +405,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -409,7 +416,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { void ClassicPairingHandler::OnReceive(hci::UserPasskeyRequestView packet) { ASSERT(packet.IsValid()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnUserInput(bool user_input) { Loading @@ -422,12 +429,12 @@ void ClassicPairingHandler::OnUserInput(bool user_input) { void ClassicPairingHandler::UserClickedYes() { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } void ClassicPairingHandler::UserClickedNo() { GetChannel()->SendCommand( hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } void ClassicPairingHandler::OnPasskeyInput(uint32_t passkey) { Loading system/gd/security/record/Android.bp 0 → 100644 +13 −0 Original line number Diff line number Diff line filegroup { name: "BluetoothSecurityRecordSources", srcs: [ "security_record_storage.cc" ], } filegroup { name: "BluetoothSecurityRecordTestSources", srcs: [ "security_record_storage_test.cc" ], } No newline at end of file Loading
system/gd/security/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ filegroup { "security_module.cc", ":BluetoothSecurityChannelSources", ":BluetoothSecurityPairingSources", ":BluetoothSecurityRecordSources", ], } Loading @@ -27,6 +28,7 @@ filegroup { "test/pairing_handler_le_pair_test.cc", ":BluetoothSecurityChannelTestSources", ":BluetoothSecurityPairingTestSources", ":BluetoothSecurityRecordTestSources", ], } Loading
system/gd/security/internal/security_manager_impl.cc +18 −7 Original line number Diff line number Diff line Loading @@ -37,13 +37,13 @@ void SecurityManagerImpl::DispatchPairingHandler( std::shared_ptr<record::SecurityRecord> record, bool locally_initiated) { common::OnceCallback<void(hci::Address, PairingResultOrFailure)> callback = common::BindOnce(&SecurityManagerImpl::OnPairingHandlerComplete, common::Unretained(this)); auto entry = pairing_handler_map_.find(record->GetPseudoAddress().GetAddress()); auto entry = pairing_handler_map_.find(record->GetPseudoAddress()->GetAddress()); if (entry != pairing_handler_map_.end()) { LOG_WARN("Device already has a pairing handler, and is in the middle of pairing!"); return; } std::shared_ptr<pairing::PairingHandler> pairing_handler = nullptr; switch (record->GetPseudoAddress().GetAddressType()) { switch (record->GetPseudoAddress()->GetAddressType()) { case hci::AddressType::PUBLIC_DEVICE_ADDRESS: { pairing_handler = std::make_shared<security::pairing::ClassicPairingHandler>( security_manager_channel_, Loading @@ -56,10 +56,10 @@ void SecurityManagerImpl::DispatchPairingHandler( break; } default: ASSERT_LOG(false, "Pairing type %hhu not implemented!", record->GetPseudoAddress().GetAddressType()); ASSERT_LOG(false, "Pairing type %hhu not implemented!", record->GetPseudoAddress()->GetAddressType()); } auto new_entry = std::pair<hci::Address, std::shared_ptr<pairing::PairingHandler>>( record->GetPseudoAddress().GetAddress(), pairing_handler); record->GetPseudoAddress()->GetAddress(), pairing_handler); pairing_handler_map_.insert(std::move(new_entry)); pairing_handler->Initiate(locally_initiated, this->local_io_capability_, this->local_oob_data_present_, this->local_authentication_requirements_); Loading @@ -69,8 +69,9 @@ void SecurityManagerImpl::Init() { security_manager_channel_->SetChannelListener(this); security_manager_channel_->SendCommand(hci::WriteSimplePairingModeBuilder::Create(hci::Enable::ENABLED)); security_manager_channel_->SendCommand(hci::WriteSecureConnectionsHostSupportBuilder::Create(hci::Enable::ENABLED)); ASSERT_LOG(storage_module_ != nullptr, "Storage module must not be null!"); // TODO(optedoblivion): Populate security record memory map from disk security_database_.LoadRecordsFromStorage(); // TODO(b/161543441): read the privacy policy from device-specific configuration, and IRK from config file. hci::LeAddressManager::AddressPolicy address_policy = hci::LeAddressManager::AddressPolicy::USE_RESOLVABLE_ADDRESS; Loading Loading @@ -102,7 +103,7 @@ void SecurityManagerImpl::CreateBond(hci::AddressWithType device) { void SecurityManagerImpl::CreateBondLe(hci::AddressWithType address) { auto record = security_database_.FindOrCreate(address); if (record->IsBonded()) { if (record->IsPaired()) { NotifyDeviceBondFailed(address, PairingFailure("Already bonded")); return; } Loading Loading @@ -229,6 +230,8 @@ void SecurityManagerImpl::HandleEvent(T packet) { return; } auto device = storage_module_->GetDeviceByClassicMacAddress(bd_addr); auto record = security_database_.FindOrCreate(hci::AddressWithType{bd_addr, hci::AddressType::PUBLIC_DEVICE_ADDRESS}); LOG_WARN("Dispatch #2"); Loading Loading @@ -306,6 +309,10 @@ void SecurityManagerImpl::OnConnectionClosed(hci::Address address) { LOG_DEBUG("Cancelling pairing handler for '%s'", address.ToString().c_str()); entry->second->Cancel(); } auto record = security_database_.FindOrCreate(hci::AddressWithType(address, hci::AddressType::PUBLIC_DEVICE_ADDRESS)); if (record->IsTemporary()) { security_database_.Remove(hci::AddressWithType(address, hci::AddressType::PUBLIC_DEVICE_ADDRESS)); } } void SecurityManagerImpl::OnHciLeEvent(hci::LeMetaEventView event) { Loading Loading @@ -367,6 +374,7 @@ void SecurityManagerImpl::OnPairingHandlerComplete(hci::Address address, Pairing } auto record = this->security_database_.FindOrCreate(remote); record->CancelPairing(); security_database_.SaveRecordsToStorage(); } void SecurityManagerImpl::OnL2capRegistrationCompleteLe( Loading Loading @@ -591,7 +599,9 @@ SecurityManagerImpl::SecurityManagerImpl( hci_layer->GetLeSecurityInterface(security_handler_->BindOn(this, &SecurityManagerImpl::OnHciLeEvent))), security_manager_channel_(security_manager_channel), acl_manager_(acl_manager), storage_module_(storage_module) { storage_module_(storage_module), security_record_storage_(storage_module, security_handler), security_database_(security_record_storage_) { Init(); l2cap_manager_le_->RegisterService( Loading Loading @@ -620,6 +630,7 @@ void SecurityManagerImpl::OnPairingFinished(security::PairingResultOrFailure pai NotifyDeviceBonded(result.connection_address); security_handler_->CallOn(this, &SecurityManagerImpl::WipeLePairingHandler); security_database_.SaveRecordsToStorage(); } void SecurityManagerImpl::WipeLePairingHandler() { Loading
system/gd/security/internal/security_manager_impl.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener, pub channel::SecurityManagerChannel* security_manager_channel_; hci::AclManager* acl_manager_; storage::StorageModule* storage_module_ __attribute__((unused)); record::SecurityRecordStorage security_record_storage_; record::SecurityRecordDatabase security_database_; std::unordered_map<hci::Address, std::shared_ptr<pairing::PairingHandler>> pairing_handler_map_; hci::IoCapability local_io_capability_ = kDefaultIoCapability; Loading
system/gd/security/pairing/classic_pairing_handler.cc +50 −43 Original line number Diff line number Diff line Loading @@ -25,32 +25,31 @@ namespace pairing { void ClassicPairingHandler::NotifyUiDisplayYesNo(uint32_t numeric_value) { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayConfirmValue, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_, numeric_value)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayConfirmValue, *GetRecord()->GetPseudoAddress(), device_name_, numeric_value); } void ClassicPairingHandler::NotifyUiDisplayYesNo() { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayYesNoDialog, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayYesNoDialog, *GetRecord()->GetPseudoAddress(), device_name_); } void ClassicPairingHandler::NotifyUiDisplayPasskey(uint32_t passkey) { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayPasskey, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_, passkey)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayPasskey, *GetRecord()->GetPseudoAddress(), device_name_, passkey); } void ClassicPairingHandler::NotifyUiDisplayPasskeyInput() { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post(common::BindOnce(&UI::DisplayEnterPasskeyDialog, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress(), device_name_)); user_interface_handler_->CallOn( user_interface_, &UI::DisplayEnterPasskeyDialog, *GetRecord()->GetPseudoAddress(), device_name_); } void ClassicPairingHandler::NotifyUiDisplayCancel() { ASSERT(user_interface_handler_ != nullptr); user_interface_handler_->Post( common::BindOnce(&UI::Cancel, common::Unretained(user_interface_), GetRecord()->GetPseudoAddress())); user_interface_handler_->CallOn(user_interface_, &UI::Cancel, *GetRecord()->GetPseudoAddress()); } void ClassicPairingHandler::OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) { Loading @@ -60,10 +59,10 @@ void ClassicPairingHandler::OnPairingPromptAccepted(const bluetooth::hci::Addres void ClassicPairingHandler::OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) { if (confirmed) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } else { GetChannel()->SendCommand( hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } } Loading @@ -82,7 +81,7 @@ void ClassicPairingHandler::Initiate(bool locally_initiated, hci::IoCapability i // TODO(optedoblivion): Read OOB data // if host and controller support secure connections used HCIREADLOCALOOBEXTENDEDDATA vs HCIREADLOCALOOBDATA GetChannel()->Connect(GetRecord()->GetPseudoAddress().GetAddress()); GetChannel()->Connect(GetRecord()->GetPseudoAddress()->GetAddress()); } void ClassicPairingHandler::Cancel() { Loading @@ -92,7 +91,7 @@ void ClassicPairingHandler::Cancel() { if (last_status_ != hci::ErrorCode::SUCCESS) { result = PairingFailure(hci::ErrorCodeText(last_status_)); } std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress().GetAddress(), result); std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress()->GetAddress(), result); } void ClassicPairingHandler::OnReceive(hci::ChangeConnectionLinkKeyCompleteView packet) { Loading @@ -108,25 +107,27 @@ void ClassicPairingHandler::OnReceive(hci::MasterLinkKeyCompleteView packet) { void ClassicPairingHandler::OnReceive(hci::PinCodeRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnReceive(hci::LinkKeyRequestView packet) { ASSERT(packet.IsValid()); if (already_link_key_replied_) return; if (already_link_key_replied_) { LOG_WARN("Pairing is already in progress..."); return; } already_link_key_replied_ = true; // TODO(optedoblivion): Add collision detection here LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); if (GetRecord()->IsBonded() || GetRecord()->IsPaired()) { auto packet = hci::LinkKeyRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress(), GetRecord()->GetLinkKey()); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); if (GetRecord()->IsPaired()) { auto packet = hci::LinkKeyRequestReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress(), GetRecord()->GetLinkKey()); LOG_INFO("Sending: LINK_KEY_REQUEST_REPLY"); this->GetChannel()->SendCommand(std::move(packet)); last_status_ = hci::ErrorCode::SUCCESS; Cancel(); } else { auto packet = hci::LinkKeyRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress()); auto packet = hci::LinkKeyRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress()); LOG_INFO("Sending: LINK_KEY_REQUEST_NEGATIVE_REPLY"); this->GetChannel()->SendCommand(std::move(packet)); } Loading @@ -135,7 +136,7 @@ void ClassicPairingHandler::OnReceive(hci::LinkKeyRequestView packet) { void ClassicPairingHandler::OnReceive(hci::LinkKeyNotificationView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); GetRecord()->SetLinkKey(packet.GetLinkKey(), packet.GetKeyType()); Cancel(); } Loading @@ -143,19 +144,19 @@ void ClassicPairingHandler::OnReceive(hci::LinkKeyNotificationView packet) { void ClassicPairingHandler::OnReceive(hci::IoCapabilityRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); hci::IoCapability io_capability = local_io_capability_; hci::OobDataPresent oob_present = hci::OobDataPresent::NOT_PRESENT; hci::AuthenticationRequirements authentication_requirements = local_authentication_requirements_; auto reply_packet = hci::IoCapabilityRequestReplyBuilder::Create( GetRecord()->GetPseudoAddress().GetAddress(), io_capability, oob_present, authentication_requirements); GetRecord()->GetPseudoAddress()->GetAddress(), io_capability, oob_present, authentication_requirements); this->GetChannel()->SendCommand(std::move(reply_packet)); } void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); // Using local variable until device database pointer is ready remote_io_capability_ = packet.GetIoCapability(); Loading @@ -165,10 +166,17 @@ void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { case hci::AuthenticationRequirements::NO_BONDING: GetRecord()->SetIsEncryptionRequired(false); GetRecord()->SetRequiresMitmProtection(false); // TODO(optedoblivion): check for HID device and if HID don't make temporary GetRecord()->SetIsTemporary( local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING || local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING_MITM_PROTECTION); break; case hci::AuthenticationRequirements::NO_BONDING_MITM_PROTECTION: GetRecord()->SetIsEncryptionRequired(false); GetRecord()->SetRequiresMitmProtection(true); GetRecord()->SetIsTemporary( local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING || local_authentication_requirements_ == hci::AuthenticationRequirements::NO_BONDING_MITM_PROTECTION); break; case hci::AuthenticationRequirements::DEDICATED_BONDING: GetRecord()->SetIsEncryptionRequired(true); Loading @@ -195,7 +203,7 @@ void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { void ClassicPairingHandler::OnReceive(hci::SimplePairingCompleteView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); last_status_ = packet.GetStatus(); if (last_status_ != hci::ErrorCode::SUCCESS) { LOG_INFO("Failed SimplePairingComplete: %s", hci::ErrorCodeText(last_status_).c_str()); Loading @@ -222,13 +230,13 @@ void ClassicPairingHandler::OnReceive(hci::EncryptionKeyRefreshCompleteView pack void ClassicPairingHandler::OnReceive(hci::RemoteOobDataRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnReceive(hci::UserPasskeyNotificationView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnReceive(hci::KeypressNotificationView packet) { Loading Loading @@ -262,11 +270,10 @@ void ClassicPairingHandler::OnReceive(hci::KeypressNotificationView packet) { void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); // if locally_initialized, use default, otherwise us remote io caps hci::IoCapability initiator_io_capability = (locally_initiated_) ? local_io_capability_ : remote_io_capability_; hci::IoCapability responder_io_capability = (!locally_initiated_) ? local_io_capability_ : remote_io_capability_; // TODO(optedoblivion): Check for TEMPORARY pairing case switch (initiator_io_capability) { case hci::IoCapability::DISPLAY_ONLY: switch (responder_io_capability) { Loading @@ -274,14 +281,14 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, Both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; case hci::IoCapability::DISPLAY_YES_NO: // NumericComparison, Initiator auto confirm, Responder display GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); LOG_INFO("Numeric Comparison: A auto confirm"); // Unauthenticated GetRecord()->SetAuthenticated(true); Loading @@ -297,7 +304,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, Both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(true); break; Loading Loading @@ -328,8 +335,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { break; case hci::IoCapability::NO_INPUT_NO_OUTPUT: // NumericComparison, auto confirm Responder, Yes/No confirm Initiator. Don't show confirmation value NotifyUiDisplayYesNo(); LOG_INFO("Numeric Comparison: A DisplayYesNo, B auto confirm, no show value"); NotifyUiDisplayYesNo(); // Unauthenticated GetRecord()->SetAuthenticated(true); break; Loading Loading @@ -362,7 +369,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -374,7 +381,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -382,7 +389,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, Initiator auto confirm, Responder Yes/No confirm, no show conf val LOG_INFO("Numeric Comparison: A auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -390,7 +397,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -398,7 +405,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // NumericComparison, both auto confirm LOG_INFO("Numeric Comparison: A and B auto confirm"); GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // Unauthenticated GetRecord()->SetAuthenticated(false); break; Loading @@ -409,7 +416,7 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { void ClassicPairingHandler::OnReceive(hci::UserPasskeyRequestView packet) { ASSERT(packet.IsValid()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); } void ClassicPairingHandler::OnUserInput(bool user_input) { Loading @@ -422,12 +429,12 @@ void ClassicPairingHandler::OnUserInput(bool user_input) { void ClassicPairingHandler::UserClickedYes() { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } void ClassicPairingHandler::UserClickedNo() { GetChannel()->SendCommand( hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress())); hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); } void ClassicPairingHandler::OnPasskeyInput(uint32_t passkey) { Loading
system/gd/security/record/Android.bp 0 → 100644 +13 −0 Original line number Diff line number Diff line filegroup { name: "BluetoothSecurityRecordSources", srcs: [ "security_record_storage.cc" ], } filegroup { name: "BluetoothSecurityRecordTestSources", srcs: [ "security_record_storage_test.cc" ], } No newline at end of file