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/parameter_provider.h" 18 19 #include <mutex> 20 #include <string> 21 22 namespace bluetooth { 23 namespace os { 24 25 namespace { 26 std::mutex parameter_mutex; 27 std::string config_file_path; 28 std::string snoop_log_file_path; 29 std::string snooz_log_file_path; 30 } // namespace 31 32 // On Android we always write a single default location ConfigFilePath()33std::string ParameterProvider::ConfigFilePath() { 34 { 35 std::lock_guard<std::mutex> lock(parameter_mutex); 36 if (!config_file_path.empty()) { 37 return config_file_path; 38 } 39 } 40 return "/data/misc/bluedroid/bt_config.conf"; 41 } 42 OverrideConfigFilePath(const std::string & path)43void ParameterProvider::OverrideConfigFilePath(const std::string& path) { 44 std::lock_guard<std::mutex> lock(parameter_mutex); 45 config_file_path = path; 46 } 47 SnoopLogFilePath()48std::string ParameterProvider::SnoopLogFilePath() { 49 { 50 std::lock_guard<std::mutex> lock(parameter_mutex); 51 if (!snoop_log_file_path.empty()) { 52 return snoop_log_file_path; 53 } 54 } 55 return "/data/misc/bluetooth/logs/btsnoop_hci.log"; 56 } 57 OverrideSnoopLogFilePath(const std::string & path)58void ParameterProvider::OverrideSnoopLogFilePath(const std::string& path) { 59 std::lock_guard<std::mutex> lock(parameter_mutex); 60 snoop_log_file_path = path; 61 } 62 63 // Return the path to the default snooz log file location SnoozLogFilePath()64std::string ParameterProvider::SnoozLogFilePath() { 65 { 66 std::lock_guard<std::mutex> lock(parameter_mutex); 67 if (!snooz_log_file_path.empty()) { 68 return snooz_log_file_path; 69 } 70 } 71 return "/data/misc/bluetooth/logs/btsnooz_hci.log"; 72 } 73 OverrideSnoozLogFilePath(const std::string & path)74void ParameterProvider::OverrideSnoozLogFilePath(const std::string& path) { 75 std::lock_guard<std::mutex> lock(parameter_mutex); 76 snooz_log_file_path = path; 77 } 78 79 } // namespace os 80 } // namespace bluetooth