1 /****************************************************************************** 2 * 3 * Copyright 2019 The Android Open Source Project 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 #include "init_flags.h" 20 21 #include <string> 22 23 #include "os/log.h" 24 25 namespace bluetooth { 26 namespace common { 27 28 const std::string kGdHciFlag = "INIT_gd_hci"; 29 bool InitFlags::gd_hci_enabled = false; 30 31 const std::string kGdControllerFlag = "INIT_gd_controller"; 32 bool InitFlags::gd_controller_enabled = false; 33 34 const std::string kGdCoreFlag = "INIT_gd_core"; 35 bool InitFlags::gd_core_enabled = false; 36 Load(const char ** flags)37void InitFlags::Load(const char** flags) { 38 gd_core_enabled = false; 39 gd_hci_enabled = false; 40 while (flags != nullptr && *flags != nullptr) { 41 if (kGdCoreFlag == *flags) { 42 gd_core_enabled = true; 43 } else if (kGdHciFlag == *flags) { 44 gd_hci_enabled = true; 45 } else if (kGdControllerFlag == *flags) { 46 gd_controller_enabled = true; 47 } 48 flags++; 49 } 50 51 if (gd_core_enabled && !gd_controller_enabled) { 52 gd_controller_enabled = true; 53 } 54 if (gd_controller_enabled && !gd_hci_enabled) { 55 gd_hci_enabled = true; 56 } 57 58 LOG_INFO( 59 "Flags loaded: gd_hci_enabled: %s, gd_controller_enabled: %s, gd_core_enabled: %s", 60 gd_hci_enabled ? "true" : "false", 61 gd_controller_enabled ? "true" : "false", 62 gd_core_enabled ? "true" : "false"); 63 } 64 65 } // namespace common 66 } // namespace bluetooth 67