Android-cuttlefish cvd tool
usb.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <sys/types.h>
20
21#include "adb.h"
22#include "transport.h"
23
24// USB host/client interface.
25
26struct usb_handle;
27
28void usb_init();
29void usb_cleanup();
30int usb_write(usb_handle* h, const void* data, int len);
31int usb_read(usb_handle* h, void* data, int len);
32int usb_close(usb_handle* h);
33void usb_reset(usb_handle* h);
34void usb_kick(usb_handle* h);
36
37// USB device detection.
38bool is_adb_interface(int usb_class, int usb_subclass, int usb_protocol);
39
41
43 explicit UsbConnection(usb_handle* handle) : handle_(handle) {}
45
46 bool Read(apacket* packet) override final;
47 bool Write(apacket* packet) override final;
48 bool DoTlsHandshake(RSA* key, std::string* auth_key) override final;
49
50 void Close() override final;
51 virtual void Reset() override final;
52
54};
bool is_adb_interface(int usb_class, int usb_subclass, int usb_protocol)
Definition: transport_usb.cpp:170
int usb_write(usb_handle *h, const void *data, int len)
Definition: usb_linux.cpp:433
void usb_reset(usb_handle *h)
Definition: usb_linux.cpp:491
void usb_init()
Definition: usb_linux.cpp:634
bool is_libusb_enabled()
Definition: transport_usb.cpp:179
void usb_cleanup()
Definition: usb_linux.cpp:645
void usb_kick(usb_handle *h)
Definition: usb_linux.cpp:496
size_t usb_get_max_packet_size(usb_handle *)
Definition: usb_linux.cpp:540
int usb_close(usb_handle *h)
Definition: usb_linux.cpp:529
int usb_read(usb_handle *h, void *data, int len)
Definition: usb_linux.cpp:460
char data[Size]
Definition: incremental_server.cpp:1
Definition: transport.h:150
Definition: usb.h:42
bool DoTlsHandshake(RSA *key, std::string *auth_key) override final
Definition: transport_usb.cpp:148
virtual void Reset() override final
Definition: transport_usb.cpp:154
void Close() override final
Definition: transport_usb.cpp:159
bool Read(apacket *packet) override final
Definition: transport_usb.cpp:127
bool Write(apacket *packet) override final
Definition: transport_usb.cpp:132
~UsbConnection()
Definition: transport_usb.cpp:123
UsbConnection(usb_handle *handle)
Definition: usb.h:43
usb_handle * handle_
Definition: usb.h:53
Definition: types.h:157
Definition: usb_linux.cpp:60