Android-cuttlefish cvd tool
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
cuttlefish::confui::HostServer Class Reference

#include <host_server.h>

Collaboration diagram for cuttlefish::confui::HostServer:
Collaboration graph
[legend]

Public Member Functions

 INJECT (HostServer(HostModeCtrl &host_mode_ctrl, ConfUiRenderer &host_renderer, const PipeConnectionPair &fd_pair))
 
void Start ()
 
virtual ~HostServer ()
 
void TouchEvent (const int x, const int y, const bool is_down)
 
void UserAbortEvent ()
 

Private Types

using Multiplexer = Multiplexer< std::unique_ptr< ConfUiMessage >, ThreadSafeQueue< std::unique_ptr< ConfUiMessage > > >
 

Private Member Functions

 HostServer ()=delete
 
void MainLoop ()
 
void HalCmdFetcherLoop ()
 
bool IsVirtioConsoleOpen () const
 
bool CheckVirtioConsole ()
 
std::shared_ptr< SessionCreateSession (const std::string &session_name)
 
void SendUserSelection (std::unique_ptr< ConfUiMessage > &input)
 
void Transition (std::unique_ptr< ConfUiMessage > &input_ptr)
 
std::string GetCurrentSessionId ()
 
std::string GetCurrentState ()
 

Private Attributes

const std::uint32_t display_num_
 
ConfUiRendererhost_renderer_
 
HostModeCtrlhost_mode_ctrl_
 
std::shared_ptr< Sessioncurr_session_
 
SharedFD from_guest_fifo_fd_
 
SharedFD to_guest_fifo_fd_
 
Multiplexer input_multiplexer_
 
int hal_cmd_q_id_
 
int user_input_evt_q_id_
 
std::thread main_loop_thread_
 
std::thread hal_input_fetcher_thread_
 

Member Typedef Documentation

◆ Multiplexer

Constructor & Destructor Documentation

◆ ~HostServer()

virtual cuttlefish::confui::HostServer::~HostServer ( )
inlinevirtual

◆ HostServer()

cuttlefish::confui::HostServer::HostServer ( )
privatedelete

Member Function Documentation

◆ CheckVirtioConsole()

bool cuttlefish::confui::HostServer::CheckVirtioConsole ( )
private

◆ CreateSession()

std::shared_ptr< Session > cuttlefish::confui::HostServer::CreateSession ( const std::string &  session_name)
private

◆ GetCurrentSessionId()

std::string cuttlefish::confui::HostServer::GetCurrentSessionId ( )
inlineprivate

◆ GetCurrentState()

std::string cuttlefish::confui::HostServer::GetCurrentState ( )
inlineprivate

◆ HalCmdFetcherLoop()

void cuttlefish::confui::HostServer::HalCmdFetcherLoop ( )
private

◆ INJECT()

cuttlefish::confui::HostServer::INJECT ( HostServer(HostModeCtrl &host_mode_ctrl, ConfUiRenderer &host_renderer, const PipeConnectionPair &fd_pair)  )

◆ IsVirtioConsoleOpen()

bool cuttlefish::confui::HostServer::IsVirtioConsoleOpen ( ) const
private

◆ MainLoop()

void cuttlefish::confui::HostServer::MainLoop ( )
private

basic prompt flow: (1) Without preemption send "kStart" with confirmation message wait kCliAck from the host service with the echoed command wait the confirmation/cancellation (or perhaps reset?) send kStop wait kCliAck from the host service with the echoed command

(2) With preemption (e.g.) send "kStart" with confirmation message wait kCliAck from the host service with the echoed command wait the confirmation/cancellation (or perhaps reset?) send kSuspend // when HAL is preempted send kRestore // when HAL resumes send kStop

From the host end, it is a close-to-Mealy FSM. There are four states S = {init, session, wait_ack, suspended}

'session' means in a confirmation session. 'wait_ack' means server sends the confirmation and waiting "stop" command from HAL 'suspended' means the HAL service is preemptied. So, the host should render the Android guest frames but keep the confirmation UI session and frame

The inputs are I = {u, g}. 'u' is the user input from webRTC clients. Note that the host service serialized the concurrent user inputs from multiple clients. 'g' is the command from the HAL service

The transition rules: (S, I) --> (S, O) where O is the output

init, g(start) --> session, set Conf UI mode, render a frame session, u(cancel/confirm) --> waitstop, send the result to HAL session, g(suspend) --> suspend, create a saved session session, g(abort) --> init, clear saved frame waitstop, g(stop) --> init, clear saved frame waitstop, g(suspend) --> suspend, no need to save the session waitstop, g(abort) --> init, clear saved frame suspend, g(restore) --> return to the saved state, restore if there's a saved session suspend, g(abort) --> init, clear saved frame

For now, we did not yet implement suspend or abort.

◆ SendUserSelection()

void cuttlefish::confui::HostServer::SendUserSelection ( std::unique_ptr< ConfUiMessage > &  input)
private

Send inputs generated not by auto-tester but by the human users

Send such inputs into the command queue consumed by the state machine in the main loop/current session.

◆ Start()

void cuttlefish::confui::HostServer::Start ( )

◆ TouchEvent()

void cuttlefish::confui::HostServer::TouchEvent ( const int  x,
const int  y,
const bool  is_down 
)

◆ Transition()

void cuttlefish::confui::HostServer::Transition ( std::unique_ptr< ConfUiMessage > &  input_ptr)
private

◆ UserAbortEvent()

void cuttlefish::confui::HostServer::UserAbortEvent ( )

Member Data Documentation

◆ curr_session_

std::shared_ptr<Session> cuttlefish::confui::HostServer::curr_session_
private

◆ display_num_

const std::uint32_t cuttlefish::confui::HostServer::display_num_
private

◆ from_guest_fifo_fd_

SharedFD cuttlefish::confui::HostServer::from_guest_fifo_fd_
private

◆ hal_cmd_q_id_

int cuttlefish::confui::HostServer::hal_cmd_q_id_
private

◆ hal_input_fetcher_thread_

std::thread cuttlefish::confui::HostServer::hal_input_fetcher_thread_
private

◆ host_mode_ctrl_

HostModeCtrl& cuttlefish::confui::HostServer::host_mode_ctrl_
private

◆ host_renderer_

ConfUiRenderer& cuttlefish::confui::HostServer::host_renderer_
private

◆ input_multiplexer_

Multiplexer cuttlefish::confui::HostServer::input_multiplexer_
private

◆ main_loop_thread_

std::thread cuttlefish::confui::HostServer::main_loop_thread_
private

◆ to_guest_fifo_fd_

SharedFD cuttlefish::confui::HostServer::to_guest_fifo_fd_
private

◆ user_input_evt_q_id_

int cuttlefish::confui::HostServer::user_input_evt_q_id_
private

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