Loading system/gd/common/init_flags.cc +9 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ namespace bluetooth { namespace common { const std::string kGdAdvertisingFlag = "INIT_gd_advertising"; bool InitFlags::gd_advertising_enabled = false; const std::string kGdSecurityFlag = "INIT_gd_security"; bool InitFlags::gd_security_enabled = false; Loading @@ -48,6 +51,8 @@ void InitFlags::Load(const char** flags) { while (flags != nullptr && *flags != nullptr) { if (kGdCoreFlag == *flags) { gd_core_enabled = true; } else if (kGdAdvertisingFlag == *flags) { gd_advertising_enabled = true; } else if (kGdSecurityFlag == *flags) { gd_security_enabled = true; } else if (kGdAclFlag == *flags) { Loading Loading @@ -76,8 +81,10 @@ void InitFlags::Load(const char** flags) { } LOG_INFO( "Flags loaded: gd_security_enabled: %s, gd_acl_enabled: %s, gd_hci_enabled: %s, gd_controller_enabled: %s, " "Flags loaded: gd_advertising_enabled %s, gd_security_enabled: %s, gd_acl_enabled: %s, gd_hci_enabled: %s, " "gd_controller_enabled: %s, " "gd_core_enabled: %s", gd_advertising_enabled ? "true" : "false", gd_security_enabled ? "true" : "false", gd_acl_enabled ? "true" : "false", gd_hci_enabled ? "true" : "false", Loading @@ -87,6 +94,7 @@ void InitFlags::Load(const char** flags) { void InitFlags::SetAll(bool value) { gd_core_enabled = value; gd_advertising_enabled = value; gd_acl_enabled = value; gd_security_enabled = value; gd_controller_enabled = value; Loading system/gd/common/init_flags.fbs +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ attribute "privacy"; table InitFlagsData { title:string; gd_advertising_enabled:bool; gd_security_enabled:bool; gd_acl_enabled:bool; gd_hci_enabled:bool; Loading system/gd/common/init_flags.h +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ class InitFlags final { public: static void Load(const char** flags); static bool GdAdvertisingEnabled() { return gd_advertising_enabled; } static bool GdSecurityEnabled() { return gd_security_enabled; } Loading Loading @@ -51,6 +55,7 @@ class InitFlags final { private: static void SetAll(bool value); static bool gd_advertising_enabled; static bool gd_security_enabled; static bool gd_acl_enabled; static bool gd_hci_enabled; Loading system/gd/dumpsys/init_flags.cc +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ flatbuffers::Offset<bluetooth::common::InitFlagsData> bluetooth::dumpsys::InitFl auto title = fb_builder->CreateString("----- Init Flags -----"); common::InitFlagsDataBuilder builder(*fb_builder); builder.add_title(title); builder.add_gd_advertising_enabled(bluetooth::common::InitFlags::GdAdvertisingEnabled()); builder.add_gd_security_enabled(bluetooth::common::InitFlags::GdSecurityEnabled()); builder.add_gd_acl_enabled(bluetooth::common::InitFlags::GdAclEnabled()); builder.add_gd_hci_enabled(bluetooth::common::InitFlags::GdHciEnabled()); Loading system/main/shim/hci_layer.cc +40 −3 Original line number Diff line number Diff line Loading @@ -185,6 +185,29 @@ static bool event_already_registered_in_hci_layer( } } static bool event_already_registered_in_le_advertising_manager( bluetooth::hci::EventCode event_code) { switch (event_code) { case bluetooth::hci::EventCode::CONNECTION_PACKET_TYPE_CHANGED: case bluetooth::hci::EventCode::ROLE_CHANGE: case bluetooth::hci::EventCode::CONNECTION_COMPLETE: case bluetooth::hci::EventCode::CONNECTION_REQUEST: case bluetooth::hci::EventCode::AUTHENTICATION_COMPLETE: case bluetooth::hci::EventCode::READ_CLOCK_OFFSET_COMPLETE: case bluetooth::hci::EventCode::MODE_CHANGE: case bluetooth::hci::EventCode::QOS_SETUP_COMPLETE: case bluetooth::hci::EventCode::FLOW_SPECIFICATION_COMPLETE: case bluetooth::hci::EventCode::FLUSH_OCCURRED: case bluetooth::hci::EventCode::READ_REMOTE_SUPPORTED_FEATURES_COMPLETE: case bluetooth::hci::EventCode::READ_REMOTE_EXTENDED_FEATURES_COMPLETE: case bluetooth::hci::EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE: case bluetooth::hci::EventCode::LINK_SUPERVISION_TIMEOUT_CHANGED: return bluetooth::shim::is_gd_advertising_enabled(); default: return false; } } std::unique_ptr<bluetooth::packet::RawBuilder> MakeUniquePacket( const uint8_t* data, size_t len) { bluetooth::packet::RawBuilder builder; Loading Loading @@ -412,14 +435,23 @@ void bluetooth::shim::hci_on_reset_complete() { auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw); if (event_already_registered_in_hci_layer(event_code)) { continue; } else if (event_already_registered_in_le_advertising_manager(event_code)) { continue; } auto handler = bluetooth::shim::GetGdShimHandler(); bluetooth::shim::GetHciLayer()->RegisterEventHandler( event_code, handler->Bind(event_callback)); } hci_queue_end = bluetooth::shim::GetHciLayer()->GetAclQueueEnd(); // if gd advertising enabled, hci_queue_end will be register in // AclManager::impl::Start if (!bluetooth::shim::is_gd_advertising_enabled()) { hci_queue_end->RegisterDequeue(bluetooth::shim::GetGdShimHandler(), bluetooth::common::Bind(acl_data_callback)); } pending_data = new bluetooth::os::EnqueueBuffer<bluetooth::hci::AclPacketBuilder>( hci_queue_end); Loading @@ -432,7 +464,9 @@ void bluetooth::shim::hci_on_shutting_down() { pending_data = nullptr; } if (hci_queue_end != nullptr) { if (!bluetooth::shim::is_gd_advertising_enabled()) { hci_queue_end->UnregisterDequeue(); } for (uint8_t event_code_raw = 0; event_code_raw < 0xFF; event_code_raw++) { if (!is_valid_event_code(event_code_raw)) { continue; Loading @@ -440,6 +474,9 @@ void bluetooth::shim::hci_on_shutting_down() { auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw); if (event_already_registered_in_hci_layer(event_code)) { continue; } else if (event_already_registered_in_le_advertising_manager( event_code)) { continue; } bluetooth::shim::GetHciLayer()->UnregisterEventHandler(event_code); } Loading Loading
system/gd/common/init_flags.cc +9 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ namespace bluetooth { namespace common { const std::string kGdAdvertisingFlag = "INIT_gd_advertising"; bool InitFlags::gd_advertising_enabled = false; const std::string kGdSecurityFlag = "INIT_gd_security"; bool InitFlags::gd_security_enabled = false; Loading @@ -48,6 +51,8 @@ void InitFlags::Load(const char** flags) { while (flags != nullptr && *flags != nullptr) { if (kGdCoreFlag == *flags) { gd_core_enabled = true; } else if (kGdAdvertisingFlag == *flags) { gd_advertising_enabled = true; } else if (kGdSecurityFlag == *flags) { gd_security_enabled = true; } else if (kGdAclFlag == *flags) { Loading Loading @@ -76,8 +81,10 @@ void InitFlags::Load(const char** flags) { } LOG_INFO( "Flags loaded: gd_security_enabled: %s, gd_acl_enabled: %s, gd_hci_enabled: %s, gd_controller_enabled: %s, " "Flags loaded: gd_advertising_enabled %s, gd_security_enabled: %s, gd_acl_enabled: %s, gd_hci_enabled: %s, " "gd_controller_enabled: %s, " "gd_core_enabled: %s", gd_advertising_enabled ? "true" : "false", gd_security_enabled ? "true" : "false", gd_acl_enabled ? "true" : "false", gd_hci_enabled ? "true" : "false", Loading @@ -87,6 +94,7 @@ void InitFlags::Load(const char** flags) { void InitFlags::SetAll(bool value) { gd_core_enabled = value; gd_advertising_enabled = value; gd_acl_enabled = value; gd_security_enabled = value; gd_controller_enabled = value; Loading
system/gd/common/init_flags.fbs +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ attribute "privacy"; table InitFlagsData { title:string; gd_advertising_enabled:bool; gd_security_enabled:bool; gd_acl_enabled:bool; gd_hci_enabled:bool; Loading
system/gd/common/init_flags.h +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ class InitFlags final { public: static void Load(const char** flags); static bool GdAdvertisingEnabled() { return gd_advertising_enabled; } static bool GdSecurityEnabled() { return gd_security_enabled; } Loading Loading @@ -51,6 +55,7 @@ class InitFlags final { private: static void SetAll(bool value); static bool gd_advertising_enabled; static bool gd_security_enabled; static bool gd_acl_enabled; static bool gd_hci_enabled; Loading
system/gd/dumpsys/init_flags.cc +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ flatbuffers::Offset<bluetooth::common::InitFlagsData> bluetooth::dumpsys::InitFl auto title = fb_builder->CreateString("----- Init Flags -----"); common::InitFlagsDataBuilder builder(*fb_builder); builder.add_title(title); builder.add_gd_advertising_enabled(bluetooth::common::InitFlags::GdAdvertisingEnabled()); builder.add_gd_security_enabled(bluetooth::common::InitFlags::GdSecurityEnabled()); builder.add_gd_acl_enabled(bluetooth::common::InitFlags::GdAclEnabled()); builder.add_gd_hci_enabled(bluetooth::common::InitFlags::GdHciEnabled()); Loading
system/main/shim/hci_layer.cc +40 −3 Original line number Diff line number Diff line Loading @@ -185,6 +185,29 @@ static bool event_already_registered_in_hci_layer( } } static bool event_already_registered_in_le_advertising_manager( bluetooth::hci::EventCode event_code) { switch (event_code) { case bluetooth::hci::EventCode::CONNECTION_PACKET_TYPE_CHANGED: case bluetooth::hci::EventCode::ROLE_CHANGE: case bluetooth::hci::EventCode::CONNECTION_COMPLETE: case bluetooth::hci::EventCode::CONNECTION_REQUEST: case bluetooth::hci::EventCode::AUTHENTICATION_COMPLETE: case bluetooth::hci::EventCode::READ_CLOCK_OFFSET_COMPLETE: case bluetooth::hci::EventCode::MODE_CHANGE: case bluetooth::hci::EventCode::QOS_SETUP_COMPLETE: case bluetooth::hci::EventCode::FLOW_SPECIFICATION_COMPLETE: case bluetooth::hci::EventCode::FLUSH_OCCURRED: case bluetooth::hci::EventCode::READ_REMOTE_SUPPORTED_FEATURES_COMPLETE: case bluetooth::hci::EventCode::READ_REMOTE_EXTENDED_FEATURES_COMPLETE: case bluetooth::hci::EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE: case bluetooth::hci::EventCode::LINK_SUPERVISION_TIMEOUT_CHANGED: return bluetooth::shim::is_gd_advertising_enabled(); default: return false; } } std::unique_ptr<bluetooth::packet::RawBuilder> MakeUniquePacket( const uint8_t* data, size_t len) { bluetooth::packet::RawBuilder builder; Loading Loading @@ -412,14 +435,23 @@ void bluetooth::shim::hci_on_reset_complete() { auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw); if (event_already_registered_in_hci_layer(event_code)) { continue; } else if (event_already_registered_in_le_advertising_manager(event_code)) { continue; } auto handler = bluetooth::shim::GetGdShimHandler(); bluetooth::shim::GetHciLayer()->RegisterEventHandler( event_code, handler->Bind(event_callback)); } hci_queue_end = bluetooth::shim::GetHciLayer()->GetAclQueueEnd(); // if gd advertising enabled, hci_queue_end will be register in // AclManager::impl::Start if (!bluetooth::shim::is_gd_advertising_enabled()) { hci_queue_end->RegisterDequeue(bluetooth::shim::GetGdShimHandler(), bluetooth::common::Bind(acl_data_callback)); } pending_data = new bluetooth::os::EnqueueBuffer<bluetooth::hci::AclPacketBuilder>( hci_queue_end); Loading @@ -432,7 +464,9 @@ void bluetooth::shim::hci_on_shutting_down() { pending_data = nullptr; } if (hci_queue_end != nullptr) { if (!bluetooth::shim::is_gd_advertising_enabled()) { hci_queue_end->UnregisterDequeue(); } for (uint8_t event_code_raw = 0; event_code_raw < 0xFF; event_code_raw++) { if (!is_valid_event_code(event_code_raw)) { continue; Loading @@ -440,6 +474,9 @@ void bluetooth::shim::hci_on_shutting_down() { auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw); if (event_already_registered_in_hci_layer(event_code)) { continue; } else if (event_already_registered_in_le_advertising_manager( event_code)) { continue; } bluetooth::shim::GetHciLayer()->UnregisterEventHandler(event_code); } Loading