From 6753a9be728c06ec62fd128dac50b80ef5a32787 Mon Sep 17 00:00:00 2001 From: Ruchi Kandoi Date: Tue, 1 Aug 2017 17:30:17 -0700 Subject: [PATCH] nfc: NCI 2.0: Add CORE_INIT_CMD for NCI 2.0 Bug: 64245250 Test: run vts test Merged-In: I4ca434fb1fb44a6278942f020ddd02b162d7f605 Change-Id: I4ca434fb1fb44a6278942f020ddd02b162d7f605 (cherry picked from commit c901276e6063e739b742435a161e51978c5f4ec5) (cherry picked from commit 029633dcd0cf6d95c2c7f37738392660c34dcd17) --- .../functional/VtsHalNfcV1_0TargetTest.cpp | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp index e67f94f723..2f00fbb8b7 100644 --- a/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp +++ b/nfc/1.0/vts/functional/VtsHalNfcV1_0TargetTest.cpp @@ -44,6 +44,8 @@ using ::android::sp; { 0x20, 0x04, 0x02, 0x01, 0x00 } #define CORE_INIT_CMD \ { 0x20, 0x01, 0x00 } +#define CORE_INIT_CMD_NCI20 \ + { 0x20, 0x01, 0x02, 0x00, 0x00 } #define INVALID_COMMAND \ { 0x20, 0x00, 0x00 } @@ -290,16 +292,23 @@ TEST_F(NfcHidlTest, WriteInvalidAndThenValidCommand) { // Wait for CORE_RESET_NTF res = nfc_cb_->WaitForCallback(kCallbackNameSendData); EXPECT_TRUE(res.no_timeout); + cmd = CORE_INIT_CMD_NCI20; + } else { + cmd = CORE_INIT_CMD; } - - cmd = CORE_INIT_CMD; data = cmd; + EXPECT_EQ(data.size(), nfc_->write(data)); // Wait for CORE_INIT_RSP res = nfc_cb_->WaitForCallback(kCallbackNameSendData); EXPECT_TRUE(res.no_timeout); EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]); - + if (nci_version == NCI_VERSION_2 && res.args->last_data_.size() > 13 && + res.args->last_data_[13] == 0x00) { + // Wait for CORE_CONN_CREDITS_NTF + res = nfc_cb_->WaitForCallback(kCallbackNameSendData); + EXPECT_TRUE(res.no_timeout); + } // Send an Error Data Packet cmd = INVALID_COMMAND; data = cmd; @@ -347,15 +356,23 @@ TEST_F(NfcHidlTest, Bandwidth) { // Wait for CORE_RESET_NTF res = nfc_cb_->WaitForCallback(kCallbackNameSendData); EXPECT_TRUE(res.no_timeout); + cmd = CORE_INIT_CMD_NCI20; + } else { + cmd = CORE_INIT_CMD; } - - cmd = CORE_INIT_CMD; data = cmd; + EXPECT_EQ(data.size(), nfc_->write(data)); // Wait for CORE_INIT_RSP res = nfc_cb_->WaitForCallback(kCallbackNameSendData); EXPECT_TRUE(res.no_timeout); EXPECT_EQ((int)NfcStatus::OK, res.args->last_data_[3]); + if (nci_version == NCI_VERSION_2 && res.args->last_data_.size() > 13 && + res.args->last_data_[13] == 0x00) { + // Wait for CORE_CONN_CREDITS_NTF + res = nfc_cb_->WaitForCallback(kCallbackNameSendData); + EXPECT_TRUE(res.no_timeout); + } cmd = CORE_CONN_CREATE_CMD; data = cmd;