blob: 22b4ae14df6efdc40c89cf331c630b4226eeb911 [file] [log] [blame]
Chienyuan4d7cc812019-07-12 18:00:12 +08001/*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
Chienyuan4d7cc812019-07-12 18:00:12 +080019#include "common/link_key.h"
Martin Brabham94db40c2019-03-29 10:24:52 -070020#include "hci/address.h"
Chienyuan4d7cc812019-07-12 18:00:12 +080021#include "hci/hci_packets.h"
22#include "module.h"
23
24namespace bluetooth {
25namespace hci {
26
27class ClassicSecurityCommandCallbacks {
28 public:
29 virtual ~ClassicSecurityCommandCallbacks() = default;
30 // Invoked when controller sends Command Complete event
31 virtual void OnCommandComplete(CommandCompleteView status) = 0;
32};
33
34class ClassicSecurityManager : public Module {
35 public:
36 ClassicSecurityManager();
37
38 bool RegisterCallbacks(ClassicSecurityCommandCallbacks* callbacks, os::Handler* handler);
39
Martin Brabham94db40c2019-03-29 10:24:52 -070040 void LinkKeyRequestReply(Address address, common::LinkKey link_key);
41 void LinkKeyRequestNegativeReply(Address address);
42 void PinCodeRequestReply(Address address, uint8_t len, std::string pin_code);
43 void PinCodeRequestNegativeReply(Address address);
44 void IoCapabilityRequestReply(Address address, IoCapability io_capability, OobDataPresent oob_present,
Chienyuan4d7cc812019-07-12 18:00:12 +080045 AuthenticationRequirements authentication_requirements);
Martin Brabham94db40c2019-03-29 10:24:52 -070046 void IoCapabilityRequestNegativeReply(Address address, ErrorCode reason);
47 void UserConfirmationRequestReply(Address address);
48 void UserConfirmationRequestNegativeReply(Address address);
49 void UserPasskeyRequestReply(Address address, uint32_t passkey);
50 void UserPasskeyRequestNegativeReply(Address address);
51 void RemoteOobDataRequestReply(Address address, std::array<uint8_t, 16> c, std::array<uint8_t, 16> r);
52 void RemoteOobDataRequestNegativeReply(Address address);
53 void ReadStoredLinkKey(Address address, ReadStoredLinkKeyReadAllFlag read_all_flag);
Myles Watson2d234432019-08-19 13:33:27 -070054 void WriteStoredLinkKey(std::vector<KeyAndAddress> keys);
Martin Brabham94db40c2019-03-29 10:24:52 -070055 void DeleteStoredLinkKey(Address address, DeleteStoredLinkKeyDeleteAllFlag delete_all_flag);
Chienyuan4d7cc812019-07-12 18:00:12 +080056 void RefreshEncryptionKey(uint16_t connection_handle);
57 void ReadSimplePairingMode();
58 void WriteSimplePairingMode(Enable simple_pairing_mode);
59 void ReadLocalOobData();
Martin Brabham94db40c2019-03-29 10:24:52 -070060 void SendKeypressNotification(Address address, KeypressNotificationType notification_type);
Chienyuan4d7cc812019-07-12 18:00:12 +080061 void ReadLocalOobExtendedData();
62 void ReadEncryptionKeySize(uint16_t connection_handle);
63
Chienyuan4d7cc812019-07-12 18:00:12 +080064 static const ModuleFactory Factory;
65
66 protected:
67 void ListDependencies(ModuleList* list) override;
68
69 void Start() override;
70
71 void Stop() override;
72
Zongheng Wang6fd349a2019-11-12 16:14:01 -080073 std::string ToString() const override;
74
Chienyuan4d7cc812019-07-12 18:00:12 +080075 private:
76 struct impl;
77 std::unique_ptr<impl> pimpl_;
78};
79
80} // namespace hci
81} // namespace bluetooth