1 /*
2 * Copyright (C) 2022 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
17 #include "host/libs/confui/secure_input.h"
18
19 namespace cuttlefish {
20 namespace confui {
21 namespace {
22
23 template <typename T>
CheckAndReturnSessionId(const std::unique_ptr<T> & msg)24 auto CheckAndReturnSessionId(const std::unique_ptr<T>& msg) {
25 CHECK(msg) << "ConfUiUserSelectionMessage must not be null";
26 return msg->GetSessionId();
27 }
28
29 } // end of namespace
30
ConfUiSecureUserSelectionMessage(std::unique_ptr<ConfUiUserSelectionMessage> && msg,const bool secure)31 ConfUiSecureUserSelectionMessage::ConfUiSecureUserSelectionMessage(
32 std::unique_ptr<ConfUiUserSelectionMessage>&& msg, const bool secure)
33 : ConfUiMessage(CheckAndReturnSessionId(msg)),
34 msg_(std::move(msg)),
35 is_secure_(secure) {}
36
ConfUiSecureUserTouchMessage(std::unique_ptr<ConfUiUserTouchMessage> && msg,const bool secure)37 ConfUiSecureUserTouchMessage::ConfUiSecureUserTouchMessage(
38 std::unique_ptr<ConfUiUserTouchMessage>&& msg, const bool secure)
39 : ConfUiMessage(CheckAndReturnSessionId(msg)),
40 msg_(std::move(msg)),
41 is_secure_(secure) {}
42
ToSecureSelectionMessage(std::unique_ptr<ConfUiUserSelectionMessage> && msg,const bool secure)43 std::unique_ptr<ConfUiSecureUserSelectionMessage> ToSecureSelectionMessage(
44 std::unique_ptr<ConfUiUserSelectionMessage>&& msg, const bool secure) {
45 return std::make_unique<ConfUiSecureUserSelectionMessage>(std::move(msg),
46 secure);
47 }
48
ToSecureTouchMessage(std::unique_ptr<ConfUiUserTouchMessage> && msg,const bool secure)49 std::unique_ptr<ConfUiSecureUserTouchMessage> ToSecureTouchMessage(
50 std::unique_ptr<ConfUiUserTouchMessage>&& msg, const bool secure) {
51 return std::make_unique<ConfUiSecureUserTouchMessage>(std::move(msg), secure);
52 }
53
54 } // end of namespace confui
55 } // end of namespace cuttlefish
56