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 25 #include "common/libs/confui/packet_types.h" 26 #include "common/libs/confui/protocol_types.h" 27 #include "common/libs/fs/shared_fd.h" 28 29 namespace cuttlefish { 30 namespace confui { 31 32 std::string ToString(const ConfUiMessage& msg); 33 34 constexpr 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 */ 42 std::unique_ptr<ConfUiMessage> RecvConfUiMsg(SharedFD fd); 43 std::unique_ptr<ConfUiMessage> RecvConfUiMsg(const std::string& session_id, 44 SharedFD fd); 45 46 bool SendAbortCmd(SharedFD fd, const std::string& session_id); 47 48 bool SendAck(SharedFD fd, const std::string& session_id, const bool is_success, 49 const std::string& status_message); 50 bool 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 57 bool 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 63 bool SendStopCmd(SharedFD fd, const std::string& session_id); 64 65 // for HAL::deliverSecureInputEvent 66 bool 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 71