78 lines
3.0 KiB
C++
78 lines
3.0 KiB
C++
/*
|
|
* Copyright (C) 2022 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include "common/libs/confui/confui.h"
|
|
|
|
/** ConfUiUserSelectionMessage with a security flag
|
|
*
|
|
* Inputs generated by something that belong to (virtualized) TEE is regarded
|
|
* as secure. Otherwise (e.g. inputs generated by the guest calling
|
|
* deliverSecureInputEvent), it is regarded as insecure.
|
|
*
|
|
* The host marks the security field, and use it internally and exclusively.
|
|
*
|
|
*/
|
|
namespace cuttlefish {
|
|
namespace confui {
|
|
class ConfUiSecureUserSelectionMessage : public ConfUiMessage {
|
|
public:
|
|
ConfUiSecureUserSelectionMessage(const ConfUiUserSelectionMessage& msg,
|
|
const bool secure)
|
|
: ConfUiMessage(msg.GetSessionId()), msg_(msg), is_secure_(secure) {}
|
|
ConfUiSecureUserSelectionMessage() = delete;
|
|
virtual ~ConfUiSecureUserSelectionMessage() = default;
|
|
std::string ToString() const override { return msg_.ToString(); }
|
|
ConfUiCmd GetType() const override { return msg_.GetType(); }
|
|
auto GetResponse() const { return msg_.GetResponse(); }
|
|
// SendOver is between guest and host, so it doesn't send the is_secure_
|
|
bool SendOver(SharedFD fd) override { return msg_.SendOver(fd); }
|
|
bool IsSecure() const { return is_secure_; }
|
|
// SetSecure() might be needed later on but not now.
|
|
|
|
private:
|
|
ConfUiUserSelectionMessage msg_;
|
|
bool is_secure_;
|
|
};
|
|
|
|
class ConfUiSecureUserTouchMessage : public ConfUiMessage {
|
|
public:
|
|
ConfUiSecureUserTouchMessage(const ConfUiUserTouchMessage& msg,
|
|
const bool secure)
|
|
: ConfUiMessage(msg.GetSessionId()), msg_(msg), is_secure_(secure) {}
|
|
virtual ~ConfUiSecureUserTouchMessage() = default;
|
|
std::string ToString() const override { return msg_.ToString(); }
|
|
ConfUiCmd GetType() const override { return msg_.GetType(); }
|
|
auto GetResponse() const { return msg_.GetResponse(); }
|
|
bool SendOver(SharedFD fd) override { return msg_.SendOver(fd); }
|
|
std::pair<int, int> GetLocation() { return msg_.GetLocation(); }
|
|
bool IsSecure() const { return is_secure_; }
|
|
|
|
private:
|
|
ConfUiUserTouchMessage msg_;
|
|
bool is_secure_;
|
|
};
|
|
|
|
std::unique_ptr<ConfUiSecureUserSelectionMessage> ToSecureSelectionMessage(
|
|
const ConfUiUserSelectionMessage& msg, const bool secure);
|
|
std::unique_ptr<ConfUiSecureUserTouchMessage> ToSecureTouchMessage(
|
|
const ConfUiUserTouchMessage& msg, const bool secure);
|
|
} // end of namespace confui
|
|
} // end of namespace cuttlefish
|