From ed1af4bade0d7acf66ef16a5645b0813124f194f Mon Sep 17 00:00:00 2001 From: q30043944 Date: Wed, 18 Jun 2025 20:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E9=80=82=E9=85=8D=E6=80=BB?= =?UTF-8?q?=E7=BA=BF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: q30043944 --- .../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 -------- .../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 ++ 16 files changed, 43 insertions(+), 56 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 cb4bb85bc..b93d073e4 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,7 +106,6 @@ 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 b1685ebec..0b9578252 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 @@ -110,7 +110,6 @@ public: std::vector &dmDeviceProfileInfos) = 0; virtual int32_t RestoreLocalDeviceName() = 0; virtual void ClearCacheWhenLogout(int32_t userId, const std::string &oldAccountId) = 0; - virtual int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) = 0; virtual void HandleScreenLockEvent(bool isLock) = 0; }; 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 e85db7292..5fc5b0a45 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 @@ -178,7 +178,6 @@ public: * @return std::string the name without privacy info */ virtual std::string GetLocalDisplayDeviceNameForPrivacy() = 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 aaa548f36..b3dfc2840 100644 --- a/services/implementation/include/dependency/softbus/softbus_session.h +++ b/services/implementation/include/dependency/softbus/softbus_session.h @@ -59,6 +59,13 @@ 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 9eaf1fa7f..26d07d2d1 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -868,11 +868,10 @@ 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 = listener_->OpenAuthSessionWithPara(deviceId, + sessionId = softbusConnector_->GetSoftbusSession()->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 1563f8b86..056eb4044 100644 --- a/services/implementation/src/dependency/softbus/softbus_session.cpp +++ b/services/implementation/src/dependency/softbus/softbus_session.cpp @@ -23,6 +23,9 @@ #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 { @@ -72,6 +75,29 @@ 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 0d3886893..4de0a19f1 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -1523,8 +1523,8 @@ int DeviceManagerServiceImpl::OpenAuthSession(const std::string& deviceId, return ret; } LOGI("hmlActionId %{public}d, hmlEnable160M %{public}d", hmlActionId, hmlEnable160M); - CHECK_NULL_RETURN(listener_, ERR_DM_FAILED); - return listener_->OpenAuthSessionWithPara(deviceId, hmlActionId, hmlEnable160M); + return softbusConnector_->GetSoftbusSession()->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 d2bec5c49..da3023d9a 100644 --- a/services/service/include/device_manager_service.h +++ b/services/service/include/device_manager_service.h @@ -253,7 +253,6 @@ 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 fbf03d22a..f4780273b 100644 --- a/services/service/include/device_manager_service_listener.h +++ b/services/service/include/device_manager_service_listener.h @@ -91,7 +91,6 @@ public: const std::string &deviceName, int32_t code) override; std::string GetLocalDisplayDeviceNameForPrivacy() 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 c32ff62d2..2bcd88c8f 100644 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -4169,15 +4169,6 @@ 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 d1d0a84b8..2fa0fe73b 100644 --- a/services/service/src/device_manager_service_listener.cpp +++ b/services/service/src/device_manager_service_listener.cpp @@ -45,7 +45,6 @@ #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 @@ -1019,15 +1018,5 @@ std::string DeviceManagerServiceListener::GetLocalDisplayDeviceNameForPrivacy() 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 DM_OK; -#endif -} } // namespace DistributedHardware } // namespace OHOS diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index 28dbe3832..c4e7f4be8 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -2493,15 +2493,6 @@ 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 4f654d2d4..a2bc5c562 100644 --- a/test/unittest/UTTest_device_manager_service_listener.cpp +++ b/test/unittest/UTTest_device_manager_service_listener.cpp @@ -1084,16 +1084,6 @@ HWTEST_F(DeviceManagerServiceListenerTest, SetDeviceInfo_001, testing::ext::Test listener_->SetDeviceInfo(pReq, processInfo, state, deviceInfo, deviceBasicInfo); EXPECT_EQ(listener_->alreadyOnlinePkgName_.empty(), false); } - -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 58c9e4ef6..547e5717e 100644 --- a/test/unittest/UTTest_dm_pin_holder.h +++ b/test/unittest/UTTest_dm_pin_holder.h @@ -260,14 +260,6 @@ public: { return ""; } - - 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 331e0e2cb..c85d7045d 100644 --- a/test/unittest/mock/softbus_session_mock.cpp +++ b/test/unittest/mock/softbus_session_mock.cpp @@ -30,6 +30,11 @@ 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 bdb1ad0f5..9f386d183 100644 --- a/test/unittest/mock/softbus_session_mock.h +++ b/test/unittest/mock/softbus_session_mock.h @@ -28,6 +28,7 @@ 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: @@ -38,6 +39,7 @@ 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