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_shim_enabled()57 bool bluetooth::shim::is_gd_shim_enabled() {
58 return common::InitFlags::GdCoreEnabled();
59 }
60
is_gd_stack_started_up()61 bool bluetooth::shim::is_gd_stack_started_up() {
62 return bluetooth::shim::Stack::GetInstance()->IsRunning();
63 }
64