Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 1 | /* |
| 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 | |
Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 19 | #include "common/link_key.h" |
Martin Brabham | 94db40c | 2019-03-29 10:24:52 -0700 | [diff] [blame] | 20 | #include "hci/address.h" |
Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 21 | #include "hci/hci_packets.h" |
| 22 | #include "module.h" |
| 23 | |
| 24 | namespace bluetooth { |
| 25 | namespace hci { |
| 26 | |
| 27 | class ClassicSecurityCommandCallbacks { |
| 28 | public: |
| 29 | virtual ~ClassicSecurityCommandCallbacks() = default; |
| 30 | // Invoked when controller sends Command Complete event |
| 31 | virtual void OnCommandComplete(CommandCompleteView status) = 0; |
| 32 | }; |
| 33 | |
| 34 | class ClassicSecurityManager : public Module { |
| 35 | public: |
| 36 | ClassicSecurityManager(); |
| 37 | |
| 38 | bool RegisterCallbacks(ClassicSecurityCommandCallbacks* callbacks, os::Handler* handler); |
| 39 | |
Martin Brabham | 94db40c | 2019-03-29 10:24:52 -0700 | [diff] [blame] | 40 | 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, |
Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 45 | AuthenticationRequirements authentication_requirements); |
Martin Brabham | 94db40c | 2019-03-29 10:24:52 -0700 | [diff] [blame] | 46 | 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 Watson | 2d23443 | 2019-08-19 13:33:27 -0700 | [diff] [blame] | 54 | void WriteStoredLinkKey(std::vector<KeyAndAddress> keys); |
Martin Brabham | 94db40c | 2019-03-29 10:24:52 -0700 | [diff] [blame] | 55 | void DeleteStoredLinkKey(Address address, DeleteStoredLinkKeyDeleteAllFlag delete_all_flag); |
Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 56 | void RefreshEncryptionKey(uint16_t connection_handle); |
| 57 | void ReadSimplePairingMode(); |
| 58 | void WriteSimplePairingMode(Enable simple_pairing_mode); |
| 59 | void ReadLocalOobData(); |
Martin Brabham | 94db40c | 2019-03-29 10:24:52 -0700 | [diff] [blame] | 60 | void SendKeypressNotification(Address address, KeypressNotificationType notification_type); |
Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 61 | void ReadLocalOobExtendedData(); |
| 62 | void ReadEncryptionKeySize(uint16_t connection_handle); |
| 63 | |
Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 64 | 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 Wang | 6fd349a | 2019-11-12 16:14:01 -0800 | [diff] [blame] | 73 | std::string ToString() const override; |
| 74 | |
Chienyuan | 4d7cc81 | 2019-07-12 18:00:12 +0800 | [diff] [blame] | 75 | private: |
| 76 | struct impl; |
| 77 | std::unique_ptr<impl> pimpl_; |
| 78 | }; |
| 79 | |
| 80 | } // namespace hci |
| 81 | } // namespace bluetooth |