From 651d0fe43546a2fd71d7b9043b62872ee3fa8488 Mon Sep 17 00:00:00 2001 From: Haryslee Date: Mon, 22 Jul 2024 23:03:26 +0800 Subject: [PATCH] feat: support transparet for system app Signed-off-by: Haryslee --- frameworks/security_component/src/save_button.cpp | 2 +- .../security_component/include/sec_comp_client.h | 1 + .../inner_api/security_component/include/sec_comp_kit.h | 1 + .../inner_api/security_component/src/sec_comp_client.cpp | 8 ++++++++ .../inner_api/security_component/src/sec_comp_kit.cpp | 5 +++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/frameworks/security_component/src/save_button.cpp b/frameworks/security_component/src/save_button.cpp index ed05cb4..73a5a9d 100644 --- a/frameworks/security_component/src/save_button.cpp +++ b/frameworks/security_component/src/save_button.cpp @@ -15,9 +15,9 @@ #include "save_button.h" #include +#include "ipc_skeleton.h" #include "sec_comp_log.h" #include "tokenid_kit.h" -#include "ipc_skeleton.h" namespace OHOS { namespace Security { diff --git a/interfaces/inner_api/security_component/include/sec_comp_client.h b/interfaces/inner_api/security_component/include/sec_comp_client.h index a1913ab..563376e 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_client.h +++ b/interfaces/inner_api/security_component/include/sec_comp_client.h @@ -41,6 +41,7 @@ public: int32_t PreRegisterSecCompProcess(); bool IsServiceExist(); bool LoadService(); + bool IsSystemAppCalling(); void FinishStartSASuccess(const sptr& remoteObject); void FinishStartSAFail(); 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 7cabd4e..a264993 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_kit.h +++ b/interfaces/inner_api/security_component/include/sec_comp_kit.h @@ -38,6 +38,7 @@ public: static int32_t PreRegisterSecCompProcess(); static bool IsServiceExist(); static bool LoadService(); + static bool IsSystemAppCalling(); }; } // namespace SecurityComponent } // namespace Security diff --git a/interfaces/inner_api/security_component/src/sec_comp_client.cpp b/interfaces/inner_api/security_component/src/sec_comp_client.cpp index 210e724..b38f9cb 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_client.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_client.cpp @@ -14,10 +14,12 @@ */ #include "sec_comp_client.h" +#include "ipc_skeleton.h" #include "iservice_registry.h" #include "sec_comp_load_callback.h" #include "sec_comp_log.h" #include "sec_comp_proxy.h" +#include "tokenid_kit.h" namespace OHOS { namespace Security { @@ -104,6 +106,12 @@ bool SecCompClient::VerifySavePermission(AccessToken::AccessTokenID tokenId) return proxy->VerifySavePermission(tokenId); } +bool SecCompClient::IsSystemAppCalling() +{ + auto selfToken = IPCSkeleton::GetSelfTokenID(); + return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken); +} + sptr SecCompClient::GetEnhanceRemoteObject(bool doLoadSa) { auto proxy = GetProxy(doLoadSa); diff --git a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp index c4d6b82..c7a9e94 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp @@ -159,6 +159,11 @@ bool SecCompKit::LoadService() { return SecCompClient::GetInstance().LoadService(); } + +bool SecCompKit::IsSystemAppCalling() +{ + return SecCompClient::GetInstance().IsSystemAppCalling(); +} } // namespace SecurityComponent } // namespace Security } // namespace OHOS