From ba14ade8c68c085aa6726413df8e5a8792ff884f Mon Sep 17 00:00:00 2001 From: wangzhaohao Date: Sat, 5 Jul 2025 18:23:13 +0800 Subject: [PATCH 01/13] add fuzz Signed-off-by: wangzhaohao --- .../auth_message_processor_fuzzer.cpp | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp b/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp index 84d93153e..9fa37aac6 100644 --- a/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp +++ b/test/servicesfuzztest/authmessageprocessor_fuzzer/auth_message_processor_fuzzer.cpp @@ -70,6 +70,7 @@ void GenerateJsonObject(JsonObject &jsonObject, FuzzedDataProvider &fdp) jsonObject[TAG_DEVICE_VERSION] = fdp.ConsumeRandomLengthString(); jsonObject[TAG_DEVICE_NAME] = fdp.ConsumeRandomLengthString(); jsonObject[TAG_NETWORKID_ID] = fdp.ConsumeRandomLengthString(); + jsonObject[PARAM_KEY_SUBJECT_PROXYED_SUBJECTS] = fdp.ConsumeRandomLengthString(); } void AuthContextFuzzTest(FuzzedDataProvider &fdp) @@ -131,6 +132,52 @@ void AuthMessageProcessorFuzzTestNext(JsonObject &jsonObject) FromJson(jsonObject, sync); } +void AuthMessageProcessorFuzzTestNextTwo(FuzzedDataProvider &fdp, JsonObject &jsonObject) +{ + int32_t userId = fdp.ConsumeIntegral(); + int32_t skId = fdp.ConsumeIntegral(); + std::string suffix = fdp.ConsumeRandomLengthString(); + int64_t tokenId = fdp.ConsumeIntegral(); + DistributedDeviceProfile::AccessControlProfile acl; + DistributedDeviceProfile::Accesser accesser; + DistributedDeviceProfile::Accessee accessee; + acl.SetExtraData(fdp.ConsumeRandomLengthString()); + accesser.SetAccesserExtraData(fdp.ConsumeRandomLengthString()); + accessee.SetAccesseeExtraData(fdp.ConsumeRandomLengthString()); + DmProxyAuthContext dmProxyAuthContext; + dmProxyAuthContext.customData = fdp.ConsumeRandomLengthString(); + context_->IsProxyBind = false; + context_->subjectProxyOnes.clear(); + dmAuthMessageProcessor_->ParseProxyCredExchangeToSync(context_, jsonObject); + context_->IsProxyBind = true; + context_->subjectProxyOnes.emplace_back(dmProxyAuthContext); + dmAuthMessageProcessor_->ParseProxyCredExchangeToSync(context_, jsonObject); + dmAuthMessageProcessor_->CreateProxyNegotiateMessage(context_, jsonObject); + dmAuthMessageProcessor_->CreateProxyRespNegotiateMessage(context_, jsonObject); + dmAuthMessageProcessor_->CreateProxyCredExchangeMessage(context_, jsonObject); + dmAuthMessageProcessor_->ParseProxyAccessToSync(context_, jsonObject); + dmAuthMessageProcessor_->ParseProxyNegotiateMessage(jsonObject, context_); + context_->accessee.dmVersion = DM_VERSION_5_1_0; + dmAuthMessageProcessor_->ParseMessageProxyRespAclNegotiate(jsonObject, context_); + context_->accessee.dmVersion = DM_VERSION_5_1_1; + dmAuthMessageProcessor_->ParseMessageProxyRespAclNegotiate(jsonObject, context_); + dmAuthMessageProcessor_->ParseMessageProxyReqUserConfirm(jsonObject, context_); + dmAuthMessageProcessor_->ParseMessageProxyRespUserConfirm(jsonObject, context_); + dmAuthMessageProcessor_->CreateMessageProxyReqUserConfirm(context_, jsonObject); + dmAuthMessageProcessor_->CreateProxyAccessMessage(context_, jsonObject); + dmAuthMessageProcessor_->cryptoMgr_ = std::make_shared(); + dmAuthMessageProcessor_->SaveDerivativeSessionKeyToDP(userId, suffix, skId); + dmAuthMessageProcessor_->GetSessionKey(userId, skId); + context_->accesser.extraInfo = ""; + dmAuthMessageProcessor_->SetProxyAccess(context_, dmProxyAuthContext, accesser, accessee); + dmAuthMessageProcessor_->PutProxyAccessControlList(context_, acl, accesser, accessee); + dmAuthMessageProcessor_->IsExistTheToken(jsonObject, tokenId); + dmAuthMessageProcessor_->SetAclProxyRelate(context_); + acl.accesser_.SetAccesserExtraData(""); + acl.accessee_.SetAccesseeExtraData(""); + dmAuthMessageProcessor_->SetAclProxyRelate(context_, acl); +} + void AuthMessageProcessorFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { @@ -178,6 +225,7 @@ void AuthMessageProcessorFuzzTest(const uint8_t* data, size_t size) dmAuthMessageProcessor_ -> SetTransmitAccessControlList(context_, accesser, accessee); dmAuthMessageProcessor_ -> SetLnnAccessControlList(context_, accesser, accessee); AuthMessageProcessorFuzzTestNext(jsonObject); + AuthMessageProcessorFuzzTestNextTwo(fdp, jsonObject); AuthContextFuzzTest(fdp); } } -- Gitee From 1219fb27c05ccf2ea2f01aeac8b71920dd87219a Mon Sep 17 00:00:00 2001 From: wangbaidong Date: Sat, 5 Jul 2025 20:01:52 +0800 Subject: [PATCH 02/13] add fuzz Signed-off-by: wangbaidong --- .../authcredential_fuzzer/BUILD.gn | 1 + .../auth_credential_fuzzer.cpp | 51 +++++++++++++++++++ .../dm_negotiate_process_fuzzer.cpp | 44 ++++++++++++++++ .../auth_manager_fuzzer.cpp | 46 +++++++++++++++++ 4 files changed, 142 insertions(+) diff --git a/test/commonfuzztest/authcredential_fuzzer/BUILD.gn b/test/commonfuzztest/authcredential_fuzzer/BUILD.gn index 5928e20dd..95b5069e4 100644 --- a/test/commonfuzztest/authcredential_fuzzer/BUILD.gn +++ b/test/commonfuzztest/authcredential_fuzzer/BUILD.gn @@ -46,6 +46,7 @@ ohos_fuzztest("AuthCredentialFuzzTest") { deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", + "${json_path}:devicemanagerjson", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutilstest", diff --git a/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp b/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp index df8f7027a..9e258bf0b 100644 --- a/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp +++ b/test/commonfuzztest/authcredential_fuzzer/auth_credential_fuzzer.cpp @@ -19,6 +19,7 @@ #include #include "device_manager_service_listener.h" +#include "dm_auth_message_processor.h" #include "dm_auth_state.h" #include "dm_freeze_process.h" @@ -26,6 +27,53 @@ namespace OHOS { namespace DistributedHardware { constexpr uint32_t SERVICE = 2; +void DerivativeSessionKeyFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::shared_ptr context = std::make_shared(); + context->IsProxyBind = true; + context->accesser.userId = fdp.ConsumeIntegral(); + context->accesser.transmitSessionKeyId = fdp.ConsumeIntegral(); + DmProxyAuthContext dmProxyAuthContext; + context->subjectProxyOnes.push_back(dmProxyAuthContext); + std::shared_ptr authPtr = std::make_shared(); + context->authMessageProcessor = std::make_shared(); + authPtr->DerivativeSessionKey(context); +} + +void DerivativeProxySessionKeyFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::shared_ptr context = std::make_shared(); + context->reUseCreId = fdp.ConsumeRandomLengthString(); + context->IsProxyBind = true; + context->accesser.isAuthed = true; + context->accesser.deviceIdHash = fdp.ConsumeRandomLengthString(); + context->accessee.deviceIdHash = fdp.ConsumeRandomLengthString(); + context->accesser.tokenIdHash = fdp.ConsumeRandomLengthString(); + context->accessee.tokenIdHash = fdp.ConsumeRandomLengthString(); + context->accesser.userId = fdp.ConsumeIntegral(); + context->accesser.transmitSkTimeStamp = fdp.ConsumeIntegral(); + context->accesser.transmitSessionKeyId = fdp.ConsumeIntegral(); + context->authMessageProcessor = std::make_shared(); + DmProxyAuthContext dmProxyAuthContext; + context->subjectProxyOnes.push_back(dmProxyAuthContext); + std::shared_ptr authSrcPtr = std::make_shared(); + authSrcPtr->DerivativeProxySessionKey(context); + std::shared_ptr authSinkPtr = + std::make_shared(); + authSinkPtr->DerivativeSessionKey(context); + std::shared_ptr authCrePtr = std::make_shared(); + JsonObject jsonObject; + authCrePtr->GenerateTokenIds(context, jsonObject); +} + void AuthCredentialFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { @@ -59,6 +107,9 @@ void AuthCredentialFuzzTest(const uint8_t* data, size_t size) authForth->GetStateType(); authFifth->GetStateType(); authSixth->GetStateType(); + + DerivativeSessionKeyFuzzTest(data, size); + DerivativeProxySessionKeyFuzzTest(data, size); } } } diff --git a/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp b/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp index 4a4bd8d94..51c8eb047 100644 --- a/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp +++ b/test/commonfuzztest/dmnegotiateprocess_fuzzer/dm_negotiate_process_fuzzer.cpp @@ -19,11 +19,52 @@ #include #include "device_manager_service_listener.h" +#include "dm_auth_state.h" #include "dm_negotiate_process.h" namespace OHOS { namespace DistributedHardware { +void RespQueryProxyAcceseeIdsFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::shared_ptr context = std::make_shared(); + context->IsProxyBind = true; + context->accessee.userId = fdp.ConsumeIntegral(); + DmProxyAuthContext dmProxyAuthContext; + dmProxyAuthContext.proxyAccessee.bundleName = fdp.ConsumeRandomLengthString(); + dmProxyAuthContext.proxyAccessee.tokenId = fdp.ConsumeIntegral(); + context->subjectProxyOnes.push_back(dmProxyAuthContext); + std::shared_ptr authSinkPtr = std::make_shared(); + authSinkPtr->RespQueryProxyAcceseeIds(context); +} + +void GetSinkProxyCredTypeForP2PFuzzTest(const uint8_t* data, size_t size) +{ + if ((data == nullptr) || (size < sizeof(int32_t))) { + return; + } + FuzzedDataProvider fdp(data, size); + std::shared_ptr context = std::make_shared(); + context->IsProxyBind = true; + context->accessee.userId = fdp.ConsumeIntegral(); + DmProxyAuthContext dmProxyAuthContext; + dmProxyAuthContext.proxyAccessee.bundleName = fdp.ConsumeRandomLengthString(); + dmProxyAuthContext.proxyAccessee.tokenId = fdp.ConsumeIntegral(); + dmProxyAuthContext.proxyAccessee.credInfoJson = fdp.ConsumeRandomLengthString(); + dmProxyAuthContext.proxyAccessee.aclTypeList = fdp.ConsumeRandomLengthString(); + dmProxyAuthContext.proxyAccessee.credTypeList = fdp.ConsumeRandomLengthString(); + context->subjectProxyOnes.push_back(dmProxyAuthContext); + std::shared_ptr authSinkPtr = std::make_shared(); + std::vector deleteCredInfo; + authSinkPtr->GetSinkProxyCredTypeForP2P(context, deleteCredInfo); + DistributedDeviceProfile::AccessControlProfile profile; + authSinkPtr->GetSinkProxyAclInfoForP2P(context, profile); +} + void DmNegotiateProcessFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < sizeof(int32_t))) { @@ -66,6 +107,9 @@ void DmNegotiateProcessFuzzTest(const uint8_t* data, size_t size) p2pCredP2pAclImportAuthType.NegotiateHandle(context); P2pCredP2pAclInputAuthType p2pCredP2pAclInputAuthType; p2pCredP2pAclInputAuthType.NegotiateHandle(context); + + RespQueryProxyAcceseeIdsFuzzTest(data, size); + GetSinkProxyCredTypeForP2PFuzzTest(data, size); } } // namespace DistributedHardware } // namespace OHOS diff --git a/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp b/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp index 594728573..7adab1c32 100644 --- a/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp +++ b/test/servicesfuzztest/authmanager_fuzzer/auth_manager_fuzzer.cpp @@ -376,6 +376,49 @@ void HandleBusinessEventsFuzzTest(FuzzedDataProvider &fdp) authManager->PrepareSoftbusSessionCallback(); } +void CheckProxyAuthParamVaildFuzzTest(FuzzedDataProvider &fdp) +{ + std::string extra = fdp.ConsumeRandomLengthString(); + authManager->CheckProxyAuthParamVaild(extra); + + JsonObject jsonObject; + jsonObject[PARAM_KEY_IS_PROXY_BIND] = "true"; + std::string bundleNameDemoA = "com.ohos.devicemanagerdemoA"; + std::string bundleNameDemoGame = "com.game.gamenearbydemo"; + JsonObject jsonA; + jsonA["pakgName"] = bundleNameDemoA; + jsonA["bundleName"] = bundleNameDemoA; + + JsonObject jsonGame; + jsonGame["pakgName"] = bundleNameDemoGame; + jsonGame["bundleName"] = bundleNameDemoGame; + + JsonObject subJsonArr(JsonCreateType::JSON_CREATE_TYPE_ARRAY); + subJsonArr.PushBack(jsonA); + subJsonArr.PushBack(jsonGame); + jsonObject[PARAM_KEY_SUBJECT_PROXYED_SUBJECTS] = subJsonArr.Dump(); + std::string extra1 = jsonObject.Dump(); + authManager->CheckProxyAuthParamVaild(extra1); + authManager->ParseProxyJsonObject(jsonObject); +} + +void ParseProxyJsonObjectFuzzTest(FuzzedDataProvider &fdp) +{ + JsonObject jsonObject; + jsonObject[PARAM_KEY_IS_PROXY_BIND] = fdp.ConsumeRandomLengthString(); + jsonObject[PARAM_KEY_IS_CALLING_PROXY_AS_SUBJECT] = fdp.ConsumeRandomLengthString(); + jsonObject[PARAM_KEY_SUBJECT_PROXYED_SUBJECTS] = fdp.ConsumeRandomLengthString(); + authManager->ParseProxyJsonObject(jsonObject); +} + +void GetBindLevelByBundleNameFuzzTest(FuzzedDataProvider &fdp) +{ + std::string bundleName = fdp.ConsumeRandomLengthString(); + int32_t requestId = fdp.ConsumeIntegral(); + int32_t bindLevel = 0; + authManager->GetBindLevelByBundleName(bundleName, requestId, bindLevel); +} + void AuthManagerFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size == 0)) { @@ -422,6 +465,9 @@ void AuthManagerFuzzTest(const uint8_t* data, size_t size) AuthSinkDeviceSessionKeyFuzzTest(fdp); AuthSinkDeviceRequestFuzzTest(fdp); HandleBusinessEventsFuzzTest(fdp); + CheckProxyAuthParamVaildFuzzTest(fdp); + ParseProxyJsonObjectFuzzTest(fdp); + GetBindLevelByBundleNameFuzzTest(fdp); } } } -- Gitee From 9019224ccde87bafc61c1fe0683f7161c24db1bc Mon Sep 17 00:00:00 2001 From: l30054665 Date: Sun, 6 Jul 2025 18:31:58 +0800 Subject: [PATCH 03/13] fuzz Signed-off-by: l30054665 --- test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp | 1 + test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp index 0b1103234..ade8df988 100644 --- a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp +++ b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp @@ -45,6 +45,7 @@ void AuthAclFuzzTest(const uint8_t* data, size_t size) context->accesser.isCommonFlag = false; authSink->VerifyCertificate(context); authSink->VerifyCertificate(nullptr); + } } } diff --git a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp index a60faf0ed..544025b0b 100644 --- a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp +++ b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp @@ -215,6 +215,7 @@ void AuthConfirmFuzzTestThird(FuzzedDataProvider &fdp) authSinkForwardUltrasonicDoneState_->GetStateType(); authSrcPinNegotiateStartState_->ProcessCredAuth(context_); int32_t credType = fdp.ConsumeIntegral(); + authSrcPinNegotiateStartState_->GetCredIdByCredType(context_, credType); } -- Gitee From 7112a525d0d3f360e7b54e47267c949f77711ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Sun, 6 Jul 2025 10:34:24 +0000 Subject: [PATCH 04/13] update test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp index ade8df988..52dab3e6c 100644 --- a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp +++ b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp @@ -32,6 +32,7 @@ void AuthAclFuzzTest(const uint8_t* data, size_t size) FuzzedDataProvider fdp(data, size); int32_t sessionId = fdp.ConsumeIntegral(); std::string result = fdp.ConsumeRandomLengthString(); + std::string peerDeviceId = fdp.ConsumeRandomLengthString(); std::shared_ptr authSink = std::make_shared(); std::shared_ptr authSrc = std::make_shared(); @@ -45,7 +46,8 @@ void AuthAclFuzzTest(const uint8_t* data, size_t size) context->accesser.isCommonFlag = false; authSink->VerifyCertificate(context); authSink->VerifyCertificate(nullptr); - + authSink->DerivativeSessionKey(context); + authSrc->GetPeerDeviceId(context, peerDeviceId); } } } -- Gitee From 9685fe40225f290b8170f85996a5e17ceb4c6e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Sun, 6 Jul 2025 10:35:08 +0000 Subject: [PATCH 05/13] update test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- .../authconfirm_fuzzer/auth_confirm_fuzzer.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp index 544025b0b..0418c112a 100644 --- a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp +++ b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp @@ -165,6 +165,7 @@ void AuthConfirmFuzzTestNext(JsonObject &jsonObject, FuzzedDataProvider &fdp) authSrcConfirmState_->GetIdenticalCredentialInfo(context_, jsonObject); authSrcConfirmState_->GetShareCredentialInfo(context_, jsonObject); authSrcConfirmState_->GetP2PCredentialInfo(context_, jsonObject); + authSinkConfirmState_->CreateProxyData(context_, jsonObject); authSinkConfirmState_->NegotiateCredential(context_, jsonObject); authSinkConfirmState_->NegotiateAcl(context_, jsonObject); authSinkNegotiateStateMachine_->GetIdenticalCredentialInfo(context_, jsonObject); @@ -200,6 +201,9 @@ void AuthConfirmFuzzTestThird(FuzzedDataProvider &fdp) { std::string businessId = fdp.ConsumeRandomLengthString(); std::string businessValue = fdp.ConsumeRandomLengthString(); + std::string authorizeInfo = fdp.ConsumeRandomLengthString(); + std::vector deleteCredInfo; + DistributedDeviceProfile::AccessControlProfile acl; authSinkNegotiateStateMachine_->IsAntiDisturbanceMode(businessId); authSinkNegotiateStateMachine_->IsAntiDisturbanceMode(""); authSinkNegotiateStateMachine_->ParseAndCheckAntiDisturbanceMode(businessId, businessValue); @@ -215,8 +219,18 @@ void AuthConfirmFuzzTestThird(FuzzedDataProvider &fdp) authSinkForwardUltrasonicDoneState_->GetStateType(); authSrcPinNegotiateStartState_->ProcessCredAuth(context_); int32_t credType = fdp.ConsumeIntegral(); - authSrcPinNegotiateStartState_->GetCredIdByCredType(context_, credType); + authSrcConfirmState_->NegotiateProxyCredential(context_); + authSrcConfirmState_->NegotiateProxyAcl(context_); + authSrcConfirmState_->ResetBindLevel(context_); + authSinkConfirmState_->GetBundleLabel(context_); + authSinkConfirmState_->NegotiateProxyAcl(context_); + authSinkConfirmState_->ProcessUserAuthorize(context_); + authSinkConfirmState_->ProcessServerAuthorize(context_); + authSinkConfirmState_->NegotiateProxyCredential(context_); + authSrcConfirmState_->GetSrcProxyCredTypeForP2P(context_, deleteCredInfo); + authSinkConfirmState_->ProcessUserOption(context_, authorizeInfo); + authSrcConfirmState_->GetSrcProxyAclInfoForP2P(context_, acl); } void AuthConfirmFuzzTest(const uint8_t* data, size_t size) -- Gitee From 8d31ee95e203b0dfe056002f5969550361891859 Mon Sep 17 00:00:00 2001 From: daiyunlong Date: Sun, 6 Jul 2025 20:30:43 +0800 Subject: [PATCH 06/13] =?UTF-8?q?13/14/68=E6=8E=A5=E5=8F=A3cppcrash?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: daiyunlong --- .../service/src/ipc/standard/ipc_server_stub.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/service/src/ipc/standard/ipc_server_stub.cpp b/services/service/src/ipc/standard/ipc_server_stub.cpp index c85383af7..a971dd983 100644 --- a/services/service/src/ipc/standard/ipc_server_stub.cpp +++ b/services/service/src/ipc/standard/ipc_server_stub.cpp @@ -16,6 +16,7 @@ #include "ipc_server_stub.h" #include +#include #include "ipc_cmd_register.h" #include "ipc_skeleton.h" @@ -44,6 +45,15 @@ namespace OHOS { namespace DistributedHardware { +namespace { +const std::unordered_set CLIENT_CODE { SERVER_DEVICE_STATE_NOTIFY, SERVER_DEVICE_FOUND, BIND_TARGET_RESULT, +SERVER_DEVICE_DISCOVERY, SERVER_PUBLISH_FINISH, SERVER_AUTH_RESULT, SERVER_DEVICE_FA_NOTIFY, SERVER_CREDENTIAL_RESULT, +SERVER_CREATE_PIN_HOLDER, SERVER_DESTROY_PIN_HOLDER, SERVER_CREATE_PIN_HOLDER_RESULT, SERVER_DESTROY_PIN_HOLDER_RESULT, +SERVER_ON_PIN_HOLDER_EVENT, UNBIND_TARGET_RESULT, REMOTE_DEVICE_TRUST_CHANGE, SERVER_DEVICE_SCREEN_STATE_NOTIFY, +SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY, SINK_BIND_TARGET_RESULT, GET_DEVICE_PROFILE_INFO_LIST_RESULT, +GET_DEVICE_ICON_INFO_RESULT, SET_LOCAL_DEVICE_NAME_RESULT, SET_REMOTE_DEVICE_NAME_RESULT }; +} + DM_IMPLEMENT_SINGLE_INSTANCE(IpcServerStub); const bool REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(&IpcServerStub::GetInstance()); @@ -242,6 +252,9 @@ void IpcServerStub::OnStop() int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + if (CLIENT_CODE.find(code) != CLIENT_CODE.end()) { + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } auto remoteDescriptor = data.ReadInterfaceToken(); if (GetDescriptor() != remoteDescriptor) { LOGI("ReadInterfaceToken fail!"); -- Gitee From 2ed14f3586d91a66fb6e05c3c1410da625af98eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Mon, 7 Jul 2025 02:58:36 +0000 Subject: [PATCH 07/13] update test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp index 52dab3e6c..f04209748 100644 --- a/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp +++ b/test/commonfuzztest/authacl_fuzzer/auth_acl_fuzzer.cpp @@ -46,6 +46,7 @@ void AuthAclFuzzTest(const uint8_t* data, size_t size) context->accesser.isCommonFlag = false; authSink->VerifyCertificate(context); authSink->VerifyCertificate(nullptr); + context->IsProxyBind = true; authSink->DerivativeSessionKey(context); authSrc->GetPeerDeviceId(context, peerDeviceId); } -- Gitee From a60efa86533529dfa98e9baef36f8d60c61882ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=9A?= Date: Mon, 7 Jul 2025 02:59:10 +0000 Subject: [PATCH 08/13] update test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李尚 --- test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp index 0418c112a..0571eab22 100644 --- a/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp +++ b/test/servicesfuzztest/authconfirm_fuzzer/auth_confirm_fuzzer.cpp @@ -220,6 +220,7 @@ void AuthConfirmFuzzTestThird(FuzzedDataProvider &fdp) authSrcPinNegotiateStartState_->ProcessCredAuth(context_); int32_t credType = fdp.ConsumeIntegral(); authSrcPinNegotiateStartState_->GetCredIdByCredType(context_, credType); + context_->IsProxyBind = true; authSrcConfirmState_->NegotiateProxyCredential(context_); authSrcConfirmState_->NegotiateProxyAcl(context_); authSrcConfirmState_->ResetBindLevel(context_); -- Gitee From 3ee991309fb44357687b9a03443fb20796d3138f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 7 Jul 2025 11:22:06 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E6=8C=87=E9=92=88=E7=BD=AE=E7=A9=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- interfaces/kits/js/src/native_devicemanager_js.cpp | 6 +++--- interfaces/kits/js4.0/src/native_devicemanager_js.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 633b02b6b..2eb015b6c 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -207,7 +207,7 @@ napi_value CreateBusinessError(napi_env env, int32_t errCode, bool isAsync = tru return error; } -void DeleteUvWork(uv_work_t *work) +void DeleteUvWork(uv_work_t *&work) { if (work == nullptr) { return; @@ -217,7 +217,7 @@ void DeleteUvWork(uv_work_t *work) LOGI("delete work!"); } -void DeleteDmNapiStateJsCallbackPtr(DmNapiStateJsCallback *pJsCallbackPtr) +void DeleteDmNapiStateJsCallbackPtr(DmNapiStateJsCallback *&pJsCallbackPtr) { if (pJsCallbackPtr == nullptr) { return; @@ -227,7 +227,7 @@ void DeleteDmNapiStateJsCallbackPtr(DmNapiStateJsCallback *pJsCallbackPtr) LOGI("delete DmNapiStateJsCallback callbackPtr!"); } -void DeleteAsyncCallbackInfo(DeviceInfoListAsyncCallbackInfo *pAsynCallbackInfo) +void DeleteAsyncCallbackInfo(DeviceInfoListAsyncCallbackInfo *&pAsynCallbackInfo) { if (pAsynCallbackInfo == nullptr) { return; diff --git a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp index 005d39c8a..2aa78c1ab 100644 --- a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp @@ -86,7 +86,7 @@ std::mutex g_authCallbackMapMutex; std::mutex g_bindCallbackMapMutex; std::mutex g_dmUiCallbackMapMutex; -void DeleteUvWork(uv_work_t *work) +void DeleteUvWork(uv_work_t *&work) { if (work == nullptr) { return; @@ -96,7 +96,7 @@ void DeleteUvWork(uv_work_t *work) LOGI("delete work!"); } -void DeleteDmNapiStatusJsCallbackPtr(DmNapiStatusJsCallback *pJsCallbackPtr) +void DeleteDmNapiStatusJsCallbackPtr(DmNapiStatusJsCallback *&pJsCallbackPtr) { if (pJsCallbackPtr == nullptr) { return; @@ -106,7 +106,7 @@ void DeleteDmNapiStatusJsCallbackPtr(DmNapiStatusJsCallback *pJsCallbackPtr) LOGI("delete DmNapiStatusJsCallback callbackPtr!"); } -void DeleteAsyncCallbackInfo(DeviceBasicInfoListAsyncCallbackInfo *pAsynCallbackInfo) +void DeleteAsyncCallbackInfo(DeviceBasicInfoListAsyncCallbackInfo *&pAsynCallbackInfo) { if (pAsynCallbackInfo == nullptr) { return; -- Gitee From 4717309e28813714080d053728859fdfb6707503 Mon Sep 17 00:00:00 2001 From: daiyunlong Date: Sun, 6 Jul 2025 20:30:43 +0800 Subject: [PATCH 10/13] =?UTF-8?q?13/14/68=E6=8E=A5=E5=8F=A3cppcrash?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: daiyunlong --- .../service/src/ipc/standard/ipc_server_stub.cpp | 13 +++++++++++++ test/unittest/UTTest_ipc_server_stub.cpp | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/services/service/src/ipc/standard/ipc_server_stub.cpp b/services/service/src/ipc/standard/ipc_server_stub.cpp index c85383af7..a971dd983 100644 --- a/services/service/src/ipc/standard/ipc_server_stub.cpp +++ b/services/service/src/ipc/standard/ipc_server_stub.cpp @@ -16,6 +16,7 @@ #include "ipc_server_stub.h" #include +#include #include "ipc_cmd_register.h" #include "ipc_skeleton.h" @@ -44,6 +45,15 @@ namespace OHOS { namespace DistributedHardware { +namespace { +const std::unordered_set CLIENT_CODE { SERVER_DEVICE_STATE_NOTIFY, SERVER_DEVICE_FOUND, BIND_TARGET_RESULT, +SERVER_DEVICE_DISCOVERY, SERVER_PUBLISH_FINISH, SERVER_AUTH_RESULT, SERVER_DEVICE_FA_NOTIFY, SERVER_CREDENTIAL_RESULT, +SERVER_CREATE_PIN_HOLDER, SERVER_DESTROY_PIN_HOLDER, SERVER_CREATE_PIN_HOLDER_RESULT, SERVER_DESTROY_PIN_HOLDER_RESULT, +SERVER_ON_PIN_HOLDER_EVENT, UNBIND_TARGET_RESULT, REMOTE_DEVICE_TRUST_CHANGE, SERVER_DEVICE_SCREEN_STATE_NOTIFY, +SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY, SINK_BIND_TARGET_RESULT, GET_DEVICE_PROFILE_INFO_LIST_RESULT, +GET_DEVICE_ICON_INFO_RESULT, SET_LOCAL_DEVICE_NAME_RESULT, SET_REMOTE_DEVICE_NAME_RESULT }; +} + DM_IMPLEMENT_SINGLE_INSTANCE(IpcServerStub); const bool REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(&IpcServerStub::GetInstance()); @@ -242,6 +252,9 @@ void IpcServerStub::OnStop() int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + if (CLIENT_CODE.find(code) != CLIENT_CODE.end()) { + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } auto remoteDescriptor = data.ReadInterfaceToken(); if (GetDescriptor() != remoteDescriptor) { LOGI("ReadInterfaceToken fail!"); diff --git a/test/unittest/UTTest_ipc_server_stub.cpp b/test/unittest/UTTest_ipc_server_stub.cpp index 67f91bd30..adc33ab53 100644 --- a/test/unittest/UTTest_ipc_server_stub.cpp +++ b/test/unittest/UTTest_ipc_server_stub.cpp @@ -159,8 +159,8 @@ HWTEST_F(IpcServerStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) int ret = 0; // 2. Call IpcServerStub OnRemoteRequest with param ret = IpcServerStub::GetInstance().OnRemoteRequest(code, data, reply, option); - // 3. check ret not ERR_DM_IPC_READ_FAILED - ASSERT_EQ(ret, ERR_DM_IPC_READ_FAILED); + // 3. check ret not DM_OK + ASSERT_NE(ret, DM_OK); } /** -- Gitee From 14ce5a6d28dad48b8d67dcf8ba75cc8f08eb0581 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Mon, 7 Jul 2025 10:28:59 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=80=BB=E7=BA=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gaoqiang_strong --- .../include/i_dm_service_impl_ext.h | 1 + .../include/i_dm_service_impl_ext_resident.h | 1 + .../idevice_manager_service_listener.h | 1 + .../dependency/softbus/softbus_session.h | 7 ----- .../src/authentication/dm_auth_manager.cpp | 3 ++- .../dependency/softbus/softbus_session.cpp | 26 ------------------- .../src/device_manager_service_impl.cpp | 4 +-- .../service/include/device_manager_service.h | 1 + .../include/device_manager_service_listener.h | 1 + .../service/src/device_manager_service.cpp | 9 +++++++ .../src/device_manager_service_listener.cpp | 11 ++++++++ .../softbus_session_fuzzer.cpp | 2 -- .../UTTest_device_manager_service.cpp | 9 +++++++ ...UTTest_device_manager_service_listener.cpp | 10 +++++++ test/unittest/UTTest_dm_pin_holder.h | 8 ++++++ test/unittest/mock/softbus_session_mock.cpp | 5 ---- test/unittest/mock/softbus_session_mock.h | 2 -- 17 files changed, 56 insertions(+), 45 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext.h b/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext.h index b93d073e4..cb4bb85bc 100644 --- a/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext.h +++ b/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext.h @@ -106,6 +106,7 @@ public: virtual void OnSessionOpened(int32_t sessionId, int32_t sessionSide, int32_t result) = 0; virtual void OnSessionClosed(const int32_t sessionId) = 0; virtual void OnBytesReceived(const int32_t sessionId, const std::string message) = 0; + virtual int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) = 0; }; using CreateDMServiceImplExtFuncPtr = IDMServiceImplExt *(*)(void); diff --git a/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext_resident.h b/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext_resident.h index 0b9578252..3211cd8c2 100644 --- a/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext_resident.h +++ b/interfaces/inner_kits/native_cpp/include/i_dm_service_impl_ext_resident.h @@ -111,6 +111,7 @@ public: virtual int32_t RestoreLocalDeviceName() = 0; virtual void ClearCacheWhenLogout(int32_t userId, const std::string &oldAccountId) = 0; virtual void HandleScreenLockEvent(bool isLock) = 0; + virtual int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) = 0; }; using CreateDMServiceExtResidentFuncPtr = IDMServiceImplExtResident *(*)(void); diff --git a/interfaces/inner_kits/native_cpp/include/idevice_manager_service_listener.h b/interfaces/inner_kits/native_cpp/include/idevice_manager_service_listener.h index cc7a97ace..336c5b631 100644 --- a/interfaces/inner_kits/native_cpp/include/idevice_manager_service_listener.h +++ b/interfaces/inner_kits/native_cpp/include/idevice_manager_service_listener.h @@ -176,6 +176,7 @@ public: virtual void SetExistPkgName(const std::set &pkgNameSet) = 0; virtual std::string GetLocalDisplayDeviceName() = 0; + virtual int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) = 0; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/include/dependency/softbus/softbus_session.h b/services/implementation/include/dependency/softbus/softbus_session.h index b3dfc2840..aaa548f36 100644 --- a/services/implementation/include/dependency/softbus/softbus_session.h +++ b/services/implementation/include/dependency/softbus/softbus_session.h @@ -59,13 +59,6 @@ public: */ int32_t OpenAuthSession(const std::string &deviceId); - /** - * @tc.name: SoftbusSession::OpenAuthSessionWithPara - * @tc.desc: Open HML AuthSession of the Softbus Session - * @tc.type: FUNC - */ - int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m); - /** * @tc.name: SoftbusSession::CloseAuthSession * @tc.desc: Close AuthSession of the Softbus Session diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index ded639356..60f51ac5c 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -868,10 +868,11 @@ int32_t DmAuthManager::EstablishAuthChannel(const std::string &deviceId) int32_t sessionId = 0; if (IsHmlSessionType()) { CHECK_NULL_RETURN(authRequestContext_, ERR_DM_FAILED); + CHECK_NULL_RETURN(listener_, ERR_DM_FAILED); LOGI("hmlActionId %{public}d, hmlReleaseTime %{public}d, hmlEnable160M %{public}d", authRequestContext_->hmlActionId, authRequestContext_->closeSessionDelaySeconds, authRequestContext_->hmlEnable160M); - sessionId = softbusConnector_->GetSoftbusSession()->OpenAuthSessionWithPara(deviceId, + sessionId = listener_->OpenAuthSessionWithPara(deviceId, authRequestContext_->hmlActionId, authRequestContext_->hmlEnable160M); } else { sessionId = softbusConnector_->GetSoftbusSession()->OpenAuthSession(deviceId); diff --git a/services/implementation/src/dependency/softbus/softbus_session.cpp b/services/implementation/src/dependency/softbus/softbus_session.cpp index 056eb4044..1563f8b86 100644 --- a/services/implementation/src/dependency/softbus/softbus_session.cpp +++ b/services/implementation/src/dependency/softbus/softbus_session.cpp @@ -23,9 +23,6 @@ #include "json_object.h" #include "softbus_connector.h" #include "softbus_error_code.h" -#ifndef DEVICE_MANAGER_COMMON_FLAG -#include "session_ex.h" -#endif namespace OHOS { namespace DistributedHardware { @@ -75,29 +72,6 @@ int32_t SoftbusSession::OpenAuthSession(const std::string &deviceId) return sessionId; } -int32_t SoftbusSession::OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) -{ -#ifdef DEVICE_MANAGER_COMMON_FLAG - LOGE("[SOFTBUS] OpenAuthSessionWithPara no implement"); - return SOFTBUS_NOT_IMPLEMENT; -#else - DmTraceStart(std::string(DM_HITRACE_AUTH_TO_OPPEN_SESSION)); - LinkPara para; - para.type = PARA_ACTION; - para.action.actionId = static_cast(actionId); - para.enable160M = isEnable160m; - para.accountInfo = false; - int32_t sessionId = ::OpenAuthSessionWithPara(DM_SESSION_NAME, ¶); - if (sessionId < 0) { - LOGE("[SOFTBUS]open session error, sessionId: %{public}d.", sessionId); - return sessionId; - } - DmTraceEnd(); - LOGI("OpenAuthSessionWithPara success. sessionId: %{public}d.", sessionId); - return sessionId; -#endif -} - int32_t SoftbusSession::CloseAuthSession(int32_t sessionId) { LOGI("CloseAuthSession."); diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 370064b1d..36dccf96a 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -1529,8 +1529,8 @@ int DeviceManagerServiceImpl::OpenAuthSession(const std::string& deviceId, return ret; } LOGI("hmlActionId %{public}d, hmlEnable160M %{public}d", hmlActionId, hmlEnable160M); - return softbusConnector_->GetSoftbusSession()->OpenAuthSessionWithPara(deviceId, - hmlActionId, hmlEnable160M); + CHECK_NULL_RETURN(listener_, ERR_DM_FAILED); + return listener_->OpenAuthSessionWithPara(deviceId, hmlActionId, hmlEnable160M); } else { return softbusConnector_->GetSoftbusSession()->OpenAuthSession(deviceId); } diff --git a/services/service/include/device_manager_service.h b/services/service/include/device_manager_service.h index 4ac7e9d87..70c27f371 100644 --- a/services/service/include/device_manager_service.h +++ b/services/service/include/device_manager_service.h @@ -258,6 +258,7 @@ public: int32_t GetDeviceNetworkIdList(const std::string &pkgName, const NetworkIdQueryFilter &queryFilter, std::vector &networkIds); void ProcessSyncAccountLogout(const std::string &accountId, const std::string &peerUdid, int32_t userId); + int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m); int32_t UnRegisterPinHolderCallback(const std::string &pkgName); void ProcessReceiveRspAppUninstall(const std::string &remoteUdid); void ProcessReceiveRspAppUnbind(const std::string &remoteUdid); diff --git a/services/service/include/device_manager_service_listener.h b/services/service/include/device_manager_service_listener.h index c6b9128b6..216835016 100644 --- a/services/service/include/device_manager_service_listener.h +++ b/services/service/include/device_manager_service_listener.h @@ -92,6 +92,7 @@ public: void SetExistPkgName(const std::set &pkgNameSet) override; std::string GetLocalDisplayDeviceName() override; + int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) override; private: void ConvertDeviceInfoToDeviceBasicInfo(const std::string &pkgName, diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index f8eb37b84..4b66bb655 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -4301,6 +4301,15 @@ void DeviceManagerService::ProcessSyncAccountLogout(const std::string &accountId dmServiceImpl_->HandleAccountLogoutEvent(userId, accountId, peerUdid); } +int32_t DeviceManagerService::OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) +{ + if (!IsDMServiceAdapterResidentLoad()) { + LOGE("failed, adapter instance not init or init failed."); + return ERR_DM_UNSUPPORTED_METHOD; + } + return dmServiceImplExtResident_->OpenAuthSessionWithPara(deviceId, actionId, isEnable160m); +} + int32_t DeviceManagerService::UnRegisterPinHolderCallback(const std::string &pkgName) { if (!PermissionManager::GetInstance().CheckPermission()) { diff --git a/services/service/src/device_manager_service_listener.cpp b/services/service/src/device_manager_service_listener.cpp index 7bf14c146..bc47a6a81 100644 --- a/services/service/src/device_manager_service_listener.cpp +++ b/services/service/src/device_manager_service_listener.cpp @@ -45,6 +45,7 @@ #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "datetime_ex.h" #include "device_name_manager.h" +#include "device_manager_service.h" #include "kv_adapter_manager.h" #include "multiple_user_connector.h" #endif @@ -1041,5 +1042,15 @@ std::string DeviceManagerServiceListener::GetLocalDisplayDeviceName() return ""; #endif } + +int32_t DeviceManagerServiceListener::OpenAuthSessionWithPara(const std::string &deviceId, + int32_t actionId, bool isEnable160m) +{ +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) + return DeviceManagerService::GetInstance().OpenAuthSessionWithPara(deviceId, actionId, isEnable160m); +#else + return ERR_DM_UNSUPPORTED_METHOD; +#endif +} } // namespace DistributedHardware } // namespace OHOS diff --git a/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp b/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp index 57c6d3e99..9df6f8cdc 100644 --- a/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp +++ b/test/softbusfuzztest/softbussession_fuzzer/softbus_session_fuzzer.cpp @@ -75,8 +75,6 @@ void SoftBusSessionFuzzTest(const uint8_t* data, size_t size) softbusSession->SendHeartbeatData(sessionId, str); softbusSession->OnSessionClosed(result); softbusSession->UnRegisterSessionCallback(); - bool isEnable = fdp.ConsumeBool(); - softbusSession->OpenAuthSessionWithPara(str, sessionId, isEnable); } } } diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index 1a5576f52..731169b4f 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -2493,6 +2493,15 @@ HWTEST_F(DeviceManagerServiceTest, GetEncryptedUuidByNetworkId_004, testing::ext EXPECT_EQ(ret, DM_OK); } +HWTEST_F(DeviceManagerServiceTest, OpenAuthSessionWithPara_001, testing::ext::TestSize.Level1) +{ + const std::string deviceId = "OpenAuthSessionWithPara"; + int32_t actionId = 0; + bool isEnable160m = false; + int32_t ret = DeviceManagerService::GetInstance().OpenAuthSessionWithPara(deviceId, actionId, isEnable160m); + EXPECT_NE(ret, DM_OK); +} + #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) HWTEST_F(DeviceManagerServiceTest, ConvertUdidHashToAnoyDeviceId_001, testing::ext::TestSize.Level1) { diff --git a/test/unittest/UTTest_device_manager_service_listener.cpp b/test/unittest/UTTest_device_manager_service_listener.cpp index 84d1bc6ff..ff761bb53 100644 --- a/test/unittest/UTTest_device_manager_service_listener.cpp +++ b/test/unittest/UTTest_device_manager_service_listener.cpp @@ -1093,6 +1093,16 @@ HWTEST_F(DeviceManagerServiceListenerTest, GetLocalDisplayDeviceName_001, testin displayDeviceName = listener_->GetLocalDisplayDeviceName(); EXPECT_FALSE(displayDeviceName.empty()); } + +HWTEST_F(DeviceManagerServiceListenerTest, OpenAuthSessionWithPara_001, testing::ext::TestSize.Level1) +{ + const std::string deviceId = "OpenAuthSessionWithPara"; + int32_t actionId = 0; + bool isEnable160m = false; + std::shared_ptr listener_ = std::make_shared(); + int32_t ret = listener_->OpenAuthSessionWithPara(deviceId, actionId, isEnable160m); + EXPECT_NE(ret, DM_OK); +} } // namespace } // namespace DistributedHardware } // namespace OHOS diff --git a/test/unittest/UTTest_dm_pin_holder.h b/test/unittest/UTTest_dm_pin_holder.h index 7d38ad3ce..4dfb660f8 100644 --- a/test/unittest/UTTest_dm_pin_holder.h +++ b/test/unittest/UTTest_dm_pin_holder.h @@ -265,6 +265,14 @@ public: { (void)pkgNameSet; } + + virtual int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) + { + (void)deviceId; + (void)actionId; + (void)isEnable160m; + return 0; + } }; } // namespace DistributedHardware } // namespace OHOS diff --git a/test/unittest/mock/softbus_session_mock.cpp b/test/unittest/mock/softbus_session_mock.cpp index c85d7045d..331e0e2cb 100644 --- a/test/unittest/mock/softbus_session_mock.cpp +++ b/test/unittest/mock/softbus_session_mock.cpp @@ -30,11 +30,6 @@ int32_t SoftbusSession::SendData(int32_t sessionId, std::string &message) return DmSoftbusSession::dmSoftbusSession->SendData(sessionId, message); } -int32_t SoftbusSession::OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) -{ - return DmSoftbusSession::dmSoftbusSession->OpenAuthSessionWithPara(deviceId, actionId, isEnable160m); -} - int32_t SoftbusSession::OpenAuthSession(const std::string &deviceId) { return DmSoftbusSession::dmSoftbusSession->OpenAuthSession(deviceId); diff --git a/test/unittest/mock/softbus_session_mock.h b/test/unittest/mock/softbus_session_mock.h index 9f386d183..bdb1ad0f5 100644 --- a/test/unittest/mock/softbus_session_mock.h +++ b/test/unittest/mock/softbus_session_mock.h @@ -28,7 +28,6 @@ public: public: virtual int32_t GetPeerDeviceId(int32_t sessionId, std::string &peerDevId) = 0; virtual int32_t SendData(int32_t sessionId, std::string &message) = 0; - virtual int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) = 0; virtual int32_t OpenAuthSession(const std::string &deviceId) = 0; public: @@ -39,7 +38,6 @@ class SoftbusSessionMock : public DmSoftbusSession { public: MOCK_METHOD(int32_t, GetPeerDeviceId, (int32_t, std::string &)); MOCK_METHOD(int32_t, SendData, (int32_t, std::string &)); - MOCK_METHOD(int32_t, OpenAuthSessionWithPara, (const std::string &, int32_t, bool)); MOCK_METHOD(int32_t, OpenAuthSession, (const std::string &)); }; } -- Gitee From ad14938e85989c52259611b6e094cb07d1777aec Mon Sep 17 00:00:00 2001 From: BrainL Date: Tue, 8 Jul 2025 10:16:34 +0800 Subject: [PATCH 12/13] merge_0708 Signed-off-by: BrainL --- test/unittest/UTTest_device_manager_service.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index 294500bd0..bf2d124ea 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -2607,7 +2607,6 @@ HWTEST_F(DeviceManagerServiceTest, OpenAuthSessionWithPara_001, testing::ext::Te int32_t ret = DeviceManagerService::GetInstance().OpenAuthSessionWithPara(deviceId, actionId, isEnable160m); EXPECT_NE(ret, DM_OK); } -#endif } // namespace } // namespace DistributedHardware } // namespace OHOS -- Gitee From 5ba51a2c7dcbdc868b72aa3cdf74078b2d34ee26 Mon Sep 17 00:00:00 2001 From: BrainL Date: Tue, 8 Jul 2025 10:49:50 +0800 Subject: [PATCH 13/13] merge_0708 Signed-off-by: BrainL --- .vscode/settings.json | 59 ------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index f6cd5e4f9..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "files.associations": { - "vector": "cpp", - "array": "cpp", - "atomic": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "map": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "set": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "typeinfo": "cpp" - } -} \ No newline at end of file -- Gitee