Merge "Changes to adapt confirmationui AIDL spec." am: 7014fa9fa3
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2251741 Change-Id: Ibdacf1d3ec047002fca69341e731fc3e233c3300 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
7fee997381
8 changed files with 124 additions and 130 deletions
|
|
@ -24,21 +24,23 @@ package {
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "android.hardware.confirmationui@1.0-service.trusty",
|
name: "android.hardware.confirmationui-service.trusty",
|
||||||
relative_install_path: "hw",
|
relative_install_path: "hw",
|
||||||
vendor: true,
|
vendor: true,
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"android.hardware.confirmationui@1.0",
|
"android.hardware.confirmationui-V1-ndk",
|
||||||
"android.hardware.confirmationui.not-so-secure-input",
|
"android.hardware.confirmationui.not-so-secure-input",
|
||||||
"android.hardware.confirmationui@1.0-lib.trusty",
|
"android.hardware.confirmationui-lib.trusty",
|
||||||
|
"libbinder_ndk",
|
||||||
|
"libteeui_hal_support",
|
||||||
"libbase",
|
"libbase",
|
||||||
"libhidlbase",
|
"libhidlbase",
|
||||||
"libutils",
|
"libutils",
|
||||||
],
|
],
|
||||||
|
|
||||||
init_rc: ["android.hardware.confirmationui@1.0-service.trusty.rc"],
|
init_rc: ["android.hardware.confirmationui-service.trusty.rc"],
|
||||||
|
|
||||||
vintf_fragments: ["android.hardware.confirmationui@1.0-service.trusty.xml"],
|
vintf_fragments: ["android.hardware.confirmationui-service.trusty.xml"],
|
||||||
|
|
||||||
srcs: [
|
srcs: [
|
||||||
"service.cpp",
|
"service.cpp",
|
||||||
|
|
@ -52,17 +54,20 @@ cc_binary {
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "android.hardware.confirmationui@1.0-lib.trusty",
|
name: "android.hardware.confirmationui-lib.trusty",
|
||||||
|
defaults: [
|
||||||
|
"keymint_use_latest_hal_aidl_ndk_shared",
|
||||||
|
],
|
||||||
vendor: true,
|
vendor: true,
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"android.hardware.confirmationui@1.0",
|
"android.hardware.confirmationui-V1-ndk",
|
||||||
"android.hardware.keymaster@4.0",
|
|
||||||
"libbase",
|
"libbase",
|
||||||
|
"libcutils",
|
||||||
"libdmabufheap",
|
"libdmabufheap",
|
||||||
"libhidlbase",
|
|
||||||
"libteeui_hal_support",
|
"libteeui_hal_support",
|
||||||
"libtrusty",
|
"libtrusty",
|
||||||
"libutils",
|
"libutils",
|
||||||
|
"libbinder_ndk",
|
||||||
],
|
],
|
||||||
|
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
#include "TrustyConfirmationUI.h"
|
#include "TrustyConfirmationUI.h"
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android/hardware/confirmationui/1.0/types.h>
|
|
||||||
#include <android/hardware/keymaster/4.0/types.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
@ -42,12 +40,7 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace android {
|
namespace aidl::android::hardware::confirmationui {
|
||||||
namespace hardware {
|
|
||||||
namespace confirmationui {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using namespace secure_input;
|
using namespace secure_input;
|
||||||
|
|
||||||
using ::android::trusty::confirmationui::TrustyAppError;
|
using ::android::trusty::confirmationui::TrustyAppError;
|
||||||
|
|
@ -64,8 +57,6 @@ using ::teeui::ResultMsg;
|
||||||
|
|
||||||
using ::secure_input::createSecureInput;
|
using ::secure_input::createSecureInput;
|
||||||
|
|
||||||
using ::android::hardware::keymaster::V4_0::HardwareAuthToken;
|
|
||||||
|
|
||||||
using ::std::tie;
|
using ::std::tie;
|
||||||
|
|
||||||
using TeeuiRc = ::teeui::ResponseCode;
|
using TeeuiRc = ::teeui::ResponseCode;
|
||||||
|
|
@ -87,46 +78,47 @@ class Finalize {
|
||||||
void release() { f_ = {}; }
|
void release() { f_ = {}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
ResponseCode convertRc(TeeuiRc trc) {
|
int convertRc(TeeuiRc trc) {
|
||||||
static_assert(
|
static_assert(
|
||||||
uint32_t(TeeuiRc::OK) == uint32_t(ResponseCode::OK) &&
|
uint32_t(TeeuiRc::OK) == uint32_t(IConfirmationUI::OK) &&
|
||||||
uint32_t(TeeuiRc::Canceled) == uint32_t(ResponseCode::Canceled) &&
|
uint32_t(TeeuiRc::Canceled) == uint32_t(IConfirmationUI::CANCELED) &&
|
||||||
uint32_t(TeeuiRc::Aborted) == uint32_t(ResponseCode::Aborted) &&
|
uint32_t(TeeuiRc::Aborted) == uint32_t(IConfirmationUI::ABORTED) &&
|
||||||
uint32_t(TeeuiRc::OperationPending) == uint32_t(ResponseCode::OperationPending) &&
|
uint32_t(TeeuiRc::OperationPending) == uint32_t(IConfirmationUI::OPERATION_PENDING) &&
|
||||||
uint32_t(TeeuiRc::Ignored) == uint32_t(ResponseCode::Ignored) &&
|
uint32_t(TeeuiRc::Ignored) == uint32_t(IConfirmationUI::IGNORED) &&
|
||||||
uint32_t(TeeuiRc::SystemError) == uint32_t(ResponseCode::SystemError) &&
|
uint32_t(TeeuiRc::SystemError) == uint32_t(IConfirmationUI::SYSTEM_ERROR) &&
|
||||||
uint32_t(TeeuiRc::Unimplemented) == uint32_t(ResponseCode::Unimplemented) &&
|
uint32_t(TeeuiRc::Unimplemented) == uint32_t(IConfirmationUI::UNIMPLEMENTED) &&
|
||||||
uint32_t(TeeuiRc::Unexpected) == uint32_t(ResponseCode::Unexpected) &&
|
uint32_t(TeeuiRc::Unexpected) == uint32_t(IConfirmationUI::UNEXPECTED) &&
|
||||||
uint32_t(TeeuiRc::UIError) == uint32_t(ResponseCode::UIError) &&
|
uint32_t(TeeuiRc::UIError) == uint32_t(IConfirmationUI::UI_ERROR) &&
|
||||||
uint32_t(TeeuiRc::UIErrorMissingGlyph) == uint32_t(ResponseCode::UIErrorMissingGlyph) &&
|
uint32_t(TeeuiRc::UIErrorMissingGlyph) ==
|
||||||
|
uint32_t(IConfirmationUI::UI_ERROR_MISSING_GLYPH) &&
|
||||||
uint32_t(TeeuiRc::UIErrorMessageTooLong) ==
|
uint32_t(TeeuiRc::UIErrorMessageTooLong) ==
|
||||||
uint32_t(ResponseCode::UIErrorMessageTooLong) &&
|
uint32_t(IConfirmationUI::UI_ERROR_MESSAGE_TOO_LONG) &&
|
||||||
uint32_t(TeeuiRc::UIErrorMalformedUTF8Encoding) ==
|
uint32_t(TeeuiRc::UIErrorMalformedUTF8Encoding) ==
|
||||||
uint32_t(ResponseCode::UIErrorMalformedUTF8Encoding),
|
uint32_t(IConfirmationUI::UI_ERROR_MALFORMED_UTF8ENCODING),
|
||||||
"teeui::ResponseCode and "
|
"teeui::ResponseCode and "
|
||||||
"::android::hardware::confirmationui::V1_0::Responsecude are out of "
|
"::android::hardware::confirmationui::V1_0::Responsecude are out of "
|
||||||
"sync");
|
"sync");
|
||||||
return ResponseCode(trc);
|
return static_cast<int>(trc);
|
||||||
}
|
}
|
||||||
|
|
||||||
teeui::UIOption convertUIOption(UIOption uio) {
|
teeui::UIOption convertUIOption(UIOption uio) {
|
||||||
static_assert(uint32_t(UIOption::AccessibilityInverted) ==
|
static_assert(uint32_t(UIOption::ACCESSIBILITY_INVERTED) ==
|
||||||
uint32_t(teeui::UIOption::AccessibilityInverted) &&
|
uint32_t(teeui::UIOption::AccessibilityInverted) &&
|
||||||
uint32_t(UIOption::AccessibilityMagnified) ==
|
uint32_t(UIOption::ACCESSIBILITY_MAGNIFIED) ==
|
||||||
uint32_t(teeui::UIOption::AccessibilityMagnified),
|
uint32_t(teeui::UIOption::AccessibilityMagnified),
|
||||||
"teeui::UIOPtion and ::android::hardware::confirmationui::V1_0::UIOption "
|
"teeui::UIOPtion and ::android::hardware::confirmationui::V1_0::UIOption "
|
||||||
"anre out of sync");
|
"are out of sync");
|
||||||
return teeui::UIOption(uio);
|
return teeui::UIOption(uio);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline MsgString hidl2MsgString(const hidl_string& s) {
|
inline MsgString stdString2MsgString(const string& s) {
|
||||||
return {s.c_str(), s.c_str() + s.size()};
|
return {s.c_str(), s.c_str() + s.size()};
|
||||||
}
|
}
|
||||||
template <typename T> inline MsgVector<T> hidl2MsgVector(const hidl_vec<T>& v) {
|
template <typename T> inline MsgVector<T> stdVector2MsgVector(const vector<T>& v) {
|
||||||
return {v};
|
return {v};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline MsgVector<teeui::UIOption> hidl2MsgVector(const hidl_vec<UIOption>& v) {
|
inline MsgVector<teeui::UIOption> stdVector2MsgVector(const vector<UIOption>& v) {
|
||||||
MsgVector<teeui::UIOption> result(v.size());
|
MsgVector<teeui::UIOption> result(v.size());
|
||||||
for (unsigned int i = 0; i < v.size(); ++i) {
|
for (unsigned int i = 0; i < v.size(); ++i) {
|
||||||
result[i] = convertUIOption(v[i]);
|
result[i] = convertUIOption(v[i]);
|
||||||
|
|
@ -137,7 +129,7 @@ inline MsgVector<teeui::UIOption> hidl2MsgVector(const hidl_vec<UIOption>& v) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TrustyConfirmationUI::TrustyConfirmationUI()
|
TrustyConfirmationUI::TrustyConfirmationUI()
|
||||||
: listener_state_(ListenerState::None), prompt_result_(ResponseCode::Ignored) {}
|
: listener_state_(ListenerState::None), prompt_result_(IConfirmationUI::IGNORED) {}
|
||||||
|
|
||||||
TrustyConfirmationUI::~TrustyConfirmationUI() {
|
TrustyConfirmationUI::~TrustyConfirmationUI() {
|
||||||
ListenerState state = listener_state_;
|
ListenerState state = listener_state_;
|
||||||
|
|
@ -385,15 +377,16 @@ TrustyConfirmationUI::promptUserConfirmation_(const MsgString& promptText,
|
||||||
// ############################## Start 4th Phase - cleanup ##################################
|
// ############################## Start 4th Phase - cleanup ##################################
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from ::android::hardware::confirmationui::V1_0::IConfirmationUI
|
// Methods from ::aidl::android::hardware::confirmationui::IConfirmationUI
|
||||||
// follow.
|
// follow.
|
||||||
Return<ResponseCode> TrustyConfirmationUI::promptUserConfirmation(
|
::ndk::ScopedAStatus TrustyConfirmationUI::promptUserConfirmation(
|
||||||
const sp<IConfirmationResultCallback>& resultCB, const hidl_string& promptText,
|
const shared_ptr<IConfirmationResultCallback>& resultCB, const vector<uint8_t>& promptTextBytes,
|
||||||
const hidl_vec<uint8_t>& extraData, const hidl_string& locale,
|
const vector<uint8_t>& extraData, const string& locale, const vector<UIOption>& uiOptions) {
|
||||||
const hidl_vec<UIOption>& uiOptions) {
|
|
||||||
std::unique_lock<std::mutex> stateLock(listener_state_lock_, std::defer_lock);
|
std::unique_lock<std::mutex> stateLock(listener_state_lock_, std::defer_lock);
|
||||||
|
string promptText(promptTextBytes.begin(), promptTextBytes.end());
|
||||||
if (!stateLock.try_lock()) {
|
if (!stateLock.try_lock()) {
|
||||||
return ResponseCode::OperationPending;
|
return ndk::ScopedAStatus(
|
||||||
|
AStatus_fromServiceSpecificError(IConfirmationUI::OPERATION_PENDING));
|
||||||
}
|
}
|
||||||
switch (listener_state_) {
|
switch (listener_state_) {
|
||||||
case ListenerState::None:
|
case ListenerState::None:
|
||||||
|
|
@ -401,23 +394,25 @@ Return<ResponseCode> TrustyConfirmationUI::promptUserConfirmation(
|
||||||
case ListenerState::Starting:
|
case ListenerState::Starting:
|
||||||
case ListenerState::SetupDone:
|
case ListenerState::SetupDone:
|
||||||
case ListenerState::Interactive:
|
case ListenerState::Interactive:
|
||||||
return ResponseCode::OperationPending;
|
return ndk::ScopedAStatus(
|
||||||
|
AStatus_fromServiceSpecificError(IConfirmationUI::OPERATION_PENDING));
|
||||||
case ListenerState::Terminating:
|
case ListenerState::Terminating:
|
||||||
callback_thread_.join();
|
callback_thread_.join();
|
||||||
listener_state_ = ListenerState::None;
|
listener_state_ = ListenerState::None;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return ResponseCode::Unexpected;
|
return ndk::ScopedAStatus(AStatus_fromServiceSpecificError(IConfirmationUI::UNEXPECTED));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(listener_state_ == ListenerState::None);
|
assert(listener_state_ == ListenerState::None);
|
||||||
|
|
||||||
callback_thread_ = std::thread(
|
callback_thread_ = std::thread(
|
||||||
[this](sp<IConfirmationResultCallback> resultCB, hidl_string promptText,
|
[this](const shared_ptr<IConfirmationResultCallback>& resultCB, const string& promptText,
|
||||||
hidl_vec<uint8_t> extraData, hidl_string locale, hidl_vec<UIOption> uiOptions) {
|
const vector<uint8_t>& extraData, const string& locale,
|
||||||
auto [trc, msg, token] =
|
const vector<UIOption>& uiOptions) {
|
||||||
promptUserConfirmation_(hidl2MsgString(promptText), hidl2MsgVector(extraData),
|
auto [trc, msg, token] = promptUserConfirmation_(
|
||||||
hidl2MsgString(locale), hidl2MsgVector(uiOptions));
|
stdString2MsgString(promptText), stdVector2MsgVector(extraData),
|
||||||
|
stdString2MsgString(locale), stdVector2MsgVector(uiOptions));
|
||||||
bool do_callback = (listener_state_ == ListenerState::Interactive ||
|
bool do_callback = (listener_state_ == ListenerState::Interactive ||
|
||||||
listener_state_ == ListenerState::SetupDone) &&
|
listener_state_ == ListenerState::SetupDone) &&
|
||||||
resultCB;
|
resultCB;
|
||||||
|
|
@ -426,7 +421,7 @@ Return<ResponseCode> TrustyConfirmationUI::promptUserConfirmation(
|
||||||
if (do_callback) {
|
if (do_callback) {
|
||||||
auto error = resultCB->result(prompt_result_, msg, token);
|
auto error = resultCB->result(prompt_result_, msg, token);
|
||||||
if (!error.isOk()) {
|
if (!error.isOk()) {
|
||||||
LOG(ERROR) << "Result callback failed " << error.description();
|
LOG(ERROR) << "Result callback failed " << error.getDescription();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
listener_state_condv_.notify_all();
|
listener_state_condv_.notify_all();
|
||||||
|
|
@ -442,14 +437,14 @@ Return<ResponseCode> TrustyConfirmationUI::promptUserConfirmation(
|
||||||
if (listener_state_ == ListenerState::Terminating) {
|
if (listener_state_ == ListenerState::Terminating) {
|
||||||
callback_thread_.join();
|
callback_thread_.join();
|
||||||
listener_state_ = ListenerState::None;
|
listener_state_ = ListenerState::None;
|
||||||
return prompt_result_;
|
return ndk::ScopedAStatus(AStatus_fromServiceSpecificError(prompt_result_));
|
||||||
}
|
}
|
||||||
return ResponseCode::OK;
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<ResponseCode>
|
::ndk::ScopedAStatus
|
||||||
TrustyConfirmationUI::deliverSecureInputEvent(const HardwareAuthToken& secureInputToken) {
|
TrustyConfirmationUI::deliverSecureInputEvent(const HardwareAuthToken& secureInputToken) {
|
||||||
ResponseCode rc = ResponseCode::Ignored;
|
int rc = IConfirmationUI::IGNORED;
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* deliverSecureInputEvent is only used by the VTS test to mock human input. A correct
|
* deliverSecureInputEvent is only used by the VTS test to mock human input. A correct
|
||||||
|
|
@ -467,13 +462,17 @@ TrustyConfirmationUI::deliverSecureInputEvent(const HardwareAuthToken& secureInp
|
||||||
listener_state_condv_.wait(stateLock,
|
listener_state_condv_.wait(stateLock,
|
||||||
[this] { return listener_state_ != ListenerState::SetupDone; });
|
[this] { return listener_state_ != ListenerState::SetupDone; });
|
||||||
|
|
||||||
if (listener_state_ != ListenerState::Interactive) return ResponseCode::Ignored;
|
if (listener_state_ != ListenerState::Interactive)
|
||||||
|
return ndk::ScopedAStatus(AStatus_fromServiceSpecificError(IConfirmationUI::IGNORED));
|
||||||
auto sapp = app_.lock();
|
auto sapp = app_.lock();
|
||||||
if (!sapp) return ResponseCode::Ignored;
|
if (!sapp)
|
||||||
|
return ndk::ScopedAStatus(AStatus_fromServiceSpecificError(IConfirmationUI::IGNORED));
|
||||||
auto [error, response] =
|
auto [error, response] =
|
||||||
sapp->issueCmd<DeliverTestCommandMessage, DeliverTestCommandResponse>(
|
sapp->issueCmd<DeliverTestCommandMessage, DeliverTestCommandResponse>(
|
||||||
static_cast<teeui::TestModeCommands>(secureInputToken.challenge));
|
static_cast<teeui::TestModeCommands>(secureInputToken.challenge));
|
||||||
if (error != TrustyAppError::OK) return ResponseCode::SystemError;
|
if (error != TrustyAppError::OK)
|
||||||
|
return ndk::ScopedAStatus(
|
||||||
|
AStatus_fromServiceSpecificError(IConfirmationUI::SYSTEM_ERROR));
|
||||||
auto& [trc] = response;
|
auto& [trc] = response;
|
||||||
if (trc != TeeuiRc::Ignored) secureInputDelivered_ = true;
|
if (trc != TeeuiRc::Ignored) secureInputDelivered_ = true;
|
||||||
rc = convertRc(trc);
|
rc = convertRc(trc);
|
||||||
|
|
@ -484,11 +483,14 @@ TrustyConfirmationUI::deliverSecureInputEvent(const HardwareAuthToken& secureInp
|
||||||
// Canceled into OK. Canceled is only returned if the delivered event canceled
|
// Canceled into OK. Canceled is only returned if the delivered event canceled
|
||||||
// the operation, which means that the event was successfully delivered. Thus
|
// the operation, which means that the event was successfully delivered. Thus
|
||||||
// we return OK.
|
// we return OK.
|
||||||
if (rc == ResponseCode::Canceled) return ResponseCode::OK;
|
if (rc == IConfirmationUI::CANCELED) return ndk::ScopedAStatus::ok();
|
||||||
return rc;
|
if (rc != IConfirmationUI::OK) {
|
||||||
|
return ndk::ScopedAStatus(AStatus_fromServiceSpecificError(rc));
|
||||||
|
}
|
||||||
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> TrustyConfirmationUI::abort() {
|
::ndk::ScopedAStatus TrustyConfirmationUI::abort() {
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> stateLock(listener_state_lock_);
|
std::unique_lock<std::mutex> stateLock(listener_state_lock_);
|
||||||
if (listener_state_ == ListenerState::SetupDone ||
|
if (listener_state_ == ListenerState::SetupDone ||
|
||||||
|
|
@ -499,15 +501,11 @@ Return<void> TrustyConfirmationUI::abort() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listener_state_condv_.notify_all();
|
listener_state_condv_.notify_all();
|
||||||
return Void();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
android::sp<IConfirmationUI> createTrustyConfirmationUI() {
|
std::shared_ptr<IConfirmationUI> createTrustyConfirmationUI() {
|
||||||
return new TrustyConfirmationUI();
|
return ndk::SharedRefBase::make<TrustyConfirmationUI>();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace aidl::android::hardware::confirmationui
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace confirmationui
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,11 @@
|
||||||
#ifndef ANDROID_HARDWARE_CONFIRMATIONUI_V1_0_TRUSTY_CONFIRMATIONUI_H
|
#ifndef ANDROID_HARDWARE_CONFIRMATIONUI_V1_0_TRUSTY_CONFIRMATIONUI_H
|
||||||
#define ANDROID_HARDWARE_CONFIRMATIONUI_V1_0_TRUSTY_CONFIRMATIONUI_H
|
#define ANDROID_HARDWARE_CONFIRMATIONUI_V1_0_TRUSTY_CONFIRMATIONUI_H
|
||||||
|
|
||||||
#include <android/hardware/confirmationui/1.0/IConfirmationUI.h>
|
#include <aidl/android/hardware/confirmationui/BnConfirmationUI.h>
|
||||||
#include <android/hardware/keymaster/4.0/types.h>
|
#include <aidl/android/hardware/confirmationui/IConfirmationResultCallback.h>
|
||||||
#include <hidl/Status.h>
|
#include <aidl/android/hardware/confirmationui/UIOption.h>
|
||||||
|
#include <aidl/android/hardware/security/keymint/HardwareAuthToken.h>
|
||||||
|
#include <android/binder_manager.h>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
@ -30,35 +32,29 @@
|
||||||
|
|
||||||
#include "TrustyApp.h"
|
#include "TrustyApp.h"
|
||||||
|
|
||||||
namespace android {
|
namespace aidl::android::hardware::confirmationui {
|
||||||
namespace hardware {
|
|
||||||
namespace confirmationui {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::sp;
|
using std::shared_ptr;
|
||||||
using ::android::hardware::hidl_array;
|
using std::string;
|
||||||
using ::android::hardware::hidl_string;
|
using std::vector;
|
||||||
using ::android::hardware::hidl_vec;
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
|
|
||||||
|
using ::aidl::android::hardware::security::keymint::HardwareAuthToken;
|
||||||
using ::android::trusty::confirmationui::TrustyApp;
|
using ::android::trusty::confirmationui::TrustyApp;
|
||||||
|
|
||||||
class TrustyConfirmationUI : public IConfirmationUI {
|
class TrustyConfirmationUI : public BnConfirmationUI {
|
||||||
public:
|
public:
|
||||||
TrustyConfirmationUI();
|
TrustyConfirmationUI();
|
||||||
virtual ~TrustyConfirmationUI();
|
virtual ~TrustyConfirmationUI();
|
||||||
// Methods from ::android::hardware::confirmationui::V1_0::IConfirmationUI
|
// Methods from ::aidl::android::hardware::confirmationui::IConfirmationUI
|
||||||
// follow.
|
// follow.
|
||||||
Return<ResponseCode> promptUserConfirmation(const sp<IConfirmationResultCallback>& resultCB,
|
::ndk::ScopedAStatus
|
||||||
const hidl_string& promptText,
|
promptUserConfirmation(const shared_ptr<IConfirmationResultCallback>& resultCB,
|
||||||
const hidl_vec<uint8_t>& extraData,
|
const vector<uint8_t>& promptText, const vector<uint8_t>& extraData,
|
||||||
const hidl_string& locale,
|
const string& locale, const vector<UIOption>& uiOptions) override;
|
||||||
const hidl_vec<UIOption>& uiOptions) override;
|
::ndk::ScopedAStatus
|
||||||
Return<ResponseCode> deliverSecureInputEvent(
|
deliverSecureInputEvent(const HardwareAuthToken& secureInputToken) override;
|
||||||
const ::android::hardware::keymaster::V4_0::HardwareAuthToken& secureInputToken) override;
|
|
||||||
Return<void> abort() override;
|
::ndk::ScopedAStatus abort() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::weak_ptr<TrustyApp> app_;
|
std::weak_ptr<TrustyApp> app_;
|
||||||
|
|
@ -85,7 +81,7 @@ class TrustyConfirmationUI : public IConfirmationUI {
|
||||||
bool abort_called_;
|
bool abort_called_;
|
||||||
std::mutex listener_state_lock_;
|
std::mutex listener_state_lock_;
|
||||||
std::condition_variable listener_state_condv_;
|
std::condition_variable listener_state_condv_;
|
||||||
ResponseCode prompt_result_;
|
int prompt_result_;
|
||||||
bool secureInputDelivered_;
|
bool secureInputDelivered_;
|
||||||
|
|
||||||
std::tuple<teeui::ResponseCode, teeui::MsgVector<uint8_t>, teeui::MsgVector<uint8_t>>
|
std::tuple<teeui::ResponseCode, teeui::MsgVector<uint8_t>, teeui::MsgVector<uint8_t>>
|
||||||
|
|
@ -95,10 +91,6 @@ class TrustyConfirmationUI : public IConfirmationUI {
|
||||||
const teeui::MsgVector<teeui::UIOption>& uiOptions);
|
const teeui::MsgVector<teeui::UIOption>& uiOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace aidl::android::hardware::confirmationui
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace confirmationui
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
||||||
|
|
||||||
#endif // ANDROID_HARDWARE_CONFIRMATIONUI_V1_0_TRUSTY_CONFIRMATIONUI_H
|
#endif // ANDROID_HARDWARE_CONFIRMATIONUI_V1_0_TRUSTY_CONFIRMATIONUI_H
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
service vendor.confirmationui_default /vendor/bin/hw/android.hardware.confirmationui-service.trusty
|
||||||
|
interface aidl android.hardware.confirmationui.IConfirmationUI/default
|
||||||
|
class hal
|
||||||
|
user system
|
||||||
|
group drmrpc input system
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
<manifest version="1.0" type="device">
|
<manifest version="1.0" type="device">
|
||||||
<hal format="hidl">
|
<hal format="aidl">
|
||||||
<name>android.hardware.confirmationui</name>
|
<name>android.hardware.confirmationui</name>
|
||||||
<transport>hwbinder</transport>
|
<version>1</version>
|
||||||
<version>1.0</version>
|
|
||||||
<interface>
|
<interface>
|
||||||
<name>IConfirmationUI</name>
|
<name>IConfirmationUI</name>
|
||||||
<instance>default</instance>
|
<instance>default</instance>
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
service confirmationui-1-0 /vendor/bin/hw/android.hardware.confirmationui@1.0-service.trusty
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group drmrpc input system
|
|
||||||
|
|
@ -16,18 +16,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <android/hardware/confirmationui/1.0/IConfirmationUI.h>
|
#include <aidl/android/hardware/confirmationui/IConfirmationUI.h>
|
||||||
|
|
||||||
namespace android {
|
namespace aidl::android::hardware::confirmationui {
|
||||||
namespace hardware {
|
|
||||||
namespace confirmationui {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
android::sp<IConfirmationUI> createTrustyConfirmationUI();
|
std::shared_ptr<IConfirmationUI> createTrustyConfirmationUI();
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace aidl::android::hardware::confirmationui
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace confirmationui
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
||||||
|
|
|
||||||
|
|
@ -15,21 +15,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <hidl/HidlTransportSupport.h>
|
#include <android/binder_manager.h>
|
||||||
|
#include <android/binder_process.h>
|
||||||
|
|
||||||
#include <TrustyConfirmationuiHal.h>
|
#include <TrustyConfirmationuiHal.h>
|
||||||
|
|
||||||
using android::sp;
|
using ::aidl::android::hardware::confirmationui::createTrustyConfirmationUI;
|
||||||
using android::hardware::confirmationui::V1_0::implementation::createTrustyConfirmationUI;
|
using ::aidl::android::hardware::confirmationui::IConfirmationUI;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
::android::hardware::configureRpcThreadpool(1, true /*willJoinThreadpool*/);
|
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||||
auto service = createTrustyConfirmationUI();
|
|
||||||
auto status = service->registerAsService();
|
auto confirmationui = createTrustyConfirmationUI();
|
||||||
if (status != android::OK) {
|
|
||||||
LOG(FATAL) << "Could not register service for ConfirmationUI 1.0 (" << status << ")";
|
const auto instance = std::string(IConfirmationUI::descriptor) + "/default";
|
||||||
|
binder_status_t status =
|
||||||
|
AServiceManager_addService(confirmationui->asBinder().get(), instance.c_str());
|
||||||
|
|
||||||
|
if (status != STATUS_OK) {
|
||||||
|
LOG(FATAL) << "Could not register service for " << instance.c_str() << "(" << status << ")";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
::android::hardware::joinRpcThreadpool();
|
|
||||||
|
ABinderProcess_joinThreadPool();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue