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 #define LOG_TAG "bt_shim"
18
19 #include "main/shim/shim.h"
20 #include "main/shim/entry.h"
21 #include "main/shim/stack.h"
22
23 #include "gd/common/init_flags.h"
24 #include "gd/os/log.h"
25
IdleModuleStartUp()26 future_t* IdleModuleStartUp() {
27 bluetooth::shim::Stack::GetInstance()->StartIdleMode();
28 return kReturnImmediate;
29 }
30
ShimModuleStartUp()31 future_t* ShimModuleStartUp() {
32 bluetooth::shim::Stack::GetInstance()->StartEverything();
33 return kReturnImmediate;
34 }
35
GeneralShutDown()36 future_t* GeneralShutDown() {
37 bluetooth::shim::Stack::GetInstance()->Stop();
38 return kReturnImmediate;
39 }
40
41 EXPORT_SYMBOL extern const module_t gd_idle_module = {
42 .name = GD_IDLE_MODULE,
43 .init = kUnusedModuleApi,
44 .start_up = IdleModuleStartUp,
45 .shut_down = GeneralShutDown,
46 .clean_up = kUnusedModuleApi,
47 .dependencies = {kUnusedModuleDependencies}};
48
49 EXPORT_SYMBOL extern const module_t gd_shim_module = {
50 .name = GD_SHIM_MODULE,
51 .init = kUnusedModuleApi,
52 .start_up = ShimModuleStartUp,
53 .shut_down = GeneralShutDown,
54 .clean_up = kUnusedModuleApi,
55 .dependencies = {kUnusedModuleDependencies}};
56
is_gd_advertising_enabled()57 bool bluetooth::shim::is_gd_advertising_enabled() {
58 return bluetooth::common::init_flags::gd_advertising_is_enabled();
59 }
60
is_gd_scanning_enabled()61 bool bluetooth::shim::is_gd_scanning_enabled() {
62 return bluetooth::common::init_flags::gd_scanning_is_enabled();
63 }
64
is_gd_security_enabled()65 bool bluetooth::shim::is_gd_security_enabled() {
66 return bluetooth::common::init_flags::gd_security_is_enabled();
67 }
68
is_gd_acl_enabled()69 bool bluetooth::shim::is_gd_acl_enabled() {
70 return bluetooth::common::init_flags::gd_acl_is_enabled();
71 }
72
is_gd_link_policy_enabled()73 bool bluetooth::shim::is_gd_link_policy_enabled() {
74 return bluetooth::common::init_flags::gd_link_policy_is_enabled();
75 }
76
is_gd_hci_enabled()77 bool bluetooth::shim::is_gd_hci_enabled() {
78 return bluetooth::common::init_flags::gd_hci_is_enabled();
79 }
80
is_gd_controller_enabled()81 bool bluetooth::shim::is_gd_controller_enabled() {
82 return bluetooth::common::init_flags::gd_controller_is_enabled();
83 }
84
is_gd_l2cap_enabled()85 bool bluetooth::shim::is_gd_l2cap_enabled() {
86 return bluetooth::common::init_flags::gd_l2cap_is_enabled();
87 }
88
is_gd_shim_enabled()89 bool bluetooth::shim::is_gd_shim_enabled() {
90 return bluetooth::common::init_flags::gd_core_is_enabled();
91 }
92
is_any_gd_enabled()93 bool bluetooth::shim::is_any_gd_enabled() {
94 return bluetooth::common::init_flags::gd_hci_is_enabled();
95 }
96
is_gd_stack_started_up()97 bool bluetooth::shim::is_gd_stack_started_up() {
98 return bluetooth::shim::Stack::GetInstance()->IsRunning();
99 }
100
is_gd_dumpsys_module_started()101 bool bluetooth::shim::is_gd_dumpsys_module_started() {
102 return bluetooth::shim::Stack::GetInstance()->IsDumpsysModuleStarted();
103 }
104
is_gd_btaa_enabled()105 bool bluetooth::shim::is_gd_btaa_enabled() {
106 return bluetooth::common::init_flags::btaa_hci_is_enabled();
107 }
108