• 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 #pragma once
19 
20 #include <unordered_map>
21 
22 #include "hci/hci_packets.h"
23 #include "os/handler.h"
24 #include "os/utils.h"
25 #include "security/record/security_record.h"
26 #include "storage/classic_device.h"
27 #include "storage/le_device.h"
28 #include "storage/storage_module.h"
29 
30 namespace bluetooth {
31 namespace security {
32 namespace record {
33 
34 #if defined(OS_GENERIC)
35 static const char* CONFIG_FILE_PATH = "bt_config.conf";
36 #else   // !defined(OS_GENERIC)
37 static const char* CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.conf";
38 #endif  // defined(OS_GENERIC)
39 
40 class SecurityRecordStorage {
41  public:
42   SecurityRecordStorage(storage::StorageModule* storage_module, os::Handler* handler);
43 
44   /**
45    * Iterates through given vector and stores each record's metadata to disk.
46    *
47    * <p>Job gets posted to the Handler.
48    *
49    * @param records set of shared pointers to records.
50    */
51   void SaveSecurityRecords(std::set<std::shared_ptr<record::SecurityRecord>>* records);
52 
53   /**
54    * Reads the record metadata from disk and converts each item into a SecurityRecord.
55    *
56    * <p>Job gets posted to the Handler.
57    *
58    * @param records set of shared pointers to records.
59    */
60   void LoadSecurityRecords(std::set<std::shared_ptr<record::SecurityRecord>>* records);
61 
62   /**
63    * Removes a device from the storage
64    *
65    * @param address of device to remove
66    */
67   void RemoveDevice(hci::AddressWithType address);
68 
69  private:
70   storage::StorageModule* storage_module_ __attribute__((unused));
71   os::Handler* handler_ __attribute__((unused));
72 };
73 
74 }  // namespace record
75 }  // namespace security
76 }  // namespace bluetooth
77