blob: f9c1440186c1cfae9d922f4b864d427ea56916ad [file] [log] [blame]
Martin Brabham80854c22019-11-12 14:52:42 -08001/*
Martin Brabham605d6f12019-03-29 12:02:30 -07002 *
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 Brabham80854c22019-11-12 14:52:42 -080017 */
Martin Brabham605d6f12019-03-29 12:02:30 -070018#include "security_manager.h"
19
20#include "os/log.h"
21
22using namespace bluetooth::security;
23
Jakub Pawlowskiaf9379b2019-11-18 17:51:13 +010024// Definition of Pure Virtual Destructor
25ISecurityManagerListener::~ISecurityManagerListener() {}
26
Martin Brabham605d6f12019-03-29 12:02:30 -070027void SecurityManager::Init() {
28 security_handler_->Post(
29 common::BindOnce(&internal::SecurityManagerImpl::Init, common::Unretained(security_manager_impl_)));
30}
31
Martin Brabham80854c22019-11-12 14:52:42 -080032void SecurityManager::CreateBond(hci::AddressWithType device) {
Martin Brabham605d6f12019-03-29 12:02:30 -070033 security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CreateBond,
34 common::Unretained(security_manager_impl_),
Martin Brabham80854c22019-11-12 14:52:42 -080035 std::forward<hci::AddressWithType>(device)));
Martin Brabham605d6f12019-03-29 12:02:30 -070036}
37
Martin Brabham80854c22019-11-12 14:52:42 -080038void SecurityManager::CancelBond(hci::AddressWithType device) {
Martin Brabham605d6f12019-03-29 12:02:30 -070039 security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CancelBond,
40 common::Unretained(security_manager_impl_),
Martin Brabham80854c22019-11-12 14:52:42 -080041 std::forward<hci::AddressWithType>(device)));
Martin Brabham605d6f12019-03-29 12:02:30 -070042}
43
Martin Brabham80854c22019-11-12 14:52:42 -080044void SecurityManager::RemoveBond(hci::AddressWithType device) {
Martin Brabham605d6f12019-03-29 12:02:30 -070045 security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::RemoveBond,
46 common::Unretained(security_manager_impl_),
Martin Brabham80854c22019-11-12 14:52:42 -080047 std::forward<hci::AddressWithType>(device)));
Martin Brabham605d6f12019-03-29 12:02:30 -070048}
49
Jakub Pawlowski24d5f352019-11-18 18:54:09 +010050void SecurityManager::RegisterCallbackListener(ISecurityManagerListener* listener, os::Handler* handler) {
Martin Brabham605d6f12019-03-29 12:02:30 -070051 security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::RegisterCallbackListener,
Jakub Pawlowski24d5f352019-11-18 18:54:09 +010052 common::Unretained(security_manager_impl_), listener, handler));
Martin Brabham605d6f12019-03-29 12:02:30 -070053}
54
Jakub Pawlowski5a67e402019-11-18 16:14:22 +010055void SecurityManager::UnregisterCallbackListener(ISecurityManagerListener* listener) {
Martin Brabham605d6f12019-03-29 12:02:30 -070056 security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::UnregisterCallbackListener,
Jakub Pawlowski24d5f352019-11-18 18:54:09 +010057 common::Unretained(security_manager_impl_), listener));
Martin Brabham605d6f12019-03-29 12:02:30 -070058}