1 /*
2  * Copyright 2020 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 
23 #define DEBUGGABLE_SYS_PROP_NAME "ro.debuggable"
24 
25 namespace bluetooth {
26 namespace os {
27 
28 /* System Property to indicate if the dual mode audio feature is enabled */
29 static const std::string kIsDualModeAudioEnabledProperty =
30     "persist.bluetooth.enable_dual_mode_audio";
31 
32 // Get |property| keyed system property from supported platform, return std::nullopt if the property does not exist
33 // or if the platform does not support system property
34 std::optional<std::string> GetSystemProperty(const std::string& property);
35 
36 // Get |property| keyed system property as uint32_t from supported platform, return |default_value| if the property
37 // does not exist or if the platform does not support system property
38 uint32_t GetSystemPropertyUint32(const std::string& property, uint32_t default_value);
39 
40 // Get |property| keyed system property as uint32_t from supported platform, return |default_value|
41 // if the property does not exist or if the platform does not support system property if property is
42 // found it will call stoul with |base|
43 uint32_t GetSystemPropertyUint32Base(
44     const std::string& property, uint32_t default_value, int base = 0);
45 
46 // Get |property| keyed property as bool from supported platform, return
47 // |default_value| if the property does not exist or if the platform
48 // does not support system property
49 bool GetSystemPropertyBool(const std::string& property, bool default_value);
50 
51 // Set |property| keyed system property to |value|, return true if the set was successful and false if the set failed
52 // Replace existing value if property already exists
53 bool SetSystemProperty(const std::string& property, const std::string& value);
54 
55 // Clear system properties for host only return true on success
56 bool ClearSystemPropertiesForHost();
57 
58 // Check if the vendor image is using root canal simulated Bluetooth stack
59 bool IsRootCanalEnabled();
60 
61 // Get Android Vendor Image release version in numeric value (e.g. Android R is 11), return 0 if not on Android or
62 // version not available
63 int GetAndroidVendorReleaseVersion();
64 
65 }  // namespace os
66 }  // namespace bluetooth
67