#include "device/fido/hid/fido_hid_device.h"
#include <limits>
#include <string_view>
#include <vector>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/fixed_flat_set.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "components/device_event_log/device_event_log.h"
#include "crypto/random.h"
#include "device/fido/hid/fido_hid_message.h"
namespace device {
static constexpr uint8_t kReportId = …;
static constexpr uint8_t kWinkCapability = …;
FidoHidDevice::FidoHidDevice(device::mojom::HidDeviceInfoPtr device_info,
device::mojom::HidManager* hid_manager)
: … { … }
FidoHidDevice::~FidoHidDevice() = default;
FidoDevice::CancelToken FidoHidDevice::DeviceTransact(
std::vector<uint8_t> command,
DeviceCallback callback) { … }
void FidoHidDevice::Cancel(CancelToken token) { … }
void FidoHidDevice::Transition(std::optional<State> next_state) { … }
FidoHidDevice::PendingTransaction::PendingTransaction(
FidoHidDeviceCommand command_type,
std::vector<uint8_t> in_command,
DeviceCallback in_callback,
CancelToken in_token)
: … { … }
FidoHidDevice::PendingTransaction::~PendingTransaction() = default;
void FidoHidDevice::Connect(
device::mojom::HidManager::ConnectCallback callback) { … }
void FidoHidDevice::OnConnect(
mojo::PendingRemote<device::mojom::HidConnection> connection) { … }
void FidoHidDevice::OnInitWriteComplete(std::vector<uint8_t> nonce,
bool success) { … }
std::optional<uint32_t> FidoHidDevice::ParseInitReply(
const std::vector<uint8_t>& nonce,
const std::vector<uint8_t>& buf) { … }
void FidoHidDevice::OnPotentialInitReply(
std::vector<uint8_t> nonce,
bool success,
uint8_t report_id,
const std::optional<std::vector<uint8_t>>& buf) { … }
void FidoHidDevice::WriteMessage(FidoHidMessage message) { … }
void FidoHidDevice::PacketWritten(FidoHidMessage message, bool success) { … }
void FidoHidDevice::ReadMessage() { … }
void FidoHidDevice::OnRead(bool success,
uint8_t report_id,
const std::optional<std::vector<uint8_t>>& buf) { … }
void FidoHidDevice::OnReadContinuation(
FidoHidMessage message,
bool success,
uint8_t report_id,
const std::optional<std::vector<uint8_t>>& buf) { … }
void FidoHidDevice::MessageReceived(FidoHidMessage message) { … }
void FidoHidDevice::RetryAfterChannelBusy() { … }
void FidoHidDevice::TryWink(base::OnceClosure callback) { … }
void FidoHidDevice::ArmTimeout() { … }
void FidoHidDevice::OnTimeout() { … }
void FidoHidDevice::WriteCancelComplete(
scoped_refptr<FidoHidDevice::RefCountedHidConnection> connection,
bool success) { … }
void FidoHidDevice::WriteCancel() { … }
static std::string VidPidToString(const mojom::HidDeviceInfoPtr& device_info) { … }
std::string FidoHidDevice::GetDisplayName() const { … }
std::string FidoHidDevice::GetId() const { … }
FidoTransportProtocol FidoHidDevice::DeviceTransport() const { … }
void FidoHidDevice::DiscoverSupportedProtocolAndDeviceInfo(
base::OnceClosure done) { … }
std::string FidoHidDevice::GetIdForDevice(
const device::mojom::HidDeviceInfo& device_info) { … }
base::WeakPtr<FidoDevice> FidoHidDevice::GetWeakPtr() { … }
}