From e36390fe347d97680ab8276757bbd1b6e2b2e3c8 Mon Sep 17 00:00:00 2001 From: kaiju Date: Sat, 30 Aug 2025 15:36:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:dsoftbus=E3=80=81devicemanager=E8=A7=A3?= =?UTF-8?q?=E8=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kaiju Change-Id: Ib299959796a5a507aae1b694721280a5be52eca1 --- frameworks/common/BUILD.gn | 13 ++++ frameworks/common/inc/auth_common_utils.h | 33 ++++++++ frameworks/common/src/auth_common_utils.cpp | 61 +++++++++++++++ services/context/BUILD.gn | 22 ++++-- services/context/inc/context_factory.h | 2 + .../context/inc/local_remote_auth_context.h | 2 + services/context/inc/remote_auth_context.h | 2 + .../context/inc/remote_auth_invoker_context.h | 2 + services/context/inc/remote_auth_service.h | 4 +- services/context/inc/remote_executor_stub.h | 4 +- services/context/inc/remote_iam_callback.h | 4 +- services/context/src/context_factory.cpp | 2 + services/core/BUILD.gn | 28 ++++++- services/core/inc/remote_executor_proxy.h | 4 +- services/core/inc/remote_msg_util.h | 4 +- services/core/src/resource_node_impl.cpp | 12 ++- services/ipc/BUILD.gn | 27 ++++++- services/ipc/src/co_auth_service.cpp | 15 +++- services/ipc/src/service_init_manager.cpp | 6 ++ services/ipc/src/user_auth_service.cpp | 18 ++++- services/load_mode/BUILD.gn | 9 ++- test/fuzztest/common_fuzzer/BUILD.gn | 69 +++++++++++++---- test/fuzztest/services/BUILD.gn | 12 ++- .../context/remoteauthcontext_fuzzer/BUILD.gn | 6 ++ .../core/remoteexecutorstub_fuzzer/BUILD.gn | 6 ++ .../fuzztest/services/softbus_fuzzer/BUILD.gn | 6 ++ test/unittest/services/BUILD.gn | 76 ++++++++++++------- user_auth_framework.gni | 7 ++ 28 files changed, 384 insertions(+), 72 deletions(-) create mode 100644 frameworks/common/inc/auth_common_utils.h create mode 100644 frameworks/common/src/auth_common_utils.cpp diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn index e37f29592..23b53adfe 100644 --- a/frameworks/common/BUILD.gn +++ b/frameworks/common/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/ohos.gni") +import("../../user_auth_framework.gni") config("user_auth_common_config") { include_dirs = [ "inc" ] @@ -59,6 +60,18 @@ ohos_source_set("user_auth_common") { "../../common:iam_utils_config", ] + defines = [] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + } else { + sources += [ + "src/auth_common_utils.cpp", + ] + external_deps += [ + "c_utils:utils", + ] + } + public_configs = [ ":user_auth_common_config" ] subsystem_name = "useriam" diff --git a/frameworks/common/inc/auth_common_utils.h b/frameworks/common/inc/auth_common_utils.h new file mode 100644 index 000000000..6826ad733 --- /dev/null +++ b/frameworks/common/inc/auth_common_utils.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef REMOTE_CONNECT_ENABLE +#ifndef OHOS_AUTH_COMMON_UTILS_H +#define OHOS_AUTH_COMMON_UTILS_H + +#include + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +class AuthCommonUtils { +public: + bool GetDeviceUdid(std::string &udid); +}; +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS +#endif /* OHOS_AUTH_COMMON_UTILS_H */ +#endif \ No newline at end of file diff --git a/frameworks/common/src/auth_common_utils.cpp b/frameworks/common/src/auth_common_utils.cpp new file mode 100644 index 000000000..92112e73f --- /dev/null +++ b/frameworks/common/src/auth_common_utils.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef REMOTE_CONNECT_ENABLE + +#include "auth_common_utils.h" +#include "iam_logger.h" +#include +#include + +#define LOG_TAG "AUTH_COMMON_UTILS" + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +#define RTLD_LAZY 1 +using PAclGetDevUdid = int (*)(char *, int); +bool AuthCommonUtils::GetDeviceUdid(std::string &udid) +{ + static const char *BEGET_PROXY_LIB = "libbeget_proxy.z.so"; + constexpr int UDID_LENGTH = 65; + char udidDevice[UDID_LENGTH] = {0}; + void *handle = dlopen(BEGET_PROXY_LIB, RTLD_LAZY); + if (handle == nullptr) { + IAM_LOGI("load begetlib failed %{public}s", dlerror()); + return false; + } + PAclGetDevUdid fun = (PAclGetDevUdid)dlsym(handle, "AclGetDevUdid"); + if (fun == nullptr) { + IAM_LOGE("get symbol failed %{public}s", dlerror()); + dlclose(handle); + return false; + } + int udidRes = fun(udidDevice, UDID_LENGTH); + dlclose(handle); + if (udidRes == 0) { + IAM_LOGI("GetDeviceUdid udidRes == 0"); + std::string udidString(udidDevice, strlen(udidDevice)); + udid = udidString; + return true; + } else { + IAM_LOGE("GetDeviceUdid get udid failed %{public}d", udidRes); + return false; + } +} +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS +#endif \ No newline at end of file diff --git a/services/context/BUILD.gn b/services/context/BUILD.gn index f60391adf..78ada75cf 100644 --- a/services/context/BUILD.gn +++ b/services/context/BUILD.gn @@ -48,12 +48,6 @@ ohos_source_set("userauth_service_context") { "src/delete_context.cpp", "src/enroll_context.cpp", "src/identify_context.cpp", - "src/local_remote_auth_context.cpp", - "src/remote_auth_context.cpp", - "src/remote_auth_invoker_context.cpp", - "src/remote_auth_service.cpp", - "src/remote_executor_stub.cpp", - "src/remote_iam_callback.cpp", "src/schedule_holder_context.cpp", "src/simple_auth_context.cpp", "src/trace.cpp", @@ -113,9 +107,23 @@ ohos_source_set("userauth_service_context") { "../../common:iam_log_config", "../../common:iam_utils_config", "../../frameworks/native/ipc:userauth_client_ipc_config", - "../remote_connect:userauth_service_remote_connect_config", ] + if (remote_connect_enable) { + configs += [ + "../remote_connect:userauth_service_remote_connect_config", + ] + defines += [ "REMOTE_CONNECT_ENABLE" ] + sources += [ + "src/local_remote_auth_context.cpp", + "src/remote_auth_context.cpp", + "src/remote_auth_invoker_context.cpp", + "src/remote_auth_service.cpp", + "src/remote_executor_stub.cpp", + "src/remote_iam_callback.cpp", + ] + } + subsystem_name = "useriam" part_name = "user_auth_framework" } diff --git a/services/context/inc/context_factory.h b/services/context/inc/context_factory.h index 89a5152b8..fc3300fb8 100644 --- a/services/context/inc/context_factory.h +++ b/services/context/inc/context_factory.h @@ -65,12 +65,14 @@ public: static std::shared_ptr CreateSimpleAuthContext(const Authentication::AuthenticationPara ¶, const std::shared_ptr &callback, bool needSubscribeAppState); +#ifdef REMOTE_CONNECT_ENABLE static std::shared_ptr CreateRemoteAuthContext(const Authentication::AuthenticationPara ¶, RemoteAuthContextParam &remoteAuthContextParam, const std::shared_ptr &callback); static std::shared_ptr CreateRemoteAuthInvokerContext(AuthParamInner authParam, RemoteAuthInvokerContextParam param, std::shared_ptr callback); static std::shared_ptr CreateLocalRemoteAuthContext(const Authentication::AuthenticationPara ¶, LocalRemoteAuthContextParam &localRemoteAuthContextParam, const std::shared_ptr &callback); +#endif static std::shared_ptr CreateIdentifyContext(const Identification::IdentificationPara ¶, const std::shared_ptr &callback); static std::shared_ptr CreateEnrollContext(const Enrollment::EnrollmentPara ¶, diff --git a/services/context/inc/local_remote_auth_context.h b/services/context/inc/local_remote_auth_context.h index b1c4e057d..c966422e5 100644 --- a/services/context/inc/local_remote_auth_context.h +++ b/services/context/inc/local_remote_auth_context.h @@ -30,6 +30,7 @@ struct LocalRemoteAuthContextParam { std::string collectorNetworkId; }; +#ifdef REMOTE_CONNECT_ENABLE class LocalRemoteAuthContext : public SimpleAuthContext { public: LocalRemoteAuthContext(uint64_t contextId, std::shared_ptr auth, LocalRemoteAuthContextParam ¶m, @@ -49,6 +50,7 @@ private: std::string collectorNetworkId_; std::optional cancelTimerId_ = std::nullopt; }; +#endif } // namespace UserAuth } // namespace UserIam diff --git a/services/context/inc/remote_auth_context.h b/services/context/inc/remote_auth_context.h index 028017d5a..6c41ed009 100644 --- a/services/context/inc/remote_auth_context.h +++ b/services/context/inc/remote_auth_context.h @@ -34,6 +34,7 @@ struct RemoteAuthContextParam { std::vector executorInfoMsg; }; +#ifdef REMOTE_CONNECT_ENABLE class RemoteAuthContext : public SimpleAuthContext { public: RemoteAuthContext(uint64_t contextId, std::shared_ptr auth, RemoteAuthContextParam ¶m, @@ -71,6 +72,7 @@ private: std::shared_ptr remoteExecutorProxy_ = nullptr; std::optional cancelTimerId_ = std::nullopt; }; +#endif } // namespace UserAuth } // namespace UserIam } // namespace OHOS diff --git a/services/context/inc/remote_auth_invoker_context.h b/services/context/inc/remote_auth_invoker_context.h index 0a48bf6e8..894936ab4 100644 --- a/services/context/inc/remote_auth_invoker_context.h +++ b/services/context/inc/remote_auth_invoker_context.h @@ -39,6 +39,7 @@ struct RemoteAuthInvokerContextParam { int32_t callerType; }; +#ifdef REMOTE_CONNECT_ENABLE class RemoteAuthInvokerContext : public BaseContext { public: RemoteAuthInvokerContext(uint64_t contextId, AuthParamInner authParam, RemoteAuthInvokerContextParam param, @@ -85,6 +86,7 @@ private: std::optional verifierContextId_; std::optional cancelTimerId_; }; +#endif } // namespace UserAuth } // namespace UserIam } // namespace OHOS diff --git a/services/context/inc/remote_auth_service.h b/services/context/inc/remote_auth_service.h index 198cba1d6..7ca52be41 100644 --- a/services/context/inc/remote_auth_service.h +++ b/services/context/inc/remote_auth_service.h @@ -13,6 +13,7 @@ * limitations under the License. */ +#ifdef REMOTE_CONNECT_ENABLE #ifndef REMOTE_AUTH_SERVICE_H #define REMOTE_AUTH_SERVICE_H @@ -56,4 +57,5 @@ public: } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // REMOTE_AUTH_SERVICE_H \ No newline at end of file +#endif // REMOTE_AUTH_SERVICE_H +#endif \ No newline at end of file diff --git a/services/context/inc/remote_executor_stub.h b/services/context/inc/remote_executor_stub.h index 09194e9ab..a7704da97 100644 --- a/services/context/inc/remote_executor_stub.h +++ b/services/context/inc/remote_executor_stub.h @@ -13,6 +13,7 @@ * limitations under the License. */ +#ifdef REMOTE_CONNECT_ENABLE #ifndef REMOTE_EXECUTOR_STUB_H #define REMOTE_EXECUTOR_STUB_H @@ -60,4 +61,5 @@ private: } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // REMOTE_EXECUTOR_STUB_H \ No newline at end of file +#endif // REMOTE_EXECUTOR_STUB_H +#endif \ No newline at end of file diff --git a/services/context/inc/remote_iam_callback.h b/services/context/inc/remote_iam_callback.h index 7aac0e983..d0981bbfa 100644 --- a/services/context/inc/remote_iam_callback.h +++ b/services/context/inc/remote_iam_callback.h @@ -13,6 +13,7 @@ * limitations under the License. */ +#ifdef REMOTE_CONNECT_ENABLE #ifndef REMOTE_IAM_CALLBACK_H #define REMOTE_IAM_CALLBACK_H @@ -39,4 +40,5 @@ private: } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // REMOTE_IAM_CALLBACK_H \ No newline at end of file +#endif // REMOTE_IAM_CALLBACK_H +#endif \ No newline at end of file diff --git a/services/context/src/context_factory.cpp b/services/context/src/context_factory.cpp index 1275867cd..a0efeb4db 100644 --- a/services/context/src/context_factory.cpp +++ b/services/context/src/context_factory.cpp @@ -84,6 +84,7 @@ std::shared_ptr ContextFactory::CreateWidgetContext(const AuthWidgetCon return Common::MakeShared(newContextId, para, callback, modalCallback); } +#ifdef REMOTE_CONNECT_ENABLE std::shared_ptr ContextFactory::CreateRemoteAuthContext(const Authentication::AuthenticationPara ¶, RemoteAuthContextParam &remoteAuthContextParam, const std::shared_ptr &callback) { @@ -128,6 +129,7 @@ std::shared_ptr ContextFactory::CreateLocalRemoteAuthContext(const Auth auth->SetAccessTokenId(para.tokenId); return Common::MakeShared(newContextId, auth, localRemoteAuthContextParam, callback); } +#endif std::shared_ptr ContextFactory::CreateScheduleHolderContext(std::shared_ptr scheduleNode) { diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index 60888b650..bfdaa9149 100644 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -65,8 +65,6 @@ ohos_source_set("userauth_service_core") { "src/event_listener_manager.cpp", "src/identification_impl.cpp", "src/ipc_common.cpp", - "src/remote_executor_proxy.cpp", - "src/remote_msg_util.cpp", "src/resource_node_impl.cpp", "src/resource_node_pool_impl.cpp", "src/resource_node_utils.cpp", @@ -96,7 +94,6 @@ ohos_source_set("userauth_service_core") { "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", - "device_manager:devicemanagersdk", "drivers_interface_user_auth:libuser_auth_proxy_4.0", "hdf_core:libhdf_utils", "hdf_core:libhdi", @@ -151,10 +148,33 @@ ohos_source_set("userauth_service_core") { "../../common:iam_log_config", "../../common:iam_utils_config", "../../frameworks/native/ipc:userauth_client_ipc_config", - "../remote_connect:userauth_service_remote_connect_config", "../load_mode:userauth_service_load_mode_config", ] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + sources += [ + "src/remote_executor_proxy.cpp", + "src/remote_msg_util.cpp", + ] + external_deps += [ + "device_manager:devicemanagersdk", + ] + configs += [ + "../remote_connect:userauth_service_remote_connect_config", + ] + } else { + include_dirs += [ + "../../frameworks/common/inc", + ] + deps += [ + "../../frameworks/common:user_auth_common", + ] + configs += [ + "../../frameworks/common:user_auth_common_config", + ] + } + subsystem_name = "useriam" part_name = "user_auth_framework" } diff --git a/services/core/inc/remote_executor_proxy.h b/services/core/inc/remote_executor_proxy.h index 978f41281..f744fd7d2 100644 --- a/services/core/inc/remote_executor_proxy.h +++ b/services/core/inc/remote_executor_proxy.h @@ -13,6 +13,7 @@ * limitations under the License. */ +#ifdef REMOTE_CONNECT_ENABLE #ifndef REMOTE_EXECUTOR_PROXY_H #define REMOTE_EXECUTOR_PROXY_H @@ -67,4 +68,5 @@ private: } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // REMOTE_EXECUTOR_PROXY_H \ No newline at end of file +#endif // REMOTE_EXECUTOR_PROXY_H +#endif \ No newline at end of file diff --git a/services/core/inc/remote_msg_util.h b/services/core/inc/remote_msg_util.h index 268531e76..e97fe45d6 100644 --- a/services/core/inc/remote_msg_util.h +++ b/services/core/inc/remote_msg_util.h @@ -13,6 +13,7 @@ * limitations under the License. */ +#ifdef REMOTE_CONNECT_ENABLE #ifndef REMOTE_MSG_UTIL_H #define REMOTE_MSG_UTIL_H @@ -53,4 +54,5 @@ private: } // namespace UserAuth } // namespace UserIam } // namespace OHOS -#endif // REMOTE_MSG_UTIL_H \ No newline at end of file +#endif // REMOTE_MSG_UTIL_H +#endif \ No newline at end of file diff --git a/services/core/src/resource_node_impl.cpp b/services/core/src/resource_node_impl.cpp index c939da9d6..573a9856f 100644 --- a/services/core/src/resource_node_impl.cpp +++ b/services/core/src/resource_node_impl.cpp @@ -19,7 +19,11 @@ #include #include +#ifdef REMOTE_CONNECT_ENABLE #include "device_manager_util.h" +#else +#include "auth_common_utils.h" +#endif #include "hdi_wrapper.h" #include "iam_check.h" #include "iam_common_defines.h" @@ -74,7 +78,13 @@ ResourceNodeImpl::ResourceNodeImpl(ExecutorRegisterInfo info, std::shared_ptr &contextCallback) { +#ifdef REMOTE_CONNECT_ENABLE Attributes extraInfo; std::shared_ptr context = ContextFactory::CreateRemoteAuthInvokerContext(authParam, param, contextCallback); @@ -600,11 +603,15 @@ uint64_t UserAuthService::StartRemoteAuthInvokerContext(AuthParamInner authParam return BAD_CONTEXT_ID; } return context->GetContextId(); +#else + return BAD_CONTEXT_ID; +#endif } uint64_t UserAuthService::StartLocalRemoteAuthContext(Authentication::AuthenticationPara para, LocalRemoteAuthContextParam &localRemoteAuthContextParam, const std::shared_ptr &contextCallback) { +#ifdef REMOTE_CONNECT_ENABLE Attributes extraInfo; std::shared_ptr context = ContextFactory::CreateLocalRemoteAuthContext(para, localRemoteAuthContextParam, contextCallback); @@ -626,6 +633,9 @@ uint64_t UserAuthService::StartLocalRemoteAuthContext(Authentication::Authentica return BAD_CONTEXT_ID; } return context->GetContextId(); +#else + return BAD_CONTEXT_ID; +#endif } bool UserAuthService::CheckAuthPermissionAndParam(AuthType authType, AuthTrustLevel authTrustLevel, @@ -723,8 +733,10 @@ int32_t UserAuthService::DoPrepareRemoteAuth(const std::string &networkId) IAM_LOGI("start"); std::string udid; +#ifdef REMOTE_CONNECT_ENABLE bool getUdidRet = DeviceManagerUtil::GetInstance().GetUdidByNetworkId(networkId, udid); IF_FALSE_LOGE_AND_RETURN_VAL(getUdidRet, GENERAL_ERROR); +#endif auto hdi = HdiWrapper::GetHdiInstance(); IF_FALSE_LOGE_AND_RETURN_VAL(hdi != nullptr, GENERAL_ERROR); @@ -834,6 +846,7 @@ bool UserAuthService::ProcessAuthParamForRemoteAuth(AuthParamInner &authParam, A uint64_t UserAuthService::AuthRemoteUser(AuthParamInner &authParam, Authentication::AuthenticationPara ¶, RemoteAuthParam &remoteAuthParam, const std::shared_ptr &contextCallback, ResultCode &failReason) { +#ifdef REMOTE_CONNECT_ENABLE IAM_LOGI("start"); std::string localNetworkId; @@ -879,6 +892,9 @@ uint64_t UserAuthService::AuthRemoteUser(AuthParamInner &authParam, Authenticati IAM_LOGI("start remote auth context"); return RemoteAuthService::GetInstance().StartRemoteAuthContext( para, remoteAuthContextParam, contextCallback, dummyLastError); +#else + return BAD_CONTEXT_ID; +#endif } int32_t UserAuthService::Identify(const std::vector &challenge, int32_t authType, diff --git a/services/load_mode/BUILD.gn b/services/load_mode/BUILD.gn index 4ad32491d..016e9f7be 100644 --- a/services/load_mode/BUILD.gn +++ b/services/load_mode/BUILD.gn @@ -61,7 +61,6 @@ ohos_source_set("userauth_service_load_mode") { "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", - "device_manager:devicemanagersdk", "drivers_interface_user_auth:libuser_auth_proxy_4.0", "hdf_core:libhdi", "hilog:libhilog", @@ -73,6 +72,14 @@ ohos_source_set("userauth_service_load_mode") { "samgr:samgr_proxy", ] + defines = [] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + external_deps += [ + "device_manager:devicemanagersdk", + ] + } + configs = [ "../../common:iam_log_config", "../../common:iam_utils_config", diff --git a/test/fuzztest/common_fuzzer/BUILD.gn b/test/fuzztest/common_fuzzer/BUILD.gn index aef2668f6..f09f2698a 100644 --- a/test/fuzztest/common_fuzzer/BUILD.gn +++ b/test/fuzztest/common_fuzzer/BUILD.gn @@ -130,8 +130,6 @@ ohos_source_set("userauth_service_core_fuzzer") { "../../../services/core/src/event_listener_manager.cpp", "../../../services/core/src/identification_impl.cpp", "../../../services/core/src/publish_event_adapter_mock.cpp", - "../../../services/core/src/remote_executor_proxy.cpp", - "../../../services/core/src/remote_msg_util.cpp", "../../../services/core/src/resource_node_impl.cpp", "../../../services/core/src/resource_node_pool_impl.cpp", "../../../services/core/src/resource_node_utils.cpp", @@ -166,7 +164,6 @@ ohos_source_set("userauth_service_core_fuzzer") { "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", "c_utils:utils", - "device_manager:devicemanagersdk", "drivers_interface_user_auth:libuser_auth_proxy_4.0", "hdf_core:libhdf_utils", "hdf_core:libhdi", @@ -216,10 +213,33 @@ ohos_source_set("userauth_service_core_fuzzer") { "../../../common:iam_log_config", "../../../common:iam_utils_config", "../../../frameworks/native/ipc:userauth_client_ipc_config", - "../../../services/remote_connect:userauth_service_remote_connect_config", "../../../services/load_mode:userauth_service_load_mode_config", ] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + sources += [ + "../../../services/core/src/remote_executor_proxy.cpp", + "../../../services/core/src/remote_msg_util.cpp", + ] + external_deps += [ + "device_manager:devicemanagersdk", + ] + configs += [ + "../../../services/remote_connect:userauth_service_remote_connect_config", + ] + } else { + include_dirs += [ + "../../../frameworks/common/inc", + ] + deps += [ + "../../../frameworks/common:user_auth_common", + ] + configs += [ + "../../../frameworks/common:user_auth_common_config", + ] + } + subsystem_name = "useriam" part_name = "user_auth_framework" } @@ -245,12 +265,6 @@ ohos_source_set("userauth_service_context_fuzzer") { "../../../services/context/src/delete_context.cpp", "../../../services/context/src/enroll_context.cpp", "../../../services/context/src/identify_context.cpp", - "../../../services/context/src/local_remote_auth_context.cpp", - "../../../services/context/src/remote_auth_context.cpp", - "../../../services/context/src/remote_auth_invoker_context.cpp", - "../../../services/context/src/remote_auth_service.cpp", - "../../../services/context/src/remote_executor_stub.cpp", - "../../../services/context/src/remote_iam_callback.cpp", "../../../services/context/src/schedule_holder_context.cpp", "../../../services/context/src/simple_auth_context.cpp", "../../../services/context/src/trace.cpp", @@ -305,10 +319,24 @@ ohos_source_set("userauth_service_context_fuzzer") { "../../../common:iam_log_config", "../../../common:iam_utils_config", "../../../frameworks/native/ipc:userauth_client_ipc_config", - "../../../services/remote_connect:userauth_service_remote_connect_config", "../../../services/load_mode:userauth_service_load_mode_config", ] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + sources += [ + "../../../services/context/src/local_remote_auth_context.cpp", + "../../../services/context/src/remote_auth_context.cpp", + "../../../services/context/src/remote_auth_invoker_context.cpp", + "../../../services/context/src/remote_auth_service.cpp", + "../../../services/context/src/remote_executor_stub.cpp", + "../../../services/context/src/remote_iam_callback.cpp", + ] + configs += [ + "../../../services/remote_connect:userauth_service_remote_connect_config", + ] + } + subsystem_name = "useriam" part_name = "user_auth_framework" } @@ -392,7 +420,6 @@ ohos_source_set("userauth_services_ipc_fuzzer") { "../common_fuzzer:dfx_fuzzer", "../common_fuzzer:iam_utils_fuzzer", "../common_fuzzer:userauth_service_context_fuzzer", - "../common_fuzzer:userauth_service_remote_connect_fuzzer", ] external_deps = [ @@ -400,9 +427,7 @@ ohos_source_set("userauth_services_ipc_fuzzer") { "access_token:libaccesstoken_sdk", "c_utils:utils", "common_event_service:cesfwk_innerkits", - "device_manager:devicemanagersdk", "drivers_interface_user_auth:libuser_auth_proxy_4.0", - "dsoftbus:softbus_client", "hdf_core:libhdf_utils", "hdf_core:libhdi", "hicollie:libhicollie", @@ -424,10 +449,24 @@ ohos_source_set("userauth_services_ipc_fuzzer") { "../../../services/base:userauth_service_base_config", "../../../common:iam_log_config", "../../../services/core:userauth_service_core_config", - "../../../services/remote_connect:userauth_service_remote_connect_config", "../../../services/load_mode:userauth_service_load_mode_config", ] + defines = [] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + deps += [ + "../common_fuzzer:userauth_service_remote_connect_fuzzer", + ] + external_deps += [ + "device_manager:devicemanagersdk", + "dsoftbus:softbus_client", + ] + configs += [ + "../../../services/remote_connect:userauth_service_remote_connect_config", + ] + } + subsystem_name = "useriam" part_name = "user_auth_framework" } diff --git a/test/fuzztest/services/BUILD.gn b/test/fuzztest/services/BUILD.gn index 5a2a0b281..952cf2556 100644 --- a/test/fuzztest/services/BUILD.gn +++ b/test/fuzztest/services/BUILD.gn @@ -13,6 +13,7 @@ import("//build/ohos.gni") import("//build/test.gni") +import("../../../user_auth_framework.gni") group("iam_services_fuzztest") { testonly = true @@ -20,13 +21,18 @@ group("iam_services_fuzztest") { "coauthservice_fuzzer:CoAuthServiceFuzzTest", "context/contextcallbackimpl_fuzzer:ContextCallbackImplFuzzTest", "context/contextpoolimpl_fuzzer:ContextPoolImplFuzzTest", - "context/remoteauthcontext_fuzzer:RemoteAuthContextFuzzTest", "context/widgetcontext_fuzzer:WidgetContextFuzzTest", - "core/remoteexecutorstub_fuzzer:RemoteExecutorStubFuzzTest", "servicecore_fuzzer:ServiceCoreFuzzTest", - "softbus_fuzzer:SoftBusFuzzTest", "templatecachemanager_fuzzer:TemplateCacheManagerFuzzTest", "userauthservice_fuzzer:UserAuthServiceFuzzTest", "useridmservice_fuzzer:UserIdmServiceFuzzTest", ] + + if (remote_connect_enable) { + deps += [ + "context/remoteauthcontext_fuzzer:RemoteAuthContextFuzzTest", + "core/remoteexecutorstub_fuzzer:RemoteExecutorStubFuzzTest", + "softbus_fuzzer:SoftBusFuzzTest", + ] + } } diff --git a/test/fuzztest/services/context/remoteauthcontext_fuzzer/BUILD.gn b/test/fuzztest/services/context/remoteauthcontext_fuzzer/BUILD.gn index 14411cd55..4e2e64ac5 100644 --- a/test/fuzztest/services/context/remoteauthcontext_fuzzer/BUILD.gn +++ b/test/fuzztest/services/context/remoteauthcontext_fuzzer/BUILD.gn @@ -13,6 +13,7 @@ import("//build/ohos.gni") import("//build/test.gni") +import("../../../../../user_auth_framework.gni") ohos_fuzztest("RemoteAuthContextFuzzTest") { branch_protector_ret = "pac_ret" @@ -87,6 +88,11 @@ ohos_fuzztest("RemoteAuthContextFuzzTest") { "init:libbegetutil", "napi:ace_napi", ] + + defines = [] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + } subsystem_name = "useriam" part_name = "user_auth_framework" diff --git a/test/fuzztest/services/core/remoteexecutorstub_fuzzer/BUILD.gn b/test/fuzztest/services/core/remoteexecutorstub_fuzzer/BUILD.gn index f8ad20072..2025e8123 100644 --- a/test/fuzztest/services/core/remoteexecutorstub_fuzzer/BUILD.gn +++ b/test/fuzztest/services/core/remoteexecutorstub_fuzzer/BUILD.gn @@ -13,6 +13,7 @@ import("//build/ohos.gni") import("//build/test.gni") +import("../../../../../user_auth_framework.gni") ohos_fuzztest("RemoteExecutorStubFuzzTest") { branch_protector_ret = "pac_ret" @@ -68,6 +69,11 @@ ohos_fuzztest("RemoteExecutorStubFuzzTest") { "samgr:samgr_proxy", ] + defines = [] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + } + subsystem_name = "useriam" part_name = "user_auth_framework" } diff --git a/test/fuzztest/services/softbus_fuzzer/BUILD.gn b/test/fuzztest/services/softbus_fuzzer/BUILD.gn index de7e56a1a..83f6e6b5f 100644 --- a/test/fuzztest/services/softbus_fuzzer/BUILD.gn +++ b/test/fuzztest/services/softbus_fuzzer/BUILD.gn @@ -13,6 +13,7 @@ import("//build/ohos.gni") import("//build/test.gni") +import("../../../../user_auth_framework.gni") ohos_fuzztest("SoftBusFuzzTest") { branch_protector_ret = "pac_ret" @@ -71,6 +72,11 @@ ohos_fuzztest("SoftBusFuzzTest") { "samgr:samgr_proxy", ] + defines = [] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + } + subsystem_name = "useriam" part_name = "user_auth_framework" } diff --git a/test/unittest/services/BUILD.gn b/test/unittest/services/BUILD.gn index 3aa2a2b37..7a4ef6868 100644 --- a/test/unittest/services/BUILD.gn +++ b/test/unittest/services/BUILD.gn @@ -42,7 +42,6 @@ ohos_unittest("iam_services_test") { "../../../services/context/src", "../../../services/ipc/inc", "../../../services/load_mode/inc", - "../../../services/remote_connect/inc", "../../../frameworks/common/inc", "../../../frameworks/native/ipc/inc", "../../../frameworks/native/ipc/common_defines", @@ -68,12 +67,6 @@ ohos_unittest("iam_services_test") { "../../../services/context/src/delete_context.cpp", "../../../services/context/src/enroll_context.cpp", "../../../services/context/src/identify_context.cpp", - "../../../services/context/src/local_remote_auth_context.cpp", - "../../../services/context/src/remote_auth_context.cpp", - "../../../services/context/src/remote_auth_invoker_context.cpp", - "../../../services/context/src/remote_auth_service.cpp", - "../../../services/context/src/remote_executor_stub.cpp", - "../../../services/context/src/remote_iam_callback.cpp", "../../../services/context/src/schedule_holder_context.cpp", "../../../services/context/src/simple_auth_context.cpp", "../../../services/context/src/trace.cpp", @@ -92,8 +85,6 @@ ohos_unittest("iam_services_test") { "../../../services/core/src/identification_impl.cpp", "../../../services/core/src/os_accounts_manager_impl.cpp", "../../../services/core/src/publish_event_adapter_mock.cpp", - "../../../services/core/src/remote_executor_proxy.cpp", - "../../../services/core/src/remote_msg_util.cpp", "../../../services/core/src/resource_node_impl.cpp", "../../../services/core/src/resource_node_pool_impl.cpp", "../../../services/core/src/resource_node_utils.cpp", @@ -118,20 +109,8 @@ ohos_unittest("iam_services_test") { "../../../services/ipc/src/user_idm_service.cpp", "../../../services/load_mode/src/load_mode_handler.cpp", "../../../services/load_mode/src/load_mode_handler_default.cpp", - "../../../services/remote_connect/src/device_manager_util.cpp", - "../../../services/remote_connect/src/remote_connect_listener.cpp", - "../../../services/remote_connect/src/remote_connect_listener_manager.cpp", - "../../../services/remote_connect/src/remote_connect_manager.cpp", - "../../../services/remote_connect/src/socket_factory.cpp", - "../../../services/remote_connect/src/soft_bus_base_socket.cpp", - "../../../services/remote_connect/src/soft_bus_client_socket.cpp", - "../../../services/remote_connect/src/soft_bus_manager.cpp", - "../../../services/remote_connect/src/soft_bus_message.cpp", - "../../../services/remote_connect/src/soft_bus_server_socket.cpp", - "../../../services/remote_connect/src/soft_bus_socket_listener.cpp", "mocks/mock_ipc_common.cpp", "mocks/mock_iuser_auth_interface.cpp", - "mocks/mock_socket.cpp", "src/attributes_test.cpp", "src/auth_widget_helper_test.cpp", "src/authentication_impl_test.cpp", @@ -155,8 +134,6 @@ ohos_unittest("iam_services_test") { "src/ipc_common_test.cpp", "src/os_accounts_manager_test.cpp", "src/relative_timer_test.cpp", - "src/remote_auth_context_test.cpp", - "src/remote_auth_invoker_context_test.cpp", "src/resource_node_pool_test.cpp", "src/resource_node_test.cpp", "src/resource_node_utils_test.cpp", @@ -166,10 +143,6 @@ ohos_unittest("iam_services_test") { "src/screenlock_status_listener_test.cpp", "src/secure_user_info_test.cpp", "src/simple_auth_context_test.cpp", - "src/soft_bus_base_socket_test.cpp", - "src/soft_bus_client_socket_test.cpp", - "src/soft_bus_manager_test.cpp", - "src/soft_bus_server_socket_test.cpp", "src/state_machine_test.cpp", "src/strong_auth_status_manager_test.cpp", "src/system_ability_listener_test.cpp", @@ -212,9 +185,7 @@ ohos_unittest("iam_services_test") { "access_token:libtoken_setproc", "access_token:libtokenid_sdk", "c_utils:utils", - "device_manager:devicemanagersdk", "drivers_interface_user_auth:libuser_auth_proxy_4.0", - "dsoftbus:softbus_client", "googletest:gmock", "hdf_core:libhdf_utils", "hdf_core:libhdi", @@ -253,6 +224,53 @@ ohos_unittest("iam_services_test") { "../../../common:iam_utils_config", ] + defines = [] + if (remote_connect_enable) { + defines += [ "REMOTE_CONNECT_ENABLE" ] + external_deps += [ + "device_manager:devicemanagersdk", + "dsoftbus:softbus_client", + ] + include_dirs += [ + "../../../services/remote_connect/inc", + ] + sources += [ + "../../../services/context/src/local_remote_auth_context.cpp", + "../../../services/context/src/remote_auth_context.cpp", + "../../../services/context/src/remote_auth_invoker_context.cpp", + "../../../services/context/src/remote_auth_service.cpp", + "../../../services/context/src/remote_executor_stub.cpp", + "../../../services/context/src/remote_iam_callback.cpp", + "../../../services/core/src/remote_executor_proxy.cpp", + "../../../services/core/src/remote_msg_util.cpp", + "../../../services/remote_connect/src/device_manager_util.cpp", + "../../../services/remote_connect/src/remote_connect_listener.cpp", + "../../../services/remote_connect/src/remote_connect_listener_manager.cpp", + "../../../services/remote_connect/src/remote_connect_manager.cpp", + "../../../services/remote_connect/src/socket_factory.cpp", + "../../../services/remote_connect/src/soft_bus_base_socket.cpp", + "../../../services/remote_connect/src/soft_bus_client_socket.cpp", + "../../../services/remote_connect/src/soft_bus_manager.cpp", + "../../../services/remote_connect/src/soft_bus_message.cpp", + "../../../services/remote_connect/src/soft_bus_server_socket.cpp", + "../../../services/remote_connect/src/soft_bus_socket_listener.cpp", + "mocks/mock_socket.cpp", + "src/remote_auth_context_test.cpp", + "src/remote_auth_invoker_context_test.cpp", + "src/soft_bus_base_socket_test.cpp", + "src/soft_bus_client_socket_test.cpp", + "src/soft_bus_manager_test.cpp", + "src/soft_bus_server_socket_test.cpp", + ] + } else { + deps += [ + "../../../frameworks/common:user_auth_common", + ] + configs += [ + "../../../frameworks/common:user_auth_common_config", + ] + } + remove_configs = [ "//build/config/compiler:no_exceptions" ] module_out_path = "user_auth_framework/user_auth_framework" diff --git a/user_auth_framework.gni b/user_auth_framework.gni index 6d7369047..41b31eeec 100644 --- a/user_auth_framework.gni +++ b/user_auth_framework.gni @@ -19,4 +19,11 @@ declare_args() { !defined(global_parts_info.theme_screenlock_mgr)) { screenlock_client_enable = false } + + remote_connect_enable = true + if (defined(global_parts_info) && + (!defined(global_parts_info.distributedhardware_device_manager) || + !defined(global_parts_info.communication_dsoftbus))) { + remote_connect_enable = false + } } -- Gitee