OSDN Git Service

Remove always false flag BTM_BYPASS_EVENT_FILTERING
[android-x86/system-bt.git] / main / stack_config.c
1 /******************************************************************************
2  *
3  *  Copyright (C) 2014 Google, Inc.
4  *
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:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  ******************************************************************************/
18
19 #define LOG_TAG "bt_stack_config"
20
21 #include <assert.h>
22 #include <utils/Log.h>
23
24 #include "future.h"
25 #include "stack_config.h"
26
27 const char *BTSNOOP_LOG_PATH_KEY = "BtSnoopFileName";
28 const char *BTSNOOP_TURNED_ON_KEY = "BtSnoopLogOutput";
29 const char *TRACE_CONFIG_ENABLED_KEY = "TraceConf";
30
31 static config_t *config;
32
33 // Module lifecycle functions
34
35 static future_t *init() {
36   const char *path = "/etc/bluetooth/bt_stack.conf";
37   assert(path != NULL);
38
39   ALOGI("%s attempt to load stack conf from %s", __func__, path);
40
41   config = config_new(path);
42   if (!config) {
43     ALOGI("%s file >%s< not found", __func__, path);
44     return future_new_immediate(FUTURE_FAIL);
45   }
46
47   return future_new_immediate(FUTURE_SUCCESS);
48 }
49
50 static future_t *clean_up() {
51   config_free(config);
52   return future_new_immediate(FUTURE_SUCCESS);
53 }
54
55 const module_t stack_config_module = {
56   .name = STACK_CONFIG_MODULE,
57   .init = init,
58   .start_up = NULL,
59   .shut_down = NULL,
60   .clean_up = clean_up,
61   .dependencies = {
62     NULL
63   }
64 };
65
66 // Interface functions
67
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");
70 }
71
72 static bool get_btsnoop_turned_on(void) {
73   return config_get_bool(config, CONFIG_DEFAULT_SECTION, BTSNOOP_TURNED_ON_KEY, false);
74 }
75
76 static bool get_trace_config_enabled(void) {
77   return config_get_bool(config, CONFIG_DEFAULT_SECTION, TRACE_CONFIG_ENABLED_KEY, false);
78 }
79
80 static config_t *get_all(void) {
81   return config;
82 }
83
84 const stack_config_t interface = {
85   get_btsnoop_log_path,
86   get_btsnoop_turned_on,
87   get_trace_config_enabled,
88   get_all
89 };
90
91 const stack_config_t *stack_config_get_interface() {
92   return &interface;
93 }