• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #pragma once
18 
19 #include <stdexcept>
20 #include <string>
21 #include <unordered_map>
22 
23 #include "src/init_flags.rs.h"
24 
25 namespace bluetooth {
26 namespace common {
27 
28 class InitFlags final {
29  public:
Load(const char ** flags)30   inline static void Load(const char** flags) {
31     rust::Vec<rust::String> rusted_flags = rust::Vec<rust::String>();
32     while (flags != nullptr && *flags != nullptr) {
33       rusted_flags.push_back(rust::String(*flags));
34       flags++;
35     }
36     init_flags::load(std::move(rusted_flags));
37   }
38 
GetLogLevelForTag(const std::string & tag)39   inline static int GetLogLevelForTag(const std::string& tag) {
40     return init_flags::get_log_level_for_tag(tag);
41   }
42 
GetDefaultLogLevel()43   inline static int GetDefaultLogLevel() {
44     return init_flags::get_default_log_level();
45   }
46 
IsDeviceIotConfigLoggingEnabled()47   inline static bool IsDeviceIotConfigLoggingEnabled() {
48     return init_flags::device_iot_config_logging_is_enabled();
49   }
50 
IsBtmDmFlushDiscoveryQueueOnSearchCancel()51   inline static bool IsBtmDmFlushDiscoveryQueueOnSearchCancel() {
52     return init_flags::btm_dm_flush_discovery_queue_on_search_cancel_is_enabled();
53   }
54 
IsSnoopLoggerSocketEnabled()55   inline static bool IsSnoopLoggerSocketEnabled() {
56     return init_flags::gd_hal_snoop_logger_socket_is_enabled();
57   }
58 
IsSnoopLoggerFilteringEnabled()59   inline static bool IsSnoopLoggerFilteringEnabled() {
60     return init_flags::gd_hal_snoop_logger_filtering_is_enabled();
61   }
62 
IsBluetoothQualityReportCallbackEnabled()63   inline static bool IsBluetoothQualityReportCallbackEnabled() {
64     return init_flags::bluetooth_quality_report_callback_is_enabled();
65   }
66 
IsTargetedAnnouncementReconnectionMode()67   inline static bool IsTargetedAnnouncementReconnectionMode() {
68     return init_flags::leaudio_targeted_announcement_reconnection_mode_is_enabled();
69   }
70 
GetAdapterIndex()71   inline static int GetAdapterIndex() {
72     return init_flags::get_hci_adapter();
73   }
74 
SetAllForTesting()75   inline static void SetAllForTesting() {
76     init_flags::set_all_for_testing();
77   }
78 };
79 
80 }  // namespace common
81 }  // namespace bluetooth
82