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 <cstdint>
19#include <memory>
20#include <string>
21#include <vector>
22
23#include <teeui/common_message_types.h> // /system/teeui/libteeui/.../include
24
28
29namespace cuttlefish {
30namespace confui {
31
32std::string ToString(const ConfUiMessage& msg);
33
34constexpr auto SESSION_ANY = "";
35/*
36 * received confirmation UI message on the guest could be abort or
37 * ack/response. Thus, the guest APIs should call RecvConfUiMsg(fd),
38 * see which is it, and then use Into*(conf_ui_message) to
39 * parse & use it.
40 *
41 */
42std::unique_ptr<ConfUiMessage> RecvConfUiMsg(SharedFD fd);
43std::unique_ptr<ConfUiMessage> RecvConfUiMsg(const std::string& session_id,
44 SharedFD fd);
45
46bool SendAbortCmd(SharedFD fd, const std::string& session_id);
47
48bool SendAck(SharedFD fd, const std::string& session_id, const bool is_success,
49 const std::string& status_message);
50bool SendResponse(SharedFD fd, const std::string& session_id,
51 const UserResponse::type& plain_selection,
52 const std::vector<std::uint8_t>& signed_response,
53 // signing is a function of message, key
54 const std::vector<std::uint8_t>& message);
55
56// for HAL
57bool SendStartCmd(SharedFD fd, const std::string& session_id,
58 const std::string& prompt_text,
59 const std::vector<std::uint8_t>& extra_data,
60 const std::string& locale,
61 const std::vector<teeui::UIOption>& ui_opts);
62
63bool SendStopCmd(SharedFD fd, const std::string& session_id);
64
65// for HAL::deliverSecureInputEvent
66bool SendUserSelection(SharedFD fd, const std::string& session_id,
67 const UserResponse::type& confirm_cancel);
68
69} // end of namespace confui
70} // end of namespace cuttlefish
Definition: shared_fd.h:129
bool SendResponse(SharedFD fd, const std::string &session_id, const UserResponse::type &plain_selection, const std::vector< std::uint8_t > &signed_response, const std::vector< std::uint8_t > &message)
Definition: protocol.cpp:133
std::unique_ptr< ConfUiMessage > RecvConfUiMsg(SharedFD fd)
Definition: protocol.cpp:87
bool SendAbortCmd(SharedFD fd, const std::string &session_id)
Definition: protocol.cpp:117
bool SendAck(SharedFD fd, const std::string &session_id, const bool is_success, const std::string &status_message)
Definition: protocol.cpp:127
bool SendUserSelection(SharedFD fd, const std::string &session_id, const UserResponse::type &confirm_cancel)
Definition: protocol.cpp:153
bool SendStartCmd(SharedFD fd, const std::string &session_id, const std::string &prompt_text, const std::vector< std::uint8_t > &extra_data, const std::string &locale, const std::vector< teeui::UIOption > &ui_opts)
Definition: protocol.cpp:142
std::string ToString(const ConfUiMessage &msg)
Definition: protocol.cpp:85
constexpr auto SESSION_ANY
Definition: protocol.h:34
bool SendStopCmd(SharedFD fd, const std::string &session_id)
Definition: protocol.cpp:122
Definition: alloc_utils.cpp:23
std::string type
Definition: protocol_types.h:65