From bed4c549c46aa08f8cfdce4b7ad1f4150e948c76 Mon Sep 17 00:00:00 2001 From: wuminjie Date: Mon, 30 Dec 2024 08:45:04 +0800 Subject: [PATCH] =?UTF-8?q?accesstoken=E8=A7=A3=E8=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuminjie --- interfaces/innerkits/rust/tests/BUILD.gn | 11 ++- services/samgr/native/test/unittest/BUILD.gn | 96 +++++++++++++++---- .../test/unittest/rust/service/BUILD.gn | 16 ++-- .../unittest/src/manual_ondemand_helper.cpp | 4 +- .../unittest/src/mock_accesstoken_kit.cpp | 4 +- .../test/unittest/src/mock_permission.cpp | 6 ++ .../test/unittest/src/ondemand_helper.cpp | 4 +- .../system_ability_manager_dumper_test.cpp | 10 ++ .../src/system_ability_mgr_load_test.cpp | 8 ++ .../src/system_ability_mgr_new_test.cpp | 4 + .../src/system_ability_mgr_ondemand_test.cpp | 12 +++ .../src/system_ability_mgr_stub_load_test.cpp | 6 ++ .../src/system_ability_mgr_stub_test.cpp | 26 +++++ .../system_ability_mgr_stub_unload_test.cpp | 8 ++ .../src/system_ability_mgr_subscribe_test.cpp | 2 + .../unittest/src/system_ability_mgr_test.cpp | 2 + .../src/system_ability_mgr_util_test.cpp | 4 + .../unittest/src/system_ability_test_tool.cpp | 8 +- services/samgr/var.gni | 5 + test/fuzztest/samgr_fuzzer/BUILD.gn | 10 +- test/fuzztest/samgrcoverage_fuzzer/BUILD.gn | 9 +- test/fuzztest/samgrdumper_fuzzer/BUILD.gn | 10 +- .../systemabilitymanager_fuzzer/BUILD.gn | 10 +- 23 files changed, 235 insertions(+), 40 deletions(-) diff --git a/interfaces/innerkits/rust/tests/BUILD.gn b/interfaces/innerkits/rust/tests/BUILD.gn index ac817642..bfff3bd4 100644 --- a/interfaces/innerkits/rust/tests/BUILD.gn +++ b/interfaces/innerkits/rust/tests/BUILD.gn @@ -12,6 +12,7 @@ # limitations under the License. import("//build/test.gni") +import("../../../../services/samgr/var.gni") rust_cxx("samgr_rust_test_gen") { sources = [ "mem.rs" ] @@ -69,12 +70,18 @@ ohos_rust_systemtest("rust_samgr_sdv_test") { "//third_party/rust/crates/cxx:lib", ] external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "hilog:hilog_rust", "ipc:ipc_rust", "safwk:system_ability_fwk_rust", ] + defines = [] + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken", + "access_token:libtoken_setproc", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } subsystem_name = "systemabilitymgr" part_name = "samgr" diff --git a/services/samgr/native/test/unittest/BUILD.gn b/services/samgr/native/test/unittest/BUILD.gn index 5b33a54b..a76daa2d 100644 --- a/services/samgr/native/test/unittest/BUILD.gn +++ b/services/samgr/native/test/unittest/BUILD.gn @@ -101,8 +101,6 @@ ohos_unittest("SystemAbilityMgrTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -123,6 +121,13 @@ ohos_unittest("SystemAbilityMgrTest") { defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ] } } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } if (hicollie_able) { external_deps += [ "hicollie:libhicollie" ] defines += [ "HICOLLIE_ENABLE" ] @@ -202,8 +207,6 @@ ohos_unittest("SystemAbilityMgrCollectTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -229,6 +232,14 @@ ohos_unittest("SystemAbilityMgrCollectTest") { defines += [ "HICOLLIE_ENABLE" ] } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } + if (preferences_enable) { external_deps += [ "preferences:native_preferences" ] sources += @@ -316,8 +327,6 @@ ohos_unittest("SystemAbilityMgrDeviceNetworkingTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -338,6 +347,13 @@ ohos_unittest("SystemAbilityMgrDeviceNetworkingTest") { defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ] } } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } if (hicollie_able) { external_deps += [ "hicollie:libhicollie" ] defines += [ "HICOLLIE_ENABLE" ] @@ -403,8 +419,6 @@ ohos_unittest("SystemAbilityMgrStubTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -436,6 +450,14 @@ ohos_unittest("SystemAbilityMgrStubTest") { external_deps += [ "device_manager:devicemanagersdk" ] defines += [ "SUPPORT_DEVICE_MANAGER" ] } + + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } } ohos_unittest("SystemAbilityMgrProxyTest") { @@ -476,8 +498,6 @@ ohos_unittest("SystemAbilityMgrProxyTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "googletest:gtest_main", "hilog:libhilog", @@ -485,6 +505,14 @@ ohos_unittest("SystemAbilityMgrProxyTest") { "ipc:ipc_single", "json:nlohmann_json_static", ] + defines = [] + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } } ohos_unittest("LocalAbilityManagerProxyTest") { @@ -571,8 +599,6 @@ ohos_unittest("SystemAbilityStateSchedulerTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -587,6 +613,14 @@ ohos_unittest("SystemAbilityStateSchedulerTest") { "json:nlohmann_json_static", "safwk:system_ability_fwk", ] + defines = [] + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } if (support_device_manager) { external_deps += [ "device_manager:devicemanagersdk" ] @@ -635,8 +669,6 @@ ohos_unittest("SystemAbilityMgrDumperTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "ffrt:libffrt", "googletest:gtest_main", @@ -650,6 +682,14 @@ ohos_unittest("SystemAbilityMgrDumperTest") { "json:nlohmann_json_static", "safwk:system_ability_fwk", ] + defines = [] + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } } ohos_executable("manual_ondemand") { @@ -669,8 +709,6 @@ ohos_executable("manual_ondemand") { cflags += [ "-DBINDER_IPC_32BIT" ] } external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "hilog:libhilog", "init:libbeget_proxy", @@ -684,6 +722,13 @@ ohos_executable("manual_ondemand") { external_deps += [ "dsoftbus:softbus_client" ] defines += [ "SUPPORT_SOFTBUS" ] } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } part_name = "samgr" subsystem_name = "systemabilitymgr" } @@ -705,8 +750,6 @@ ohos_executable("ondemand") { cflags += [ "-DBINDER_IPC_32BIT" ] } external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "hilog:libhilog", "init:libbeget_proxy", @@ -720,6 +763,13 @@ ohos_executable("ondemand") { external_deps += [ "dsoftbus:softbus_client" ] defines += [ "SUPPORT_SOFTBUS" ] } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } part_name = "samgr" subsystem_name = "systemabilitymgr" } @@ -788,6 +838,14 @@ ohos_executable("TestTool") { defines += [ "SUPPORT_SOFTBUS" ] } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } + if (support_device_manager) { sources += [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp" ] @@ -796,8 +854,6 @@ ohos_executable("TestTool") { } external_deps += [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", diff --git a/services/samgr/native/test/unittest/rust/service/BUILD.gn b/services/samgr/native/test/unittest/rust/service/BUILD.gn index c1e6701a..f33b0526 100644 --- a/services/samgr/native/test/unittest/rust/service/BUILD.gn +++ b/services/samgr/native/test/unittest/rust/service/BUILD.gn @@ -12,18 +12,22 @@ # limitations under the License. import("//build/ohos.gni") +import("../../../../../var.gni") ohos_rust_shared_library("test_access_token") { sources = [ "src/access_token.rs", "src/lib.rs", ] - - external_deps = [ - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", - ] - + external_deps = [] + defines = [] + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } crate_name = "test_access_token" crate_type = "dylib" subsystem_name = "systemabilitymgr" diff --git a/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp b/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp index 1951a872..0a181ca6 100644 --- a/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp +++ b/services/samgr/native/test/unittest/src/manual_ondemand_helper.cpp @@ -27,14 +27,16 @@ #include "iremote_object.h" #include "iservice_registry.h" #include "isystem_ability_load_callback.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" +#include "token_setproc.h" +#endif #include "sam_mock_permission.h" #ifdef SUPPORT_SOFTBUS #include "softbus_bus_center.h" #endif #include "system_ability_ondemand_reason.h" #include "system_ability_definition.h" -#include "token_setproc.h" #include "parameter.h" #include "parameters.h" diff --git a/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp b/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp index 44d6ed2c..a49a0f17 100644 --- a/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp +++ b/services/samgr/native/test/unittest/src/mock_accesstoken_kit.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" namespace OHOS { @@ -22,4 +23,5 @@ int AccessTokenKit::VerifyAccessToken(AccessTokenID tokenID, const std::string& return PERMISSION_GRANTED; } } // namespace Security::AccessToken -} // namespace OHOS \ No newline at end of file +} // namespace OHOS +#endif \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/mock_permission.cpp b/services/samgr/native/test/unittest/src/mock_permission.cpp index b5c444bf..e9352ee2 100644 --- a/services/samgr/native/test/unittest/src/mock_permission.cpp +++ b/services/samgr/native/test/unittest/src/mock_permission.cpp @@ -15,12 +15,15 @@ #include "sam_mock_permission.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" #include "token_setproc.h" +#endif namespace OHOS { void SamMockPermission::MockPermission() { +#ifdef SUPPORT_ACCESS_TOKEN static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC", "ohos.permission.ACCESS_EXT_SYSTEM_ABILITY" @@ -38,10 +41,12 @@ void SamMockPermission::MockPermission() }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif } void SamMockPermission::MockProcess(const char* processName) { +#ifdef SUPPORT_ACCESS_TOKEN static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC" }; @@ -58,5 +63,6 @@ void SamMockPermission::MockProcess(const char* processName) }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif } } \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/ondemand_helper.cpp b/services/samgr/native/test/unittest/src/ondemand_helper.cpp index 78a8da1c..014c8aca 100644 --- a/services/samgr/native/test/unittest/src/ondemand_helper.cpp +++ b/services/samgr/native/test/unittest/src/ondemand_helper.cpp @@ -27,14 +27,16 @@ #include "iremote_object.h" #include "iservice_registry.h" #include "isystem_ability_load_callback.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" +#include "token_setproc.h" +#endif #include "sam_mock_permission.h" #ifdef SUPPORT_SOFTBUS #include "softbus_bus_center.h" #endif #include "system_ability_ondemand_reason.h" #include "system_ability_definition.h" -#include "token_setproc.h" #include "parameter.h" #include "parameters.h" diff --git a/services/samgr/native/test/unittest/src/system_ability_manager_dumper_test.cpp b/services/samgr/native/test/unittest/src/system_ability_manager_dumper_test.cpp index 1623623e..812aa5aa 100644 --- a/services/samgr/native/test/unittest/src/system_ability_manager_dumper_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_manager_dumper_test.cpp @@ -78,11 +78,13 @@ void SystemAbilityManagerDumperTest::TearDown() * @tc.require: I7VEPG */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityManagerDumperTest, CanDump001, TestSize.Level3) { bool result = SystemAbilityManagerDumper::CanDump(); EXPECT_FALSE(result); } +#endif /** * @tc.name: FfrtDumpProc001 @@ -91,6 +93,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, CanDump001, TestSize.Level3) * @tc.require: I9I86P */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityManagerDumperTest, FfrtDumpProc001, TestSize.Level3) { DTEST_LOG << "FfrtDumpProc001 begin" << std::endl; @@ -101,6 +104,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, FfrtDumpProc001, TestSize.Level3) EXPECT_EQ(ret, ERR_PERMISSION_DENIED); DTEST_LOG << "FfrtDumpProc001 end" << std::endl; } +#endif /** * @tc.name: GetSAMgrFfrtInfo001 @@ -650,6 +654,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser006, TestSize.Level3) * @tc.require: I9DR69 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser007, TestSize.Level3) { DTEST_LOG << "IpcDumpCmdParser007 begin" << std::endl; @@ -664,6 +669,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser007, TestSize.Level3) EXPECT_FALSE(ret); DTEST_LOG << "IpcDumpCmdParser007 end" << std::endl; } +#endif /** * @tc.name: IpcDumpCmdParser008 @@ -672,6 +678,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser007, TestSize.Level3) * @tc.require: I9DR69 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser008, TestSize.Level3) { DTEST_LOG << "IpcDumpCmdParser008 begin" << std::endl; @@ -686,6 +693,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser008, TestSize.Level3) EXPECT_FALSE(ret); DTEST_LOG << "IpcDumpCmdParser008 end" << std::endl; } +#endif /** * @tc.name: IpcDumpCmdParser009 @@ -694,6 +702,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser008, TestSize.Level3) * @tc.require: I9DR69 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser009, TestSize.Level3) { DTEST_LOG << "IpcDumpCmdParser009 begin" << std::endl; @@ -708,6 +717,7 @@ HWTEST_F(SystemAbilityManagerDumperTest, IpcDumpCmdParser009, TestSize.Level3) EXPECT_FALSE(ret); DTEST_LOG << "IpcDumpCmdParser009 end" << std::endl; } +#endif /** * @tc.name: IpcDumpCmdParser010 diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp index d3dcc777..82210df7 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp @@ -31,7 +31,9 @@ #include "test_log.h" #define private public #include "ipc_skeleton.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "system_ability_manager.h" #ifdef SUPPORT_COMMON_EVENT #include "common_event_collect.h" @@ -674,6 +676,7 @@ HWTEST_F(SystemAbilityMgrTest, UnloadSystemAbility001, TestSize.Level3) * @tc.type: FUNC * @tc.require: I5KMF7 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, UnloadSystemAbility002, TestSize.Level3) { DTEST_LOG << "UnloadSystemAbility002 begin" << std::endl; @@ -687,6 +690,7 @@ HWTEST_F(SystemAbilityMgrTest, UnloadSystemAbility002, TestSize.Level3) EXPECT_EQ(result, INVALID_CALL_PROC); DTEST_LOG << "UnloadSystemAbility002 end" << std::endl; } +#endif /** * @tc.name: UnloadSystemAbility003 @@ -812,6 +816,7 @@ HWTEST_F(SystemAbilityMgrTest, CancelUnloadSystemAbility005, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6J4T7 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, CancelUnloadSystemAbility006, TestSize.Level3) { DTEST_LOG << " CancelUnloadSystemAbility006 begin" << std::endl; @@ -830,6 +835,7 @@ HWTEST_F(SystemAbilityMgrTest, CancelUnloadSystemAbility006, TestSize.Level3) EXPECT_EQ(ret, ERR_INVALID_VALUE); DTEST_LOG << "CancelUnloadSystemAbility006 end" << std::endl; } +#endif /** * @tc.name: DoUnloadSystemAbility001 @@ -926,6 +932,7 @@ HWTEST_F(SystemAbilityMgrTest, UnloadAllIdleSystemAbility002, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6NKWX */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, UnloadAllIdleSystemAbility003, TestSize.Level3) { DTEST_LOG << "UnloadAllIdleSystemAbility003 begin" << std::endl; @@ -935,5 +942,6 @@ HWTEST_F(SystemAbilityMgrTest, UnloadAllIdleSystemAbility003, TestSize.Level3) EXPECT_EQ(ret, ERR_PERMISSION_DENIED); DTEST_LOG << "UnloadAllIdleSystemAbility003 end" << std::endl; } +#endif } // namespace OHOS \ No newline at end of file diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp index 5fe1b663..7facca6b 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp @@ -34,7 +34,9 @@ #ifdef SUPPORT_COMMON_EVENT #include "common_event_collect.h" #include "ipc_skeleton.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "ability_death_recipient.h" #endif @@ -1069,6 +1071,7 @@ HWTEST_F(SystemAbilityMgrTest, IpcDumpSamgrProcess001, TestSize.Level2) * @tc.desc: test IpcDumpSingleProcess. * @tc.type: FUNC */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, IpcDumpSingleProcess001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; @@ -1082,6 +1085,7 @@ HWTEST_F(SystemAbilityMgrTest, IpcDumpSingleProcess001, TestSize.Level2) saMgr->IpcDumpSingleProcess(fd, cmd, nativeTokenInfo.processName); EXPECT_TRUE(ret); } +#endif /** * @tc.name: Test DoLoadForPerf diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_ondemand_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_ondemand_test.cpp index b5fd00fc..e76de558 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_ondemand_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_ondemand_test.cpp @@ -32,7 +32,9 @@ #include "test_log.h" #define private public #include "ipc_skeleton.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "system_ability_manager.h" #ifdef SUPPORT_COMMON_EVENT #include "common_event_collect.h" @@ -521,6 +523,7 @@ HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy002, TestSize.Level3) EXPECT_EQ(ERR_INVALID_VALUE, ret); } +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy003, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; @@ -539,7 +542,9 @@ HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy003, TestSize.Level3) int32_t ret = saMgr->GetOnDemandPolicy(systemAbilityId, type, abilityOnDemandEvents); EXPECT_EQ(ERR_PERMISSION_DENIED, ret); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy004, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; @@ -560,7 +565,9 @@ HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy004, TestSize.Level3) int32_t ret = saMgr->GetOnDemandPolicy(systemAbilityId, type, abilityOnDemandEvents); EXPECT_EQ(ERR_INVALID_VALUE, ret); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy005, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; @@ -581,7 +588,9 @@ HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy005, TestSize.Level3) int32_t ret = saMgr->GetOnDemandPolicy(systemAbilityId, type, abilityOnDemandEvents); EXPECT_EQ(ERR_INVALID_VALUE, ret); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy006, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; @@ -609,6 +618,7 @@ HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy006, TestSize.Level3) int32_t ret = saMgr->GetOnDemandPolicy(systemAbilityId, type, abilityOnDemandEvents); EXPECT_EQ(ERR_OK, ret); } +#endif /** * @tc.name: UpdateOnDemandPolicy001 @@ -616,6 +626,7 @@ HWTEST_F(SystemAbilityMgrTest, GetOnDemandPolicy006, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6V4AX */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrTest, UpdateOnDemandPolicy001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; @@ -650,6 +661,7 @@ HWTEST_F(SystemAbilityMgrTest, UpdateOnDemandPolicy001, TestSize.Level3) EXPECT_EQ(ret, ERR_INVALID_VALUE); saMgr->saProfileMap_.erase(TEST_OVERFLOW_SAID); } +#endif /** * @tc.name: GetOnDemandReasonExtraData001 diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp index 26cc1a6b..0d61f4ba 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp @@ -43,6 +43,7 @@ constexpr int64_t DEFAULT_EVENTID = 0; constexpr int32_t INVALID_SAID = -1; } +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, AddSystemAbilityInner001, TestSize.Level4) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -52,7 +53,9 @@ HWTEST_F(SystemAbilityMgrStubTest, AddSystemAbilityInner001, TestSize.Level4) int32_t result = saMgr->AddSystemAbilityInner(data, reply); EXPECT_EQ(result, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, AddSystemProcessInner001, TestSize.Level4) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -62,7 +65,9 @@ HWTEST_F(SystemAbilityMgrStubTest, AddSystemProcessInner001, TestSize.Level4) int32_t result = saMgr->AddSystemProcessInner(data, reply); EXPECT_EQ(result, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, SubscribeSystemProcessInner001, TestSize.Level3) { DTEST_LOG << "SubscribeSystemProcessInner001" << std::endl; @@ -73,6 +78,7 @@ HWTEST_F(SystemAbilityMgrStubTest, SubscribeSystemProcessInner001, TestSize.Leve int32_t ret = saMgr->SubscribeSystemProcessInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif HWTEST_F(SystemAbilityMgrStubTest, SubsSystemAbilityInner002, TestSize.Level3) { diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp index 3f599221..9b6ddf00 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp @@ -119,6 +119,7 @@ HWTEST_F(SystemAbilityMgrStubTest, OnRemoteRequest001, TestSize.Level4) EXPECT_EQ(result, IPC_STUB_UNKNOW_TRANS_ERR); } +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, ListSystemAbilityInner001, TestSize.Level4) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -128,6 +129,7 @@ HWTEST_F(SystemAbilityMgrStubTest, ListSystemAbilityInner001, TestSize.Level4) int32_t result = saMgr->ListSystemAbilityInner(data, reply); EXPECT_EQ(result, ERR_PERMISSION_DENIED); } +#endif HWTEST_F(SystemAbilityMgrStubTest, SubsSystemAbilityInner001, TestSize.Level4) { @@ -149,6 +151,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnSubsSystemAbilityInner001, TestSize.Level4) EXPECT_EQ(result, ERR_NULL_OBJECT); } +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, CheckRemtSystemAbilityInner001, TestSize.Level4) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -158,7 +161,9 @@ HWTEST_F(SystemAbilityMgrStubTest, CheckRemtSystemAbilityInner001, TestSize.Leve int32_t result = saMgr->CheckRemtSystemAbilityInner(data, reply); EXPECT_EQ(result, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, AddOndemandSystemAbilityInner001, TestSize.Level4) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -168,7 +173,9 @@ HWTEST_F(SystemAbilityMgrStubTest, AddOndemandSystemAbilityInner001, TestSize.Le int32_t result = saMgr->AddOndemandSystemAbilityInner(data, reply); EXPECT_EQ(result, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbilityInner001, TestSize.Level4) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -178,7 +185,9 @@ HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbilityInner001, TestSize.Level4) int32_t result = saMgr->RemoveSystemAbilityInner(data, reply); EXPECT_EQ(result, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, GetSystemProcessInfoInner001, TestSize.Level3) { DTEST_LOG << "GetSystemProcessInfoInner001" << std::endl; @@ -188,7 +197,9 @@ HWTEST_F(SystemAbilityMgrStubTest, GetSystemProcessInfoInner001, TestSize.Level3 int32_t ret = saMgr->GetSystemProcessInfoInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, GetRunningSystemProcessInner001, TestSize.Level3) { DTEST_LOG << "GetRunningSystemProcessInner001" << std::endl; @@ -198,7 +209,9 @@ HWTEST_F(SystemAbilityMgrStubTest, GetRunningSystemProcessInner001, TestSize.Lev int32_t ret = saMgr->GetRunningSystemProcessInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, UnSubscribeSystemProcessInner001, TestSize.Level3) { DTEST_LOG << "UnSubscribeSystemProcessInner001" << std::endl; @@ -208,7 +221,9 @@ HWTEST_F(SystemAbilityMgrStubTest, UnSubscribeSystemProcessInner001, TestSize.Le int32_t ret = saMgr->UnSubscribeSystemProcessInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, GetOnDemandPolicyInner001, TestSize.Level3) { DTEST_LOG << "GetOnDemandPolicyInner001" << std::endl; @@ -218,6 +233,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetOnDemandPolicyInner001, TestSize.Level3) int32_t ret = saMgr->GetOnDemandPolicyInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif /** * @tc.name: Test UpdateOnDemandPolicyInner001 @@ -225,6 +241,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetOnDemandPolicyInner001, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6T116 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, UpdateOnDemandPolicyInner001, TestSize.Level3) { DTEST_LOG << "UpdateOnDemandPolicyInner001" << std::endl; @@ -234,6 +251,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UpdateOnDemandPolicyInner001, TestSize.Level3 int32_t ret = saMgr->UpdateOnDemandPolicyInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif /** * @tc.name: GetOnDemandReasonExtraDataInner001 @@ -241,6 +259,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UpdateOnDemandPolicyInner001, TestSize.Level3 * @tc.type: FUNC * @tc.require: I6XB42 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, GetOnDemandReasonExtraDataInner001, TestSize.Level3) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -249,6 +268,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetOnDemandReasonExtraDataInner001, TestSize. int32_t ret = saMgr->GetOnDemandReasonExtraDataInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif /** * @tc.name: GetExtensionSaIdsInner001 @@ -256,6 +276,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetOnDemandReasonExtraDataInner001, TestSize. * @tc.type: FUNC * @tc.require: I6XB42 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, GetExtensionSaIdsInner001, TestSize.Level3) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -264,6 +285,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetExtensionSaIdsInner001, TestSize.Level3) int32_t ret = saMgr->GetExtensionSaIdsInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif /** * @tc.name: GetExtensionRunningSaListInner001 @@ -271,6 +293,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetExtensionSaIdsInner001, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6XB42 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, GetExtensionRunningSaListInner001, TestSize.Level3) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -279,6 +302,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetExtensionRunningSaListInner001, TestSize.L int32_t ret = saMgr->GetExtensionRunningSaListInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif /** * @tc.name: GetCommonEventExtraDataIdlistInner001 @@ -286,6 +310,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetExtensionRunningSaListInner001, TestSize.L * @tc.type: FUNC * @tc.require: I6XB42 */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, GetCommonEventExtraDataIdlistInner001, TestSize.Level3) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -294,6 +319,7 @@ HWTEST_F(SystemAbilityMgrStubTest, GetCommonEventExtraDataIdlistInner001, TestSi int32_t ret = saMgr->GetCommonEventExtraDataIdlistInner(data, reply); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); } +#endif /** * @tc.name: ListSystemAbilityInner002 diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_unload_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_unload_test.cpp index cb2c5f25..f020bbf4 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_unload_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_unload_test.cpp @@ -347,6 +347,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbilityInner001, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6AJ3S */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbilityInner002, TestSize.Level3) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -357,6 +358,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbilityInner002, TestSize.Level3) int32_t result = saMgr->UnloadSystemAbilityInner(data, reply); EXPECT_EQ(result, INVALID_CALL_PROC); } +#endif /** * @tc.name: UnloadSystemAbility001 @@ -378,6 +380,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility001, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6AJ3S */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility002, TestSize.Level3) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -385,6 +388,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility002, TestSize.Level3) int32_t result = saMgr->UnloadSystemAbility(SAID); EXPECT_EQ(result, INVALID_CALL_PROC); } +#endif /** * @tc.name: UnloadSystemAbility003 @@ -392,6 +396,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility002, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6AJ3S */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility003, TestSize.Level3) { sptr saMgr = SystemAbilityManager::GetInstance(); @@ -401,6 +406,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility003, TestSize.Level3) int32_t result = saMgr->UnloadSystemAbility(SAID); EXPECT_EQ(result, INVALID_CALL_PROC); } +#endif /** * @tc.name: UnloadSystemAbility004 @@ -408,6 +414,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility003, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6AJ3S */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility004, TestSize.Level3) { SamMockPermission::MockProcess("invalidProcess"); @@ -419,6 +426,7 @@ HWTEST_F(SystemAbilityMgrStubTest, UnloadSystemAbility004, TestSize.Level3) int32_t result = saMgr->UnloadSystemAbility(SAID); EXPECT_EQ(result, INVALID_CALL_PROC); } +#endif /** * @tc.name: UnloadSystemAbility005 diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_subscribe_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_subscribe_test.cpp index 58803b8e..3056c597 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_subscribe_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_subscribe_test.cpp @@ -32,7 +32,9 @@ #include "test_log.h" #define private public #include "ipc_skeleton.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "system_ability_manager.h" #ifdef SUPPORT_COMMON_EVENT #include "common_event_collect.h" diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp index c29e147a..69743254 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp @@ -32,7 +32,9 @@ #include "ability_death_recipient.h" #define private public #include "ipc_skeleton.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "accesstoken_kit.h" +#endif #include "system_ability_manager.h" #ifdef SUPPORT_COMMON_EVENT #include "common_event_collect.h" diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_util_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_util_test.cpp index 6abb8fe7..4b3c142a 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_util_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_util_test.cpp @@ -178,6 +178,7 @@ HWTEST_F(SamgrUtilTest, TransformDeviceId002, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6V4AX */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SamgrUtilTest, CheckCallerProcess001, TestSize.Level3) { CommonSaProfile saProfile; @@ -196,6 +197,7 @@ HWTEST_F(SamgrUtilTest, CheckCallerProcess001, TestSize.Level3) bool ret = SamgrUtil::CheckCallerProcess(saProfile); EXPECT_EQ(false, ret); } +#endif /** * @tc.name: CheckCallerProcess002 @@ -203,6 +205,7 @@ HWTEST_F(SamgrUtilTest, CheckCallerProcess001, TestSize.Level3) * @tc.type: FUNC * @tc.require: I6V4AX */ +#ifdef SUPPORT_ACCESS_TOKEN HWTEST_F(SamgrUtilTest, CheckCallerProcess002, TestSize.Level3) { CommonSaProfile saProfile; @@ -221,6 +224,7 @@ HWTEST_F(SamgrUtilTest, CheckCallerProcess002, TestSize.Level3) bool ret = SamgrUtil::CheckCallerProcess(saProfile); EXPECT_EQ(false, ret); } +#endif /** * @tc.name: CheckAllowUpdate001 diff --git a/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp b/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp index 04035884..41c19723 100644 --- a/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_test_tool.cpp @@ -21,7 +21,10 @@ #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "itest_transaction_service.h" +#ifdef SUPPORT_ACCESS_TOKEN #include "nativetoken_kit.h" +#include "token_setproc.h" +#endif #include "sam_log.h" #ifdef SUPPORT_SOFTBUS #include "softbus_bus_center.h" @@ -30,7 +33,6 @@ #include "system_ability_definition.h" #include "system_ability_load_callback_stub.h" #include "system_ability_status_change_stub.h" -#include "token_setproc.h" #define private public #include "system_ability_manager.h" @@ -281,6 +283,7 @@ namespace { static void MockProcess(const char* processName) { +#ifdef SUPPORT_ACCESS_TOKEN uint64_t tokenId; NativeTokenInfoParams infoInstance = { .dcapsNum = 0, @@ -294,6 +297,7 @@ namespace { }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif } static void DoSend(int32_t said, int32_t rssProcess) @@ -415,6 +419,7 @@ static void DoRemote(char* argv[]) int main(int argc, char* argv[]) { +#ifdef SUPPORT_ACCESS_TOKEN static const char *PERMS[] = { "ohos.permission.DISTRIBUTED_DATASYNC" }; @@ -431,6 +436,7 @@ int main(int argc, char* argv[]) }; tokenId = GetAccessTokenId(&infoInstance); SetSelfTokenID(tokenId); +#endif if (argc == ARGC_DEFAULT_LENTH) { DoDefault(argv); } else if (argc == ARGC_EXTEND_LENTH) { diff --git a/services/samgr/var.gni b/services/samgr/var.gni index 2fd2d341..429ba162 100644 --- a/services/samgr/var.gni +++ b/services/samgr/var.gni @@ -18,6 +18,7 @@ declare_args() { support_device_manager = false support_common_event = false support_softbus = true + samgr_support_access_token = true if (!defined(global_parts_info) || defined(global_parts_info.communication_bluetooth)) { bluetooth_part_enable = true @@ -42,4 +43,8 @@ declare_args() { !defined(global_parts_info.communication_dsoftbus)) { support_softbus = false } + if (defined(global_parts_info) && + !defined(global_parts_info.security_access_token)) { + samgr_support_access_token = false + } } diff --git a/test/fuzztest/samgr_fuzzer/BUILD.gn b/test/fuzztest/samgr_fuzzer/BUILD.gn index cb32a1e0..a9aac270 100644 --- a/test/fuzztest/samgr_fuzzer/BUILD.gn +++ b/test/fuzztest/samgr_fuzzer/BUILD.gn @@ -171,8 +171,6 @@ foreach(item, samgr_fuzztests) { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -193,6 +191,14 @@ foreach(item, samgr_fuzztests) { defines += [ "HICOLLIE_ENABLE" ] } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } + if (support_device_manager) { sources += [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp", diff --git a/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn b/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn index fcbf4312..f082e2c6 100644 --- a/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn +++ b/test/fuzztest/samgrcoverage_fuzzer/BUILD.gn @@ -74,8 +74,6 @@ ohos_fuzztest("SamgrCoverageFuzzTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -96,6 +94,13 @@ ohos_fuzztest("SamgrCoverageFuzzTest") { defines += [ "HICOLLIE_ENABLE" ] } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } if (support_device_manager) { sources += [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp" ] diff --git a/test/fuzztest/samgrdumper_fuzzer/BUILD.gn b/test/fuzztest/samgrdumper_fuzzer/BUILD.gn index 0593cef9..7ed1b8bc 100644 --- a/test/fuzztest/samgrdumper_fuzzer/BUILD.gn +++ b/test/fuzztest/samgrdumper_fuzzer/BUILD.gn @@ -73,8 +73,6 @@ ohos_fuzztest("SamgrDumperFuzzTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -95,6 +93,14 @@ ohos_fuzztest("SamgrDumperFuzzTest") { defines += [ "HICOLLIE_ENABLE" ] } + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } + if (support_device_manager) { sources += [ "${samgr_services_dir}/source/collect/device_networking_collect.cpp" ] diff --git a/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn b/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn index 8ac7aa82..e18e9483 100644 --- a/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn +++ b/test/fuzztest/systemabilitymanager_fuzzer/BUILD.gn @@ -73,8 +73,6 @@ ohos_fuzztest("SystemAbilityManagerFuzzTest") { external_deps = [ "access_token:libaccesstoken_sdk", - "access_token:libnativetoken_shared", - "access_token:libtokensetproc_shared", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -101,6 +99,14 @@ ohos_fuzztest("SystemAbilityManagerFuzzTest") { external_deps += [ "device_manager:devicemanagersdk" ] defines += [ "SUPPORT_DEVICE_MANAGER" ] } + + if (samgr_support_access_token) { + external_deps += [ + "access_token:libnativetoken_shared", + "access_token:libtokensetproc_shared", + ] + defines += [ "SUPPORT_ACCESS_TOKEN" ] + } } group("fuzztest") { -- Gitee