From 9d27d5640a6765ecb45d71264722cfee390fd5a6 Mon Sep 17 00:00:00 2001 From: Haryslee Date: Wed, 26 Feb 2025 15:49:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20sasdk=20=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81cross=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Haryslee --- BUILD.gn | 7 +- bundle.json | 23 ++++-- frameworks/BUILD.gn | 43 ++++++++-- .../inner_api/enhance_kits/BUILD.gn | 1 + .../enhance_kits/src/sec_comp_enhance_kit.cpp | 0 .../inner_api/enhance_kits/test/BUILD.gn | 7 +- .../unittest/src/sec_comp_enhance_test.cpp | 0 .../test/unittest/src/sec_comp_enhance_test.h | 0 .../inner_api/security_component/BUILD.gn | 14 ++-- .../include/i_sec_comp_dialog_callback.h | 0 .../include/i_sec_comp_service.h | 2 +- .../include/sec_comp_caller_authorization.h | 0 .../include/sec_comp_client.h | 2 +- .../include/sec_comp_death_recipient.h | 0 .../include/sec_comp_dialog_callback.h | 0 .../include/sec_comp_dialog_callback_stub.h | 0 .../include/sec_comp_load_callback.h | 0 .../include/sec_comp_proxy.h | 2 +- .../src/sec_comp_caller_authorization.cpp | 0 .../src/sec_comp_client.cpp | 2 +- .../src/sec_comp_death_recipient.cpp | 0 .../src/sec_comp_dialog_callback.cpp | 0 .../src/sec_comp_dialog_callback_stub.cpp | 0 .../security_component/src/sec_comp_kit.cpp | 2 +- .../src/sec_comp_load_callback.cpp | 0 .../security_component/src/sec_comp_proxy.cpp | 2 +- .../src/sec_comp_ui_register.cpp | 0 .../security_component/test/BUILD.gn | 25 +++--- .../unittest/src/location_button_test.cpp | 0 .../test/unittest/src/location_button_test.h | 0 .../test/unittest/src/paste_button_test.cpp | 0 .../test/unittest/src/paste_button_test.h | 0 .../test/unittest/src/save_button_test.cpp | 0 .../test/unittest/src/save_button_test.h | 0 .../test/unittest/src/sec_comp_kit_test.cpp | 0 .../test/unittest/src/sec_comp_kit_test.h | 0 .../src/sec_comp_register_callback_test.cpp | 2 +- .../test/unittest/src/test_common.cpp | 6 ++ .../test/unittest/src/test_common.h | 0 .../security_component/src/sec_comp_base.cpp | 79 ++++++++++++++---- .../include/sec_comp_base.h | 8 ++ .../include/sec_comp_enhance_adapter.h | 4 + .../include/sec_comp_enhance_kit.h | 0 .../include/sec_comp_enhance_kit_c.h | 0 .../include/sec_comp_err.h | 0 .../include/sec_comp_info.h | 6 ++ .../security_component/include/sec_comp_kit.h | 2 +- .../delay_exit_task.h | 5 +- .../sec_comp_info_helper.h | 6 +- .../sec_event_handler.h | 2 +- .../security_component_service/sa/BUILD.gn | 81 ++++++++++++++++--- .../sa/sa_main/delay_exit_task.cpp | 10 +-- .../sa/sa_main/first_use_dialog.cpp | 57 +++++++++++-- .../sa/sa_main/first_use_dialog.h | 10 ++- .../sa/sa_main/sec_comp_entity.cpp | 38 ++++++++- .../sa/sa_main/sec_comp_entity.h | 7 +- .../sa/sa_main/sec_comp_info_helper.cpp | 79 ++++-------------- .../sa/sa_main/sec_comp_manager.cpp | 55 ++++++++++--- .../sa/sa_main/sec_comp_manager.h | 6 +- .../sa/sa_main/sec_comp_perm_manager.cpp | 51 ++++++++++++ .../sa/sa_main/sec_comp_perm_manager.h | 3 + .../sa/sa_main/sec_comp_service.cpp | 2 +- .../sa/sa_main/sec_comp_service.h | 2 +- .../sa/sa_main/window_info_helper.h | 2 +- .../sa/test/BUILD.gn | 4 +- .../unittest/src/first_use_dialog_test.cpp | 23 +++--- .../unittest/src/sec_comp_entity_test.cpp | 21 ++--- .../src/sec_comp_info_helper_test.cpp | 67 +++++---------- .../src/sec_comp_perm_manager_test.cpp | 31 +++++++ .../unittest/src/sec_comp_stub_mock_test.h | 2 +- .../sa/test/unittest/src/sec_comp_stub_test.h | 2 +- .../test/unittest/src/service_test_common.cpp | 6 ++ .../security_component/common/fuzz_common.cpp | 6 ++ .../getenhanceremoteobject_fuzzer/BUILD.gn | 7 +- .../BUILD.gn | 7 +- .../registersecuritycomponent_fuzzer/BUILD.gn | 3 +- .../BUILD.gn | 3 +- .../innerkits/setenhancecfg_fuzzer/BUILD.gn | 7 +- .../BUILD.gn | 3 +- .../updatesecuritycomponent_fuzzer/BUILD.gn | 5 +- .../verifysavepermission_fuzzer/BUILD.gn | 2 +- .../BUILD.gn | 2 +- .../service/security_component_fuzz.gni | 4 +- 83 files changed, 588 insertions(+), 272 deletions(-) rename {interfaces => frameworks}/inner_api/enhance_kits/BUILD.gn (96%) rename {interfaces => frameworks}/inner_api/enhance_kits/src/sec_comp_enhance_kit.cpp (100%) rename {interfaces => frameworks}/inner_api/enhance_kits/test/BUILD.gn (89%) rename {interfaces => frameworks}/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.cpp (100%) rename {interfaces => frameworks}/inner_api/enhance_kits/test/unittest/src/sec_comp_enhance_test.h (100%) rename {interfaces => frameworks}/inner_api/security_component/BUILD.gn (86%) rename {interfaces => frameworks}/inner_api/security_component/include/i_sec_comp_dialog_callback.h (100%) rename {interfaces => frameworks}/inner_api/security_component/include/i_sec_comp_service.h (93%) rename {interfaces => frameworks}/inner_api/security_component/include/sec_comp_caller_authorization.h (100%) rename {interfaces => frameworks}/inner_api/security_component/include/sec_comp_client.h (96%) rename {interfaces => frameworks}/inner_api/security_component/include/sec_comp_death_recipient.h (100%) rename {interfaces => frameworks}/inner_api/security_component/include/sec_comp_dialog_callback.h (100%) rename {interfaces => frameworks}/inner_api/security_component/include/sec_comp_dialog_callback_stub.h (100%) rename {interfaces => frameworks}/inner_api/security_component/include/sec_comp_load_callback.h (100%) rename {interfaces => frameworks}/inner_api/security_component/include/sec_comp_proxy.h (95%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_caller_authorization.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_client.cpp (99%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_death_recipient.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_dialog_callback.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_dialog_callback_stub.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_kit.cpp (99%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_load_callback.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_proxy.cpp (99%) rename {interfaces => frameworks}/inner_api/security_component/src/sec_comp_ui_register.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/test/BUILD.gn (80%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/location_button_test.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/location_button_test.h (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/paste_button_test.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/paste_button_test.h (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/save_button_test.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/save_button_test.h (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/sec_comp_kit_test.h (100%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp (99%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/test_common.cpp (96%) rename {interfaces => frameworks}/inner_api/security_component/test/unittest/src/test_common.h (100%) rename {frameworks/enhance_adapter => interfaces/inner_api/security_component}/include/sec_comp_enhance_adapter.h (97%) rename interfaces/inner_api/{enhance_kits => security_component}/include/sec_comp_enhance_kit.h (100%) rename interfaces/inner_api/{enhance_kits => security_component}/include/sec_comp_enhance_kit_c.h (100%) rename {frameworks/common => interfaces/inner_api/security_component}/include/sec_comp_err.h (100%) rename {services/security_component_service/sa/sa_main => interfaces/inner_api/security_component_common}/delay_exit_task.h (88%) rename {services/security_component_service/sa/sa_main => interfaces/inner_api/security_component_common}/sec_comp_info_helper.h (90%) rename {services/security_component_service/sa/sa_main => interfaces/inner_api/security_component_common}/sec_event_handler.h (92%) diff --git a/BUILD.gn b/BUILD.gn index 11bad1b..0d544d7 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 6e1fbb6..93938db 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 a287271..584cc15 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 49f1699..f147db4 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 7f4e140..b46f0a1 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 29068dd..bddf601 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 155604b..18452ec 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 563376e..6b4f15f 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 bb637ea..d4d6ba7 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 b38f9cb..cbdf031 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 6df28a1..17ed21a 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 f8eb802..4b1d119 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 2b59ae1..62d2366 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 48d587d..95ea841 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 2c602e3..7ce03fc 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 22d10f3..3d121ec 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 f7c0130..44b493a 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 4118341..c54a575 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 a712f0e..665b47f 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 a264993..a2881a9 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 cdc3bda..6c4a127 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 5c7630c..a2c73b0 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 86b0734..9898522 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 6156d84..73c5072 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 109281b..40c4c7e 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 f5bc9e1..f630c71 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 ea80cad..255cd52 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 4a98fad..410924b 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 2bc4d64..cac7c41 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 245d9eb..bd52aa5 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" @@ -74,10 +73,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 +89,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 +120,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 +229,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 4ae69ff..944f141 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 323f5d5..a11ffb2 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 187cd42..7f561b5 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 b157e78..356e297 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 5f35b29..525a490 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 ff95582..4d205a0 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 ad60af2..a831bc1 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 528b6fd..ec2c3ab 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 fc4d4a0..d0a5901 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 9070eae..60647d1 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 0e463d0..c7e8215 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 a7ddbb7..4111522 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 022d533..4deacac 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 2c2c1c3..7f12ae0 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 d3433d1..75db0fc 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 d591bee..741833f 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 9ac717c..8e19eb8 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 10e2a48..aea2f88 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 3c3b124..c170e55 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 703821d..e89a4f8 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 0a01687..f0a32c1 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 804dcc5..305328f 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 1f3e65d..fb8d9c3 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 02125c0..84d8633 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 0c45709..01b0d0c 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 36aa3d6..13123c4 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", -- Gitee From 7a00de75653eaeb927e2abe81a4bda45e693eddb Mon Sep 17 00:00:00 2001 From: li-li-wang Date: Fri, 14 Feb 2025 16:53:50 +0800 Subject: [PATCH 2/2] windowRect fit scale --- .../sa/sa_main/sec_comp_info_helper.cpp | 3 +++ 1 file changed, 3 insertions(+) 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 bd52aa5..44a9285 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 @@ -45,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) -- Gitee