mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
Add android.hardware.secure_element@1.1
Test: None Bug: 122590188 Change-Id: If68b7bfeb5fa36f3dc05e82fab078fbb8f6040cf
This commit is contained in:
19
secure_element/1.1/Android.bp
Normal file
19
secure_element/1.1/Android.bp
Normal file
@@ -0,0 +1,19 @@
|
||||
// This file is autogenerated by hidl-gen -Landroidbp.
|
||||
|
||||
hidl_interface {
|
||||
name: "android.hardware.secure_element@1.1",
|
||||
root: "android.hardware",
|
||||
vndk: {
|
||||
enabled: true,
|
||||
},
|
||||
srcs: [
|
||||
"ISecureElement.hal",
|
||||
"ISecureElementHalCallback.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"android.hardware.secure_element@1.0",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: true,
|
||||
}
|
||||
|
||||
35
secure_element/1.1/ISecureElement.hal
Normal file
35
secure_element/1.1/ISecureElement.hal
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
package android.hardware.secure_element@1.1;
|
||||
|
||||
import @1.1::ISecureElementHalCallback;
|
||||
import @1.0::ISecureElement;
|
||||
|
||||
interface ISecureElement extends @1.0::ISecureElement {
|
||||
/**
|
||||
* Initializes the Secure Element. This may include updating the applet
|
||||
* and/or vendor-specific initialization.
|
||||
*
|
||||
* HAL service must send onStateChange() with connected equal to true
|
||||
* after all the initialization has been successfully completed.
|
||||
* Clients must wait for a onStateChange(true) before opening channels.
|
||||
*
|
||||
* @param clientCallback callback used to sent status of the SE back to the
|
||||
* client
|
||||
*/
|
||||
init_1_1(ISecureElementHalCallback clientCallback);
|
||||
};
|
||||
33
secure_element/1.1/ISecureElementHalCallback.hal
Normal file
33
secure_element/1.1/ISecureElementHalCallback.hal
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
package android.hardware.secure_element@1.1;
|
||||
|
||||
import @1.0::ISecureElementHalCallback;
|
||||
|
||||
interface ISecureElementHalCallback extends @1.0::ISecureElementHalCallback {
|
||||
/*
|
||||
* Used to inform the client about changes in the state of the Secure
|
||||
* Element.
|
||||
*
|
||||
* @param connected indicates the current state of the SE
|
||||
* @param reason provides additional data why there was a change in state
|
||||
* ex. initialization error, SE removed etc
|
||||
* This is used only for debugging purpose to understand
|
||||
* in-field issues.
|
||||
*/
|
||||
onStateChange_1_1(bool connected, string debugReason);
|
||||
};
|
||||
26
secure_element/1.1/vts/functional/Android.bp
Normal file
26
secure_element/1.1/vts/functional/Android.bp
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright (C) 2019 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.
|
||||
//
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalSecureElementV1_1TargetTest",
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalSecureElementV1_1TargetTest.cpp"],
|
||||
static_libs: [
|
||||
"android.hardware.secure_element@1.0",
|
||||
"android.hardware.secure_element@1.1",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#define LOG_TAG "secure_element_hidl_hal_test"
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <android/hardware/secure_element/1.0/types.h>
|
||||
#include <android/hardware/secure_element/1.1/ISecureElement.h>
|
||||
#include <android/hardware/secure_element/1.1/ISecureElementHalCallback.h>
|
||||
|
||||
#include <VtsHalHidlTargetCallbackBase.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::secure_element::V1_1::ISecureElement;
|
||||
using ::android::hardware::secure_element::V1_1::ISecureElementHalCallback;
|
||||
using ::testing::VtsHalHidlTargetTestEnvBase;
|
||||
|
||||
constexpr char kCallbackNameOnStateChange[] = "onStateChange";
|
||||
|
||||
class SecureElementCallbackArgs {
|
||||
public:
|
||||
bool state_;
|
||||
hidl_string reason_;
|
||||
};
|
||||
|
||||
class SecureElementHalCallback
|
||||
: public ::testing::VtsHalHidlTargetCallbackBase<SecureElementCallbackArgs>,
|
||||
public ISecureElementHalCallback {
|
||||
public:
|
||||
virtual ~SecureElementHalCallback() = default;
|
||||
|
||||
Return<void> onStateChange_1_1(bool state, const hidl_string& reason) override {
|
||||
SecureElementCallbackArgs args;
|
||||
args.state_ = state;
|
||||
args.reason_ = reason;
|
||||
NotifyFromCallback(kCallbackNameOnStateChange, args);
|
||||
return Void();
|
||||
};
|
||||
|
||||
Return<void> onStateChange(__attribute__((unused)) bool state) override { return Void(); }
|
||||
};
|
||||
|
||||
class SecureElementHidlEnvironment : public VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static SecureElementHidlEnvironment* Instance() {
|
||||
static SecureElementHidlEnvironment* instance = new SecureElementHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<ISecureElement>(); }
|
||||
|
||||
private:
|
||||
SecureElementHidlEnvironment() {}
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(SecureElementHidlEnvironment);
|
||||
};
|
||||
|
||||
class SecureElementHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
std::string serviceName =
|
||||
SecureElementHidlEnvironment::Instance()->getServiceName<ISecureElement>("eSE1");
|
||||
LOG(INFO) << "get service with name:" << serviceName;
|
||||
ASSERT_FALSE(serviceName.empty());
|
||||
se_ = ::testing::VtsHalHidlTargetTestBase::getService<ISecureElement>(serviceName);
|
||||
ASSERT_NE(se_, nullptr);
|
||||
|
||||
se_cb_ = new SecureElementHalCallback();
|
||||
ASSERT_NE(se_cb_, nullptr);
|
||||
se_->init_1_1(se_cb_);
|
||||
auto res = se_cb_->WaitForCallback(kCallbackNameOnStateChange);
|
||||
EXPECT_TRUE(res.no_timeout);
|
||||
EXPECT_TRUE(res.args->state_);
|
||||
EXPECT_NE(res.args->reason_, "");
|
||||
}
|
||||
|
||||
sp<ISecureElement> se_;
|
||||
sp<SecureElementHalCallback> se_cb_;
|
||||
};
|
||||
|
||||
/*
|
||||
* isCardPresent:
|
||||
* Expects the card to be present
|
||||
*/
|
||||
TEST_F(SecureElementHidlTest, isCardPresent) {
|
||||
EXPECT_TRUE(se_->isCardPresent());
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(SecureElementHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
SecureElementHidlEnvironment::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
return status;
|
||||
}
|
||||
Reference in New Issue
Block a user