• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *  Copyright 2019 The Android Open Source Project
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  */
18 #include "security_manager.h"
19 
20 #include "os/log.h"
21 
22 namespace bluetooth {
23 namespace security {
24 
25 // Definition of Pure Virtual Destructor
~ISecurityManagerListener()26 ISecurityManagerListener::~ISecurityManagerListener() {}
27 
Init()28 void SecurityManager::Init() {
29   security_handler_->Post(
30       common::BindOnce(&internal::SecurityManagerImpl::Init, common::Unretained(security_manager_impl_)));
31 }
32 
CreateBond(hci::AddressWithType device)33 void SecurityManager::CreateBond(hci::AddressWithType device) {
34   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CreateBond,
35                                            common::Unretained(security_manager_impl_),
36                                            std::forward<hci::AddressWithType>(device)));
37 }
38 
CreateBondLe(hci::AddressWithType device)39 void SecurityManager::CreateBondLe(hci::AddressWithType device) {
40   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CreateBondLe,
41                                            common::Unretained(security_manager_impl_),
42                                            std::forward<hci::AddressWithType>(device)));
43 }
44 
CancelBond(hci::AddressWithType device)45 void SecurityManager::CancelBond(hci::AddressWithType device) {
46   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CancelBond,
47                                            common::Unretained(security_manager_impl_),
48                                            std::forward<hci::AddressWithType>(device)));
49 }
50 
RemoveBond(hci::AddressWithType device)51 void SecurityManager::RemoveBond(hci::AddressWithType device) {
52   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::RemoveBond,
53                                            common::Unretained(security_manager_impl_),
54                                            std::forward<hci::AddressWithType>(device)));
55 }
56 
SetUserInterfaceHandler(UI * user_interface,os::Handler * handler)57 void SecurityManager::SetUserInterfaceHandler(UI* user_interface, os::Handler* handler) {
58   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::SetUserInterfaceHandler,
59                                            common::Unretained(security_manager_impl_), user_interface, handler));
60 }
61 
RegisterCallbackListener(ISecurityManagerListener * listener,os::Handler * handler)62 void SecurityManager::RegisterCallbackListener(ISecurityManagerListener* listener, os::Handler* handler) {
63   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::RegisterCallbackListener,
64                                            common::Unretained(security_manager_impl_), listener, handler));
65 }
66 
UnregisterCallbackListener(ISecurityManagerListener * listener)67 void SecurityManager::UnregisterCallbackListener(ISecurityManagerListener* listener) {
68   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::UnregisterCallbackListener,
69                                            common::Unretained(security_manager_impl_), listener));
70 }
71 
OnPairingPromptAccepted(const bluetooth::hci::AddressWithType & address,bool confirmed)72 void SecurityManager::OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) {
73   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::OnPairingPromptAccepted,
74                                            common::Unretained(security_manager_impl_), address, confirmed));
75 }
OnConfirmYesNo(const bluetooth::hci::AddressWithType & address,bool confirmed)76 void SecurityManager::OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) {
77   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::OnConfirmYesNo,
78                                            common::Unretained(security_manager_impl_), address, confirmed));
79 }
OnPasskeyEntry(const bluetooth::hci::AddressWithType & address,uint32_t passkey)80 void SecurityManager::OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) {
81   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::OnPasskeyEntry,
82                                            common::Unretained(security_manager_impl_), address, passkey));
83 }
84 
85 }  // namespace security
86 }  // namespace bluetooth
87