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

Commit 8b968164 authored by Joseph Hwang's avatar Joseph Hwang Committed by Automerger Merge Worker
Browse files

Merge changes from topic "erroneous_data_reporting_log_and_return" am: ce04c6b1

parents 80789c07 ce04c6b1
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
@@ -179,6 +179,13 @@ struct Controller::impl {
          handler->BindOnceOn(this, &Controller::impl::le_set_host_feature_handler));
    }

    if (is_supported(OpCode::READ_DEFAULT_ERRONEOUS_DATA_REPORTING)) {
      hci_->EnqueueCommand(
          ReadDefaultErroneousDataReportingBuilder::Create(),
          handler->BindOnceOn(
              this, &Controller::impl::read_default_erroneous_data_reporting_handler));
    }

    // Skip vendor capabilities check if configured.
    if (os::GetSystemPropertyBool(
            kPropertyVendorCapabilitiesEnabled, kDefaultVendorCapabilitiesEnabled)) {
@@ -382,6 +389,62 @@ struct Controller::impl {
    ASSERT_LOG(status == ErrorCode::SUCCESS, "Status 0x%02hhx, %s", status, ErrorCodeText(status).c_str());
  }

  void read_default_erroneous_data_reporting_handler(CommandCompleteView view) {
    ASSERT(view.GetCommandOpCode() == OpCode::READ_DEFAULT_ERRONEOUS_DATA_REPORTING);
    auto complete_view = ReadDefaultErroneousDataReportingCompleteView::Create(view);
    // Check to see that the opcode was correct.
    // ASSERT(complete_view.IsValid()) is not used here to avoid process abort.
    // Some devices, such as mokey_go32, may claim to support it but do not
    // actually do so (b/277589118).
    if (!complete_view.IsValid()) {
      LOG_ERROR("invalid command complete view");
      return;
    }

    ErrorCode status = complete_view.GetStatus();
    // This is an optional feature to enhance audio quality. It is okay
    // to just return if the status is not SUCCESS.
    if (status != ErrorCode::SUCCESS) {
      LOG_ERROR("Unexpected status: %s", ErrorCodeText(status).c_str());
      return;
    }

    Enable erroneous_data_reporting = complete_view.GetErroneousDataReporting();
    LOG_INFO("erroneous data reporting: %hhu", erroneous_data_reporting);

    // Enable Erroneous Data Reporting if it is disabled and the write command is supported.
    if (erroneous_data_reporting == Enable::DISABLED &&
        is_supported(OpCode::WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING)) {
      std::unique_ptr<WriteDefaultErroneousDataReportingBuilder> packet =
          WriteDefaultErroneousDataReportingBuilder::Create(Enable::ENABLED);
      hci_->EnqueueCommand(
          std::move(packet),
          module_.GetHandler()->BindOnceOn(
              this, &Controller::impl::write_default_erroneous_data_reporting_handler));
    }
  }

  void write_default_erroneous_data_reporting_handler(CommandCompleteView view) {
    ASSERT(view.GetCommandOpCode() == OpCode::WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING);
    auto complete_view = WriteDefaultErroneousDataReportingCompleteView::Create(view);
    // Check to see that the opcode was correct.
    // ASSERT(complete_view.IsValid()) is not used here to avoid process abort.
    // Some devices, such as mokey_go32, may claim to support it but do not
    // actually do so (b/277589118).
    if (!complete_view.IsValid()) {
      LOG_ERROR("invalid command complete view");
      return;
    }

    ErrorCode status = complete_view.GetStatus();
    // This is an optional feature to enhance audio quality. It is okay
    // to just return if the status is not SUCCESS.
    if (status != ErrorCode::SUCCESS) {
      LOG_ERROR("Unexpected status: %s", ErrorCodeText(status).c_str());
      return;
    }
  }

  void le_read_local_supported_features_handler(CommandCompleteView view) {
    auto complete_view = LeReadLocalSupportedFeaturesCompleteView::Create(view);
    ASSERT(complete_view.IsValid());
+34 −0
Original line number Diff line number Diff line
@@ -2506,6 +2506,40 @@ packet WriteInquiryResponseTransmitPowerLevelComplete : CommandComplete (command
  status : ErrorCode,
}

packet ReadDefaultErroneousDataReporting : Command (op_code = READ_DEFAULT_ERRONEOUS_DATA_REPORTING) {
}

test ReadDefaultErroneousDataReporting {
  "\x5a\x0c\x00",
}

packet ReadDefaultErroneousDataReportingComplete : CommandComplete (command_op_code = READ_DEFAULT_ERRONEOUS_DATA_REPORTING) {
  status : ErrorCode,
  erroneous_data_reporting : Enable,
}

test ReadDefaultErroneousDataReportingComplete {
  "\x0e\x05\x02\x5a\x0c\x00\x00", // status success, Erroneous data reporting disabled
  "\x0e\x05\x02\x5a\x0c\x00\x01", // status success, Erroneous data reporting enabled
}

packet WriteDefaultErroneousDataReporting : Command (op_code = WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING) {
  erroneous_data_reporting : Enable,
}

test WriteDefaultErroneousDataReporting {
  "\x5b\x0c\x01\x00", // disable Erroneous Data reporting
  "\x5b\x0c\x01\x01", // enable Erroneous Data reporting
}

packet WriteDefaultErroneousDataReportingComplete : CommandComplete (command_op_code = WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING) {
  status : ErrorCode,
}

test WriteDefaultErroneousDataReportingComplete {
  "\x0e\x04\x01\x5b\x0c\x00", // status success
}

enum KeypressNotificationType : 8 {
  ENTRY_STARTED = 0,
  DIGIT_ENTERED = 1,