Android-cuttlefish cvd tool
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
fastboot::FastBootDriver Class Reference

#include <fastboot_driver.h>

Inheritance diagram for fastboot::FastBootDriver:
Inheritance graph
[legend]
Collaboration diagram for fastboot::FastBootDriver:
Collaboration graph
[legend]

Public Member Functions

 FastBootDriver (std::unique_ptr< Transport > transport, DriverCallbacks driver_callbacks={}, bool no_checks=false)
 
 ~FastBootDriver ()
 
RetCode Boot (std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode Continue (std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode CreatePartition (const std::string &partition, const std::string &size)
 
RetCode DeletePartition (const std::string &partition) override
 
RetCode Download (const std::string &name, android::base::borrowed_fd fd, size_t size, std::string *response=nullptr, std::vector< std::string > *info=nullptr) override
 
RetCode Download (android::base::borrowed_fd fd, size_t size, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode Download (const std::string &name, const std::vector< char > &buf, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode Download (const std::vector< char > &buf, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode Download (const std::string &partition, struct sparse_file *s, uint32_t sz, size_t current, size_t total, bool use_crc, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode Download (sparse_file *s, bool use_crc=false, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode Erase (const std::string &partition, std::string *response=nullptr, std::vector< std::string > *info=nullptr) override
 
RetCode Flash (const std::string &partition, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode GetVar (const std::string &key, std::string *val, std::vector< std::string > *info=nullptr) override
 
RetCode GetVarAll (std::vector< std::string > *response)
 
RetCode Reboot (std::string *response=nullptr, std::vector< std::string > *info=nullptr) override
 
RetCode RebootTo (std::string target, std::string *response=nullptr, std::vector< std::string > *info=nullptr) override
 
RetCode ResizePartition (const std::string &partition, const std::string &size) override
 
RetCode SetActive (const std::string &slot, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode Upload (const std::string &outfile, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode SnapshotUpdateCommand (const std::string &command, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode FetchToFd (const std::string &partition, android::base::borrowed_fd fd, int64_t offset=-1, int64_t size=-1, std::string *response=nullptr, std::vector< std::string > *info=nullptr) override
 
RetCode FlashPartition (const std::string &partition, const std::vector< char > &data)
 
RetCode FlashPartition (const std::string &partition, android::base::borrowed_fd fd, uint32_t sz) override
 
RetCode FlashPartition (const std::string &partition, sparse_file *s, uint32_t sz, size_t current, size_t total)
 
RetCode Partitions (std::vector< std::tuple< std::string, uint64_t > > *partitions)
 
RetCode Require (const std::string &var, const std::vector< std::string > &allowed, bool *reqmet, bool invert=false)
 
void SetInfoCallback (std::function< void(const std::string &)> info)
 
std::string Error ()
 
RetCode WaitForDisconnect () override
 
void set_transport (std::unique_ptr< Transport > transport)
 
RetCode RawCommand (const std::string &cmd, const std::string &message, std::string *response=nullptr, std::vector< std::string > *info=nullptr, int *dsize=nullptr)
 
RetCode RawCommand (const std::string &cmd, std::string *response=nullptr, std::vector< std::string > *info=nullptr, int *dsize=nullptr)
 
- Public Member Functions inherited from fastboot::IFastBootDriver
virtual RetCode FlashPartition (const std::string &partition, android::base::borrowed_fd fd, uint32_t sz)=0
 
virtual RetCode DeletePartition (const std::string &partition)=0
 
virtual RetCode WaitForDisconnect ()=0
 
virtual RetCode Reboot (std::string *response=nullptr, std::vector< std::string > *info=nullptr)=0
 
virtual RetCode RebootTo (std::string target, std::string *response=nullptr, std::vector< std::string > *info=nullptr)=0
 
virtual RetCode GetVar (const std::string &key, std::string *val, std::vector< std::string > *info=nullptr)=0
 
virtual RetCode FetchToFd (const std::string &partition, android::base::borrowed_fd fd, int64_t offset=-1, int64_t size=-1, std::string *response=nullptr, std::vector< std::string > *info=nullptr)=0
 
virtual RetCode Download (const std::string &name, android::base::borrowed_fd fd, size_t size, std::string *response=nullptr, std::vector< std::string > *info=nullptr)=0
 
virtual RetCode RawCommand (const std::string &cmd, const std::string &message, std::string *response=nullptr, std::vector< std::string > *info=nullptr, int *dsize=nullptr)=0
 
virtual RetCode ResizePartition (const std::string &partition, const std::string &size)=0
 
virtual RetCode Erase (const std::string &partition, std::string *response=nullptr, std::vector< std::string > *info=nullptr)=0
 
virtual ~IFastBootDriver ()=default
 

Static Public Member Functions

static const std::string RCString (RetCode rc)
 

Static Public Attributes

static constexpr int RESP_TIMEOUT = 30
 
static constexpr uint32_t MAX_DOWNLOAD_SIZE = std::numeric_limits<uint32_t>::max()
 
static constexpr size_t TRANSPORT_CHUNK_SIZE = 1024
 

Protected Member Functions

RetCode DownloadCommand (uint32_t size, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode HandleResponse (std::string *response=nullptr, std::vector< std::string > *info=nullptr, int *dsize=nullptr)
 
std::string ErrnoStr (const std::string &msg)
 

Protected Attributes

std::unique_ptr< Transporttransport_
 

Private Member Functions

RetCode SendBuffer (android::base::borrowed_fd fd, size_t size)
 
RetCode SendBuffer (const std::vector< char > &buf)
 
RetCode SendBuffer (const void *buf, size_t size)
 
RetCode ReadBuffer (void *buf, size_t size)
 
RetCode UploadInner (const std::string &outfile, std::string *response=nullptr, std::vector< std::string > *info=nullptr)
 
RetCode RunAndReadBuffer (const std::string &cmd, std::string *response, std::vector< std::string > *info, const std::function< RetCode(const char *, uint64_t)> &write_fn)
 
int SparseWriteCallback (std::vector< char > &tpbuf, const char *data, size_t len)
 

Private Attributes

std::string error_
 
std::function< void(const std::string &)> prolog_
 
std::function< void(int)> epilog_
 
std::function< void(const std::string &)> info_
 
std::function< void(const std::string &)> text_
 
bool disable_checks_
 

Friends

class FastBootTest
 

Constructor & Destructor Documentation

◆ FastBootDriver()

fastboot::FastBootDriver::FastBootDriver ( std::unique_ptr< Transport transport,
DriverCallbacks  driver_callbacks = {},
bool  no_checks = false 
)

◆ ~FastBootDriver()

fastboot::FastBootDriver::~FastBootDriver ( )

Member Function Documentation

◆ Boot()

RetCode fastboot::FastBootDriver::Boot ( std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ Continue()

RetCode fastboot::FastBootDriver::Continue ( std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ CreatePartition()

RetCode fastboot::FastBootDriver::CreatePartition ( const std::string &  partition,
const std::string &  size 
)

◆ DeletePartition()

RetCode fastboot::FastBootDriver::DeletePartition ( const std::string &  partition)
overridevirtual

◆ Download() [1/6]

RetCode fastboot::FastBootDriver::Download ( android::base::borrowed_fd  fd,
size_t  size,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ Download() [2/6]

RetCode fastboot::FastBootDriver::Download ( const std::string &  name,
android::base::borrowed_fd  fd,
size_t  size,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)
overridevirtual

◆ Download() [3/6]

RetCode fastboot::FastBootDriver::Download ( const std::string &  name,
const std::vector< char > &  buf,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ Download() [4/6]

RetCode fastboot::FastBootDriver::Download ( const std::string &  partition,
struct sparse_file *  s,
uint32_t  sz,
size_t  current,
size_t  total,
bool  use_crc,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ Download() [5/6]

RetCode fastboot::FastBootDriver::Download ( const std::vector< char > &  buf,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ Download() [6/6]

RetCode fastboot::FastBootDriver::Download ( sparse_file *  s,
bool  use_crc = false,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ DownloadCommand()

RetCode fastboot::FastBootDriver::DownloadCommand ( uint32_t  size,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)
protected

◆ Erase()

RetCode fastboot::FastBootDriver::Erase ( const std::string &  partition,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)
overridevirtual

◆ ErrnoStr()

std::string fastboot::FastBootDriver::ErrnoStr ( const std::string &  msg)
protected

◆ Error()

std::string fastboot::FastBootDriver::Error ( )

◆ FetchToFd()

RetCode fastboot::FastBootDriver::FetchToFd ( const std::string &  partition,
android::base::borrowed_fd  fd,
int64_t  offset = -1,
int64_t  size = -1,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)
overridevirtual

◆ Flash()

RetCode fastboot::FastBootDriver::Flash ( const std::string &  partition,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ FlashPartition() [1/3]

RetCode fastboot::FastBootDriver::FlashPartition ( const std::string &  partition,
android::base::borrowed_fd  fd,
uint32_t  sz 
)
overridevirtual

◆ FlashPartition() [2/3]

RetCode fastboot::FastBootDriver::FlashPartition ( const std::string &  partition,
const std::vector< char > &  data 
)

◆ FlashPartition() [3/3]

RetCode fastboot::FastBootDriver::FlashPartition ( const std::string &  partition,
sparse_file *  s,
uint32_t  sz,
size_t  current,
size_t  total 
)

◆ GetVar()

RetCode fastboot::FastBootDriver::GetVar ( const std::string &  key,
std::string *  val,
std::vector< std::string > *  info = nullptr 
)
overridevirtual

◆ GetVarAll()

RetCode fastboot::FastBootDriver::GetVarAll ( std::vector< std::string > *  response)

◆ HandleResponse()

RetCode fastboot::FastBootDriver::HandleResponse ( std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr,
int *  dsize = nullptr 
)
protected

◆ Partitions()

RetCode fastboot::FastBootDriver::Partitions ( std::vector< std::tuple< std::string, uint64_t > > *  partitions)

◆ RawCommand() [1/2]

RetCode fastboot::FastBootDriver::RawCommand ( const std::string &  cmd,
const std::string &  message,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr,
int *  dsize = nullptr 
)
virtual

◆ RawCommand() [2/2]

RetCode fastboot::FastBootDriver::RawCommand ( const std::string &  cmd,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr,
int *  dsize = nullptr 
)

◆ RCString()

const std::string fastboot::FastBootDriver::RCString ( RetCode  rc)
static

◆ ReadBuffer()

RetCode fastboot::FastBootDriver::ReadBuffer ( void *  buf,
size_t  size 
)
private

◆ Reboot()

RetCode fastboot::FastBootDriver::Reboot ( std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)
overridevirtual

◆ RebootTo()

RetCode fastboot::FastBootDriver::RebootTo ( std::string  target,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)
overridevirtual

◆ Require()

RetCode fastboot::FastBootDriver::Require ( const std::string &  var,
const std::vector< std::string > &  allowed,
bool *  reqmet,
bool  invert = false 
)

◆ ResizePartition()

RetCode fastboot::FastBootDriver::ResizePartition ( const std::string &  partition,
const std::string &  size 
)
overridevirtual

◆ RunAndReadBuffer()

RetCode fastboot::FastBootDriver::RunAndReadBuffer ( const std::string &  cmd,
std::string *  response,
std::vector< std::string > *  info,
const std::function< RetCode(const char *, uint64_t)> &  write_fn 
)
private

◆ SendBuffer() [1/3]

RetCode fastboot::FastBootDriver::SendBuffer ( android::base::borrowed_fd  fd,
size_t  size 
)
private

◆ SendBuffer() [2/3]

RetCode fastboot::FastBootDriver::SendBuffer ( const std::vector< char > &  buf)
private

◆ SendBuffer() [3/3]

RetCode fastboot::FastBootDriver::SendBuffer ( const void *  buf,
size_t  size 
)
private

◆ set_transport()

void fastboot::FastBootDriver::set_transport ( std::unique_ptr< Transport transport)

◆ SetActive()

RetCode fastboot::FastBootDriver::SetActive ( const std::string &  slot,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ SetInfoCallback()

void fastboot::FastBootDriver::SetInfoCallback ( std::function< void(const std::string &)>  info)

◆ SnapshotUpdateCommand()

RetCode fastboot::FastBootDriver::SnapshotUpdateCommand ( const std::string &  command,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ SparseWriteCallback()

int fastboot::FastBootDriver::SparseWriteCallback ( std::vector< char > &  tpbuf,
const char *  data,
size_t  len 
)
private

◆ Upload()

RetCode fastboot::FastBootDriver::Upload ( const std::string &  outfile,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)

◆ UploadInner()

RetCode fastboot::FastBootDriver::UploadInner ( const std::string &  outfile,
std::string *  response = nullptr,
std::vector< std::string > *  info = nullptr 
)
private

◆ WaitForDisconnect()

RetCode fastboot::FastBootDriver::WaitForDisconnect ( )
overridevirtual

Friends And Related Function Documentation

◆ FastBootTest

friend class FastBootTest
friend

Member Data Documentation

◆ disable_checks_

bool fastboot::FastBootDriver::disable_checks_
private

◆ epilog_

std::function<void(int)> fastboot::FastBootDriver::epilog_
private

◆ error_

std::string fastboot::FastBootDriver::error_
private

◆ info_

std::function<void(const std::string&)> fastboot::FastBootDriver::info_
private

◆ MAX_DOWNLOAD_SIZE

constexpr uint32_t fastboot::FastBootDriver::MAX_DOWNLOAD_SIZE = std::numeric_limits<uint32_t>::max()
staticconstexpr

◆ prolog_

std::function<void(const std::string&)> fastboot::FastBootDriver::prolog_
private

◆ RESP_TIMEOUT

constexpr int fastboot::FastBootDriver::RESP_TIMEOUT = 30
staticconstexpr

◆ text_

std::function<void(const std::string&)> fastboot::FastBootDriver::text_
private

◆ transport_

std::unique_ptr<Transport> fastboot::FastBootDriver::transport_
protected

◆ TRANSPORT_CHUNK_SIZE

constexpr size_t fastboot::FastBootDriver::TRANSPORT_CHUNK_SIZE = 1024
staticconstexpr

The documentation for this class was generated from the following files: