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 
19 #include <cstdint>
20 #include <optional>
21 #include <string>
22 #include <vector>
23 
24 namespace bluetooth {
25 namespace shim {
26 
27 class BtifConfigInterface {
28 public:
29   ~BtifConfigInterface() = default;
30   static bool HasSection(const std::string& section);
31   static bool HasProperty(const std::string& section, const std::string& property);
32   static bool GetInt(const std::string& section, const std::string& key, int* value);
33   static bool SetInt(const std::string& section, const std::string& key, int value);
34   static bool GetUint64(const std::string& section, const std::string& key, uint64_t* value);
35   static bool SetUint64(const std::string& section, const std::string& key, uint64_t value);
36   static bool GetStr(const std::string& section, const std::string& key, char* value,
37                      int* size_bytes);
38   static std::optional<std::string> GetStr(const std::string& section, const std::string& key);
39   static bool SetStr(const std::string& section, const std::string& key, const std::string& value);
40   static bool GetBin(const std::string& section, const std::string& key, uint8_t* value,
41                      size_t* length);
42   static size_t GetBinLength(const std::string& section, const std::string& key);
43   static bool SetBin(const std::string& section, const std::string& key, const uint8_t* value,
44                      size_t length);
45   static bool RemoveProperty(const std::string& section, const std::string& key);
46   static void RemoveSection(const std::string& section);
47   static void RemoveSectionWithProperty(const std::string& property);
48   static std::vector<std::string> GetPersistentDevices();
49   static void ConvertEncryptOrDecryptKeyIfNeeded();
50   static void Clear();
51 };
52 
53 }  // namespace shim
54 }  // namespace bluetooth
55