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 #include "os/system_properties.h"
18 
19 #include <mutex>
20 #include <string>
21 #include <unordered_map>
22 
23 namespace bluetooth {
24 namespace os {
25 
26 namespace {
27 std::mutex properties_mutex;
28 
29 // Properties set along with some default values for Floss.
30 std::unordered_map<std::string, std::string> properties = {
31     {"bluetooth.profile.avrcp.target.enabled", "true"},
32 };
33 }  // namespace
34 
GetSystemProperty(const std::string & property)35 std::optional<std::string> GetSystemProperty(const std::string& property) {
36   std::lock_guard<std::mutex> lock(properties_mutex);
37   auto iter = properties.find(property);
38   if (iter == properties.end()) {
39     return std::nullopt;
40   }
41   return iter->second;
42 }
43 
SetSystemProperty(const std::string & property,const std::string & value)44 bool SetSystemProperty(const std::string& property, const std::string& value) {
45   std::lock_guard<std::mutex> lock(properties_mutex);
46   properties.insert_or_assign(property, value);
47   return true;
48 }
49 
ClearSystemPropertiesForHost()50 bool ClearSystemPropertiesForHost() {
51   std::lock_guard<std::mutex> lock(properties_mutex);
52   properties.clear();
53   return true;
54 }
55 
IsRootCanalEnabled()56 bool IsRootCanalEnabled() {
57   return false;
58 }
59 
GetAndroidVendorReleaseVersion()60 int GetAndroidVendorReleaseVersion() {
61   return 0;
62 }
63 
64 }  // namespace os
65 }  // namespace bluetooth
66