1 /******************************************************************************
3 * Copyright (C) 2014 Google, Inc.
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ******************************************************************************/
19 #define LOG_TAG "bt_stack_config"
22 #include <utils/Log.h>
25 #include "stack_config.h"
27 const char *BTSNOOP_LOG_PATH_KEY = "BtSnoopFileName";
28 const char *BTSNOOP_TURNED_ON_KEY = "BtSnoopLogOutput";
29 const char *TRACE_CONFIG_ENABLED_KEY = "TraceConf";
31 static config_t *config;
33 // Module lifecycle functions
35 static future_t *init() {
36 const char *path = "/etc/bluetooth/bt_stack.conf";
39 ALOGI("%s attempt to load stack conf from %s", __func__, path);
41 config = config_new(path);
43 ALOGI("%s file >%s< not found", __func__, path);
44 return future_new_immediate(FUTURE_FAIL);
47 return future_new_immediate(FUTURE_SUCCESS);
50 static future_t *clean_up() {
52 return future_new_immediate(FUTURE_SUCCESS);
55 const module_t stack_config_module = {
56 .name = STACK_CONFIG_MODULE,
66 // Interface functions
68 static const char *get_btsnoop_log_path(void) {
69 return config_get_string(config, CONFIG_DEFAULT_SECTION, BTSNOOP_LOG_PATH_KEY, "/data/misc/bluedroid/btsnoop_hci.log");
72 static bool get_btsnoop_turned_on(void) {
73 return config_get_bool(config, CONFIG_DEFAULT_SECTION, BTSNOOP_TURNED_ON_KEY, false);
76 static bool get_trace_config_enabled(void) {
77 return config_get_bool(config, CONFIG_DEFAULT_SECTION, TRACE_CONFIG_ENABLED_KEY, false);
80 static config_t *get_all(void) {
84 const stack_config_t interface = {
86 get_btsnoop_turned_on,
87 get_trace_config_enabled,
91 const stack_config_t *stack_config_get_interface() {