diff --git a/BUILD.gn b/BUILD.gn index 11bad1bd5e7a4df0bee7b5798b972a9a6870fbed..0d544d73457db4d66cf2d612bedef8b9bbe7d5db 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,7 +16,8 @@ import("//build/ohos.gni") group("security_component_build_module") { if (is_standard_system) { deps = [ - "interfaces/inner_api/security_component:libsecurity_component_sdk", + "frameworks/inner_api/security_component:libsecurity_component_sdk", + "services/security_component_service/sa:security_component_common", "services/security_component_service/sa:security_component_service", "services/security_component_service/sa/sa_profile:security_component_sa_profile_standard", ] @@ -29,8 +30,8 @@ group("security_component_build_module_test") { if (is_standard_system) { deps += [ "frameworks/enhance_adapter/test:unittest", - "interfaces/inner_api/enhance_kits/test:unittest", - "interfaces/inner_api/security_component/test:unittest", + "frameworks/inner_api/enhance_kits/test:unittest", + "frameworks/inner_api/security_component/test:unittest", "services/security_component_service/sa/test:unittest", ] } diff --git a/bundle.json b/bundle.json index 6e1fbb6eff624d04d92ed24b678271f7b3d88adf..93938dbfc075c196b75195dfb1129a1d98e30091 100644 --- a/bundle.json +++ b/bundle.json @@ -51,22 +51,35 @@ ], "inner_kits": [ { - "name": "//base/security/security_component_manager/interfaces/inner_api/security_component:libsecurity_component_sdk", + "name": "//base/security/security_component_manager/frameworks/inner_api/security_component:libsecurity_component_sdk", "header": { "header_files": [ "i_sec_comp_probe.h", - "sec_comp_kit.h" + "location_button.h", + "paste_button.h", + "save_button.h", + "sec_comp_base.h", + "sec_comp_enhance_adapter.h", + "sec_comp_enhance_kit.h", + "sec_comp_enhance_kit_c.h", + "sec_comp_err.h", + "sec_comp_info.h", + "sec_comp_kit.h", + "sec_comp_ui_register.h", + "security_component_service_ipc_interface_code.h" ], "header_base": "//base/security/security_component_manager/interfaces/inner_api/security_component/include" } }, { - "name": "//base/security/security_component_manager/services/security_component_service/sa:security_component_service", + "name": "//base/security/security_component_manager/services/security_component_service/sa:security_component_common", "header": { "header_files": [ - "sec_comp_manager.h" + "delay_exit_task.h", + "sec_comp_info_helper.h", + "sec_event_handler.h" ], - "header_base": "//base/security/security_component_manager/services/security_component_service/sa/sa_main" + "header_base": "//base/security/security_component_manager/interfaces/inner_api/security_component_common" } } ], diff --git a/frameworks/BUILD.gn b/frameworks/BUILD.gn index a287271ea0709549fc3e014adcd3a9a883da26a8..584cc1595518432087040c925945cb935b4813f7 100644 --- a/frameworks/BUILD.gn +++ b/frameworks/BUILD.gn @@ -18,6 +18,8 @@ sec_comp_root_dir = ".." config("security_component_framework_src_set_config") { include_dirs = [ "common/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] } @@ -34,7 +36,6 @@ ohos_source_set("security_component_framework_src_set") { include_dirs = [ "common/include", "security_component/include", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] sources = [ @@ -67,6 +68,8 @@ config("security_component_enhance_adapter_src_set_config") { include_dirs = [ "common/include", "enhance_adapter/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] } @@ -80,11 +83,37 @@ ohos_source_set("security_component_enhance_adapter_src_set") { debug = false } branch_protector_ret = "pac_ret" - include_dirs = [ - "common/include", - "enhance_adapter/include", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", + include_dirs = [ "common/include" ] + + sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ] + + configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] + public_configs = [ ":security_component_enhance_adapter_src_set_config" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_single", + ] + + public_external_deps = [ "json:nlohmann_json_static" ] + + cflags_cc = [ + "-DHILOG_ENABLE", + "-fvisibility=hidden", ] +} + +ohos_source_set("security_component_enhance_adapter_service_src_set") { + subsystem_name = "security" + part_name = "security_component_manager" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" + include_dirs = [ "common/include" ] sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ] @@ -102,6 +131,7 @@ ohos_source_set("security_component_enhance_adapter_src_set") { cflags_cc = [ "-DHILOG_ENABLE", "-fvisibility=hidden", + "-DSEC_COMP_SERVICE_COMPILE_ENABLE", ] } @@ -112,6 +142,7 @@ ohos_source_set("security_component_no_cfi_framework_src_set") { include_dirs = [ "common/include", "security_component/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] @@ -148,7 +179,9 @@ ohos_source_set("security_component_no_cfi_enhance_adapter_src_set") { include_dirs = [ "common/include", "enhance_adapter/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", ] sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ] diff --git a/interfaces/inner_api/enhance_kits/BUILD.gn b/frameworks/inner_api/enhance_kits/BUILD.gn similarity index 96% rename from interfaces/inner_api/enhance_kits/BUILD.gn rename to frameworks/inner_api/enhance_kits/BUILD.gn index 49f1699f182b4608b8a2043688788d4d8c089b44..f147db43bcdfb950af5fe9d071cf96dd434645c7 100644 --- a/interfaces/inner_api/enhance_kits/BUILD.gn +++ b/frameworks/inner_api/enhance_kits/BUILD.gn @@ -39,6 +39,7 @@ ohos_source_set("security_component_enhance_sdk_src_set") { "include", "${sec_comp_root_dir}/frameworks/common/include", "${sec_comp_root_dir}/frameworks/enhance_adapter/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] sources = [ "src/sec_comp_enhance_kit.cpp" ] diff --git a/interfaces/inner_api/enhance_kits/src/sec_comp_enhance_kit.cpp b/frameworks/inner_api/enhance_kits/src/sec_comp_enhance_kit.cpp similarity index 100% rename from interfaces/inner_api/enhance_kits/src/sec_comp_enhance_kit.cpp rename to frameworks/inner_api/enhance_kits/src/sec_comp_enhance_kit.cpp diff --git a/interfaces/inner_api/enhance_kits/test/BUILD.gn b/frameworks/inner_api/enhance_kits/test/BUILD.gn similarity index 89% rename from interfaces/inner_api/enhance_kits/test/BUILD.gn rename to frameworks/inner_api/enhance_kits/test/BUILD.gn index 7f4e14044aedee05a3342e39be5d8b402c5dffc6..b46f0a1315de6d280ba8bd2037194d11bd0d1755 100644 --- a/interfaces/inner_api/enhance_kits/test/BUILD.gn +++ b/frameworks/inner_api/enhance_kits/test/BUILD.gn @@ -25,14 +25,17 @@ ohos_unittest("sec_comp_enhance_sdk_test") { debug = false } branch_protector_ret = "pac_ret" - include_dirs = [ "unittest/src" ] + include_dirs = [ + "unittest/src", + "${sec_comp_root_dir}/frameworks/common/include", + ] sources = [ "unittest/src/sec_comp_enhance_test.cpp" ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] cflags_cc = [ "-DHILOG_ENABLE" ] - deps = [ "${sec_comp_root_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_root_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "c_utils:utils", diff --git a/interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp b/frameworks/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp similarity index 100% rename from interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp rename to frameworks/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp diff --git a/interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.h b/frameworks/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.h similarity index 100% rename from interfaces/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.h rename to frameworks/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.h diff --git a/interfaces/inner_api/security_component/BUILD.gn b/frameworks/inner_api/security_component/BUILD.gn similarity index 86% rename from interfaces/inner_api/security_component/BUILD.gn rename to frameworks/inner_api/security_component/BUILD.gn index 29068dd7bb61c3cd7a82f81fe2861ca49cf4217c..bddf6011b8ada31fcdba0ce5a078db5330cfd95d 100644 --- a/interfaces/inner_api/security_component/BUILD.gn +++ b/frameworks/inner_api/security_component/BUILD.gn @@ -17,12 +17,8 @@ sec_comp_root_dir = "../../.." config("sec_comp_config") { visibility = [ ":*" ] - include_dirs = [ - "include", - "${sec_comp_root_dir}/frameworks/common/include", - "${sec_comp_root_dir}/frameworks/enhance_adapter/include/", - "${sec_comp_root_dir}/interfaces/inner_api/enhance_kits/include", - ] + include_dirs = + [ "${sec_comp_root_dir}/interfaces/inner_api/security_component/include" ] } ohos_shared_library("libsecurity_component_sdk") { @@ -32,13 +28,15 @@ ohos_shared_library("libsecurity_component_sdk") { output_name = "libsecurity_component_sdk" public_configs = [ ":sec_comp_config" ] + innerapi_tags = [ "sasdk" ] include_dirs = [ "include", "${sec_comp_root_dir}/frameworks/common/include", "${sec_comp_root_dir}/frameworks/enhance_adapter/include/", - "${sec_comp_root_dir}/interfaces/inner_api/enhance_kits/include", + "${sec_comp_root_dir}/frameworks/inner_api/enhance_kits/include", "${sec_comp_root_dir}/frameworks/security_component/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", ] sources = [ @@ -56,7 +54,7 @@ ohos_shared_library("libsecurity_component_sdk") { deps = [ "${sec_comp_root_dir}/frameworks:security_component_no_cfi_enhance_adapter_src_set", "${sec_comp_root_dir}/frameworks:security_component_no_cfi_framework_src_set", - "${sec_comp_root_dir}/interfaces/inner_api/enhance_kits:security_component_no_cfi_enhance_sdk_src_set", + "${sec_comp_root_dir}/frameworks/inner_api/enhance_kits:security_component_no_cfi_enhance_sdk_src_set", ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] diff --git a/interfaces/inner_api/security_component/include/i_sec_comp_dialog_callback.h b/frameworks/inner_api/security_component/include/i_sec_comp_dialog_callback.h similarity index 100% rename from interfaces/inner_api/security_component/include/i_sec_comp_dialog_callback.h rename to frameworks/inner_api/security_component/include/i_sec_comp_dialog_callback.h diff --git a/interfaces/inner_api/security_component/include/i_sec_comp_service.h b/frameworks/inner_api/security_component/include/i_sec_comp_service.h similarity index 93% rename from interfaces/inner_api/security_component/include/i_sec_comp_service.h rename to frameworks/inner_api/security_component/include/i_sec_comp_service.h index 155604b89e73a414bdc75cc2909a4f293213078b..18452ec6da1581f4056e7b879fe0c050ab03b21f 100644 --- a/interfaces/inner_api/security_component/include/i_sec_comp_service.h +++ b/frameworks/inner_api/security_component/include/i_sec_comp_service.h @@ -35,7 +35,7 @@ public: virtual int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) = 0; virtual int32_t UnregisterSecurityComponent(int32_t scId) = 0; virtual int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, - const SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback) = 0; + SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback) = 0; virtual bool VerifySavePermission(AccessToken::AccessTokenID tokenId) = 0; virtual sptr GetEnhanceRemoteObject() = 0; virtual int32_t PreRegisterSecCompProcess() = 0; diff --git a/interfaces/inner_api/security_component/include/sec_comp_caller_authorization.h b/frameworks/inner_api/security_component/include/sec_comp_caller_authorization.h similarity index 100% rename from interfaces/inner_api/security_component/include/sec_comp_caller_authorization.h rename to frameworks/inner_api/security_component/include/sec_comp_caller_authorization.h diff --git a/interfaces/inner_api/security_component/include/sec_comp_client.h b/frameworks/inner_api/security_component/include/sec_comp_client.h similarity index 96% rename from interfaces/inner_api/security_component/include/sec_comp_client.h rename to frameworks/inner_api/security_component/include/sec_comp_client.h index 563376e6675426c3cf38fac8c72f1686d5846d76..6b4f15f15552327f6acd6b80730c908ad88dbb37 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_client.h +++ b/frameworks/inner_api/security_component/include/sec_comp_client.h @@ -34,7 +34,7 @@ public: int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo); int32_t UnregisterSecurityComponent(int32_t scId); int32_t ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& clickInfo, + const std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback); bool VerifySavePermission(AccessToken::AccessTokenID tokenId); sptr GetEnhanceRemoteObject(bool doLoadSa); diff --git a/interfaces/inner_api/security_component/include/sec_comp_death_recipient.h b/frameworks/inner_api/security_component/include/sec_comp_death_recipient.h similarity index 100% rename from interfaces/inner_api/security_component/include/sec_comp_death_recipient.h rename to frameworks/inner_api/security_component/include/sec_comp_death_recipient.h diff --git a/interfaces/inner_api/security_component/include/sec_comp_dialog_callback.h b/frameworks/inner_api/security_component/include/sec_comp_dialog_callback.h similarity index 100% rename from interfaces/inner_api/security_component/include/sec_comp_dialog_callback.h rename to frameworks/inner_api/security_component/include/sec_comp_dialog_callback.h diff --git a/interfaces/inner_api/security_component/include/sec_comp_dialog_callback_stub.h b/frameworks/inner_api/security_component/include/sec_comp_dialog_callback_stub.h similarity index 100% rename from interfaces/inner_api/security_component/include/sec_comp_dialog_callback_stub.h rename to frameworks/inner_api/security_component/include/sec_comp_dialog_callback_stub.h diff --git a/interfaces/inner_api/security_component/include/sec_comp_load_callback.h b/frameworks/inner_api/security_component/include/sec_comp_load_callback.h similarity index 100% rename from interfaces/inner_api/security_component/include/sec_comp_load_callback.h rename to frameworks/inner_api/security_component/include/sec_comp_load_callback.h diff --git a/interfaces/inner_api/security_component/include/sec_comp_proxy.h b/frameworks/inner_api/security_component/include/sec_comp_proxy.h similarity index 95% rename from interfaces/inner_api/security_component/include/sec_comp_proxy.h rename to frameworks/inner_api/security_component/include/sec_comp_proxy.h index bb637ea3f660def6257ca48b1892a4aec9df9902..d4d6ba787af3b641dd610d1f9071f6097d7ec981 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_proxy.h +++ b/frameworks/inner_api/security_component/include/sec_comp_proxy.h @@ -30,7 +30,7 @@ public: int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) override; int32_t UnregisterSecurityComponent(int32_t scId) override; int32_t ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& clickInfo, + const std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback) override; bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override; sptr GetEnhanceRemoteObject() override; diff --git a/interfaces/inner_api/security_component/src/sec_comp_caller_authorization.cpp b/frameworks/inner_api/security_component/src/sec_comp_caller_authorization.cpp similarity index 100% rename from interfaces/inner_api/security_component/src/sec_comp_caller_authorization.cpp rename to frameworks/inner_api/security_component/src/sec_comp_caller_authorization.cpp diff --git a/interfaces/inner_api/security_component/src/sec_comp_client.cpp b/frameworks/inner_api/security_component/src/sec_comp_client.cpp similarity index 99% rename from interfaces/inner_api/security_component/src/sec_comp_client.cpp rename to frameworks/inner_api/security_component/src/sec_comp_client.cpp index b38f9cba98f1a1445ee2daaec77a49d79a1bacb4..cbdf031c663174e6d60a6e5453534502f5570944 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_client.cpp +++ b/frameworks/inner_api/security_component/src/sec_comp_client.cpp @@ -83,7 +83,7 @@ int32_t SecCompClient::UnregisterSecurityComponent(int32_t scId) } int32_t SecCompClient::ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& clickInfo, + const std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback) { auto proxy = GetProxy(true); diff --git a/interfaces/inner_api/security_component/src/sec_comp_death_recipient.cpp b/frameworks/inner_api/security_component/src/sec_comp_death_recipient.cpp similarity index 100% rename from interfaces/inner_api/security_component/src/sec_comp_death_recipient.cpp rename to frameworks/inner_api/security_component/src/sec_comp_death_recipient.cpp diff --git a/interfaces/inner_api/security_component/src/sec_comp_dialog_callback.cpp b/frameworks/inner_api/security_component/src/sec_comp_dialog_callback.cpp similarity index 100% rename from interfaces/inner_api/security_component/src/sec_comp_dialog_callback.cpp rename to frameworks/inner_api/security_component/src/sec_comp_dialog_callback.cpp diff --git a/interfaces/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp b/frameworks/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp similarity index 100% rename from interfaces/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp rename to frameworks/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp diff --git a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp b/frameworks/inner_api/security_component/src/sec_comp_kit.cpp similarity index 99% rename from interfaces/inner_api/security_component/src/sec_comp_kit.cpp rename to frameworks/inner_api/security_component/src/sec_comp_kit.cpp index 6df28a158b61794794c47b5f8feb5698d3e67825..17ed21a00a2afceb02933ab0f9b0e72b37640dc7 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp +++ b/frameworks/inner_api/security_component/src/sec_comp_kit.cpp @@ -102,7 +102,7 @@ int32_t SecCompKit::UnregisterSecurityComponent(int32_t scId) } int32_t SecCompKit::ReportSecurityComponentClickEvent(int32_t scId, - std::string& componentInfo, const SecCompClickEvent& clickInfo, + std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, OnFirstUseDialogCloseFunc&& callback) { if (!SecCompCallerAuthorization::GetInstance().IsKitCaller( diff --git a/interfaces/inner_api/security_component/src/sec_comp_load_callback.cpp b/frameworks/inner_api/security_component/src/sec_comp_load_callback.cpp similarity index 100% rename from interfaces/inner_api/security_component/src/sec_comp_load_callback.cpp rename to frameworks/inner_api/security_component/src/sec_comp_load_callback.cpp diff --git a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp b/frameworks/inner_api/security_component/src/sec_comp_proxy.cpp similarity index 99% rename from interfaces/inner_api/security_component/src/sec_comp_proxy.cpp rename to frameworks/inner_api/security_component/src/sec_comp_proxy.cpp index f8eb8029cdb4b74d222bb51bbcf1229b30b7c98f..4b1d1195d9e410c4b709caed13cb9c11871f68d7 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp +++ b/frameworks/inner_api/security_component/src/sec_comp_proxy.cpp @@ -230,7 +230,7 @@ int32_t SecCompProxy::SendReportClickEventRequest(MessageParcel& data) } int32_t SecCompProxy::ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& clickInfo, + const std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback) { std::lock_guard lock(useIPCMutex_); diff --git a/interfaces/inner_api/security_component/src/sec_comp_ui_register.cpp b/frameworks/inner_api/security_component/src/sec_comp_ui_register.cpp similarity index 100% rename from interfaces/inner_api/security_component/src/sec_comp_ui_register.cpp rename to frameworks/inner_api/security_component/src/sec_comp_ui_register.cpp diff --git a/interfaces/inner_api/security_component/test/BUILD.gn b/frameworks/inner_api/security_component/test/BUILD.gn similarity index 80% rename from interfaces/inner_api/security_component/test/BUILD.gn rename to frameworks/inner_api/security_component/test/BUILD.gn index 2b59ae11c69b904f2d2ad7796d47cb12c2979209..62d23662289e513debce54dbe41fa5102d6814f5 100644 --- a/interfaces/inner_api/security_component/test/BUILD.gn +++ b/frameworks/inner_api/security_component/test/BUILD.gn @@ -24,19 +24,20 @@ ohos_unittest("sec_comp_sdk_test") { include_dirs = [ "${sec_comp_root_dir}/frameworks/common/include", "${sec_comp_root_dir}/frameworks/security_component/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] sources = [ - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_caller_authorization.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_client.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_death_recipient.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_dialog_callback.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_kit.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_load_callback.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp", - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_ui_register.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_caller_authorization.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_client.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_death_recipient.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_dialog_callback.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_kit.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_load_callback.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_proxy.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_ui_register.cpp", "unittest/src/location_button_test.cpp", "unittest/src/paste_button_test.cpp", "unittest/src/save_button_test.cpp", @@ -53,7 +54,7 @@ ohos_unittest("sec_comp_sdk_test") { deps = [ "${sec_comp_root_dir}/frameworks:security_component_no_cfi_enhance_adapter_src_set", "${sec_comp_root_dir}/frameworks:security_component_no_cfi_framework_src_set", - "${sec_comp_root_dir}/interfaces/inner_api/enhance_kits:security_component_no_cfi_enhance_sdk_src_set", + "${sec_comp_root_dir}/frameworks/inner_api/enhance_kits:security_component_no_cfi_enhance_sdk_src_set", ] external_deps = [ @@ -75,6 +76,8 @@ ohos_unittest("sec_comp_register_callback_test") { include_dirs = [ "${sec_comp_root_dir}/frameworks/common/include", "${sec_comp_root_dir}/frameworks/security_component/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] @@ -92,7 +95,7 @@ ohos_unittest("sec_comp_register_callback_test") { cflags_cc += [ "-DSECURITY_COMPONENT_ENHANCE_ENABLE" ] } - deps = [ "${sec_comp_root_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_root_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "access_token:libaccesstoken_sdk", diff --git a/interfaces/inner_api/security_component/test/unittest/src/location_button_test.cpp b/frameworks/inner_api/security_component/test/unittest/src/location_button_test.cpp similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/location_button_test.cpp rename to frameworks/inner_api/security_component/test/unittest/src/location_button_test.cpp diff --git a/interfaces/inner_api/security_component/test/unittest/src/location_button_test.h b/frameworks/inner_api/security_component/test/unittest/src/location_button_test.h similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/location_button_test.h rename to frameworks/inner_api/security_component/test/unittest/src/location_button_test.h diff --git a/interfaces/inner_api/security_component/test/unittest/src/paste_button_test.cpp b/frameworks/inner_api/security_component/test/unittest/src/paste_button_test.cpp similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/paste_button_test.cpp rename to frameworks/inner_api/security_component/test/unittest/src/paste_button_test.cpp diff --git a/interfaces/inner_api/security_component/test/unittest/src/paste_button_test.h b/frameworks/inner_api/security_component/test/unittest/src/paste_button_test.h similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/paste_button_test.h rename to frameworks/inner_api/security_component/test/unittest/src/paste_button_test.h diff --git a/interfaces/inner_api/security_component/test/unittest/src/save_button_test.cpp b/frameworks/inner_api/security_component/test/unittest/src/save_button_test.cpp similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/save_button_test.cpp rename to frameworks/inner_api/security_component/test/unittest/src/save_button_test.cpp diff --git a/interfaces/inner_api/security_component/test/unittest/src/save_button_test.h b/frameworks/inner_api/security_component/test/unittest/src/save_button_test.h similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/save_button_test.h rename to frameworks/inner_api/security_component/test/unittest/src/save_button_test.h diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp b/frameworks/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp rename to frameworks/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.h b/frameworks/inner_api/security_component/test/unittest/src/sec_comp_kit_test.h similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.h rename to frameworks/inner_api/security_component/test/unittest/src/sec_comp_kit_test.h diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp b/frameworks/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp similarity index 99% rename from interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp rename to frameworks/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp index 48d587df28eed426f209d79c2015153876b409dd..95ea8416195295039ae2ea65cb3fa4571c01ceda 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp +++ b/frameworks/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp @@ -61,7 +61,7 @@ static __attribute__((noinline)) int32_t RegisterSecurityComponent( static __attribute__((noinline)) int32_t ReportSecurityComponentClickEvent( int32_t scId, std::string& componentInfo, - const SecCompClickEvent& clickInfo, sptr callerToken, OnFirstUseDialogCloseFunc dialogCall) + SecCompClickEvent& clickInfo, sptr callerToken, OnFirstUseDialogCloseFunc dialogCall) { SC_LOG_INFO(LABEL, "ReportSecurityComponentClickEvent enter"); return SecCompKit::ReportSecurityComponentClickEvent(scId, componentInfo, clickInfo, callerToken, diff --git a/interfaces/inner_api/security_component/test/unittest/src/test_common.cpp b/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp similarity index 96% rename from interfaces/inner_api/security_component/test/unittest/src/test_common.cpp rename to frameworks/inner_api/security_component/test/unittest/src/test_common.cpp index 2c602e3bca366ec109b90937594ec8955cff9222..7ce03fcb382be0cefd174e280d900555bd7bb472 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/test_common.cpp +++ b/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp @@ -71,6 +71,8 @@ void TestCommon::BuildLocationComponentInfo(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; } void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) @@ -127,6 +129,8 @@ void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; } void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) @@ -183,6 +187,8 @@ void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; } } // namespace SecurityComponent } // namespace Security diff --git a/interfaces/inner_api/security_component/test/unittest/src/test_common.h b/frameworks/inner_api/security_component/test/unittest/src/test_common.h similarity index 100% rename from interfaces/inner_api/security_component/test/unittest/src/test_common.h rename to frameworks/inner_api/security_component/test/unittest/src/test_common.h diff --git a/frameworks/security_component/src/sec_comp_base.cpp b/frameworks/security_component/src/sec_comp_base.cpp index 22d10f357e12b90cdafa5d2d897e30397edadeb4..3d121ec00930cf2835908eb91d1b51eba54eee78 100644 --- a/frameworks/security_component/src/sec_comp_base.cpp +++ b/frameworks/security_component/src/sec_comp_base.cpp @@ -62,6 +62,8 @@ const std::string JsonTagConstants::JSON_TEXT_TAG = "text"; const std::string JsonTagConstants::JSON_ICON_TAG = "icon"; const std::string JsonTagConstants::JSON_BG_TAG = "bg"; const std::string JsonTagConstants::JSON_WINDOW_ID = "windowId"; +const std::string JsonTagConstants::JSON_DISPLAY_ID = "displayId"; +const std::string JsonTagConstants::JSON_CROSS_AXIS_STATE = "crossAxisState"; bool SecCompBase::ParseDimension(const nlohmann::json& json, const std::string& tag, DimensionT& res) { @@ -244,15 +246,13 @@ bool SecCompBase::ParseRect(const nlohmann::json& json, const std::string& tag, return true; } -bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) +bool SecCompBase::ParseType(const nlohmann::json& json, const std::string& tag) { - SC_LOG_DEBUG(LABEL, "Button info %{public}s.", jsonSrc.dump().c_str()); - if ((jsonSrc.find(JsonTagConstants::JSON_SC_TYPE) == jsonSrc.end()) || - !jsonSrc.at(JsonTagConstants::JSON_SC_TYPE).is_number()) { - SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", JsonTagConstants::JSON_SC_TYPE.c_str()); + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); return false; } - int32_t value = jsonSrc.at(JsonTagConstants::JSON_SC_TYPE).get(); + int32_t value = json.at(tag).get(); if ((value <= static_cast(SecCompType::UNKNOWN_SC_TYPE)) || (value >= static_cast(SecCompType::MAX_SC_TYPE))) { SC_LOG_ERROR(LABEL, "scType value is invalid."); @@ -260,13 +260,57 @@ bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) } type_ = static_cast(value); - if ((jsonSrc.find(JsonTagConstants::JSON_NODE_ID) == jsonSrc.end()) || - !jsonSrc.at(JsonTagConstants::JSON_NODE_ID).is_number()) { - SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", JsonTagConstants::JSON_NODE_ID.c_str()); + return true; +} + +bool SecCompBase::ParseValue(const nlohmann::json& json, const std::string& tag, int32_t& value) +{ + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); + return false; + } + value = json.at(tag).get(); + + return true; +} + +bool SecCompBase::ParseDisplayId(const nlohmann::json& json, const std::string& tag) +{ + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); + return false; + } + displayId_ = json.at(tag).get(); + + return true; +} + +bool SecCompBase::ParseCrossAxisState(const nlohmann::json& json, const std::string& tag) +{ + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); + return false; + } + int32_t value = json.at(tag).get(); + if ((value < static_cast(CrossAxisState::STATE_INVALID)) || + (value > static_cast(CrossAxisState::STATE_NO_CROSS))) { + SC_LOG_ERROR(LABEL, "Cross axis state: %{public}d is invalid.", value); return false; } - nodeId_ = jsonSrc.at(JsonTagConstants::JSON_NODE_ID).get(); + crossAxisState_ = static_cast(value); + + return true; +} +bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) +{ + SC_LOG_DEBUG(LABEL, "Button info %{public}s.", jsonSrc.dump().c_str()); + if (!ParseType(jsonSrc, JsonTagConstants::JSON_SC_TYPE)) { + return false; + } + if (!ParseValue(jsonSrc, JsonTagConstants::JSON_NODE_ID, nodeId_)) { + return false; + } if (!ParseRect(jsonSrc, JsonTagConstants::JSON_RECT, rect_)) { return false; } @@ -288,13 +332,16 @@ bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) if (!ParseStyle(jsonSrc, JsonTagConstants::JSON_STYLE_TAG)) { return false; } - - if ((jsonSrc.find(JsonTagConstants::JSON_WINDOW_ID) == jsonSrc.end()) || - !jsonSrc.at(JsonTagConstants::JSON_WINDOW_ID).is_number()) { - SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", JsonTagConstants::JSON_WINDOW_ID.c_str()); + if (!ParseValue(jsonSrc, JsonTagConstants::JSON_WINDOW_ID, windowId_)) { return false; } - windowId_ = jsonSrc.at(JsonTagConstants::JSON_WINDOW_ID).get(); + if (!ParseDisplayId(jsonSrc, JsonTagConstants::JSON_DISPLAY_ID)) { + return false; + } + if (!ParseCrossAxisState(jsonSrc, JsonTagConstants::JSON_CROSS_AXIS_STATE)) { + return false; + } + return true; } @@ -353,6 +400,8 @@ void SecCompBase::ToJson(nlohmann::json& jsonRes) const { JsonTagConstants::JSON_BG_TAG, bg_ }, }; jsonRes[JsonTagConstants::JSON_WINDOW_ID] = windowId_; + jsonRes[JsonTagConstants::JSON_DISPLAY_ID] = displayId_; + jsonRes[JsonTagConstants::JSON_CROSS_AXIS_STATE] = crossAxisState_; } std::string SecCompBase::ToJsonStr() const diff --git a/interfaces/inner_api/security_component/include/sec_comp_base.h b/interfaces/inner_api/security_component/include/sec_comp_base.h index f7c013089b24191695cc7e403b49cbd2dab75d22..44b493a78ec5ca1884665ca180a7730d245a220d 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_base.h +++ b/interfaces/inner_api/security_component/include/sec_comp_base.h @@ -78,6 +78,8 @@ public: static const std::string JSON_ICON_TAG; static const std::string JSON_BG_TAG; static const std::string JSON_WINDOW_ID; + static const std::string JSON_DISPLAY_ID; + static const std::string JSON_CROSS_AXIS_STATE; }; class __attribute__((visibility("default"))) SecCompBase { @@ -131,7 +133,9 @@ public: SecCompBackground bg_ = SecCompBackground::UNKNOWN_BG; int32_t windowId_ = 0; + uint64_t displayId_ = 0; int32_t nodeId_ = 0; + CrossAxisState crossAxisState_ = CrossAxisState::STATE_INVALID; protected: virtual bool IsTextIconTypeValid() = 0; virtual bool IsCorrespondenceType() = 0; @@ -147,6 +151,10 @@ private: bool ParseParent(const nlohmann::json& json, const std::string& tag); bool ParseRect(const nlohmann::json& json, const std::string& tag, SecCompRect& rect); bool ParseStyle(const nlohmann::json& json, const std::string& tag); + bool ParseType(const nlohmann::json& json, const std::string& tag); + bool ParseValue(const nlohmann::json& json, const std::string& tag, int32_t& value); + bool ParseDisplayId(const nlohmann::json& json, const std::string& tag); + bool ParseCrossAxisState(const nlohmann::json& json, const std::string& tag); }; } // namespace SecurityComponent } // namespace Security diff --git a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h b/interfaces/inner_api/security_component/include/sec_comp_enhance_adapter.h similarity index 97% rename from frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h rename to interfaces/inner_api/security_component/include/sec_comp_enhance_adapter.h index 41183415f5ee75682acda367d9057f9f93c5208b..c54a57516ba9b84ac5b57a552399635c73b092d8 100644 --- a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h +++ b/interfaces/inner_api/security_component/include/sec_comp_enhance_adapter.h @@ -95,7 +95,11 @@ public: virtual void UnregisterScIdEnhance(const uintptr_t caller, int32_t scId) = 0; }; +#ifndef SEC_COMP_SERVICE_COMPILE_ENABLE class SecCompEnhanceAdapter final { +#else +class __attribute__((visibility("default"))) SecCompEnhanceAdapter final { +#endif public: static void InitEnhanceHandler(EnhanceInterfaceType type); static int32_t SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen); diff --git a/interfaces/inner_api/enhance_kits/include/sec_comp_enhance_kit.h b/interfaces/inner_api/security_component/include/sec_comp_enhance_kit.h similarity index 100% rename from interfaces/inner_api/enhance_kits/include/sec_comp_enhance_kit.h rename to interfaces/inner_api/security_component/include/sec_comp_enhance_kit.h diff --git a/interfaces/inner_api/enhance_kits/include/sec_comp_enhance_kit_c.h b/interfaces/inner_api/security_component/include/sec_comp_enhance_kit_c.h similarity index 100% rename from interfaces/inner_api/enhance_kits/include/sec_comp_enhance_kit_c.h rename to interfaces/inner_api/security_component/include/sec_comp_enhance_kit_c.h diff --git a/frameworks/common/include/sec_comp_err.h b/interfaces/inner_api/security_component/include/sec_comp_err.h similarity index 100% rename from frameworks/common/include/sec_comp_err.h rename to interfaces/inner_api/security_component/include/sec_comp_err.h diff --git a/interfaces/inner_api/security_component/include/sec_comp_info.h b/interfaces/inner_api/security_component/include/sec_comp_info.h index a712f0e53cff7bdcc3d10c238a44f123b740d0e9..665b47fd7cc63b8367ac761bd43060253e1423bb 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_info.h +++ b/interfaces/inner_api/security_component/include/sec_comp_info.h @@ -62,6 +62,12 @@ union SecCompColor { uint32_t value; }; +enum CrossAxisState { + STATE_INVALID = 0, + STATE_CROSS, + STATE_NO_CROSS, +}; + inline bool IsComponentTypeValid(int32_t type) { return (type > UNKNOWN_SC_TYPE && type < MAX_SC_TYPE); diff --git a/interfaces/inner_api/security_component/include/sec_comp_kit.h b/interfaces/inner_api/security_component/include/sec_comp_kit.h index a2649937bf93145ff7caf86fdc0a9ae214bc9bb2..a2881a92a7641a190d2538937ad07f3dfea61e61 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_kit.h +++ b/interfaces/inner_api/security_component/include/sec_comp_kit.h @@ -30,7 +30,7 @@ public: static int32_t UpdateSecurityComponent(int32_t scId, std::string& componentInfo); static int32_t UnregisterSecurityComponent(int32_t scId); static int32_t ReportSecurityComponentClickEvent(int32_t scId, - std::string& componentInfo, const SecCompClickEvent& clickInfo, + std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, OnFirstUseDialogCloseFunc&& callback); static bool VerifySavePermission(AccessToken::AccessTokenID tokenId); diff --git a/services/security_component_service/sa/sa_main/delay_exit_task.h b/interfaces/inner_api/security_component_common/delay_exit_task.h similarity index 88% rename from services/security_component_service/sa/sa_main/delay_exit_task.h rename to interfaces/inner_api/security_component_common/delay_exit_task.h index cdc3bdaedee83e39dc76dfcf6bd06219203ef782..6c4a12716e85cd5b6bb86749357a1f7ce80c513a 100644 --- a/services/security_component_service/sa/sa_main/delay_exit_task.h +++ b/interfaces/inner_api/security_component_common/delay_exit_task.h @@ -15,10 +15,12 @@ #ifndef SECURITY_COMPONENT_DELAY_EXIT_TASK_H #define SECURITY_COMPONENT_DELAY_EXIT_TASK_H +#include #include #include #include "nocopyable.h" #include "sec_event_handler.h" +#include "security_component_service_ipc_interface_code.h" namespace OHOS { namespace Security { @@ -28,12 +30,13 @@ public: static DelayExitTask& GetInstance(); virtual ~DelayExitTask() = default; - void Init(const std::shared_ptr& secHandler); + void Init(const std::shared_ptr& secHandler, std::function exitTask); void Start(); void Stop(); private: DelayExitTask(); std::shared_ptr secHandler_; + std::function exitTask_ = []() { return; }; DISALLOW_COPY_AND_MOVE(DelayExitTask); }; diff --git a/services/security_component_service/sa/sa_main/sec_comp_info_helper.h b/interfaces/inner_api/security_component_common/sec_comp_info_helper.h similarity index 90% rename from services/security_component_service/sa/sa_main/sec_comp_info_helper.h rename to interfaces/inner_api/security_component_common/sec_comp_info_helper.h index 5c7630cdfd80d6aad8c9818cdcf9d4ebf0e36fa3..a2c73b05cc8ef71fdfcaa07654bb26f2cc4d86fa 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_info_helper.h +++ b/interfaces/inner_api/security_component_common/sec_comp_info_helper.h @@ -19,7 +19,6 @@ #include "nlohmann/json.hpp" #include "sec_comp_base.h" #include "sec_comp_info.h" -#include "sec_comp_perm_manager.h" namespace OHOS { namespace Security { @@ -38,10 +37,9 @@ T* ConstructComponent(const nlohmann::json& jsonComponent) class __attribute__((visibility("default"))) SecCompInfoHelper { public: static SecCompBase* ParseComponent(SecCompType type, const nlohmann::json& jsonComponent); - static int32_t GrantTempPermission(AccessToken::AccessTokenID tokenId, - const std::shared_ptr& componentInfo); static bool CheckComponentValid(SecCompBase* comp); - static bool CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect); + static bool CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect, const uint64_t displayId, + const CrossAxisState crossAxisState); private: static float GetWindowScale(int32_t windowId); diff --git a/services/security_component_service/sa/sa_main/sec_event_handler.h b/interfaces/inner_api/security_component_common/sec_event_handler.h similarity index 92% rename from services/security_component_service/sa/sa_main/sec_event_handler.h rename to interfaces/inner_api/security_component_common/sec_event_handler.h index 86b07342a3a82cd06d8c026df6f0904ee0054a01..989852249bfecd0740b6d4ca509802d3905c0022 100644 --- a/services/security_component_service/sa/sa_main/sec_event_handler.h +++ b/interfaces/inner_api/security_component_common/sec_event_handler.h @@ -22,7 +22,7 @@ namespace OHOS { namespace Security { namespace SecurityComponent { -class SecEventHandler : public AppExecFwk::EventHandler { +class __attribute__((visibility("default"))) SecEventHandler : public AppExecFwk::EventHandler { public: explicit SecEventHandler(const std::shared_ptr& runner); ~SecEventHandler() override; diff --git a/services/security_component_service/sa/BUILD.gn b/services/security_component_service/sa/BUILD.gn index 6156d84a65510accc13990b6ccc0508c8a2d8dde..73c5072c647b94da81a429629419d0524a16db24 100644 --- a/services/security_component_service/sa/BUILD.gn +++ b/services/security_component_service/sa/BUILD.gn @@ -15,6 +15,72 @@ import("//build/ohos.gni") sec_comp_root_dir = "../../.." +config("security_component_common_config") { + include_dirs = [ + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", + "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", + ] +} + +ohos_shared_library("security_component_common") { + subsystem_name = "security" + part_name = "security_component_manager" + + innerapi_tags = [ "sasdk" ] + public_configs = [ ":security_component_common_config" ] + + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" + + include_dirs = [ + "${sec_comp_root_dir}/frameworks/common/include", + "${sec_comp_root_dir}/frameworks/security_component/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", + "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", + ] + + sources = [ + "sa_main/delay_exit_task.cpp", + "sa_main/sec_comp_info_helper.cpp", + "sa_main/sec_event_handler.cpp", + "sa_main/window_info_helper.cpp", + ] + + cflags_cc = [ + "-DHILOG_ENABLE", + "-fvisibility=hidden", + "-DSEC_COMP_SERVICE_COMPILE_ENABLE", + ] + cflags = [ "-DHILOG_ENABLE" ] + + deps = [ + "${sec_comp_root_dir}/frameworks:security_component_enhance_adapter_service_src_set", + "${sec_comp_root_dir}/frameworks:security_component_no_cfi_framework_src_set", + ] + + external_deps = [ + "ability_runtime:ability_manager", + "access_token:libaccesstoken_sdk", + "bundle_framework:appexecfwk_base", + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hisysevent:libhisysevent", + "ipc:ipc_core", + "ipc:ipc_single", + "json:nlohmann_json_static", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libdm", + "window_manager:libwm", + ] +} + config("security_component_service_config") { include_dirs = [ "sa_main", @@ -45,37 +111,35 @@ ohos_source_set("security_component_service_src_set") { "sa_main", "${sec_comp_root_dir}/frameworks/common/include", "${sec_comp_root_dir}/frameworks/enhance_adapter/include", - "${sec_comp_root_dir}/frameworks/security_component/include", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/include", + "${sec_comp_root_dir}/interfaces/inner_api/security_component_common", "${sec_comp_root_dir}/interfaces/inner_api/security_component/include", ] sources = [ - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", "sa_main/app_mgr_death_recipient.cpp", "sa_main/app_state_observer.cpp", - "sa_main/delay_exit_task.cpp", "sa_main/first_use_dialog.cpp", "sa_main/sec_comp_dialog_callback_proxy.cpp", "sa_main/sec_comp_entity.cpp", - "sa_main/sec_comp_info_helper.cpp", "sa_main/sec_comp_malicious_apps.cpp", "sa_main/sec_comp_manager.cpp", "sa_main/sec_comp_perm_manager.cpp", "sa_main/sec_comp_service.cpp", "sa_main/sec_comp_stub.cpp", - "sa_main/sec_event_handler.cpp", - "sa_main/window_info_helper.cpp", ] cflags_cc = [ "-DHILOG_ENABLE", "-fvisibility=hidden", + "-DSEC_COMP_SERVICE_COMPILE_ENABLE", ] cflags = [ "-DHILOG_ENABLE" ] deps = [ + ":security_component_common", ":security_component_service.rc", - "${sec_comp_root_dir}/frameworks:security_component_enhance_adapter_src_set", "${sec_comp_root_dir}/frameworks:security_component_framework_src_set", ] @@ -119,12 +183,11 @@ ohos_shared_library("security_component_service") { branch_protector_ret = "pac_ret" deps = [ + ":security_component_common", ":security_component_service.rc", ":security_component_service_src_set", - "${sec_comp_root_dir}/frameworks:security_component_enhance_adapter_src_set", "${sec_comp_root_dir}/frameworks:security_component_framework_src_set", ] external_deps = [ "hilog:libhilog" ] - public_configs = [ ":security_component_service_config" ] configs = [ "${sec_comp_root_dir}/config:coverage_flags" ] } diff --git a/services/security_component_service/sa/sa_main/delay_exit_task.cpp b/services/security_component_service/sa/sa_main/delay_exit_task.cpp index 109281bacd86ef5c0d38bd020cea0ec79f7c1d24..40c4c7e47629b9ddde156e9d58ba59000ec5fd17 100644 --- a/services/security_component_service/sa/sa_main/delay_exit_task.cpp +++ b/services/security_component_service/sa/sa_main/delay_exit_task.cpp @@ -15,7 +15,6 @@ #include "delay_exit_task.h" #include "sec_comp_log.h" -#include "sec_comp_manager.h" namespace OHOS { namespace Security { @@ -36,9 +35,10 @@ DelayExitTask& DelayExitTask::GetInstance() return instance; } -void DelayExitTask::Init(const std::shared_ptr& secHandler) +void DelayExitTask::Init(const std::shared_ptr& secHandler, std::function exitTask) { secHandler_ = secHandler; + exitTask_ = exitTask; } void DelayExitTask::Start() @@ -48,12 +48,8 @@ void DelayExitTask::Start() return; } - std::function delayed = ([]() { - SecCompManager::GetInstance().ExitSaProcess(); - }); - SC_LOG_INFO(LABEL, "Delay exit service after %{public}d ms", DELAY_EXIT_MILLISECONDS); - secHandler_->ProxyPostTask(delayed, DELAY_EXIT_TASK, DELAY_EXIT_MILLISECONDS); + secHandler_->ProxyPostTask(exitTask_, DELAY_EXIT_TASK, DELAY_EXIT_MILLISECONDS); } void DelayExitTask::Stop() diff --git a/services/security_component_service/sa/sa_main/first_use_dialog.cpp b/services/security_component_service/sa/sa_main/first_use_dialog.cpp index f5bc9e1ea81c4c3fc4dceb2b2a4815da4119922e..f630c71c7026c60bf8b95c181371007c959f8c34 100644 --- a/services/security_component_service/sa/sa_main/first_use_dialog.cpp +++ b/services/security_component_service/sa/sa_main/first_use_dialog.cpp @@ -22,13 +22,15 @@ #include "ability_manager_client.h" #include "accesstoken_kit.h" #include "bundle_mgr_client.h" +#include "display.h" +#include "display_info.h" +#include "display_manager.h" #include "hisysevent.h" #include "ipc_skeleton.h" #include "sec_comp_dialog_callback_proxy.h" #include "sec_comp_err.h" #include "sec_comp_log.h" #include "want_params_wrapper.h" -#include "want.h" namespace OHOS { namespace Security { @@ -47,7 +49,11 @@ const std::string TYPE_KEY = "ohos.user.security.type"; const std::string TOKEN_KEY = "ohos.ability.params.token"; const std::string CALLBACK_KEY = "ohos.ability.params.callback"; const std::string CALLER_UID_KEY = "ohos.caller.uid"; +const std::string DISPLAY_WIDTH = "ohos.display.width"; +const std::string DISPLAY_HEIGHT = "ohos.display.height"; +const std::string DIALOG_OFFSET = "ohos.dialog.offset"; +constexpr int32_t DISPLAY_HALF_RATIO = 2; constexpr uint32_t MAX_CFG_FILE_SIZE = 100 * 1024; // 100k constexpr uint64_t LOCATION_BUTTON_FIRST_USE = 1 << 0; constexpr uint64_t SAVE_BUTTON_FIRST_USE = 1 << 1; @@ -288,8 +294,40 @@ int32_t FirstUseDialog::GrantDialogWaitEntity(int32_t scId) return res; } -void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback) +bool FirstUseDialog::SetDialogInfo(AAFwk::Want& want, const uint64_t displayId, const CrossAxisState crossAxisState) +{ + sptr display = + OHOS::Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); + if (display == nullptr) { + SC_LOG_ERROR(LABEL, "Get display manager failed"); + return false; + } + + auto info = display->GetDisplayInfo(); + if (info == nullptr) { + SC_LOG_ERROR(LABEL, "Get display info failed"); + return false; + } + /* crossAxisState is INVALID or NO_CROSS */ + int32_t width = info->GetWidth(); + int32_t height = info->GetHeight(); + int32_t offset = 0; + /* crossAxisState is CROSS */ + if (crossAxisState == CrossAxisState::STATE_CROSS) { + height = info->GetPhysicalHeight(); + offset = static_cast(info->GetAvailableHeight()) / DISPLAY_HALF_RATIO; + } + SC_LOG_INFO(LABEL, "Display info width %{public}d height %{public}d, dialog offset %{public}d", + width, height, offset); + + want.SetParam(DISPLAY_WIDTH, width); + want.SetParam(DISPLAY_HEIGHT, height); + want.SetParam(DIALOG_OFFSET, offset); + return true; +} + +void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState) { int32_t typeNum; SecCompType type = entity->GetType(); @@ -316,6 +354,11 @@ void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, want.SetParam(CALLBACK_KEY, srvCallback); int32_t uid = IPCSkeleton::GetCallingUid(); want.SetParam(CALLER_UID_KEY, uid); + if (!SetDialogInfo(want, displayId, crossAxisState)) { + SC_LOG_ERROR(LABEL, "Set dialog info failed."); + return; + } + int startRes = AAFwk::AbilityManagerClient::GetInstance()->StartExtensionAbility(want, callerToken); SC_LOG_INFO(LABEL, "start ability res %{public}d", startRes); if (startRes != 0) { @@ -365,8 +408,8 @@ bool FirstUseDialog::SetFirstUseMap(std::shared_ptr entity) return true; } -int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback) +int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState) { if (entity == nullptr) { SC_LOG_ERROR(LABEL, "Entity is invalid."); @@ -402,7 +445,7 @@ int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr enti auto iter = firstUseMap_.find(tokenId); if (iter == firstUseMap_.end()) { SC_LOG_INFO(LABEL, "has not use record, start dialog"); - StartDialogAbility(entity, callerToken, dialogCallback); + StartDialogAbility(entity, callerToken, dialogCallback, displayId, crossAxisState); return SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE; } @@ -411,7 +454,7 @@ int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr enti SC_LOG_INFO(LABEL, "no need notify again."); return SC_OK; } - StartDialogAbility(entity, callerToken, dialogCallback); + StartDialogAbility(entity, callerToken, dialogCallback, displayId, crossAxisState); return SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE; } diff --git a/services/security_component_service/sa/sa_main/first_use_dialog.h b/services/security_component_service/sa/sa_main/first_use_dialog.h index ea80cadc8701d5a66820bb7e3a9eb39f2da8835e..255cd52d8ed73e79a3c197d6144997bbc02e8c9a 100644 --- a/services/security_component_service/sa/sa_main/first_use_dialog.h +++ b/services/security_component_service/sa/sa_main/first_use_dialog.h @@ -27,6 +27,7 @@ #include "sec_comp_err.h" #include "sec_comp_info.h" #include "sec_event_handler.h" +#include "want.h" namespace OHOS { namespace Security { @@ -53,8 +54,8 @@ public: static FirstUseDialog& GetInstance(); ~FirstUseDialog() = default; - int32_t NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback); + int32_t NotifyFirstUseDialog(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState); void Init(std::shared_ptr secHandler); int32_t GrantDialogWaitEntity(int32_t scId); void RemoveDialogWaitEntitys(int32_t pid); @@ -72,8 +73,9 @@ private: void ParseRecords(nlohmann::json& jsonRes); void LoadFirstUseRecord(void); void SaveFirstUseRecord(void); - void StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback); + void StartDialogAbility(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState); + bool SetDialogInfo(AAFwk::Want& want, const uint64_t displayId, const CrossAxisState crossAxisState); void SendSaveEventHandler(void); std::mutex useMapMutex_; diff --git a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp index 4a98fad03063c4c3ce0b86ef908e001b7bec4e0e..410924ba4452712f1b59093e3a55f26fafda642d 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp @@ -34,6 +34,7 @@ namespace { constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompEntity"}; static constexpr uint64_t MAX_TOUCH_INTERVAL = 1000000L; // 1000ms static constexpr uint64_t TIME_CONVERSION_UNIT = 1000; +static constexpr uint32_t FOLD_VIRTUAL_DISPLAY_ID = 999; constexpr const char *SETTINGS_DATA_EXT_URI = "datashare:///com.ohos.settingsdata.DataAbility"; constexpr const char *SETTINGS_DATASHARE_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true"; @@ -49,7 +50,7 @@ static bool IsScreenReadMode(); int32_t SecCompEntity::GrantTempPermission() { isGrant_ = true; - return SecCompInfoHelper::GrantTempPermission(tokenId_, componentInfo_); + return SecCompPermManager::GetInstance().GrantTempPermission(tokenId_, componentInfo_); } bool SecCompEntity::CompareComponentBasicInfo(SecCompBase* other, bool isRectCheck) const @@ -57,7 +58,8 @@ bool SecCompEntity::CompareComponentBasicInfo(SecCompBase* other, bool isRectChe return componentInfo_->CompareComponentBasicInfo(other, isRectCheck); } -int32_t SecCompEntity::CheckPointEvent(const SecCompClickEvent& clickInfo) const +int32_t SecCompEntity::CheckPointEvent(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, + const CrossAxisState crossAxisState) const { auto current = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; @@ -68,6 +70,12 @@ int32_t SecCompEntity::CheckPointEvent(const SecCompClickEvent& clickInfo) const } if (!componentInfo_->rect_.IsInRect(clickInfo.point.touchX, clickInfo.point.touchY)) { + if ((crossAxisState == CrossAxisState::STATE_CROSS) && + componentInfo_->rect_.IsInRect(clickInfo.point.touchX, clickInfo.point.touchY + superFoldOffsetY)) { + clickInfo.point.touchY += superFoldOffsetY; + SC_LOG_INFO(LABEL, "Fold PC cross state and component is in PC virtual screen."); + return SC_OK; + } SC_LOG_ERROR(LABEL, "touch point is not in component rect = (%{public}f, %{public}f)" \ "left top point of component rect = (%{public}f, %{public}f)" \ "right bottom point of component rect = (%{public}f, %{public}f)", @@ -97,8 +105,30 @@ int32_t SecCompEntity::CheckKeyEvent(const SecCompClickEvent& clickInfo) const return SC_OK; } -int32_t SecCompEntity::CheckClickInfo(const SecCompClickEvent& clickInfo) const +bool SecCompEntity::IsInPCVirtualScreen(const CrossAxisState crossAxisState) const { + bool isInPCVirtualScreen = false; + if (componentInfo_->displayId_ == FOLD_VIRTUAL_DISPLAY_ID) { + if (crossAxisState == CrossAxisState::STATE_NO_CROSS) { + isInPCVirtualScreen = true; + } else { + SC_LOG_WARN(LABEL, "Security component maybe in PC virtual screen, the cross axis state is %{public}d", + static_cast(crossAxisState)); + } + } + return isInPCVirtualScreen; +} + +int32_t SecCompEntity::CheckClickInfo(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, + const CrossAxisState crossAxisState) const +{ + bool isInPCVirtualScreen = IsInPCVirtualScreen(crossAxisState); + SC_LOG_INFO(LABEL, "The cross axis state: %{public}d, the fold offset y: %{public}d.", + static_cast(crossAxisState), superFoldOffsetY); + if (isInPCVirtualScreen) { + clickInfo.point.touchY += superFoldOffsetY; + componentInfo_->rect_.y_ += superFoldOffsetY; + } if (!WindowInfoHelper::CheckOtherWindowCoverComp(componentInfo_->windowId_, componentInfo_->rect_)) { SC_LOG_ERROR(LABEL, "Component may be covered by other window"); @@ -108,7 +138,7 @@ int32_t SecCompEntity::CheckClickInfo(const SecCompClickEvent& clickInfo) const int32_t res = SC_SERVICE_ERROR_CLICK_EVENT_INVALID; bool isScreenReadMode = IsScreenReadMode(); if (clickInfo.type == ClickEventType::POINT_EVENT_TYPE && !isScreenReadMode) { - res = CheckPointEvent(clickInfo); + res = CheckPointEvent(clickInfo, superFoldOffsetY, crossAxisState); } else if (clickInfo.type == ClickEventType::POINT_EVENT_TYPE && isScreenReadMode) { SC_LOG_WARN(LABEL, "Device is in screen read mode, skip event check."); return SC_OK; diff --git a/services/security_component_service/sa/sa_main/sec_comp_entity.h b/services/security_component_service/sa/sa_main/sec_comp_entity.h index 2bc4d64f16c118f3477fc51945c3e75afbc243b3..cac7c410614247f0fb53f24659ece44a5c9367d1 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_entity.h +++ b/services/security_component_service/sa/sa_main/sec_comp_entity.h @@ -46,7 +46,9 @@ public: } bool CompareComponentBasicInfo(SecCompBase* other, bool isRectCheck) const; - int32_t CheckClickInfo(const SecCompClickEvent& clickInfo) const; + int32_t CheckClickInfo(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, + const CrossAxisState crossAxisState) const; + bool IsInPCVirtualScreen(const CrossAxisState crossAxisState) const; std::shared_ptr componentInfo_; AccessToken::AccessTokenID tokenId_; @@ -56,7 +58,8 @@ public: private: int32_t CheckKeyEvent(const SecCompClickEvent& clickInfo) const; - int32_t CheckPointEvent(const SecCompClickEvent& clickInfo) const; + int32_t CheckPointEvent(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, + const CrossAxisState crossAxisState) const; bool isGrant_ = false; }; } // namespace SecurityComponent diff --git a/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp b/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp index 245d9ebb7d8b9ecdd52ca3780037c10b402e84a2..44a92850964f542800ad72086412dc9acd58b8c3 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp @@ -23,7 +23,6 @@ #include "save_button.h" #include "sec_comp_err.h" #include "sec_comp_log.h" -#include "sec_comp_service.h" #include "sec_comp_tool.h" #include "window_info_helper.h" @@ -46,6 +45,9 @@ void SecCompInfoHelper::AdjustSecCompRect(SecCompBase* comp, float scale) SC_LOG_DEBUG(LABEL, "After adjust x %{public}f, y %{public}f, width %{public}f, height %{public}f", comp->rect_.x_, comp->rect_.y_, comp->rect_.width_, comp->rect_.height_); + + comp->windowRect_.width_ *= scale; + comp->windowRect_.height_ *= scale; } SecCompBase* SecCompInfoHelper::ParseComponent(SecCompType type, const nlohmann::json& jsonComponent) @@ -74,10 +76,10 @@ SecCompBase* SecCompInfoHelper::ParseComponent(SecCompType type, const nlohmann: return comp; } -static bool GetScreenSize(double& width, double& height) +static bool GetScreenSize(double& width, double& height, const uint64_t displayId, const CrossAxisState crossAxisState) { sptr display = - OHOS::Rosen::DisplayManager::GetInstance().GetDefaultDisplaySync(); + OHOS::Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); if (display == nullptr) { SC_LOG_ERROR(LABEL, "Get display manager failed"); return false; @@ -90,17 +92,22 @@ static bool GetScreenSize(double& width, double& height) } width = static_cast(info->GetWidth()); - height = static_cast(info->GetHeight()); + if (crossAxisState == CrossAxisState::STATE_CROSS) { + height = static_cast(info->GetPhysicalHeight()); + } else { + height = static_cast(info->GetHeight()); + } SC_LOG_DEBUG(LABEL, "display manager Screen width %{public}f height %{public}f", width, height); return true; } -bool SecCompInfoHelper::CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect) +bool SecCompInfoHelper::CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect, + const uint64_t displayId, const CrossAxisState crossAxisState) { double curScreenWidth = 0.0F; double curScreenHeight = 0.0F; - if (!GetScreenSize(curScreenWidth, curScreenHeight)) { + if (!GetScreenSize(curScreenWidth, curScreenHeight, displayId, crossAxisState)) { SC_LOG_ERROR(LABEL, "Get screen size is invalid"); return false; } @@ -116,15 +123,15 @@ bool SecCompInfoHelper::CheckRectValid(const SecCompRect& rect, const SecCompRec return false; } - if (GreatOrEqual((rect.x_ + rect.width_), curScreenWidth) || - GreatOrEqual((rect.y_ + rect.height_), curScreenHeight)) { + if (GreatNotEqual((rect.x_ + rect.width_), curScreenWidth + 1.0) || + GreatNotEqual((rect.y_ + rect.height_), curScreenHeight + 1.0)) { SC_LOG_ERROR(LABEL, "SecurityComponentCheckFail: security component is out of screen"); return false; } - if (GreatNotEqual(windowRect.x_, rect.x_) || GreatNotEqual(windowRect.y_, rect.y_) || - GreatNotEqual(rect.x_ + rect.width_, windowRect.x_ + windowRect.width_) || - GreatNotEqual(rect.y_ + rect.height_, windowRect.y_ + windowRect.height_)) { + if (GreatNotEqual(windowRect.x_, rect.x_ + 1.0) || GreatNotEqual(windowRect.y_, rect.y_ + 1.0) || + GreatNotEqual(rect.x_ + rect.width_, windowRect.x_ + windowRect.width_ + 1.0) || + GreatNotEqual(rect.y_ + rect.height_, windowRect.y_ + windowRect.height_ + 1.0)) { SC_LOG_ERROR(LABEL, "SecurityComponentCheckFail: security component is out of window"); return false; } @@ -225,59 +232,6 @@ bool SecCompInfoHelper::CheckComponentValid(SecCompBase* comp) return true; } - -int32_t SecCompInfoHelper::GrantTempPermission(AccessToken::AccessTokenID tokenId, - const std::shared_ptr& componentInfo) -{ - if ((tokenId <= 0) || (componentInfo == nullptr)) { - SC_LOG_ERROR(LABEL, "Grant component is null"); - return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; - } - - SecCompType type = componentInfo->type_; - int32_t res; - switch (type) { - case LOCATION_COMPONENT: - { - res = SecCompPermManager::GetInstance().GrantAppPermission(tokenId, - "ohos.permission.APPROXIMATELY_LOCATION"); - if (res != SC_OK) { - return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; - } - res = SecCompPermManager::GetInstance().GrantAppPermission(tokenId, "ohos.permission.LOCATION"); - if (res != SC_OK) { - SecCompPermManager::GetInstance().RevokeAppPermission( - tokenId, "ohos.permission.APPROXIMATELY_LOCATION"); - return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; - } - SC_LOG_INFO(LABEL, "Grant location permission, scid = %{public}d.", componentInfo->nodeId_); - return SC_OK; - } - case PASTE_COMPONENT: - res = SecCompPermManager::GetInstance().GrantAppPermission(tokenId, "ohos.permission.SECURE_PASTE"); - if (res != SC_OK) { - return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; - } - SC_LOG_INFO(LABEL, "Grant paste permission, scid = %{public}d.", componentInfo->nodeId_); - return SC_OK; - case SAVE_COMPONENT: - if (IsDlpSandboxCalling(tokenId)) { - SC_LOG_INFO(LABEL, "Dlp sandbox app are not allowed to use save component."); - return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; - } - SC_LOG_INFO(LABEL, "Grant save permission, scid = %{public}d.", componentInfo->nodeId_); - return SecCompPermManager::GetInstance().GrantTempSavePermission(tokenId); - default: - SC_LOG_ERROR(LABEL, "Parse component type unknown"); - break; - } - return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; -} - -inline bool SecCompInfoHelper::IsDlpSandboxCalling(AccessToken::AccessTokenID tokenId) -{ - return AccessToken::AccessTokenKit::GetHapDlpFlag(tokenId) != 0; -} } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp index 4ae69ff658cbd91668343f41600556e7e65153ec..944f141c39f890a131b59e0286bc604be84f236b 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp @@ -16,6 +16,9 @@ #include "bundle_mgr_client.h" #include "delay_exit_task.h" +#include "display.h" +#include "display_info.h" +#include "display_manager.h" #include "hisysevent.h" #include "i_sec_comp_service.h" #include "ipc_skeleton.h" @@ -460,7 +463,8 @@ int32_t SecCompManager::CheckClickSecurityComponentInfo(std::shared_ptrrect_, reportComponentInfo->windowRect_))) { + if ((!SecCompInfoHelper::CheckRectValid(reportComponentInfo->rect_, reportComponentInfo->windowRect_, + report->displayId_, report->crossAxisState_))) { SC_LOG_ERROR(LABEL, "compare component info failed."); HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "COMPONENT_INFO_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_UID", uid, "CALLER_BUNDLE_NAME", bundleName, @@ -493,15 +497,35 @@ static void ReportEvent(std::string eventName, HiviewDFX::HiSysEvent::EventType "CALLER_PID", IPCSkeleton::GetCallingPid(), "SC_ID", scId, "SC_TYPE", scType); } -int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, - const nlohmann::json& jsonComponent, const SecCompCallerInfo& caller, - const SecCompClickEvent& clickInfo, const std::vector>& remote) +void SecCompManager::GetFoldOffsetY(const CrossAxisState crossAxisState) +{ + if (crossAxisState == CrossAxisState::STATE_INVALID) { + return; + } + if (superFoldOffsetY_ != 0) { + return; + } + auto foldCreaseRegion = OHOS::Rosen::DisplayManager::GetInstance().GetCurrentFoldCreaseRegion(); + if (foldCreaseRegion == nullptr) { + SC_LOG_ERROR(LABEL, "foldCreaseRegion is nullptr"); + return; + } + const auto& creaseRects = foldCreaseRegion->GetCreaseRects(); + if (creaseRects.empty()) { + SC_LOG_ERROR(LABEL, "creaseRects is empty"); + return; + } + const auto& rect = creaseRects.front(); + superFoldOffsetY_ = rect.height_ + rect.posY_; + SC_LOG_INFO(LABEL, "height: %{public}d, posY: %{public}d", rect.height_, rect.posY_); +} + +int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, const nlohmann::json& compJson, + const SecCompCallerInfo& caller, SecCompClickEvent& clickInfo, const std::vector>& remote) { if (remote.size() < REPORT_REMOTE_OBJECT_SIZE) { return SC_SERVICE_ERROR_VALUE_INVALID; } - auto callerToken = remote[0]; - auto dialogCallback = remote[1]; if (malicious_.IsInMaliciousAppList(caller.pid, caller.uid)) { SC_LOG_ERROR(LABEL, "app is in MaliciousAppList, never allow it"); @@ -515,12 +539,18 @@ int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, return SC_SERVICE_ERROR_COMPONENT_NOT_EXIST; } - int32_t res = CheckClickSecurityComponentInfo(sc, scId, jsonComponent, caller); + int32_t res = CheckClickSecurityComponentInfo(sc, scId, compJson, caller); if (res != SC_OK) { return res; } + SecCompBase* report = SecCompInfoHelper::ParseComponent(sc->GetType(), compJson); + if (report == nullptr) { + return SC_SERVICE_ERROR_COMPONENT_INFO_INVALID; + } + + GetFoldOffsetY(report->crossAxisState_); - res = sc->CheckClickInfo(clickInfo); + res = sc->CheckClickInfo(clickInfo, superFoldOffsetY_, report->crossAxisState_); if (res != SC_OK) { ReportEvent("CLICK_INFO_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, scId, sc->GetType()); @@ -531,8 +561,8 @@ int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; } - if (FirstUseDialog::GetInstance().NotifyFirstUseDialog(sc, callerToken, dialogCallback) == - SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE) { + if (FirstUseDialog::GetInstance().NotifyFirstUseDialog(sc, remote[0], remote[1], report->displayId_, + report->crossAxisState_) == SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE) { SC_LOG_INFO(LABEL, "start dialog, onclick will be trap after dialog closed."); return SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE; } @@ -586,7 +616,10 @@ bool SecCompManager::Initialize() } secHandler_ = std::make_shared(secRunner_); - DelayExitTask::GetInstance().Init(secHandler_); + exitSaProcessFunc_ = []() { + SecCompManager::GetInstance().ExitSaProcess(); + }; + DelayExitTask::GetInstance().Init(secHandler_, exitSaProcessFunc_); FirstUseDialog::GetInstance().Init(secHandler_); SecCompEnhanceAdapter::EnableInputEnhance(); SecCompPermManager::GetInstance().InitEventHandler(secHandler_); diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.h b/services/security_component_service/sa/sa_main/sec_comp_manager.h index 323f5d5a8e60cce17e98ab50b8eaf049cd6e523a..a11ffb281172a8bb5dc6f2c4cce916a4fed668a1 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.h +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.h @@ -15,6 +15,7 @@ #ifndef SECURITY_COMPONENT_MANAGER_H #define SECURITY_COMPONENT_MANAGER_H +#include #include #include #include @@ -57,7 +58,7 @@ public: const SecCompCallerInfo& caller); int32_t UnregisterSecurityComponent(int32_t scId, const SecCompCallerInfo& caller); int32_t ReportSecurityComponentClickEvent(int32_t scId, const nlohmann::json& jsonComponent, - const SecCompCallerInfo& caller, const SecCompClickEvent& clickInfo, + const SecCompCallerInfo& caller, SecCompClickEvent& clickInfo, const std::vector>& remote); void NotifyProcessForeground(int32_t pid); void NotifyProcessBackground(int32_t pid); @@ -81,17 +82,20 @@ private: void SendCheckInfoEnhanceSysEvent(int32_t scId, SecCompType type, const std::string& scene, int32_t res); int32_t CreateScId(); + void GetFoldOffsetY(const CrossAxisState crossAxisState); OHOS::Utils::RWLock componentInfoLock_; std::mutex scIdMtx_; std::unordered_map componentMap_; int32_t scIdStart_; bool isSaExit_ = false; + int32_t superFoldOffsetY_ = 0; std::shared_ptr secRunner_; std::shared_ptr secHandler_; SecCompMaliciousApps malicious_; + std::function exitSaProcessFunc_ = []() { return; }; DISALLOW_COPY_AND_MOVE(SecCompManager); }; } // namespace SecurityComponent diff --git a/services/security_component_service/sa/sa_main/sec_comp_perm_manager.cpp b/services/security_component_service/sa/sa_main/sec_comp_perm_manager.cpp index 187cd42af1f0ea92020a69ef32a2c01997d43af4..7f561b5a296b48598ac9326287d677a97718173e 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_perm_manager.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_perm_manager.cpp @@ -260,6 +260,57 @@ void SecCompPermManager::InitEventHandler(const std::shared_ptr { secHandler_ = secHandler; } + +int32_t SecCompPermManager::GrantTempPermission(AccessToken::AccessTokenID tokenId, + const std::shared_ptr& componentInfo) +{ + if ((tokenId <= 0) || (componentInfo == nullptr)) { + SC_LOG_ERROR(LABEL, "Grant component is null"); + return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; + } + + SecCompType type = componentInfo->type_; + int32_t res; + switch (type) { + case LOCATION_COMPONENT: + { + res = GrantAppPermission(tokenId, "ohos.permission.APPROXIMATELY_LOCATION"); + if (res != SC_OK) { + return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; + } + res = GrantAppPermission(tokenId, "ohos.permission.LOCATION"); + if (res != SC_OK) { + RevokeAppPermission(tokenId, "ohos.permission.APPROXIMATELY_LOCATION"); + return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; + } + SC_LOG_INFO(LABEL, "Grant location permission, scid = %{public}d.", componentInfo->nodeId_); + return SC_OK; + } + case PASTE_COMPONENT: + res = GrantAppPermission(tokenId, "ohos.permission.SECURE_PASTE"); + if (res != SC_OK) { + return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; + } + SC_LOG_INFO(LABEL, "Grant paste permission, scid = %{public}d.", componentInfo->nodeId_); + return SC_OK; + case SAVE_COMPONENT: + if (IsDlpSandboxCalling(tokenId)) { + SC_LOG_INFO(LABEL, "Dlp sandbox app are not allowed to use save component."); + return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; + } + SC_LOG_INFO(LABEL, "Grant save permission, scid = %{public}d.", componentInfo->nodeId_); + return GrantTempSavePermission(tokenId); + default: + SC_LOG_ERROR(LABEL, "Parse component type unknown"); + break; + } + return SC_SERVICE_ERROR_PERMISSION_OPER_FAIL; +} + +inline bool SecCompPermManager::IsDlpSandboxCalling(AccessToken::AccessTokenID tokenId) +{ + return AccessToken::AccessTokenKit::GetHapDlpFlag(tokenId) != 0; +} } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/services/security_component_service/sa/sa_main/sec_comp_perm_manager.h b/services/security_component_service/sa/sa_main/sec_comp_perm_manager.h index b157e787f28d169760c99c37f9514b00b4b09e46..356e29781e0d06b84f6578c289934251ca7af0a3 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_perm_manager.h +++ b/services/security_component_service/sa/sa_main/sec_comp_perm_manager.h @@ -32,6 +32,8 @@ public: virtual ~SecCompPermManager() = default; static SecCompPermManager& GetInstance(); + int32_t GrantTempPermission(AccessToken::AccessTokenID tokenId, + const std::shared_ptr& componentInfo); int32_t GrantTempSavePermission(AccessToken::AccessTokenID tokenId); void RevokeTempSavePermission(AccessToken::AccessTokenID tokenId); bool VerifySavePermission(AccessToken::AccessTokenID tokenId); @@ -57,6 +59,7 @@ private: const std::string& permissionName); void RemoveAppGrantPermissionRecord(AccessToken::AccessTokenID tokenId, const std::string& permissionName); + bool IsDlpSandboxCalling(AccessToken::AccessTokenID tokenId); std::unordered_map applySaveCountMap_; std::unordered_map> saveTaskDequeMap_; diff --git a/services/security_component_service/sa/sa_main/sec_comp_service.cpp b/services/security_component_service/sa/sa_main/sec_comp_service.cpp index 5f35b29f01205685ef733cc7bc6f8e3dfcf729fc..525a4906ae6e5d6e22504b7628dc205c6284a390 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_service.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_service.cpp @@ -245,7 +245,7 @@ int32_t SecCompService::UnregisterSecurityComponent(int32_t scId) } int32_t SecCompService::ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& clickInfo, + const std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback) { StartTrace(HITRACE_TAG_ACCESS_CONTROL, "SecurityComponentClick"); diff --git a/services/security_component_service/sa/sa_main/sec_comp_service.h b/services/security_component_service/sa/sa_main/sec_comp_service.h index ff955821541e8d24570bd8bbc9a334fe20ae1c65..4d205a03aa836aea81a65e3a1bb084c6450e7886 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_service.h +++ b/services/security_component_service/sa/sa_main/sec_comp_service.h @@ -44,7 +44,7 @@ public: int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) override; int32_t UnregisterSecurityComponent(int32_t scId) override; int32_t ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& clickInfo, + const std::string& componentInfo, SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCallback) override; bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override; sptr GetEnhanceRemoteObject() override; diff --git a/services/security_component_service/sa/sa_main/window_info_helper.h b/services/security_component_service/sa/sa_main/window_info_helper.h index ad60af210672d3ffa5719e9fed52aba638315821..a831bc10d1f177fb4283e3e06d3ecafadb51729f 100644 --- a/services/security_component_service/sa/sa_main/window_info_helper.h +++ b/services/security_component_service/sa/sa_main/window_info_helper.h @@ -21,7 +21,7 @@ namespace OHOS { namespace Security { namespace SecurityComponent { -class WindowInfoHelper { +class __attribute__((visibility("default"))) WindowInfoHelper { public: static float GetWindowScale(int32_t windowId); static bool CheckOtherWindowCoverComp(int32_t compWinId, const SecCompRect& secRect); diff --git a/services/security_component_service/sa/test/BUILD.gn b/services/security_component_service/sa/test/BUILD.gn index 528b6fdfd1dda0a9e43ac765069859ae42c74fd4..ec2c3ab1ee43bf32a4b72e8a0353c4566ee39698 100644 --- a/services/security_component_service/sa/test/BUILD.gn +++ b/services/security_component_service/sa/test/BUILD.gn @@ -30,7 +30,7 @@ ohos_unittest("sec_comp_service_test") { ] sources = [ - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", "${sec_comp_root_dir}/services/security_component_service/sa/sa_main/app_mgr_death_recipient.cpp", "${sec_comp_root_dir}/services/security_component_service/sa/sa_main/app_state_observer.cpp", "${sec_comp_root_dir}/services/security_component_service/sa/sa_main/delay_exit_task.cpp", @@ -114,7 +114,7 @@ ohos_unittest("sec_comp_service_mock_test") { ] sources = [ - "${sec_comp_root_dir}/interfaces/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", + "${sec_comp_root_dir}/frameworks/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", "${sec_comp_root_dir}/services/security_component_service/sa/sa_main/app_mgr_death_recipient.cpp", "${sec_comp_root_dir}/services/security_component_service/sa/sa_main/app_state_observer.cpp", "${sec_comp_root_dir}/services/security_component_service/sa/sa_main/delay_exit_task.cpp", diff --git a/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp b/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp index fc4d4a08e16eaa825de11b6f6dece6b6a88447f2..d0a5901147127a14b0ddc4c6e8c367b518866b77 100644 --- a/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp @@ -407,46 +407,51 @@ HWTEST_F(FirstUseDialogTest, NotifyFirstUseDialog001, TestSize.Level1) diag.secHandler_ = nullptr; // no entity - EXPECT_EQ(diag.NotifyFirstUseDialog(nullptr, nullptr, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(nullptr, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID), + SC_SERVICE_ERROR_VALUE_INVALID); std::shared_ptr entity = std::make_shared(nullptr, 0, 0, 0, 0); // no handler - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID), + SC_SERVICE_ERROR_VALUE_INVALID); // no calltoken std::shared_ptr runner = AppExecFwk::EventRunner::Create(true); ASSERT_NE(nullptr, runner); std::shared_ptr handler = std::make_shared(runner); diag.secHandler_ = handler; - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID), + SC_SERVICE_ERROR_VALUE_INVALID); // no dialogCallback sptr testRemoteObject = new TestRemoteObject(std::u16string()); - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, nullptr, 0, CrossAxisState::STATE_INVALID), + SC_SERVICE_ERROR_VALUE_INVALID); // type invalid - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), SC_OK); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), + SC_OK); // first use location button entity->componentInfo_ = std::make_shared(); entity->componentInfo_->type_ = LOCATION_COMPONENT; entity->tokenId_ = 0; - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE); EXPECT_EQ(0, static_cast(diag.firstUseMap_[0])); // first use save button entity->componentInfo_->type_ = SAVE_COMPONENT; - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE); EXPECT_EQ(0, static_cast(diag.firstUseMap_[0])); // second use save button - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE); EXPECT_EQ(0, static_cast(diag.firstUseMap_[0])); - diag.StartDialogAbility(entity, testRemoteObject, testRemoteObject); + diag.StartDialogAbility(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID); // wait for event handler done sleep(3); diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp index 9070eaef1614ac6f4558fa97f6ca94ca02e9f56d..60647d13b49c93c55b49f5e014a96e94ad566f0f 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp @@ -116,11 +116,11 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level1) .point.touchY = ServiceTestCommon::TEST_COORDINATE, .point.timestamp = 0, }; - ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID), SC_OK); uint64_t current = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()); touch.point.timestamp = current + 10000L; // 10s - ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID), SC_OK); entity_->componentInfo_->rect_.x_ = ServiceTestCommon::TEST_DIFF_COORDINATE; // click event will not hit this rect entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_DIFF_COORDINATE; @@ -128,7 +128,7 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level1) entity_->componentInfo_->rect_.height_ = ServiceTestCommon::TEST_DIFF_COORDINATE; touch.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; - ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID), SC_OK); entity_->componentInfo_->rect_.x_ = ServiceTestCommon::TEST_COORDINATE; entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_COORDINATE; @@ -137,7 +137,7 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level1) touch.extraInfo.data = buffer; touch.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; - ASSERT_EQ(entity_->CheckClickInfo(touch), SC_SERVICE_ERROR_CLICK_EVENT_INVALID); + ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID), SC_SERVICE_ERROR_CLICK_EVENT_INVALID); } /** @@ -154,7 +154,7 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo002, TestSize.Level1) .point.touchY = ServiceTestCommon::TEST_COORDINATE, .point.timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()), }; - ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID), SC_OK); entity_->componentInfo_->rect_.x_ = ServiceTestCommon::TEST_COORDINATE; entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_COORDINATE; @@ -163,7 +163,7 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo002, TestSize.Level1) // GetAccessibilityWindowInfo failed OHOS::Rosen::WindowManager::GetInstance().result_ = static_cast(-1); - ASSERT_EQ(entity_->CheckClickInfo(touch), SC_SERVICE_ERROR_CLICK_EVENT_INVALID); + ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID), SC_SERVICE_ERROR_CLICK_EVENT_INVALID); } /** @@ -194,14 +194,17 @@ HWTEST_F(SecCompEntityTest, CheckKeyEvent001, TestSize.Level1) auto current = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / 1000; clickInfo.key.timestamp = current - 1000000L - 1; - ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo)); + ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, 0, + CrossAxisState::STATE_INVALID)); clickInfo.key.timestamp = current + 1; - ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo)); + ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, 0, + CrossAxisState::STATE_INVALID)); clickInfo.key.timestamp = current - 1; clickInfo.key.keyCode = 1; - ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo)); + ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, 0, + CrossAxisState::STATE_INVALID)); clickInfo.key.keyCode = KEY_SPACE; ASSERT_EQ(SC_OK, entity_->CheckKeyEvent(clickInfo)); diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp index 0e463d01848707fe954f5d8649bf6001a5e41e2d..c7e821525b7f6947d2ecfcfc28bdeb1843712239 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp @@ -149,36 +149,36 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent004, TestSize.Level1) { SecCompRect rect = GetDefaultRect(); SecCompRect windowRect = GetDefaultRect(); - ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.x_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.x_ = g_testWidth; rect.y_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.y_ = g_testHeight; rect.x_ = g_curScreenWidth + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.x_ = g_testWidth; rect.y_ = g_curScreenHeight + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.y_ = g_testHeight; rect.width_ = g_curScreenWidth; rect.height_ = g_curScreenHeight; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.width_ = g_testWidth; rect.height_ = g_testHeight; rect.x_ = g_curScreenWidth - g_testWidth; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.x_ = g_testWidth; rect.y_ = g_curScreenHeight - g_testHeight; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); rect.y_ = g_testHeight; } @@ -192,30 +192,30 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent005, TestSize.Level1) { SecCompRect rect = GetDefaultRect(); SecCompRect windowRect = GetDefaultRect(); - ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); - windowRect.x_ = g_testWidth + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + windowRect.x_ = g_testWidth + 2.0; + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); windowRect.x_ = g_testWidth; - windowRect.y_ = g_testHeight + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + windowRect.y_ = g_testHeight + 2.0; + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); windowRect.y_ = g_testHeight; - windowRect.width_ = g_testWidth - 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + windowRect.width_ = g_testWidth - 2.0; + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); windowRect.width_ = g_testWidth; - windowRect.height_ = g_testHeight - 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + windowRect.height_ = g_testHeight - 2.0; + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); windowRect.height_ = g_testHeight; windowRect.width_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); windowRect.width_ = g_testWidth; windowRect.height_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID)); windowRect.height_ = g_testHeight; } @@ -599,35 +599,6 @@ HWTEST_F(SecCompInfoHelperTest, CheckComponentValid005, TestSize.Level1) ASSERT_TRUE(SecCompInfoHelper::CheckComponentValid(comp)); } -/** - * @tc.name: DLP-GrantTempPermission001 - * @tc.desc: Test DLP sandbox app grant save button - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(SecCompInfoHelperTest, GrantTempPermission001, TestSize.Level1) -{ - OHOS::Security::AccessToken::AccessTokenIDInner tokenInner = { - .tokenUniqueID = 0x00001, - .res = 1, - .dlpFlag = 1, - .type = OHOS::Security::AccessToken::TOKEN_HAP, - .version = 0, - }; - OHOS::Security::AccessToken::AccessTokenID *tokenid = - reinterpret_cast(&tokenInner); - ASSERT_NE(0, *tokenid); - - nlohmann::json jsonComponent; - ServiceTestCommon::BuildSaveComponentJson(jsonComponent); - SecCompBase* comp = SecCompInfoHelper::ParseComponent(SAVE_COMPONENT, jsonComponent); - ASSERT_NE(nullptr, comp); - std::shared_ptr shared_comp(comp); - - EXPECT_EQ(SC_SERVICE_ERROR_PERMISSION_OPER_FAIL, - SecCompInfoHelper::GrantTempPermission(*tokenid, shared_comp)); -} - /** * @tc.name: IsColorSimilar001 * @tc.desc: Test IsColorSimilar diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_perm_manager_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_perm_manager_test.cpp index a7ddbb785f8594d8658425b7cf9fafd5559de21c..4111522016986aa5aed2309d4b83cfd522740711 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_perm_manager_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_perm_manager_test.cpp @@ -16,7 +16,9 @@ #include "accesstoken_kit.h" #include "sec_comp_err.h" +#include "sec_comp_info_helper.h" #include "sec_comp_log.h" +#include "service_test_common.h" using namespace testing::ext; using namespace OHOS; @@ -168,3 +170,32 @@ HWTEST_F(SecCompPermManagerTest, VerifyPermission001, TestSize.Level1) ASSERT_FALSE(permMgr.VerifyPermission(id, SAVE_COMPONENT)); ASSERT_FALSE(permMgr.VerifyPermission(id, static_cast(-1))); } + +/** + * @tc.name: DLP-GrantTempPermission001 + * @tc.desc: Test DLP sandbox app grant save button + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompPermManagerTest, GrantTempPermission001, TestSize.Level1) +{ + OHOS::Security::AccessToken::AccessTokenIDInner tokenInner = { + .tokenUniqueID = 0x00001, + .res = 1, + .dlpFlag = 1, + .type = OHOS::Security::AccessToken::TOKEN_HAP, + .version = 0, + }; + OHOS::Security::AccessToken::AccessTokenID *tokenid = + reinterpret_cast(&tokenInner); + ASSERT_NE(0, *tokenid); + SecCompPermManager permMgr; + nlohmann::json jsonComponent; + ServiceTestCommon::BuildSaveComponentJson(jsonComponent); + SecCompBase* comp = SecCompInfoHelper::ParseComponent(SAVE_COMPONENT, jsonComponent); + ASSERT_NE(nullptr, comp); + std::shared_ptr shared_comp(comp); + + EXPECT_EQ(SC_SERVICE_ERROR_PERMISSION_OPER_FAIL, + permMgr.GrantTempPermission(*tokenid, shared_comp)); +} \ No newline at end of file diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.h b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.h index 022d53334eebaf8e6172d09fdaf427479b88d31d..4deacac351e2a43b23a2a7f04b7896328cf48a7a 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.h +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.h @@ -44,7 +44,7 @@ public: }; int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, - const SecCompClickEvent& clickInfo, sptr callerToken, + SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCall) override { return 0; diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h index 2c2c1c32847ed47a077b5a6af36cfa7038063cce..7f12ae07e67d5283cb112f480b65832a922164ab 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h @@ -44,7 +44,7 @@ public: }; int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, - const SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCall) override + SecCompClickEvent& clickInfo, sptr callerToken, sptr dialogCall) override { return 0; }; diff --git a/services/security_component_service/sa/test/unittest/src/service_test_common.cpp b/services/security_component_service/sa/test/unittest/src/service_test_common.cpp index d3433d1d5951acb21fe183faa7d61712e2ec71ac..75db0fce98012b4220dc9e09c4ab0862def7688f 100644 --- a/services/security_component_service/sa/test/unittest/src/service_test_common.cpp +++ b/services/security_component_service/sa/test/unittest/src/service_test_common.cpp @@ -71,6 +71,8 @@ void ServiceTestCommon::BuildLocationComponentJson(nlohmann::json& jsonComponent { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; } void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) @@ -127,6 +129,8 @@ void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; } void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) @@ -183,6 +187,8 @@ void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; } } // namespace SecurityComponent } // namespace Security diff --git a/test/fuzztest/security_component/common/fuzz_common.cpp b/test/fuzztest/security_component/common/fuzz_common.cpp index d591bee852dd370d2adc3456d913fb6544c3d0fa..741833f7dc91a2b0450c24dd685be0cc9b30ab92 100644 --- a/test/fuzztest/security_component/common/fuzz_common.cpp +++ b/test/fuzztest/security_component/common/fuzz_common.cpp @@ -109,6 +109,8 @@ std::string CompoRandomGenerator::ConstructLocationJson() GetData() % static_cast(SecCompBackground::MAX_BG_TYPE) }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; return jsonComponent.dump(); } @@ -151,6 +153,8 @@ std::string CompoRandomGenerator::ConstructSaveJson() GetData() % static_cast(SecCompBackground::MAX_BG_TYPE) }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; return jsonComponent.dump(); } @@ -192,6 +196,8 @@ std::string CompoRandomGenerator::ConstructPasteJson() GetData() % static_cast(SecCompBackground::MAX_BG_TYPE) }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; return jsonComponent.dump(); } diff --git a/test/fuzztest/security_component/innerkits/getenhanceremoteobject_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/getenhanceremoteobject_fuzzer/BUILD.gn index 9ac717cb769d26387e0c86ebc8e44f772e290ab7..8e19eb88f664a5cc3c216d5fd39876a973c6dcd8 100644 --- a/test/fuzztest/security_component/innerkits/getenhanceremoteobject_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/getenhanceremoteobject_fuzzer/BUILD.gn @@ -21,10 +21,7 @@ ohos_fuzztest("GetEnhanceRemoteObjectFuzzTest") { module_out_path = module_output_path fuzz_config_file = "${sec_comp_dir}/test/fuzztest/security_component/innerkits/getenhanceremoteobject_fuzzer" - include_dirs = [ - "${sec_comp_dir}/frameworks/common/include", - "${sec_comp_dir}/interfaces/inner_api/security_component/include", - ] + include_dirs = [ "${sec_comp_dir}/frameworks/common/include" ] cflags = [ "-g", "-O0", @@ -36,7 +33,7 @@ ohos_fuzztest("GetEnhanceRemoteObjectFuzzTest") { cflags_cc = [ "-DHILOG_ENABLE" ] sources = [ "getenhanceremoteobject_fuzzer.cpp" ] - deps = [ "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/security_component/innerkits/getpointereventenhancedata_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/getpointereventenhancedata_fuzzer/BUILD.gn index 10e2a48ea16aafea7eaa89a05bc1b35aca39dbda..aea2f88b122f2c358234cd6a6c673a9d27d053b8 100644 --- a/test/fuzztest/security_component/innerkits/getpointereventenhancedata_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/getpointereventenhancedata_fuzzer/BUILD.gn @@ -21,10 +21,7 @@ ohos_fuzztest("GetPointerEventEnhanceDataFuzzTest") { module_out_path = module_output_path fuzz_config_file = "${sec_comp_dir}/test/fuzztest/security_component/innerkits/getpointereventenhancedata_fuzzer" - include_dirs = [ - "${sec_comp_dir}/frameworks/common/include", - "${sec_comp_dir}/interfaces/inner_api/enhance_kits/include", - ] + include_dirs = [ "${sec_comp_dir}/frameworks/common/include" ] cflags = [ "-g", "-O0", @@ -36,7 +33,7 @@ ohos_fuzztest("GetPointerEventEnhanceDataFuzzTest") { cflags_cc = [ "-DHILOG_ENABLE" ] sources = [ "getpointereventenhancedata_fuzzer.cpp" ] - deps = [ "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/security_component/innerkits/registersecuritycomponent_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/registersecuritycomponent_fuzzer/BUILD.gn index 3c3b124e867fa459147c8992b6958b9091c567fe..c170e5583829a8ccdbb6fa833d20d2676a6a93b6 100644 --- a/test/fuzztest/security_component/innerkits/registersecuritycomponent_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/registersecuritycomponent_fuzzer/BUILD.gn @@ -23,7 +23,6 @@ ohos_fuzztest("RegisterSecurityComponentFuzzTest") { include_dirs = [ "${sec_comp_dir}/frameworks/common/include", - "${sec_comp_dir}/interfaces/inner_api/security_component/include", "${sec_comp_dir}/test/fuzztest/security_component/common", ] cflags = [ @@ -40,7 +39,7 @@ ohos_fuzztest("RegisterSecurityComponentFuzzTest") { "registersecuritycomponent_fuzzer.cpp", ] - deps = [ "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/security_component/innerkits/reportsecuritycomponentclickevent_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/reportsecuritycomponentclickevent_fuzzer/BUILD.gn index 703821d01084852a8a6786d43d6d5b4cbb6a1d38..e89a4f82414225b1c10944666858c34e8db502fd 100644 --- a/test/fuzztest/security_component/innerkits/reportsecuritycomponentclickevent_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/reportsecuritycomponentclickevent_fuzzer/BUILD.gn @@ -23,7 +23,6 @@ ohos_fuzztest("ReportSecurityComponentClickEventFuzzTest") { include_dirs = [ "${sec_comp_dir}/frameworks/common/include", - "${sec_comp_dir}/interfaces/inner_api/security_component/include", "${sec_comp_dir}/test/fuzztest/security_component/common", ] cflags = [ @@ -40,7 +39,7 @@ ohos_fuzztest("ReportSecurityComponentClickEventFuzzTest") { "reportsecuritycomponentclickevent_fuzzer.cpp", ] - deps = [ "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/security_component/innerkits/setenhancecfg_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/setenhancecfg_fuzzer/BUILD.gn index 0a0168712f14c6ff2d0e8ae8fef8d5954fb16dad..f0a32c1913dac28ace1078cdbb7f75426833114d 100644 --- a/test/fuzztest/security_component/innerkits/setenhancecfg_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/setenhancecfg_fuzzer/BUILD.gn @@ -21,10 +21,7 @@ ohos_fuzztest("SetEnhanceCfgFuzzTest") { module_out_path = module_output_path fuzz_config_file = "${sec_comp_dir}/test/fuzztest/security_component/innerkits/setenhancecfg_fuzzer" - include_dirs = [ - "${sec_comp_dir}/frameworks/common/include", - "${sec_comp_dir}/interfaces/inner_api/enhance_kits/include", - ] + include_dirs = [ "${sec_comp_dir}/frameworks/common/include" ] cflags = [ "-g", "-O0", @@ -36,7 +33,7 @@ ohos_fuzztest("SetEnhanceCfgFuzzTest") { cflags_cc = [ "-DHILOG_ENABLE" ] sources = [ "setenhancecfg_fuzzer.cpp" ] - deps = [ "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/security_component/innerkits/unregistersecuritycomponent_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/unregistersecuritycomponent_fuzzer/BUILD.gn index 804dcc5a8f541af048be620fd82adb41ad429a09..305328f13204e7de5697ba100fa93e6026d1adeb 100644 --- a/test/fuzztest/security_component/innerkits/unregistersecuritycomponent_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/unregistersecuritycomponent_fuzzer/BUILD.gn @@ -23,7 +23,6 @@ ohos_fuzztest("UnregisterSecurityComponentFuzzTest") { include_dirs = [ "${sec_comp_dir}/frameworks/common/include", - "${sec_comp_dir}/interfaces/inner_api/security_component/include", "${sec_comp_dir}/test/fuzztest/security_component/common", ] cflags = [ @@ -40,7 +39,7 @@ ohos_fuzztest("UnregisterSecurityComponentFuzzTest") { "unregistersecuritycomponent_fuzzer.cpp", ] - deps = [ "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/security_component/innerkits/updatesecuritycomponent_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/updatesecuritycomponent_fuzzer/BUILD.gn index 1f3e65d8d69ce0ec2b0df62ad0bddc67d821cd99..fb8d9c37957c705cdbdc2bff46bc50438946637e 100644 --- a/test/fuzztest/security_component/innerkits/updatesecuritycomponent_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/updatesecuritycomponent_fuzzer/BUILD.gn @@ -23,7 +23,6 @@ ohos_fuzztest("UpdateSecurityComponentFuzzTest") { include_dirs = [ "${sec_comp_dir}/frameworks/common/include", - "${sec_comp_dir}/services/security_component_service/sa/sa_main", "${sec_comp_dir}/test/fuzztest/security_component/common", ] cflags = [ @@ -41,8 +40,8 @@ ohos_fuzztest("UpdateSecurityComponentFuzzTest") { ] deps = [ - "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk", - "${sec_comp_dir}/services/security_component_service/sa:security_component_service", + "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk", + "${sec_comp_dir}/services/security_component_service/sa:security_component_common", ] external_deps = [ diff --git a/test/fuzztest/security_component/innerkits/verifysavepermission_fuzzer/BUILD.gn b/test/fuzztest/security_component/innerkits/verifysavepermission_fuzzer/BUILD.gn index 02125c071eecdacd0c9508c206839822f5fa4af0..84d8633db3bdbf392bf14f7c6ca3ab80cf86c108 100644 --- a/test/fuzztest/security_component/innerkits/verifysavepermission_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/innerkits/verifysavepermission_fuzzer/BUILD.gn @@ -40,7 +40,7 @@ ohos_fuzztest("VerifySavePermissionFuzzTest") { "verifysavepermission_fuzzer.cpp", ] - deps = [ "${sec_comp_dir}/interfaces/inner_api/security_component:libsecurity_component_sdk" ] + deps = [ "${sec_comp_dir}/frameworks/inner_api/security_component:libsecurity_component_sdk" ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/security_component/service/reportsecuritycomponentclickeventstub_fuzzer/BUILD.gn b/test/fuzztest/security_component/service/reportsecuritycomponentclickeventstub_fuzzer/BUILD.gn index 0c45709f6eca63836986f5c7d4d415ab6ac36dc2..01b0d0c8b643a3e9e7107afd3dd4bf63d96b9fb6 100644 --- a/test/fuzztest/security_component/service/reportsecuritycomponentclickeventstub_fuzzer/BUILD.gn +++ b/test/fuzztest/security_component/service/reportsecuritycomponentclickeventstub_fuzzer/BUILD.gn @@ -39,7 +39,7 @@ ohos_fuzztest("ReportSecurityComponentClickEventStubFuzzTest") { sources += sc_service_sources sources += sc_mock_sources - sources += [ "${sec_comp_dir}/interfaces/inner_api/security_component/src/sec_comp_dialog_callback.cpp" ] + sources += [ "${sec_comp_dir}/frameworks/inner_api/security_component/src/sec_comp_dialog_callback.cpp" ] deps = sc_deps diff --git a/test/fuzztest/security_component/service/security_component_fuzz.gni b/test/fuzztest/security_component/service/security_component_fuzz.gni index 36aa3d6bb1b13bd6cdcffb302b58e2fe9696b99a..13123c4213f06d811a8cffeb056031fcca7c8d89 100644 --- a/test/fuzztest/security_component/service/security_component_fuzz.gni +++ b/test/fuzztest/security_component/service/security_component_fuzz.gni @@ -19,6 +19,8 @@ sc_include_dirs = [ "${sec_comp_dir}/frameworks/common/include", "${sec_comp_dir}/frameworks/enhance_adapter/include", "${sec_comp_dir}/frameworks/security_component/include", + "${sec_comp_dir}/frameworks/inner_api/security_component/include", + "${sec_comp_dir}/interfaces/inner_api/security_component_common", "${sec_comp_dir}/interfaces/inner_api/security_component/include", "${sec_comp_dir}/services/security_component_service/sa/test/mock/include", "${sec_comp_dir}/test/fuzztest/security_component/common", @@ -54,12 +56,12 @@ sc_external_deps = [ sc_service_sources = [ "${sec_comp_dir}/frameworks/common/src/sec_comp_tool.cpp", + "${sec_comp_dir}/frameworks/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", "${sec_comp_dir}/frameworks/security_component/src/location_button.cpp", "${sec_comp_dir}/frameworks/security_component/src/paste_button.cpp", "${sec_comp_dir}/frameworks/security_component/src/save_button.cpp", "${sec_comp_dir}/frameworks/security_component/src/sec_comp_base.cpp", "${sec_comp_dir}/frameworks/security_component/src/sec_comp_click_event_parcel.cpp", - "${sec_comp_dir}/interfaces/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp", "${sec_comp_dir}/services/security_component_service/sa/sa_main/app_mgr_death_recipient.cpp", "${sec_comp_dir}/services/security_component_service/sa/sa_main/app_state_observer.cpp", "${sec_comp_dir}/services/security_component_service/sa/sa_main/delay_exit_task.cpp",