diff --git a/services/remote_connect/dynamic/src/device_manager_util.cpp b/services/remote_connect/dynamic/src/device_manager_util.cpp index 0f72c16f255fd13573adb3a2dfc786c210601c22..3ed71d44fd124d5e800c3b9fec79da999c706e11 100644 --- a/services/remote_connect/dynamic/src/device_manager_util.cpp +++ b/services/remote_connect/dynamic/src/device_manager_util.cpp @@ -46,7 +46,7 @@ bool DeviceManagerUtil::GetLocalDeviceUdid(std::string &udid) constexpr int UDID_LENGTH = 65; char udidDevice[UDID_LENGTH] = {0}; int udidRes = AclGetDevUdid(udidDevice, UDID_LENGTH); - if (udidRes == 0) { + if (udidRes == 0 && strlen(udidDevice) == UDID_LENGTH - 1) { IAM_LOGI("GetDeviceUdid udidRes == 0"); std::string udidString(udidDevice, strlen(udidDevice)); udid = udidString; diff --git a/services/remote_connect/dynamic/src/remote_connect_manager.cpp b/services/remote_connect/dynamic/src/remote_connect_manager.cpp index e13b2b3fb3a762e1dc83e42c70b510dd3a8a4fcc..77816029baf0cdbee2cc63d1e1442bfb0455af57 100644 --- a/services/remote_connect/dynamic/src/remote_connect_manager.cpp +++ b/services/remote_connect/dynamic/src/remote_connect_manager.cpp @@ -38,7 +38,7 @@ ResultCode RemoteConnectionManager::OpenConnection(const std::string &connection ResultCode RemoteConnectionManager::CloseConnection(const std::string &connectionName) { IAM_LOGD("Dynamic load mode: skip close connection"); - return SUCCESS; + return GENERAL_ERROR; } ResultCode RemoteConnectionManager::RegisterConnectionListener(const std::string &connectionName, @@ -59,13 +59,13 @@ ResultCode RemoteConnectionManager::UnregisterConnectionListener(const std::stri const std::string &endPointName) { IAM_LOGD("Dynamic load mode: skip unregister connection listener"); - return SUCCESS; + return GENERAL_ERROR; } ResultCode RemoteConnectionManager::UnregisterConnectionListener(const std::string &endPointName) { IAM_LOGD("Dynamic load mode: skip unregister connection listener"); - return SUCCESS; + return GENERAL_ERROR; } ResultCode RemoteConnectionManager::SendMessage(const std::string &connectionName, diff --git a/test/BUILD.gn b/test/BUILD.gn index e2331d0e65a64db9225561c58e96d3127b30d444..81d4747f578356256a187280353ad8cf68f3dd0b 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -20,6 +20,7 @@ group("iam_unittest") { "unittest/executors:iam_executors_test", "unittest/inner_api:iam_inner_api_test", "unittest/services:iam_services_test", + "unittest/dynamic:iam_dynamic_test", ] } diff --git a/test/unittest/dynamic/BUILD.gn b/test/unittest/dynamic/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4eab335c5346309312da2061a27488af0833bcbd --- /dev/null +++ b/test/unittest/dynamic/BUILD.gn @@ -0,0 +1,66 @@ +# 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. + +import("//build/ohos.gni") +import("//build/test.gni") + +ohos_unittest("iam_dynamic_test") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../../cfi_blocklist.txt" + } + branch_protector_ret = "pac_ret" + + cflags = [ + "-DIAM_TEST_ENABLE", + "-Dprivate=public", + "-Dprotected=public", + ] + include_dirs = [ + "inc", + "../../../services/remote_connect/inc", + "../../../common/utils", + "../../../common/logs", + ] + + sources = [ + "../../../services/remote_connect/dynamic/src/device_manager_util.cpp", + "src/dynamic_device_manager_util_test.cpp", + ] + + deps = [ + "../../../common:iam_utils", + ] + + external_deps = [ + "hilog:libhilog", + "init:libbeget_proxy", + ] + + configs = [ + "../../../common:iam_log_config", + "../../../common:iam_utils_config", + ] + + remove_configs = [ "//build/config/compiler:no_exceptions" ] + + module_out_path = "user_auth_framework/user_auth_framework" + + subsystem_name = "useriam" + part_name = "user_auth_framework" +} diff --git a/test/unittest/dynamic/inc/dynamic_device_manager_util_test.h b/test/unittest/dynamic/inc/dynamic_device_manager_util_test.h new file mode 100644 index 0000000000000000000000000000000000000000..a7c979b13403785451d7a36ef9ea3fc093060f5f --- /dev/null +++ b/test/unittest/dynamic/inc/dynamic_device_manager_util_test.h @@ -0,0 +1,37 @@ +/* + * 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 DYNAMIC_DEVICE_MANAGER_UTIL_TEST_H +#define DYNAMIC_DEVICE_MANAGER_UTIL_TEST_H + +#include + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +class DynamicDeviceManagerUtilTest : public testing::Test { +public: + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp() override; + + void TearDown() override; +}; +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS +#endif // DYNAMIC_DEVICE_MANAGER_UTIL_TEST_H \ No newline at end of file diff --git a/test/unittest/dynamic/src/dynamic_device_manager_util_test.cpp b/test/unittest/dynamic/src/dynamic_device_manager_util_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..60244a17f5dca684bb1d0bb32cc41b9e0397ab6f --- /dev/null +++ b/test/unittest/dynamic/src/dynamic_device_manager_util_test.cpp @@ -0,0 +1,49 @@ +/* + * 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. + */ + +#include "dynamic_device_manager_util_test.h" +#include "device_manager_util.h" + +namespace OHOS { +namespace UserIam { +namespace UserAuth { +using namespace testing; +using namespace testing::ext; + +void DynamicDeviceManagerUtilTest::SetUpTestCase() +{ +} + +void DynamicDeviceManagerUtilTest::TearDownTestCase() +{ +} + +void DynamicDeviceManagerUtilTest::SetUp() +{ +} + +void DynamicDeviceManagerUtilTest::TearDown() +{ +} + +HWTEST_F(DynamicDeviceManagerUtilTest, DynamicDeviceManagerUtilTest001, TestSize.Level0) +{ + std::string udid; + bool result = DeviceManagerUtil::GetInstance().GetLocalDeviceUdid(udid); + EXPECT_TRUE(result); +} +} // namespace UserAuth +} // namespace UserIam +} // namespace OHOS \ No newline at end of file