chromium/device/fido/aoa/android_accessory_discovery.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "device/fido/aoa/android_accessory_discovery.h"

#include <utility>

#include "base/containers/contains.h"
#include "base/containers/extend.h"
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/rand_util.h"
#include "base/time/time.h"
#include "components/device_event_log/device_event_log.h"
#include "device/fido/aoa/android_accessory_device.h"
#include "services/device/public/mojom/usb_manager.mojom.h"
#include "services/device/public/mojom/usb_manager_client.mojom.h"

// See https://source.android.com/devices/accessories/aoa for details on the
// protocol used to talk to apps on the phone here.

namespace device {

namespace {

// AOADiscoveryEvent enumerates several steps that occur during AOA discovery.
// Do not change the assigned values since they are used in histograms, only
// append new values. Keep synced with enums.xml.
enum class AOADiscoveryEvent {};

void RecordEvent(AOADiscoveryEvent event) {}

// KnownAccessories returns a global that stores the GUIDs of USB devices that
// we have previously put into accessory mode and, if still connected, can be
// used immediately. (GUIDs are not a USB concept, the Chromium USB layer
// generates them to identity a specific USB connection.)
base::flat_set<std::string>& KnownAccessories() {}

}  // namespace

AndroidAccessoryDiscovery::AndroidAccessoryDiscovery(
    mojo::Remote<device::mojom::UsbDeviceManager> device_manager,
    std::string request_description)
    :{}

AndroidAccessoryDiscovery::~AndroidAccessoryDiscovery() = default;

void AndroidAccessoryDiscovery::StartInternal() {}

void AndroidAccessoryDiscovery::OnDeviceAdded(
    device::mojom::UsbDeviceInfoPtr device_info) {}

static std::optional<AndroidAccessoryDiscovery::InterfaceInfo>
FindAccessoryInterface(const device::mojom::UsbDeviceInfoPtr& device_info) {}

void AndroidAccessoryDiscovery::HandleAccessoryDevice(
    mojo::Remote<device::mojom::UsbDevice> device,
    device::mojom::UsbDeviceInfoPtr device_info) {}

enum AccessoryControlRequest : uint8_t {};

static mojom::UsbControlTransferParamsPtr ControlTransferParams(
    AccessoryControlRequest request,
    uint16_t index = 0) {}

static constexpr unsigned kTimeoutMilliseconds =;
static constexpr unsigned kLongTimeoutMilliseconds =;

void AndroidAccessoryDiscovery::OnOpenAccessory(
    mojo::Remote<device::mojom::UsbDevice> device,
    device::mojom::UsbDeviceInfoPtr device_info,
    InterfaceInfo interface_info,
    device::mojom::UsbOpenDeviceResultPtr result) {}

void AndroidAccessoryDiscovery::OnAccessoryConfigured(
    mojo::Remote<device::mojom::UsbDevice> device,
    InterfaceInfo interface_info,
    bool success) {}

void AndroidAccessoryDiscovery::OnAccessoryInterfaceClaimed(
    mojo::Remote<device::mojom::UsbDevice> device,
    InterfaceInfo interface_info,
    mojom::UsbClaimInterfaceResult result) {}

void AndroidAccessoryDiscovery::OnSyncWritten(
    mojo::Remote<device::mojom::UsbDevice> device,
    InterfaceInfo interface_info,
    std::array<uint8_t, kSyncNonceLength> nonce,
    mojom::UsbTransferStatus result) {}

void AndroidAccessoryDiscovery::OnReadComplete(
    mojo::Remote<device::mojom::UsbDevice> device,
    InterfaceInfo interface_info,
    std::array<uint8_t, kSyncNonceLength> nonce,
    mojom::UsbTransferStatus result,
    base::span<const uint8_t> payload) {}

void AndroidAccessoryDiscovery::OnOpen(
    mojo::Remote<device::mojom::UsbDevice> device,
    device::mojom::UsbOpenDeviceResultPtr result) {}

void AndroidAccessoryDiscovery::OnVersionReply(
    mojo::Remote<device::mojom::UsbDevice> device,
    device::mojom::UsbTransferStatus status,
    base::span<const uint8_t> payload) {}

static std::vector<uint8_t> VectorFromString(const char* str) {}

void AndroidAccessoryDiscovery::OnConfigurationStepComplete(
    mojo::Remote<device::mojom::UsbDevice> device,
    unsigned step,
    device::mojom::UsbTransferStatus status) {}

void AndroidAccessoryDiscovery::OnDeviceRemoved(
    device::mojom::UsbDeviceInfoPtr device_info) {}

void AndroidAccessoryDiscovery::OnGetDevices(
    std::vector<device::mojom::UsbDeviceInfoPtr> devices) {}

}  // namespace device