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