From 19def3b9b8e918558a245469de283805bf402fd8 Mon Sep 17 00:00:00 2001 From: shenxz Date: Wed, 16 Jul 2025 11:07:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=20screenlock=5Fmgr=20?= =?UTF-8?q?=E8=A7=A3=E8=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shenxz --- services/distributed/BUILD.gn | 6 +++- .../helper/distributed_operation_helper.h | 4 +++ .../soft_bus/distributed_observer_service.h | 4 +++ .../helper/distributed_operation_helper.cpp | 4 +++ .../soft_bus/distributed_observer_service.cpp | 7 +++++ .../distributed_operation_service.cpp | 30 +++++++++++-------- services/distributed/test/unittest/BUILD.gn | 20 +++++++++++-- 7 files changed, 59 insertions(+), 16 deletions(-) diff --git a/services/distributed/BUILD.gn b/services/distributed/BUILD.gn index 8047e1e68..276e97e86 100644 --- a/services/distributed/BUILD.gn +++ b/services/distributed/BUILD.gn @@ -162,11 +162,15 @@ ohos_shared_library("libdans") { "power_manager:powermgr_client", "relational_store:native_rdb", "samgr:samgr_proxy", - "screenlock_mgr:screenlock_client", "time_service:time_client", "zlib:libz", ] + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + if (ans_hitrace_usage) { external_deps += [ "hitrace:hitrace_meter" ] defines += [ "HITRACE_METER_ENABLE" ] diff --git a/services/distributed/include/helper/distributed_operation_helper.h b/services/distributed/include/helper/distributed_operation_helper.h index 70962c219..b7d5124b5 100644 --- a/services/distributed/include/helper/distributed_operation_helper.h +++ b/services/distributed/include/helper/distributed_operation_helper.h @@ -23,7 +23,9 @@ #include "ans_log_wrapper.h" #include "ability_manager_client.h" #include "power_mgr_client.h" +#ifdef SCREENLOCK_MGR_ENABLE #include "screenlock_callback_interface.h" +#endif #include "notification_operation_info.h" namespace OHOS { @@ -36,6 +38,7 @@ struct OperationInfo { AAFwk::Want want; }; +#ifdef SCREENLOCK_MGR_ENABLE class UnlockScreenCallback : public IRemoteStub { public: explicit UnlockScreenCallback(const std::string& eventId); @@ -45,6 +48,7 @@ public: private: std::string eventId_; }; +#endif class OperationService { public: diff --git a/services/distributed/include/soft_bus/distributed_observer_service.h b/services/distributed/include/soft_bus/distributed_observer_service.h index c84c03d48..8cd49fcef 100644 --- a/services/distributed/include/soft_bus/distributed_observer_service.h +++ b/services/distributed/include/soft_bus/distributed_observer_service.h @@ -17,7 +17,9 @@ #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_OBSERVER_SERVICE_H #include "common_event_subscriber.h" +#ifdef SCREENLOCK_MGR_ENABLE #include "screenlock_manager.h" +#endif #include @@ -40,7 +42,9 @@ public: static OberverService& GetInstance(); int32_t IsScreenLocked(); void Destory(); +#ifdef SCREENLOCK_MGR_ENABLE int32_t Unlock(const ScreenLock::Action &action, const sptr &listener); +#endif void Init(uint16_t deviceType); private: OberverService() = default; diff --git a/services/distributed/src/helper/distributed_operation_helper.cpp b/services/distributed/src/helper/distributed_operation_helper.cpp index 170386b5c..cf765c6e2 100644 --- a/services/distributed/src/helper/distributed_operation_helper.cpp +++ b/services/distributed/src/helper/distributed_operation_helper.cpp @@ -15,7 +15,9 @@ #include "distributed_operation_helper.h" +#ifdef SCREENLOCK_MGR_ENABLE #include "screenlock_common.h" +#endif #include "in_process_call_wrapper.h" #include "distributed_service.h" #include "analytics_util.h" @@ -23,6 +25,7 @@ namespace OHOS { namespace Notification { +#ifdef SCREENLOCK_MGR_ENABLE UnlockScreenCallback::UnlockScreenCallback(const std::string& eventId) : eventId_(eventId) {} UnlockScreenCallback::~UnlockScreenCallback() {} @@ -38,6 +41,7 @@ void UnlockScreenCallback::OnCallBack(int32_t screenLockResult) "unlock screen failed"); } } +#endif OperationService& OperationService::GetInstance() { diff --git a/services/distributed/src/soft_bus/distributed_observer_service.cpp b/services/distributed/src/soft_bus/distributed_observer_service.cpp index 69d9e5e69..7f210ec3d 100644 --- a/services/distributed/src/soft_bus/distributed_observer_service.cpp +++ b/services/distributed/src/soft_bus/distributed_observer_service.cpp @@ -114,8 +114,13 @@ void OberverService::Init(uint16_t deviceType) int32_t OberverService::IsScreenLocked() { +#ifdef SCREENLOCK_MGR_ENABLE bool state = ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked(); return state ? SCREEN_OFF : SCREEN_ON; +#else + ANS_LOGI("Screenlock manager is disabled.") + return SCREEN_ON; +#endif } void OberverService::Destory() @@ -124,10 +129,12 @@ void OberverService::Destory() ANS_LOGI("OberverService service destory."); } +#ifdef SCREENLOCK_MGR_ENABLE int32_t OberverService::Unlock( const ScreenLock::Action &action, const sptr &listener) { return ScreenLock::ScreenLockManager::GetInstance()->Unlock(action, listener); } +#endif } } diff --git a/services/distributed/src/soft_bus/distributed_operation_service.cpp b/services/distributed/src/soft_bus/distributed_operation_service.cpp index 7475aa14d..867ce78e1 100644 --- a/services/distributed/src/soft_bus/distributed_operation_service.cpp +++ b/services/distributed/src/soft_bus/distributed_operation_service.cpp @@ -31,7 +31,9 @@ #include "distributed_operation_helper.h" #include "ability_manager_helper.h" #include "distributed_liveview_all_scenarios_extension_wrapper.h" +#ifdef SCREENLOCK_MGR_ENABLE #include "screenlock_manager.h" +#endif namespace OHOS { namespace Notification { @@ -72,11 +74,13 @@ void DistributedOperationService::HandleNotificationOperation(const std::shared_ if (static_cast(operationType) == DISTRIBUTE_OPERATION_JUMP_BY_TYPE) { int32_t btnIndex; responseBox.GetOperationBtnIndex(btnIndex); - if (!ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked()) { - UnlockListenerOperService::GetInstance().TriggerByJumpType(hashCode, jumpType, peerDeviceType, btnIndex); +#ifdef SCREENLOCK_MGR_ENABLE + if (ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked()) { + UnlockListenerOperService::GetInstance().AddDelayTask(hashCode, jumpType, peerDeviceType, btnIndex); return; } - UnlockListenerOperService::GetInstance().AddDelayTask(hashCode, jumpType, peerDeviceType, btnIndex); +#endif + UnlockListenerOperService::GetInstance().TriggerByJumpType(hashCode, jumpType, peerDeviceType, btnIndex); return; } TriggerByOperationType(hashCode, peerDeviceType, operationType, responseBox); @@ -279,6 +283,7 @@ void DistributedOperationService::TriggerJumpApplication(const std::string& hash } } +#ifdef SCREENLOCK_MGR_ENABLE if (ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked()) { OperationInfo info; info.deviceTypeId = deviceType; @@ -294,17 +299,18 @@ void DistributedOperationService::TriggerJumpApplication(const std::string& hash } info.want = *wantPtr; OperationService::GetInstance().AddOperation(info); + return; + } +#endif + auto ret = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(*wantPtr); + ANS_LOGI("StartAbility result:%{public}d", ret); + if (ret == ERR_OK) { + AnalyticsUtil::GetInstance().OperationalReporting(deviceType, HaOperationType::COLLABORATE_JUMP, + NotificationConstant::SlotType::LIVE_VIEW); } else { - auto ret = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(*wantPtr); - ANS_LOGI("StartAbility result:%{public}d", ret); - if (ret == ERR_OK) { - AnalyticsUtil::GetInstance().OperationalReporting(deviceType, HaOperationType::COLLABORATE_JUMP, - NotificationConstant::SlotType::LIVE_VIEW); - } else { - AnalyticsUtil::GetInstance().AbnormalReporting(MODIFY_ERROR_EVENT_CODE, 0, ret, "pull up failed"); - } - AnalyticsUtil::GetInstance().AbnormalReporting(MODIFY_ERROR_EVENT_CODE, ret, BRANCH9_ID, "pull up success"); + AnalyticsUtil::GetInstance().AbnormalReporting(MODIFY_ERROR_EVENT_CODE, 0, ret, "pull up failed"); } + AnalyticsUtil::GetInstance().AbnormalReporting(MODIFY_ERROR_EVENT_CODE, ret, BRANCH9_ID, "pull up success"); } void DistributedOperationService::TriggerByOperationType(const std::string& hashCode, const int32_t deviceType, diff --git a/services/distributed/test/unittest/BUILD.gn b/services/distributed/test/unittest/BUILD.gn index b52b8d67d..802abfa63 100644 --- a/services/distributed/test/unittest/BUILD.gn +++ b/services/distributed/test/unittest/BUILD.gn @@ -502,11 +502,16 @@ ohos_unittest("distributed_service_test") { "relational_store:native_rdb", "relational_store:native_rdb", "samgr:samgr_proxy", - "screenlock_mgr:screenlock_client", "time_service:time_client", "zlib:libz", ] + defines = [] + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + subsystem_name = "${subsystem_name}" part_name = "${component_name}" } @@ -596,11 +601,16 @@ ohos_unittest("distributed_subscriber_test") { "relational_store:native_rdb", "relational_store:native_rdb", "samgr:samgr_proxy", - "screenlock_mgr:screenlock_client", "time_service:time_client", "zlib:libz", ] + defines = [] + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + subsystem_name = "${subsystem_name}" part_name = "${component_name}" } @@ -695,11 +705,15 @@ ohos_unittest("distributed_tlvbox_test") { "relational_store:native_rdb", "relational_store:native_rdb", "samgr:samgr_proxy", - "screenlock_mgr:screenlock_client", "time_service:time_client", "zlib:libz", ] + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + subsystem_name = "${subsystem_name}" part_name = "${component_name}" } -- Gitee