diff --git a/services/distributed/BUILD.gn b/services/distributed/BUILD.gn index 8047e1e68c3822ca8d48b50a8f762a5dc091a60a..276e97e866164ff30fb2e42e1d935d9b63c72401 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 70962c219ff55ccac9b8fe44a3b767d4628b413b..b7d5124b5857840890df7db4bd7035f88cf1bedf 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 c84c03d48664a9e4a24696d68ac1e100a1f9aff5..8cd49fcef7a3b265a5e0d6962fbb045f04835973 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 170386b5c75e0eae723e35dee7ea72a128ca3e6a..cf765c6e2cad908f7663a11a3b6f24dfa8bbf803 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 69d9e5e696191c90fd8d229b7c1bc3e58289c8e2..7f210ec3de317f9aeac203e809b6d710d1d4e908 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 7475aa14d74ce805a4b9395b1222480e949402cb..867ce78e19202e2dee51f2f29b4313c4e533013a 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 b52b8d67d112674f62e838b457b34161438118e1..802abfa63151d041fc8695cac998ce2430a85442 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}" }