Android-cuttlefish cvd tool
protocol.h
Go to the documentation of this file.
1//
2// Copyright (C) 2021 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#pragma once
17
18#include <stdint.h>
19
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "teeui/common_message_types.h" // /system/teeui/libteeui/.../include
25
28
29namespace cuttlefish::confui {
30
31std::string ToString(const ConfUiMessage& msg);
32
33constexpr auto SESSION_ANY = "";
34/*
35 * received confirmation UI message on the guest could be abort or
36 * ack/response. Thus, the guest APIs should call RecvConfUiMsg(fd),
37 * see which is it, and then use Into*(conf_ui_message) to
38 * parse & use it.
39 *
40 */
41std::unique_ptr<ConfUiMessage> RecvConfUiMsg(SharedFD fd);
42std::unique_ptr<ConfUiMessage> RecvConfUiMsg(const std::string& session_id,
43 SharedFD fd);
44
45bool SendAbortCmd(SharedFD fd, const std::string& session_id);
46
47bool SendAck(SharedFD fd, const std::string& session_id, bool is_success,
48 const std::string& status_message);
49bool SendResponse(SharedFD fd, const std::string& session_id,
50 const UserResponse::type& plain_selection,
51 const std::vector<uint8_t>& signed_response,
52 // signing is a function of message, key
53 const std::vector<uint8_t>& message);
54
55// for HAL
56bool SendStartCmd(SharedFD fd, const std::string& session_id,
57 const std::string& prompt_text,
58 const std::vector<uint8_t>& extra_data,
59 const std::string& locale,
60 const std::vector<teeui::UIOption>& ui_opts);
61
62bool SendStopCmd(SharedFD fd, const std::string& session_id);
63
64// for HAL::deliverSecureInputEvent
65bool SendUserSelection(SharedFD fd, const std::string& session_id,
66 const UserResponse::type& confirm_cancel);
67
68} // namespace cuttlefish::confui
Definition: shared_fd.h:124
Definition: packet.cpp:33
std::unique_ptr< ConfUiMessage > RecvConfUiMsg(SharedFD fd)
Definition: protocol.cpp:95
bool SendAbortCmd(SharedFD fd, const std::string &session_id)
Definition: protocol.cpp:125
bool SendAck(SharedFD fd, const std::string &session_id, const bool is_success, const std::string &status_message)
Definition: protocol.cpp:135
bool SendUserSelection(SharedFD fd, const std::string &session_id, const UserResponse::type &confirm_cancel)
Definition: protocol.cpp:161
bool SendResponse(SharedFD fd, const std::string &session_id, const UserResponse::type &plain_selection, const std::vector< uint8_t > &signed_response, const std::vector< uint8_t > &message)
Definition: protocol.cpp:141
std::string ToString(const ConfUiMessage &msg)
Definition: protocol.cpp:93
constexpr auto SESSION_ANY
Definition: protocol.h:33
bool SendStartCmd(SharedFD fd, const std::string &session_id, const std::string &prompt_text, const std::vector< uint8_t > &extra_data, const std::string &locale, const std::vector< teeui::UIOption > &ui_opts)
Definition: protocol.cpp:150
bool SendStopCmd(SharedFD fd, const std::string &session_id)
Definition: protocol.cpp:130
std::string type
Definition: protocol_types.h:65