diff --git a/services/ans/include/advanced_notification_inline.h b/services/ans/include/advanced_notification_inline.h index 6658d1d126407bec5f36e79189a148c8fc730ce8..23972945c11240062f86daf38cf468fb43254e48 100644 --- a/services/ans/include/advanced_notification_inline.h +++ b/services/ans/include/advanced_notification_inline.h @@ -39,7 +39,7 @@ inline std::string GetClientBundleNameByUid(int32_t callingUid) return bundle; } -inline std::string GetClientBundleName() +inline std::string __attribute__((weak)) GetClientBundleName() { int32_t callingUid = IPCSkeleton::GetCallingUid(); return GetClientBundleNameByUid(callingUid); diff --git a/services/ans/src/advanced_notification_inline.cpp b/services/ans/src/advanced_notification_inline.cpp index 9be433936f2e42def16925f2046c509589a736e6..fcc7c3da0503e34020e01168d5c2b92e49b80347 100644 --- a/services/ans/src/advanced_notification_inline.cpp +++ b/services/ans/src/advanced_notification_inline.cpp @@ -45,7 +45,7 @@ inline std::string GetClientBundleNameByUid(int32_t callingUid) return bundle; } -inline std::string GetClientBundleName() +inline std::string __attribute__((weak)) GetClientBundleName() { int32_t callingUid = IPCSkeleton::GetCallingUid(); return GetClientBundleNameByUid(callingUid); diff --git a/test/fuzztest/advancednotificationservice/advancednotificationservice_fuzztest_common.gni b/test/fuzztest/advancednotificationservice/advancednotificationservice_fuzztest_common.gni index b0faf95a7eadd97f01987fac2431cd6b579cf4e3..e25f90b5febc7d7617c1a5984845dd5d7f47bcd4 100644 --- a/test/fuzztest/advancednotificationservice/advancednotificationservice_fuzztest_common.gni +++ b/test/fuzztest/advancednotificationservice/advancednotificationservice_fuzztest_common.gni @@ -22,7 +22,8 @@ template("advancednotificationservice_fuzztest_target") { ohos_fuzztest(target_name) { module_out_path = service_fuzz_test_path - sources = invoker.sources_value + sources = [ "${component_path}/test/fuzztest/fuzz_common_base/mock/mock_notification_func.cpp", ] + sources += invoker.sources_value fuzz_config_file = invoker.fuzz_config_file_value include_dirs = [ "${services_path}/ans/include" ] cflags = [ diff --git a/test/fuzztest/fuzz_common_base/mock/mock_notification_func.cpp b/test/fuzztest/fuzz_common_base/mock/mock_notification_func.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4854d1fa784b3c2d449d99eb47f66db61bbdda29 --- /dev/null +++ b/test/fuzztest/fuzz_common_base/mock/mock_notification_func.cpp @@ -0,0 +1,26 @@ +/* + * 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 + +namespace OHOS { +namespace Notification { +std::string GetClientBundleName() +{ + return "bundletest"; +} + +} // namespace Notification +} // namespace OHOS