From 567a44f37d59f3280e33605e02a130980f9232c9 Mon Sep 17 00:00:00 2001 From: wujie Date: Tue, 7 Jan 2025 10:15:02 +0800 Subject: [PATCH] Signed-off-by: wujie bugfix: nfc errorcode buffix --- .../js/napi/common/nfc_napi_common_utils.cpp | 3 ++ .../js/napi/common/nfc_napi_common_utils.h | 1 + .../js/napi/tag/nfc_napi_ndef_message.cpp | 21 +++++++++++ .../js/napi/tag/nfc_napi_ndef_message.h | 1 + interfaces/inner_api/common/BUILD.gn | 2 ++ interfaces/inner_api/common/ndef_message.cpp | 12 +++++++ interfaces/inner_api/common/ndef_message.h | 8 +++++ .../inner_api/common/nfc_sdk_common.cpp | 35 +++++++++++++++++- interfaces/inner_api/common/nfc_sdk_common.h | 4 +++ .../tags/foreground_callback_stub.cpp | 4 +-- .../tags/reader_mode_callback_stub.cpp | 4 +-- services/src/ipc/tags/tag_session.cpp | 36 +++++++++---------- .../services_tags_test/tag_session_test.cpp | 22 ++++++------ 13 files changed, 119 insertions(+), 34 deletions(-) diff --git a/frameworks/js/napi/common/nfc_napi_common_utils.cpp b/frameworks/js/napi/common/nfc_napi_common_utils.cpp index e44ae7c6..aec9dd9f 100644 --- a/frameworks/js/napi/common/nfc_napi_common_utils.cpp +++ b/frameworks/js/napi/common/nfc_napi_common_utils.cpp @@ -671,6 +671,9 @@ int BuildOutputErrorCode(int errCode) } else if (errCode == ERR_TAG_STATE_IO_FAILED) { return BUSI_ERR_IO_OPERATION_INVALID; } else if (errCode >= ERR_TAG_BASE && errCode < ERR_CE_BASE) { + if (NfcSdkCommon::GetSdkVersion() >= SDK_VERSION_16) && (errCode == ERR_TAG_STATE_LOST)) { + return BUSI_ERR_TAG_LEAVES_FIELD; + } return BUSI_ERR_TAG_STATE_INVALID; } return errCode; diff --git a/frameworks/js/napi/common/nfc_napi_common_utils.h b/frameworks/js/napi/common/nfc_napi_common_utils.h index 103235fb..fb2e84e9 100644 --- a/frameworks/js/napi/common/nfc_napi_common_utils.h +++ b/frameworks/js/napi/common/nfc_napi_common_utils.h @@ -37,6 +37,7 @@ const static int BUSI_ERR_ELEMENT_STATE_INVALID = 3100202; // The element state const static int BUSI_ERR_REGISTER_STATE_INVALID = 3100203; // The off() can be called only when the on() // has been called. const static int BUSI_ERR_IO_OPERATION_INVALID = 3100204; // Tag I/O operation failed. +const static int BUSI_ERR_TAG_LEAVES_FIELD = 3100205; // Tag I/O operation failed. const static uint32_t MAX_NUM_TECH_LIST = 12; const static int BUSI_ERR_HCE_STATE_INVALID = 3100301; // nfc hce state invalid. diff --git a/frameworks/js/napi/tag/nfc_napi_ndef_message.cpp b/frameworks/js/napi/tag/nfc_napi_ndef_message.cpp index 40b64af8..ce9a9183 100644 --- a/frameworks/js/napi/tag/nfc_napi_ndef_message.cpp +++ b/frameworks/js/napi/tag/nfc_napi_ndef_message.cpp @@ -156,6 +156,27 @@ napi_value NapiNdefMessage::MakeExternalRecord(napi_env env, napi_callback_info return result; } +napi_value NapiNdefMessage::MakeApplicationRecord(napi_env env, napi_callback_info info) +{ + std::size_t argc = ARGV_NUM_1; + napi_value argv[ARGV_NUM_1] = {0}; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); + + if (!CheckArgCountAndThrow(env, argc, ARGV_NUM_1) || + !CheckStringAndThrow(env, argv[ARGV_INDEX_0], "packageName", "string")) { + return CreateUndefined(env); + } + + std::string packageName = GetStringFromValue(env, argv[ARGV_INDEX_0]); + std::shared_ptr ndefRecord = NdefMessage::MakeApplicationRecord(packageName); + if (!CheckNdefRecordAndThrow(env, ndefRecord)) { + return CreateUndefined(env); + } + napi_value result = nullptr; + ConvertNdefRecordToJS(env, result, ndefRecord); + return result; +} + napi_value NapiNdefMessage::MessageToBytes(napi_env env, napi_callback_info info) { std::size_t argc = ARGV_NUM_1; diff --git a/frameworks/js/napi/tag/nfc_napi_ndef_message.h b/frameworks/js/napi/tag/nfc_napi_ndef_message.h index 53d32ed4..fdc037c7 100644 --- a/frameworks/js/napi/tag/nfc_napi_ndef_message.h +++ b/frameworks/js/napi/tag/nfc_napi_ndef_message.h @@ -33,6 +33,7 @@ struct NapiNdefMessage { static napi_value MakeTextRecord(napi_env env, napi_callback_info info); static napi_value MakeMimeRecord(napi_env env, napi_callback_info info); static napi_value MakeExternalRecord(napi_env env, napi_callback_info info); + static napi_value MakeApplicationRecord(napi_env env, napi_callback_info info); static napi_value MessageToBytes(napi_env env, napi_callback_info info); std::shared_ptr ndefMessage = nullptr; }; diff --git a/interfaces/inner_api/common/BUILD.gn b/interfaces/inner_api/common/BUILD.gn index 0f174d55..70248b13 100644 --- a/interfaces/inner_api/common/BUILD.gn +++ b/interfaces/inner_api/common/BUILD.gn @@ -61,9 +61,11 @@ ohos_shared_library("nfc_inner_kits_common") { external_deps = [ "ability_base:want", "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", + "samgr:samgr_proxy", ] part_name = "nfc" diff --git a/interfaces/inner_api/common/ndef_message.cpp b/interfaces/inner_api/common/ndef_message.cpp index 66c90272..89cc5515 100644 --- a/interfaces/inner_api/common/ndef_message.cpp +++ b/interfaces/inner_api/common/ndef_message.cpp @@ -163,6 +163,18 @@ std::shared_ptr NdefMessage::MakeExternalRecord(const std::string& d return CreateNdefRecord(TNF_EXTERNAL_TYPE, id, externalData, tagRtdType); } +std::shared_ptr NdefMessage::MakeApplicationRecord(const std::string& packageName) +{ + if (packageName.empty()) { + ErrorLog("MakeApplicationRecord, packageName is null."); + return std::shared_ptr(); + } + + std::string id = ""; + std::string tagRtdType = NfcSdkCommon::StringToHexString(GetTagRtdType(EmRtdType::RTD_OHOS_APP)); + return CreateNdefRecord(TNF_EXTERNAL_TYPE, id, packageName, tagRtdType); +} + std::string NdefMessage::MessageToString(std::weak_ptr ndefMessage) { std::string buffer; diff --git a/interfaces/inner_api/common/ndef_message.h b/interfaces/inner_api/common/ndef_message.h index 810d8ae6..ff327bc9 100644 --- a/interfaces/inner_api/common/ndef_message.h +++ b/interfaces/inner_api/common/ndef_message.h @@ -179,6 +179,14 @@ public: static std::shared_ptr MakeExternalRecord(const std::string& domainName, const std::string& serviceName, const std::string& externalData); + + /** + * @Description Create a ndef record with package name. + * @param packageName package Name of the application + * @return std::shared_ptr + */ + std::shared_ptr NdefMessage::MakeApplicationRecord(const std::string& packageName); + /** * @Description parse a ndef message into raw bytes. * @param ndefMessage a ndef message to parse diff --git a/interfaces/inner_api/common/nfc_sdk_common.cpp b/interfaces/inner_api/common/nfc_sdk_common.cpp index 04b41417..ff26ef52 100644 --- a/interfaces/inner_api/common/nfc_sdk_common.cpp +++ b/interfaces/inner_api/common/nfc_sdk_common.cpp @@ -18,13 +18,15 @@ #include #include #include +#include "bundle_mgr_proxy.h" +#include "iservice_registry.h" #include "loghelper.h" namespace OHOS { namespace NFC { namespace KITS { - +const int BUNDLE_MGR_SERVICE_SYS_ABILITY_ID = 401; bool NfcSdkCommon::IsLittleEndian() { const char LAST_DATA_BYTE = 0x78; @@ -247,6 +249,37 @@ std::string NfcSdkCommon::CodeMiddlePart(const std::string &src) } return res; } + +int NfcSdkCommon::GetSdkVersion(void) +{ + int version = SDK_VERSION_13; + + auto systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!systemAbilityManager) { + ErrorLog("fail to get system ability mgr."); + return version; + } + auto remoteObject = systemAbilityManager->systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); + if (!remoteObject) { + ErrorLog("fail to get bundle manager proxy."); + return version; + } + sptr bundleMgrProxy = iface_cast(remoteObject); + if (bundleMgrProxy == nullptr) { + ErrorLog("failed to get bundle manager proxy."); + return version; + } + AppExecFwk::BundleInfo bundleInfo; + auto flags = AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION; + auto ret = bundleMgrProxy->GetBunInfoForSelt(static_cast(flags), bundleInfo); + if (ret != ERR_OK) { + ErrorLog("GetBunInfoForSelt: get fail."); + return version; + } + + version = bundleInfo.targetversion % 100; // %100 to get the real version + return version; +} } // namespace KITS } // namespace NFC } // namespace OHOS diff --git a/interfaces/inner_api/common/nfc_sdk_common.h b/interfaces/inner_api/common/nfc_sdk_common.h index 159e7636..1625d80e 100644 --- a/interfaces/inner_api/common/nfc_sdk_common.h +++ b/interfaces/inner_api/common/nfc_sdk_common.h @@ -123,6 +123,9 @@ const uint32_t MAX_APDU_DATA_BYTE = 1024; const uint32_t MAX_APDU_DATA_HEX_STR = MAX_APDU_DATA_BYTE * 2; const uint32_t MAX_AID_LIST_NUM_PER_APP = 100; +const static int SDK_VERSION_16 = 16; +const static int SDK_VERSION_13 = 16; + #ifdef VENDOR_APPLICATIONS_ENABLED const int VENDOR_APP_INIT_DONE = 1; const int VENDOR_APP_CHANGE = 2; @@ -193,6 +196,7 @@ public: static uint64_t GetCurrentTime(); static uint64_t GetRelativeTime(); static std::string CodeMiddlePart(const std::string &src); + static int GetSdkVersion(void); }; } // namespace KITS } // namespace NFC diff --git a/interfaces/inner_api/tags/foreground_callback_stub.cpp b/interfaces/inner_api/tags/foreground_callback_stub.cpp index acefd8cd..0397f76f 100644 --- a/interfaces/inner_api/tags/foreground_callback_stub.cpp +++ b/interfaces/inner_api/tags/foreground_callback_stub.cpp @@ -60,7 +60,7 @@ int ForegroundCallbackStub::OnRemoteRequest( { DebugLog("ForegroundCallbackStub::OnRemoteRequest,code = %{public}d", code); if (mRemoteDied) { - return KITS::ERR_NFC_STATE_UNBIND; + return KITS::ERR_TAG_STATE_UNBIND; } if (data.ReadInterfaceToken() != GetDescriptor()) { ErrorLog("nfc callback stub token verification error"); @@ -71,7 +71,7 @@ int ForegroundCallbackStub::OnRemoteRequest( ErrorLog("ForegroundCallbackStub::OnRemoteRequest, got exception: (%{public}d))", exception); return exception; } - int ret = KITS::ERR_NFC_STATE_UNBIND; + int ret = KITS::ERR_TAG_STATE_UNBIND; switch (code) { case static_cast(NfcServiceIpcInterfaceCode::COMMAND_TAG_FOUND_FOREGROUND): { ret = RemoteTagDiscovered(data, reply); diff --git a/interfaces/inner_api/tags/reader_mode_callback_stub.cpp b/interfaces/inner_api/tags/reader_mode_callback_stub.cpp index b0b2945b..d6bda873 100644 --- a/interfaces/inner_api/tags/reader_mode_callback_stub.cpp +++ b/interfaces/inner_api/tags/reader_mode_callback_stub.cpp @@ -60,7 +60,7 @@ int ReaderModeCallbackStub::OnRemoteRequest( { DebugLog("ReaderModeCallbackStub::OnRemoteRequest,code = %{public}d", code); if (mRemoteDied) { - return KITS::ERR_NFC_STATE_UNBIND; + return KITS::ERR_TAG_STATE_UNBIND; } if (data.ReadInterfaceToken() != GetDescriptor()) { ErrorLog("nfc callback stub token verification error"); @@ -71,7 +71,7 @@ int ReaderModeCallbackStub::OnRemoteRequest( ErrorLog("ReaderModeCallbackStub::OnRemoteRequest, got exception: (%{public}d))", exception); return exception; } - int ret = KITS::ERR_NFC_STATE_UNBIND; + int ret = KITS::ERR_TAG_STATE_UNBIND; switch (code) { case static_cast(NfcServiceIpcInterfaceCode::COMMAND_TAG_FOUND_READER_MODE): { ret = RemoteTagDiscovered(data, reply); diff --git a/services/src/ipc/tags/tag_session.cpp b/services/src/ipc/tags/tag_session.cpp index 411db044..ac82b123 100644 --- a/services/src/ipc/tags/tag_session.cpp +++ b/services/src/ipc/tags/tag_session.cpp @@ -58,7 +58,7 @@ int TagSession::Connect(int tagRfDiscId, int technology) } if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("Connect, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("Connect, IsNfcEnabled error"); @@ -66,7 +66,7 @@ int TagSession::Connect(int tagRfDiscId, int technology) } if (!nciTagProxy_.lock()->IsTagFieldOn(tagRfDiscId)) { ErrorLog("Connect, IsTagFieldOn error"); - return NFC::KITS::ErrorCode::ERR_TAG_STATE_LOST; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (nciTagProxy_.lock()->Connect(tagRfDiscId, technology)) { @@ -87,7 +87,7 @@ int TagSession::IsConnected(int tagRfDiscId, bool &isConnected) { if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("Connect, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("Connect, IsNfcEnabled error"); @@ -107,7 +107,7 @@ int TagSession::Reconnect(int tagRfDiscId) // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("Reconnect, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("Reconnect, IsNfcEnabled error"); @@ -145,7 +145,7 @@ int TagSession::SetTimeout(int tagRfDiscId, int timeout, int technology) // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("SetTimeout, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("SetTimeout, IsNfcEnabled error"); @@ -165,7 +165,7 @@ int TagSession::GetTimeout(int tagRfDiscId, int technology, int &timeout) // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("GetTimeout, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("GetTimeout, IsNfcEnabled error"); @@ -246,7 +246,7 @@ int TagSession::SendRawFrame(const int tagRfDiscId, std::string hexCmdData, bool // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("SendRawFrame, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("SendRawFrame, IsNfcEnabled error"); @@ -266,7 +266,7 @@ int TagSession::SendRawFrame(const int tagRfDiscId, std::string hexCmdData, bool return NFC::KITS::ErrorCode::ERR_NONE; } else if (result == 1) { // result == 1 means that Tag lost ErrorLog("TagSession::SendRawFrame: tag lost."); - return NFC::KITS::ErrorCode::ERR_TAG_STATE_LOST; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } ErrorLog("TagSession::SendRawFrame: result failed."); return NFC::KITS::ErrorCode::ERR_TAG_STATE_IO_FAILED; @@ -281,7 +281,7 @@ int TagSession::NdefRead(int tagRfDiscId, std::string &ndefMessage) // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired() || !nfcService_.lock()->IsNfcEnabled()) { ErrorLog("NdefRead, IsTagFieldOn error"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } ndefMessage = nciTagProxy_.lock()->ReadNdef(tagRfDiscId); @@ -298,7 +298,7 @@ int TagSession::NdefWrite(int tagRfDiscId, std::string msg) // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("NdefWrite, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("NdefWrite, IsNfcEnabled error"); @@ -325,7 +325,7 @@ int TagSession::NdefMakeReadOnly(int tagRfDiscId) // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("NdefMakeReadOnly, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("NdefMakeReadOnly, IsNfcEnabled error"); @@ -348,7 +348,7 @@ int TagSession::FormatNdef(int tagRfDiscId, const std::string& key) // Check if NFC is enabled if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("FormatNdef, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (!nfcService_.lock()->IsNfcEnabled()) { ErrorLog("FormatNdef, IsNfcEnabled error"); @@ -365,7 +365,7 @@ int TagSession::CanMakeReadOnly(int ndefType, bool &canSetReadOnly) { if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("CanMakeReadOnly, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } canSetReadOnly = nciTagProxy_.lock()->CanMakeReadOnly(ndefType); return NFC::KITS::ErrorCode::ERR_NONE; @@ -389,7 +389,7 @@ int TagSession::IsSupportedApdusExtended(bool &isSupported) { if (nfcService_.expired() || nciTagProxy_.expired()) { ErrorLog("IsSupportedApdusExtended, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } isSupported = nciTagProxy_.lock()->IsExtendedLengthApduSupported(); return NFC::KITS::ErrorCode::ERR_NONE; @@ -533,7 +533,7 @@ int TagSession::RegForegroundDispatchInner(ElementName &element, const std::vect element.GetBundleName().c_str(), element.GetAbilityName().c_str()); if (nfcPollingManager_.expired()) { ErrorLog("RegForegroundDispatch, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (nfcPollingManager_.lock()->EnableForegroundDispatch(element, discTech, callback)) { ExternalDepsProxy::GetInstance().WriteAppBehaviorHiSysEvent( @@ -581,7 +581,7 @@ int TagSession::UnregForegroundDispatchInner(const ElementName &element, bool is element.GetBundleName().c_str(), element.GetAbilityName().c_str()); if (nfcPollingManager_.expired()) { ErrorLog("UnregForegroundDispatch, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (nfcPollingManager_.lock()->DisableForegroundDispatch(element)) { return KITS::ERR_NONE; @@ -674,7 +674,7 @@ int TagSession::RegReaderModeInner(ElementName &element, std::vector & element.GetBundleName().c_str(), element.GetAbilityName().c_str()); if (nfcPollingManager_.expired()) { ErrorLog("RegReaderModeInner, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (nfcPollingManager_.lock()->EnableReaderMode(element, discTech, callback)) { ExternalDepsProxy::GetInstance().WriteAppBehaviorHiSysEvent( @@ -694,7 +694,7 @@ int TagSession::UnregReaderModeInner(ElementName &element, bool isAppUnregister) element.GetBundleName().c_str(), element.GetAbilityName().c_str()); if (nfcPollingManager_.expired()) { ErrorLog("UnregReaderMode, expired"); - return NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND; + return NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND; } if (nfcPollingManager_.lock()->DisableReaderMode(element)) { return KITS::ERR_NONE; diff --git a/test/unittest/services/services_tags_test/tag_session_test.cpp b/test/unittest/services/services_tags_test/tag_session_test.cpp index 84d33d96..0b36155d 100644 --- a/test/unittest/services/services_tags_test/tag_session_test.cpp +++ b/test/unittest/services/services_tags_test/tag_session_test.cpp @@ -166,7 +166,7 @@ HWTEST_F(TagSessionTest, RegForegroundDispatch001, TestSize.Level1) int tagRfDiscId = TEST_DISC_ID; int result = tagSession->NdefMakeReadOnly(tagRfDiscId); tagSession->RegForegroundDispatch(element, discTech, callback); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: NdefMakeReadOnly001 @@ -179,7 +179,7 @@ HWTEST_F(TagSessionTest, NdefMakeReadOnly001, TestSize.Level1) sptr tagSession = new NFC::TAG::TagSession(service); int tagRfDiscId = TEST_DISC_ID; int result = tagSession->NdefMakeReadOnly(tagRfDiscId); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: NdefMakeReadOnly002 @@ -207,7 +207,7 @@ HWTEST_F(TagSessionTest, NdefWrite001, TestSize.Level1) int tagRfDiscId = TEST_DISC_ID; std::string msg = ""; int result = tagSession->NdefWrite(tagRfDiscId, msg); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: NdefWrite002 @@ -307,7 +307,7 @@ HWTEST_F(TagSessionTest, GetTimeout003, TestSize.Level1) int tagRfDiscId = TEST_DISC_ID; int timeout = 0; int result = tagSession->GetTimeout(tagRfDiscId, technology, timeout); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: GetTimeout004 @@ -381,7 +381,7 @@ HWTEST_F(TagSessionTest, Reconnect001, TestSize.Level1) sptr tagSession = new NFC::TAG::TagSession(service); int tagRfDiscId = TEST_DISC_ID; int result = tagSession->Reconnect(tagRfDiscId); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: Reconnect002 @@ -423,7 +423,7 @@ HWTEST_F(TagSessionTest, Connect002, TestSize.Level1) int tagRfDiscId = TEST_DISC_ID; int technology = 1; int result = tagSession->Connect(tagRfDiscId, technology); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: Connect003 @@ -467,7 +467,7 @@ HWTEST_F(TagSessionTest, SendRawFrame001, TestSize.Level1) bool raw = true; std::string hexRespData = ""; int result = tagSession->SendRawFrame(tagRfDiscId, hexCmdData, raw, hexRespData); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: SendRawFrame002 @@ -498,7 +498,7 @@ HWTEST_F(TagSessionTest, FormatNdef001, TestSize.Level1) int tagRfDiscId = TEST_DISC_ID; const std::string key = ""; int result = tagSession->FormatNdef(tagRfDiscId, key); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: FormatNdef002 @@ -528,7 +528,7 @@ HWTEST_F(TagSessionTest, CanMakeReadOnly001, TestSize.Level1) int ndefType = NDEF_TYPE1_TAG; bool canSetReadOnly = true; int result = tagSession->CanMakeReadOnly(ndefType, canSetReadOnly); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: CanMakeReadOnly002 @@ -557,7 +557,7 @@ HWTEST_F(TagSessionTest, IsSupportedApdusExtended001, TestSize.Level1) sptr tagSession = new NFC::TAG::TagSession(service); bool isSupported = true; int result = tagSession->IsSupportedApdusExtended(isSupported); - ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(result == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** * @tc.name: IsSupportedApdusExtended002 @@ -657,7 +657,7 @@ HWTEST_F(TagSessionTest, IsConnected001, TestSize.Level1) int tagRfDiscId = 0; bool isConnected = false; int ret = tagSession->IsConnected(tagRfDiscId, isConnected); - ASSERT_TRUE(ret == NFC::KITS::ErrorCode::ERR_NFC_STATE_UNBIND); + ASSERT_TRUE(ret == NFC::KITS::ErrorCode::ERR_TAG_STATE_UNBIND); } /** -- Gitee