Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d049d01b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Shim: Add GD scanning init flags" am: c722811d am: a4ea1d95 am: cba526c4

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1536703

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia0193f470160dbd19e925de2969014ba4e19d5c9
parents 0e829733 cba526c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ attribute "privacy";
table InitFlagsData {
    title:string;
    gd_advertising_enabled:bool;
    gd_scanning_enabled:bool;
    gd_security_enabled:bool;
    gd_acl_enabled:bool;
    gd_hci_enabled:bool;
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ flatbuffers::Offset<bluetooth::common::InitFlagsData> bluetooth::dumpsys::InitFl
  common::InitFlagsDataBuilder builder(*fb_builder);
  builder.add_title(title);
  builder.add_gd_advertising_enabled(bluetooth::common::init_flags::gd_advertising_is_enabled());
  builder.add_gd_scanning_enabled(bluetooth::common::init_flags::gd_scanning_is_enabled());
  builder.add_gd_security_enabled(bluetooth::common::init_flags::gd_security_is_enabled());
  builder.add_gd_acl_enabled(bluetooth::common::init_flags::gd_acl_is_enabled());
  builder.add_gd_hci_enabled(bluetooth::common::init_flags::gd_hci_is_enabled());
+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ init_flags!(
    flags: {
        gd_core,
        gd_advertising,
        gd_scanning,
        gd_security,
        gd_acl,
        gd_l2cap,
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ mod ffi {
        fn gd_core_is_enabled() -> bool;
        fn gd_security_is_enabled() -> bool;
        fn gd_advertising_is_enabled() -> bool;
        fn gd_scanning_is_enabled() -> bool;
        fn gd_acl_is_enabled() -> bool;
        fn gd_l2cap_is_enabled() -> bool;
        fn gd_hci_is_enabled() -> bool;
+20 −4
Original line number Diff line number Diff line
@@ -264,23 +264,24 @@ static bool subevent_already_registered_in_le_hci_layer(
    case bluetooth::hci::SubeventCode::REMOTE_CONNECTION_PARAMETER_REQUEST:
      return bluetooth::shim::is_gd_acl_enabled() ||
             bluetooth::shim::is_gd_l2cap_enabled() ||
             bluetooth::shim::is_gd_advertising_enabled();
             bluetooth::shim::is_gd_advertising_enabled() ||
             bluetooth::shim::is_gd_scanning_enabled();
    case bluetooth::hci::SubeventCode::ADVERTISING_SET_TERMINATED:
    case bluetooth::hci::SubeventCode::SCAN_REQUEST_RECEIVED:
      return bluetooth::shim::is_gd_acl_enabled() ||
             bluetooth::shim::is_gd_l2cap_enabled() ||
             bluetooth::shim::is_gd_advertising_enabled();
    case bluetooth::hci::SubeventCode::SCAN_TIMEOUT:
    case bluetooth::hci::SubeventCode::ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::DIRECTED_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::EXTENDED_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_SYNC_ESTABLISHED:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_SYNC_LOST:
      // TODO return bluetooth::shim::is_gd_scanning_enabled();
      return bluetooth::shim::is_gd_scanning_enabled();
    case bluetooth::hci::SubeventCode::READ_REMOTE_FEATURES_COMPLETE:
    case bluetooth::hci::SubeventCode::READ_LOCAL_P256_PUBLIC_KEY_COMPLETE:
    case bluetooth::hci::SubeventCode::GENERATE_DHKEY_COMPLETE:
    case bluetooth::hci::SubeventCode::SCAN_TIMEOUT:
    case bluetooth::hci::SubeventCode::CHANNEL_SELECTION_ALGORITHM:
    case bluetooth::hci::SubeventCode::CONNECTIONLESS_IQ_REPORT:
    case bluetooth::hci::SubeventCode::CONNECTION_IQ_REPORT:
@@ -313,6 +314,16 @@ static bool event_already_registered_in_le_advertising_manager(
  return false;
}

static bool event_already_registered_in_le_scanning_manager(
    bluetooth::hci::EventCode event_code) {
  for (auto event : bluetooth::hci::AclConnectionEvents) {
    if (event == event_code) {
      return bluetooth::shim::is_gd_scanning_enabled();
    }
  }
  return false;
}

}  // namespace

namespace cpp {
@@ -490,9 +501,10 @@ static void acl_data_callback() {
static void register_for_acl() {
  hci_queue_end = bluetooth::shim::GetHciLayer()->GetAclQueueEnd();

  // if gd advertising enabled, hci_queue_end will be register in
  // if gd advertising/scanning enabled, hci_queue_end will be register in
  // AclManager::impl::Start
  if (!bluetooth::shim::is_gd_advertising_enabled() &&
      !bluetooth::shim::is_gd_scanning_enabled() &&
      !bluetooth::shim::is_gd_l2cap_enabled()) {
    hci_queue_end->RegisterDequeue(bluetooth::shim::GetGdShimHandler(),
                                   bluetooth::common::Bind(acl_data_callback));
@@ -523,6 +535,8 @@ static void on_shutting_down() {
      } else if (event_already_registered_in_le_advertising_manager(
                     event_code)) {
        continue;
      } else if (event_already_registered_in_le_scanning_manager(event_code)) {
        continue;
      }
      bluetooth::shim::GetHciLayer()->UnregisterEventHandler(event_code);
    }
@@ -707,6 +721,8 @@ void bluetooth::shim::hci_on_reset_complete() {
      continue;
    } else if (event_already_registered_in_le_advertising_manager(event_code)) {
      continue;
    } else if (event_already_registered_in_le_scanning_manager(event_code)) {
      continue;
    }

    if (bluetooth::common::init_flags::gd_rust_is_enabled()) {
Loading