chromium/chrome/browser/devtools/device/usb/android_usb_device.cc

// Copyright 2014 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/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/devtools/device/usb/android_usb_device.h"

#include <set>
#include <utility>
#include <vector>

#include "base/barrier_closure.h"
#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/memory/ref_counted_memory.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/devtools/device/usb/android_rsa.h"
#include "chrome/browser/devtools/device/usb/android_usb_socket.h"
#include "crypto/rsa_private_key.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/socket/stream_socket.h"

UsbTransferStatus;

namespace {

const size_t kHeaderSize =;

const int kUsbTimeout =;

const uint32_t kMaxPayload =;
const uint32_t kVersion =;

static const char kHostConnectMessage[] =;

// Stores android wrappers around claimed usb devices on caller thread.
base::LazyInstance<std::vector<AndroidUsbDevice*>>::Leaky g_devices =;

// Stores the GUIDs of devices that are currently opened so that they are not
// re-probed.
base::LazyInstance<std::vector<std::string>>::Leaky g_open_devices =;

uint32_t Checksum(const std::string& data) {}

void DumpMessage(bool outgoing, const uint8_t* data, size_t length) {}

void OnProbeFinished(AndroidUsbDevicesCallback callback,
                     AndroidUsbDevices* new_devices) {}

void OnDeviceClosed(const std::string& guid,
                    mojo::Remote<device::mojom::UsbDevice> device) {}

void OnDeviceClosedWithBarrier(const std::string& guid,
                               mojo::Remote<device::mojom::UsbDevice> device,
                               const base::RepeatingClosure& barrier) {}

void CreateDeviceOnInterfaceClaimed(
    AndroidUsbDevices* devices,
    crypto::RSAPrivateKey* rsa_key,
    AndroidDeviceInfo android_device_info,
    mojo::Remote<device::mojom::UsbDevice> device,
    const base::RepeatingClosure& barrier,
    device::mojom::UsbClaimInterfaceResult result) {}

void OnInterfaceReleased(mojo::Remote<device::mojom::UsbDevice> device,
                         const std::string& guid,
                         bool release_successful) {}

void OnDeviceOpened(AndroidUsbDevices* devices,
                    crypto::RSAPrivateKey* rsa_key,
                    AndroidDeviceInfo android_device_info,
                    mojo::Remote<device::mojom::UsbDevice> device,
                    const base::RepeatingClosure& barrier,
                    device::mojom::UsbOpenDeviceResultPtr result) {}

void OpenAndroidDevices(crypto::RSAPrivateKey* rsa_key,
                        AndroidUsbDevicesCallback callback,
                        std::vector<AndroidDeviceInfo> device_info_list) {}

}  // namespace

AdbMessage::AdbMessage(uint32_t command,
                       uint32_t arg0,
                       uint32_t arg1,
                       const std::string& body)
    :{}

AdbMessage::~AdbMessage() {}

// static
void AndroidUsbDevice::Enumerate(crypto::RSAPrivateKey* rsa_key,
                                 AndroidUsbDevicesCallback callback) {}

AndroidUsbDevice::AndroidUsbDevice(
    crypto::RSAPrivateKey* rsa_key,
    const AndroidDeviceInfo& android_device_info,
    mojo::Remote<device::mojom::UsbDevice> device)
    :{}

void AndroidUsbDevice::InitOnCallerThread() {}

net::StreamSocket* AndroidUsbDevice::CreateSocket(const std::string& command) {}

void AndroidUsbDevice::Send(uint32_t command,
                            uint32_t arg0,
                            uint32_t arg1,
                            const std::string& body) {}

AndroidUsbDevice::~AndroidUsbDevice() {}

void AndroidUsbDevice::Queue(std::unique_ptr<AdbMessage> message) {}

void AndroidUsbDevice::ProcessOutgoing() {}

void AndroidUsbDevice::OutgoingMessageSent(UsbTransferStatus status) {}

void AndroidUsbDevice::ReadHeader() {}

void AndroidUsbDevice::ParseHeader(UsbTransferStatus status,
                                   base::span<const uint8_t> buffer) {}

void AndroidUsbDevice::ReadBody(std::unique_ptr<AdbMessage> message,
                                uint32_t data_length,
                                uint32_t data_check) {}

void AndroidUsbDevice::ParseBody(std::unique_ptr<AdbMessage> message,
                                 uint32_t data_length,
                                 uint32_t data_check,
                                 UsbTransferStatus status,
                                 base::span<const uint8_t> buffer) {}

void AndroidUsbDevice::HandleIncoming(std::unique_ptr<AdbMessage> message) {}

void AndroidUsbDevice::TransferError(UsbTransferStatus status) {}

void AndroidUsbDevice::Terminate() {}

void AndroidUsbDevice::SocketDeleted(uint32_t socket_id) {}