Merge "secure_element: Fix the expectation for closeChannel in VTS tests" am: 3c766f6605 am: e97f440486 am: 26bf3ab9f5

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2412572

Change-Id: Ide2135382c6ad1dcbc7c7d63d7e0d53e0f1af90a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/secure_element/aidl/default/main.cpp b/secure_element/aidl/default/main.cpp
index 6149eae..0822402 100644
--- a/secure_element/aidl/default/main.cpp
+++ b/secure_element/aidl/default/main.cpp
@@ -586,7 +586,7 @@
 
         // The selected basic or logical channel is not opened.
         if (channel_number >= channels_.size() || !channels_[channel_number].opened) {
-            return ScopedAStatus::ok();
+            return ScopedAStatus::fromServiceSpecificError(FAILED);
         }
 
         // TODO(b/123254068) - this is not an implementation of the OMAPI protocol
diff --git a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
index c265579..37ff1b2 100644
--- a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
+++ b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
@@ -109,6 +109,7 @@
     }
 
     void TearDown() override {
+        EXPECT_OK(secure_element_->reset());
         secure_element_ = nullptr;
         secure_element_callback_ = nullptr;
     }
@@ -232,10 +233,10 @@
     std::vector<uint8_t> basic_channel_response;
     LogicalChannelResponse logical_channel_response;
 
-    // closeChannel called on non-existing basic or logical channel is a no-op
-    // and shall succeed.
-    EXPECT_OK(secure_element_->closeChannel(0));
-    EXPECT_OK(secure_element_->closeChannel(1));
+    // closeChannel called on non-existing basic or logical channel
+    // shall fail.
+    EXPECT_ERR(secure_element_->closeChannel(0));
+    EXPECT_ERR(secure_element_->closeChannel(1));
 
     // closeChannel called on basic channel closes the basic channel.
     EXPECT_OK(secure_element_->openBasicChannel(kSelectableAid, 0x00, &basic_channel_response));