diff --git a/code_signature.gni b/code_signature.gni index c14b17632a055ec353431b7ee2126d09d754d239..06610841190071a2abde2cafc4b2bb73ad0a96f6 100644 --- a/code_signature.gni +++ b/code_signature.gni @@ -24,4 +24,9 @@ declare_args() { code_signature_support_oh_code_sign = false code_signature_enable_xpm_mode = false code_signature_support_oh_release_app = true + code_signature_screenlock_mgr_enable = false + if (defined(global_parts_info) && + defined(global_parts_info.theme_screenlock_mgr)) { + code_signature_screenlock_mgr_enable = true + } } diff --git a/services/key_enable/utils/BUILD.gn b/services/key_enable/utils/BUILD.gn index 6977888b1e01e19494dcd92a812c7520f169fa22..29687ad4d19ab91a3cd024e41b76f62f895298b5 100644 --- a/services/key_enable/utils/BUILD.gn +++ b/services/key_enable/utils/BUILD.gn @@ -38,8 +38,14 @@ ohos_static_library("libkey_enable_utils") { "hilog:libhilog", "init:libbegetutil", "samgr:samgr_proxy", - "screenlock_mgr:screenlock_client", ] + + defines = [] + if (code_signature_screenlock_mgr_enable) { + defines += [ "SCREENLOCK_MANAGER_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } + subsystem_name = "security" part_name = "code_signature" } diff --git a/services/key_enable/utils/src/unlock_event_helper.cpp b/services/key_enable/utils/src/unlock_event_helper.cpp index 2693d1d456c24c84b5e556336c0a947b27437614..23d97a156f603c088a8f3cadffe75001df4d064e 100644 --- a/services/key_enable/utils/src/unlock_event_helper.cpp +++ b/services/key_enable/utils/src/unlock_event_helper.cpp @@ -19,7 +19,10 @@ #include "datetime_ex.h" #include "log.h" + +#ifdef SCREENLOCK_MANAGER_ENABLED #include "screenlock_manager.h" +#endif namespace OHOS { namespace Security { @@ -48,6 +51,7 @@ UnlockEventHelper &UnlockEventHelper::GetInstance() bool UnlockEventHelper::CheckUserUnlockByScreenLockManager() { std::lock_guard lock(unlockMutex_); +#ifdef SCREENLOCK_MANAGER_ENABLED if (hasUnLocked_) { return true; } @@ -58,6 +62,7 @@ bool UnlockEventHelper::CheckUserUnlockByScreenLockManager() } else { LOG_ERROR(LABEL, "unable get lock screen status"); } +#endif return hasUnLocked_; }