Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 1 | /* |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 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 | * |
Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 17 | */ |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 18 | #include "security_manager.h" |
| 19 | |
| 20 | #include "os/log.h" |
| 21 | |
| 22 | using namespace bluetooth::security; |
| 23 | |
Jakub Pawlowski | af9379b | 2019-11-18 17:51:13 +0100 | [diff] [blame] | 24 | // Definition of Pure Virtual Destructor |
| 25 | ISecurityManagerListener::~ISecurityManagerListener() {} |
| 26 | |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 27 | void SecurityManager::Init() { |
| 28 | security_handler_->Post( |
| 29 | common::BindOnce(&internal::SecurityManagerImpl::Init, common::Unretained(security_manager_impl_))); |
| 30 | } |
| 31 | |
Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 32 | void SecurityManager::CreateBond(hci::AddressWithType device) { |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 33 | security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CreateBond, |
| 34 | common::Unretained(security_manager_impl_), |
Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 35 | std::forward<hci::AddressWithType>(device))); |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 38 | void SecurityManager::CancelBond(hci::AddressWithType device) { |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 39 | security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CancelBond, |
| 40 | common::Unretained(security_manager_impl_), |
Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 41 | std::forward<hci::AddressWithType>(device))); |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 44 | void SecurityManager::RemoveBond(hci::AddressWithType device) { |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 45 | security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::RemoveBond, |
| 46 | common::Unretained(security_manager_impl_), |
Martin Brabham | 80854c2 | 2019-11-12 14:52:42 -0800 | [diff] [blame] | 47 | std::forward<hci::AddressWithType>(device))); |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Jakub Pawlowski | 24d5f35 | 2019-11-18 18:54:09 +0100 | [diff] [blame] | 50 | void SecurityManager::RegisterCallbackListener(ISecurityManagerListener* listener, os::Handler* handler) { |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 51 | security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::RegisterCallbackListener, |
Jakub Pawlowski | 24d5f35 | 2019-11-18 18:54:09 +0100 | [diff] [blame] | 52 | common::Unretained(security_manager_impl_), listener, handler)); |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Jakub Pawlowski | 5a67e40 | 2019-11-18 16:14:22 +0100 | [diff] [blame] | 55 | void SecurityManager::UnregisterCallbackListener(ISecurityManagerListener* listener) { |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 56 | security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::UnregisterCallbackListener, |
Jakub Pawlowski | 24d5f35 | 2019-11-18 18:54:09 +0100 | [diff] [blame] | 57 | common::Unretained(security_manager_impl_), listener)); |
Martin Brabham | 605d6f1 | 2019-03-29 12:02:30 -0700 | [diff] [blame] | 58 | } |