diff --git a/frameworks/napi/runninglock/BUILD.gn b/frameworks/napi/runninglock/BUILD.gn index f3dda2222b197040b3a7782ba095e7aca748adcd..efee19d7906743b2679d91d0e3d8bf0b34c77196 100644 --- a/frameworks/napi/runninglock/BUILD.gn +++ b/frameworks/napi/runninglock/BUILD.gn @@ -38,10 +38,11 @@ ohos_shared_library("runninglock") { external_deps = deps_ex } else { external_deps = deps_ex - external_deps += [ - "hiview:libxpower_event_js", - "napi:ace_napi", - ] + external_deps += [ "napi:ace_napi" ] + + if (has_dfx_hiview_part) { + external_deps += [ "hiview:libxpower_event_js" ] + } } relative_install_dir = "module" diff --git a/frameworks/napi/runninglock/runninglock_interface.cpp b/frameworks/napi/runninglock/runninglock_interface.cpp index 7e418c57afe9e05bb2ff8d6d5ebde72ece031fbc..96f6d383b4ec3d610657ca43e1742d89af833c11 100644 --- a/frameworks/napi/runninglock/runninglock_interface.cpp +++ b/frameworks/napi/runninglock/runninglock_interface.cpp @@ -22,7 +22,9 @@ #include "power_log.h" #include "power_mgr_client.h" #include "runninglock_entity.h" +#ifdef HAS_DFX_HIVIEW_PART #include "xpower_event_js.h" +#endif namespace OHOS { namespace PowerMgr { @@ -155,7 +157,9 @@ napi_value RunningLockInterface::Lock(napi_env env, napi_callback_info info) return nullptr; } entity->runningLock->Lock(timeOut); +#ifdef HAS_DFX_HIVIEW_PART OHOS::HiviewDFX::ReportXPowerJsStackSysEvent(env, "RunningLockNapi::Lock"); +#endif return nullptr; } diff --git a/frameworks/napi/runninglock/runninglock_napi.cpp b/frameworks/napi/runninglock/runninglock_napi.cpp index 511ec836f0bff6ceb81a3b22e2518001a35d7a28..f5e98629e27752dd4f15ea17427d111af953dbd6 100644 --- a/frameworks/napi/runninglock/runninglock_napi.cpp +++ b/frameworks/napi/runninglock/runninglock_napi.cpp @@ -22,7 +22,9 @@ #include "power_common.h" #include "power_log.h" #include "runninglock_entity.h" +#ifdef HAS_DFX_HIVIEW_PART #include "xpower_event_js.h" +#endif namespace OHOS { namespace PowerMgr { @@ -100,7 +102,9 @@ napi_value RunningLockNapi::Hold(napi_env env, napi_callback_info info) auto runningLock = UnwrapRunningLock(env, thisArg); RETURN_IF_WITH_RET(runningLock == nullptr, nullptr); runningLock->Lock(timeOut); +#ifdef HAS_DFX_HIVIEW_PART OHOS::HiviewDFX::ReportXPowerJsStackSysEvent(env, "RunningLockNapi::Hold"); +#endif return nullptr; } diff --git a/powermgr.gni b/powermgr.gni index f0f8d736e62fbecb891e97609fbf489b5c832320..065bfbeb6fbbbe094fc3610c4ffc0fc0dbea2607 100644 --- a/powermgr.gni +++ b/powermgr.gni @@ -24,10 +24,11 @@ declare_args() { power_manager_feature_power_dialog = true } +defines = [] if (!defined(global_parts_info) || defined(global_parts_info.powermgr_display_manager)) { has_display_manager_part = true - cflags_cc = [ "-DHAS_DISPLAY_MANAGER_PART" ] + defines += [ "HAS_DISPLAY_MANAGER_PART" ] } else { has_display_manager_part = false } @@ -35,22 +36,30 @@ if (!defined(global_parts_info) || if (!defined(global_parts_info) || defined(global_parts_info.resourceschedule_device_standby)) { has_device_standby_part = true - cflags_cc += [ "-DHAS_DEVICE_STANDBY_PART" ] + defines += [ "HAS_DEVICE_STANDBY_PART" ] } else { has_device_standby_part = false } if (!defined(global_parts_info) || defined(global_parts_info.sensors_sensor)) { has_sensors_sensor_part = true - cflags_cc += [ "-DHAS_SENSORS_SENSOR_PART" ] + defines += [ "HAS_SENSORS_SENSOR_PART" ] } else { has_sensors_sensor_part = false } +if (!defined(global_parts_info) || + defined(global_parts_info.hiviewdfx_hiview)) { + has_dfx_hiview_part = true + defines += [ "HAS_DFX_HIVIEW_PART" ] +} else { + has_dfx_hiview_part = false +} + if (!defined(global_parts_info) || defined(global_parts_info.multimodalinput_input)) { has_multimodalinput_input_part = true - cflags_cc += [ "-DHAS_MULTIMODALINPUT_INPUT_PART" ] + defines += [ "HAS_MULTIMODALINPUT_INPUT_PART" ] } else { has_multimodalinput_input_part = false } diff --git a/services/BUILD.gn b/services/BUILD.gn index db015384da176502dfad0003ee6a24db1e6e1214..eafa53d49dbc431e03a07b78ccd40d634c0fca55 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -117,8 +117,6 @@ ohos_shared_library("powermgrservice") { "window_manager:libwm", ] - defines = [] - if (has_display_manager_part) { defines += [ "HAS_DISPLAY_MANAGER" ] external_deps += [ diff --git a/services/native/include/running_lock_mgr.h b/services/native/include/running_lock_mgr.h index cf8900eba9f6681c374e1b60320611e38d0fab73..9d6ce4379ee986a7c775d9cfd0683aa98fdaf79a 100644 --- a/services/native/include/running_lock_mgr.h +++ b/services/native/include/running_lock_mgr.h @@ -65,7 +65,9 @@ public: void ResetRunningLocks(); bool IsUsed(const sptr& remoteObj); static constexpr uint32_t CHECK_TIMEOUT_INTERVAL_MS = 60 * 1000; +#ifdef HAS_SENSORS_SENSOR_PART void SetProximity(uint32_t status); +#endif void DumpInfo(std::string& result); void EnableMock(IRunningLockAction* mockAction); private: @@ -73,7 +75,9 @@ private: void InitLocksTypeScreen(); void InitLocksTypeBackground(); +#ifdef HAS_SENSORS_SENSOR_PART void InitLocksTypeProximity(); +#endif void InitLocksTypeCoordination(); void ProxyRunningLockInner(bool isProxied, pid_t pid, pid_t uid); @@ -171,9 +175,11 @@ private: bool IsSceneRunningLockType(RunningLockType type); bool IsValidType(RunningLockType type); void PreprocessBeforeAwake(); +#ifdef HAS_SENSORS_SENSOR_PART void ProximityLockOn(); - const wptr pms_; ProximityController proximityController_; +#endif + const wptr pms_; std::mutex mutex_; RunningLockMap runningLocks_; std::map> lockCounters_; diff --git a/services/native/src/running_lock_mgr.cpp b/services/native/src/running_lock_mgr.cpp index d1ef74f8ba10a8bdc468e4eb958def2c41d71be4..dfd51b6ceee62b092429edb3e93164ff26ac3864 100644 --- a/services/native/src/running_lock_mgr.cpp +++ b/services/native/src/running_lock_mgr.cpp @@ -73,7 +73,9 @@ bool RunningLockMgr::InitLocks() { InitLocksTypeScreen(); InitLocksTypeBackground(); +#ifdef HAS_SENSORS_SENSOR_PART InitLocksTypeProximity(); +#endif InitLocksTypeCoordination(); return true; } @@ -739,10 +741,12 @@ void RunningLockMgr::DumpInfo(std::string& result) result.append("Peripherals Info: \n") .append(" Proximity: ") - .append("Enabled=") - .append(ToString(proximityController_.IsEnabled())) - .append(" Status=") - .append(ToString(proximityController_.GetStatus())) +#ifdef HAS_SENSORS_SENSOR_PART + .append("Enabled=").append(ToString(proximityController_.IsEnabled())) + .append(" Status=").append(ToString(proximityController_.GetStatus())) +#else + .append("Enabled=false") +#endif .append("\n"); } diff --git a/test/apitest/inner_api/shutdown/BUILD.gn b/test/apitest/inner_api/shutdown/BUILD.gn index c1873cc368270aa3b42bc1c93530813db65130d2..2a49adf0ba19009a88c9dc1a3a8ed874188be312 100644 --- a/test/apitest/inner_api/shutdown/BUILD.gn +++ b/test/apitest/inner_api/shutdown/BUILD.gn @@ -50,9 +50,12 @@ deps_ex = [ "power_manager:power_ffrt", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "sensor:sensor_interface_native", ] +if (has_sensors_sensor_part) { + deps_ex += [ "sensor:sensor_interface_native" ] +} + ohos_unittest("takeover_shutdown_callback_test") { sources = [ "takeover_shutdown_callback_test.cpp" ] configs = [ diff --git a/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn b/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn index 51061553df1d0b9aa1d05d56a62645ea13699923..785b1be6acd2e338875dc48d5d6b05fd597d801e 100644 --- a/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/asyncshutdowncallback_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("AsyncShutdownCallbackFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/createrunninglock_fuzzer/BUILD.gn b/test/fuzztest/createrunninglock_fuzzer/BUILD.gn index 543f1aa74d714da005d850f7b1c704d1498d1545..65d75855aca2ca580b55330337538c1e805348ba 100644 --- a/test/fuzztest/createrunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/createrunninglock_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("CreateRunningLockFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn b/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn index d8e1b31469ab409a862423a5b345a6710d15ebfe..2809e41bfa5767cd496854b026eaf46fe2f0b2a9 100644 --- a/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn +++ b/test/fuzztest/forcesuspenddevice_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("ForceSuspendDeviceFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn b/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn index efcf52b463545f25d0ebeac49cd7bf1e199b10ab..42820cd27e5554e2daf1f79beca6cd304ebc02bd 100644 --- a/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn +++ b/test/fuzztest/getsetdevicemode_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("GetSetDeviceModeFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/getstate_fuzzer/BUILD.gn b/test/fuzztest/getstate_fuzzer/BUILD.gn index de533d0cf31d091bf4e3a56329ee1dd5187caef2..323432bd3f7f117b98b2553821f37391f4811221 100644 --- a/test/fuzztest/getstate_fuzzer/BUILD.gn +++ b/test/fuzztest/getstate_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("GetStateFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn b/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn index c8f56ea09d947ef650f6e9c1525657a7dd8621b8..aa5057fe6d5140a3d46b66a2ad1d57fdc47e792b 100644 --- a/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn +++ b/test/fuzztest/isrunninglocktypesupported_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("IsRunningLockTypeSupportedFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/isscreenon_fuzzer/BUILD.gn b/test/fuzztest/isscreenon_fuzzer/BUILD.gn index 11c8fc9c9b2d188e96b40419a3c3747fe31c7d3e..9568f5682f8a4f8dcd2b870bb854234e17e48ffe 100644 --- a/test/fuzztest/isscreenon_fuzzer/BUILD.gn +++ b/test/fuzztest/isscreenon_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("IsScreenOnFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/isstandby_fuzzer/BUILD.gn b/test/fuzztest/isstandby_fuzzer/BUILD.gn index 8194b7a63dbfedb32904ffbab038db8da875c7be..e16776f9acd66afa171e7ada68c120718e3555f3 100644 --- a/test/fuzztest/isstandby_fuzzer/BUILD.gn +++ b/test/fuzztest/isstandby_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("IsStandbyFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn b/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn index c05d16a445398a9d0a11194476d2d86b13addca5..a6b60a2cbbffa3a330248d66da5b60e4bece5feb 100644 --- a/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn +++ b/test/fuzztest/lockunlockisused_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("LockUnLockIsUsedFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn b/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn index 9830d4f5a4c0ae04dddbc76d54180a1406d4102a..f72c9d3ee20d69d37c4a06b462d171b06b86f42e 100644 --- a/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn +++ b/test/fuzztest/overridescreenofftime_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("OverrideScreenOffTimeFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/powermodecallback_fuzzer/BUILD.gn b/test/fuzztest/powermodecallback_fuzzer/BUILD.gn index e9a3334c73b9fb4065f834a8f1d5c115ee496b5d..5b4d102c9a204a3bbe332476c2dc4b6efd3fb41d 100644 --- a/test/fuzztest/powermodecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/powermodecallback_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("PowerModeCallbackFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn b/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn index 2a6de804cf03c6bbbf76dd0d2e3a2ca1d3213163..0fd7b08e1c24d7c0627101ba30590e16d1c6ffad 100644 --- a/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn +++ b/test/fuzztest/powerstatecallback_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("PowerStateCallbackFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn b/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn index 56eb2f9e4d282451aa8e4d46c0a319c706891ef1..1a2c6fcf9039062b2fae63643cbe85bd0a3b30b6 100644 --- a/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/proxyrunninglock_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("ProxyRunningLocksFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn b/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn index 67694cdabcd82cb1df17b7f5452246b5d8b0db09..6b1a05abb91559f3ea20ccb7e2b2283e89d56212 100644 --- a/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn +++ b/test/fuzztest/proxyrunninglocks_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("ProxyRunningLockFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn b/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn index a658e8ad40098841af4675530723b696c13e32f7..3d5f37a719a820a863ab6db9aeb41ab9a9e96da8 100644 --- a/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn +++ b/test/fuzztest/queryrunninglocklists_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("QueryRunningLockListsFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/rebootdevice_fuzzer/BUILD.gn b/test/fuzztest/rebootdevice_fuzzer/BUILD.gn index 1242d52ee97d7e96e6c5126b1dbd9f5b1fd460d8..144cb41da26d8cdf27225a6d9a4565f3322a3757 100644 --- a/test/fuzztest/rebootdevice_fuzzer/BUILD.gn +++ b/test/fuzztest/rebootdevice_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("RebootDeviceFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/refreshactivity_fuzzer/BUILD.gn b/test/fuzztest/refreshactivity_fuzzer/BUILD.gn index 2607925366f32c8d907d3c843894d972bbf24bb2..3d189638734d1084191c9511f23c53731ce52b68 100644 --- a/test/fuzztest/refreshactivity_fuzzer/BUILD.gn +++ b/test/fuzztest/refreshactivity_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("RefreshActivityFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn b/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn index dbd3a5b9d1966bf4826fcb781369ae1c58da8313..9f567bd9238e448f3e0f7f35a347863bb9efadc6 100644 --- a/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn +++ b/test/fuzztest/releaserunninglock_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("ReleaseRunningLockFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn b/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn index 798614fff53f27ba8d16f8a419da46f64ec8fae1..c148db295100ba29acf8f347310b9a6ba766dd7e 100644 --- a/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn +++ b/test/fuzztest/resetrunninglocks_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("ResetRunningLocksFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn b/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn index a58247bed386790d556b1790da96d994532c366f..d5dc91630807d8f3a1f77f983f395bd98470e467 100644 --- a/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn +++ b/test/fuzztest/setdisplaysuspend_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("SetDisplaySuspendFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/shelldump_fuzzer/BUILD.gn b/test/fuzztest/shelldump_fuzzer/BUILD.gn index 380d8412422a855d8f9ec3652ebc95248c66a339..1f13bac20bfbf9890941db0483785fe710998e6f 100644 --- a/test/fuzztest/shelldump_fuzzer/BUILD.gn +++ b/test/fuzztest/shelldump_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("ShellDumpFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn b/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn index 85fbaa0c7cdf308c8be62a950e58e456687dfa4b..b3688732f965004d81bbed78387581b7cef808e5 100644 --- a/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn +++ b/test/fuzztest/shutdowndevice_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("ShutDownDeviceFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/suspenddevice_fuzzer/BUILD.gn b/test/fuzztest/suspenddevice_fuzzer/BUILD.gn index 16bb8bf509866b04315ec67fb4589967ab127504..f3d2ce7994389551cbaa2e6be25a75b91238ddd4 100644 --- a/test/fuzztest/suspenddevice_fuzzer/BUILD.gn +++ b/test/fuzztest/suspenddevice_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("SuspendDeviceFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn b/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn index a663520a2d9d8346dad6cdbbd4692a34c743adcf..21dadfa6b5d409daea0e80f20661b506134ce505 100644 --- a/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/syncshutdowncallback_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("SyncShutdownCallbackFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn b/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn index 6d89bf6eb118eb7bf66c310e4a9c6b3338280d66..23fed976e0fd6f319212b86f9c7122206fc2434d 100644 --- a/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn +++ b/test/fuzztest/takeovershutdowncallback_fuzzer/BUILD.gn @@ -63,6 +63,9 @@ ohos_fuzztest("TakeOverShutdownCallbackFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn b/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn index f4636e8686c1f362835187ca9bde61f5d78855d7..86f20f929b19256dd69934b9f8fcf5e211b88c0b 100644 --- a/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn +++ b/test/fuzztest/wakeupdevice_fuzzer/BUILD.gn @@ -62,6 +62,9 @@ ohos_fuzztest("WakeupDeviceFuzzTest") { "input:libmmi-client", "ipc:ipc_core", "power_manager:power_ffrt", - "sensor:sensor_interface_native", ] + + if (has_sensors_sensor_part) { + external_deps += [ "sensor:sensor_interface_native" ] + } } diff --git a/test/systemtest/BUILD.gn b/test/systemtest/BUILD.gn index 26e851a080d5615cc97aa7cc358eb85a7a76e7d3..b7232029d6a1364b3978f2a193b681e309fea917 100644 --- a/test/systemtest/BUILD.gn +++ b/test/systemtest/BUILD.gn @@ -48,9 +48,12 @@ deps_ex = [ "power_manager:power_ffrt", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "sensor:sensor_interface_native", ] +if (has_sensors_sensor_part) { + deps_ex += [ "sensor:sensor_interface_native" ] +} + ##############################systemtest########################################## ohos_systemtest("test_power_mgr_mock_system") { diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 3243f3a4cf2870dce67cbbd111aad496d158badf..71be4715e41a532ab350520af4a344db902fa837 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -66,9 +66,12 @@ deps_ex = [ "power_manager:power_ffrt", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "sensor:sensor_interface_native", ] +if (has_sensors_sensor_part) { + deps_ex += [ "sensor:sensor_interface_native" ] +} + defs = [ "POWER_GTEST" ] ##############################client_test########################################## @@ -240,7 +243,7 @@ ohos_unittest("test_power_mgr_service_death") { "${powermgr_utils_path}:coverage_flags", ] - defines = [ "POWERMGR_SERVICE_DEATH_UT" ] + defines += [ "POWERMGR_SERVICE_DEATH_UT" ] deps = [ "${powermgr_inner_api}:powermgr_client", @@ -539,7 +542,7 @@ ohos_unittest("test_mock_proxy") { "${powermgr_utils_path}:coverage_flags", ] - defines = [ + defines += [ "MOCK_WRITE_INTERFACE_TOKEN_RETURN_TRUE", "MOCK_MOCK_READSTRING_DESCRIPTIR", ] @@ -556,7 +559,7 @@ ohos_unittest("test_mock_proxy") { ohos_unittest("power_state_machine_native_test") { module_out_path = module_output_path - defines = defs + defines += defs sources = [ "src/native_power_state_machine_test.cpp" ] @@ -578,7 +581,7 @@ ohos_unittest("power_state_machine_native_test") { ohos_unittest("test_running_lock_native") { module_out_path = module_output_path - defines = defs + defines += defs sources = [ "src/running_lock_native_test.cpp" ] @@ -600,7 +603,7 @@ ohos_unittest("test_running_lock_native") { ohos_unittest("test_power_mgr_service_native") { module_out_path = module_output_path - defines = defs + defines += defs sanitize = { cfi = true @@ -632,7 +635,7 @@ ohos_unittest("test_power_mgr_service_native") { ohos_unittest("test_device_state_action_native") { module_out_path = module_output_path - defines = defs + defines += defs sources = [ "src/device_state_action_native_test.cpp" ] @@ -676,7 +679,7 @@ ohos_unittest("test_power_mgr_dump") { ohos_unittest("test_power_mgr_client_native") { module_out_path = module_output_path - defines = defs + defines += defs sources = [ "src/power_mgr_client_native_test.cpp" ] @@ -699,7 +702,7 @@ ohos_unittest("test_power_mgr_client_native") { ohos_unittest("power_mode_module_native_test") { module_out_path = module_output_path - defines = defs + defines += defs sources = [ "src/power_mode_module_native_test.cpp" ] configs = [ "${powermgr_utils_path}:utils_config", @@ -717,7 +720,7 @@ ohos_unittest("power_mode_module_native_test") { ohos_unittest("test_running_lock_hub_native") { module_out_path = module_output_path - defines = defs + defines += defs include_dirs = [ "${powermgr_service_path}/native/src/actions/default/suspend" ] @@ -785,7 +788,7 @@ ohos_unittest("test_power_suspend_parse") { include_dirs = [ "${powermgr_service_path}/native/src/setting/" ] - defines = [ "THERMAL_GTEST" ] + defines += [ "THERMAL_GTEST" ] deps = [ "${powermgr_inner_api}:powermgr_client", @@ -822,7 +825,7 @@ ohos_unittest("test_power_wakeup_parse") { include_dirs = [ "${powermgr_service_path}/native/src/setting/" ] - defines = [ "THERMAL_GTEST" ] + defines += [ "THERMAL_GTEST" ] deps = [ "${powermgr_inner_api}:powermgr_client", @@ -860,7 +863,7 @@ ohos_unittest("test_power_suspend") { include_dirs = [ "${powermgr_service_path}/native/src/setting/" ] - defines = [ "POWERMGR_GTEST" ] + defines += [ "POWERMGR_GTEST" ] deps = [ "${powermgr_inner_api}:powermgr_client", @@ -900,7 +903,7 @@ ohos_unittest("test_power_wakeup") { include_dirs = [ "${powermgr_service_path}/native/src/setting/" ] - defines = [ "POWERMGR_GTEST" ] + defines += [ "POWERMGR_GTEST" ] deps = [ "${powermgr_inner_api}:powermgr_client", @@ -959,7 +962,7 @@ ohos_unittest("test_power_getcontroller_mock") { include_dirs = [ "${powermgr_service_path}/native/src/setting/" ] - defines = [ "POWERMGR_GTEST" ] + defines += [ "POWERMGR_GTEST" ] deps = [ "${powermgr_inner_api}:powermgr_client", @@ -999,7 +1002,7 @@ ohos_unittest("test_power_screenon_mock") { include_dirs = [ "${powermgr_service_path}/native/src/setting/" ] - defines = [ "POWERMGR_GTEST" ] + defines += [ "POWERMGR_GTEST" ] deps = [ "${powermgr_inner_api}:powermgr_client", diff --git a/test/unittest/include/power_mgr_service_native_test.h b/test/unittest/include/power_mgr_service_native_test.h index bc792415d54c40edfe06cebeffaf5d0630af73e2..d01f85cd6db20eda5ea3ce4ef8a65cb481b2187c 100644 --- a/test/unittest/include/power_mgr_service_native_test.h +++ b/test/unittest/include/power_mgr_service_native_test.h @@ -25,7 +25,9 @@ #include "mock_power_action.h" #include "mock_state_action.h" #include "power_state_callback_stub.h" +#ifdef HAS_SENSORS_SENSOR_PART #include "sensor_agent.h" +#endif #include namespace OHOS { diff --git a/test/unittest/include/running_lock_native_test.h b/test/unittest/include/running_lock_native_test.h index cb6273ff9031ff2939850687812d36e823ee82ac..7d1b14d0ef19ea327e8c9c1531ecf1989575647a 100644 --- a/test/unittest/include/running_lock_native_test.h +++ b/test/unittest/include/running_lock_native_test.h @@ -30,7 +30,9 @@ #include "power_mgr_client.h" #include "power_mgr_service.h" #include "running_lock_action.h" +#ifdef HAS_SENSORS_SENSOR_PART #include "sensor_agent.h" +#endif #include "power_mgr_factory.h" namespace OHOS { diff --git a/test/unittest/src/running_lock_native_test.cpp b/test/unittest/src/running_lock_native_test.cpp index 77cae4cb888343a5ec4003f43f4b4cfb71fe92c6..893bf2de8b5df590ed1bf2270af66772223b2902 100644 --- a/test/unittest/src/running_lock_native_test.cpp +++ b/test/unittest/src/running_lock_native_test.cpp @@ -261,6 +261,7 @@ HWTEST_F (RunningLockNativeTest, RunningLockNative006, TestSize.Level0) type = static_cast(UNTYPE); runningLockMgr->NotifyRunningLockChanged(remoteObj, lockInner, type); +#ifdef HAS_SENSORS_SENSOR_PART auto runningLockMgrController = std::make_shared(); SensorEvent sensorEvent; ProximityData data; @@ -278,6 +279,7 @@ HWTEST_F (RunningLockNativeTest, RunningLockNative006, TestSize.Level0) runningLockMgrController->support_ = true; runningLockMgrController->Enable(); runningLockMgrController->Disable(); +#endif EXPECT_FALSE(runningLockMgr->ReleaseLock(remoteObj)); POWER_HILOGI(LABEL_TEST, "RunningLockNative006 end"); diff --git a/test/unittest/src/servicetest/BUILD.gn b/test/unittest/src/servicetest/BUILD.gn index ef304f38a1dd1e4d75ea7276849286d0a5c986b3..2cb343b12f44b4f74a7d7e3c03e8b072d19d1382 100644 --- a/test/unittest/src/servicetest/BUILD.gn +++ b/test/unittest/src/servicetest/BUILD.gn @@ -59,9 +59,12 @@ deps_ex = [ "power_manager:power_ffrt", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "sensor:sensor_interface_native", ] +if (has_sensors_sensor_part) { + deps_ex += [ "sensor:sensor_interface_native" ] +} + ##############################native_test########################################## ohos_unittest("powermgr_native_test") { module_out_path = module_output_path @@ -106,7 +109,7 @@ ohos_unittest("powermgr_native_mock_parcel_test") { "${powermgr_utils_path}:coverage_flags", ] - defines = [ "MOCK_WRITE_INTERFACE_TOKEN_RETURN_TRUE" ] + defines += [ "MOCK_WRITE_INTERFACE_TOKEN_RETURN_TRUE" ] deps = [ "${powermgr_inner_api}:powermgr_client", diff --git a/utils/shell/BUILD.gn b/utils/shell/BUILD.gn index 14b658fdb48707f87d128c28ba9ac13318a05f1b..834c1445e409e2b175e12402d66afac67df5b52b 100644 --- a/utils/shell/BUILD.gn +++ b/utils/shell/BUILD.gn @@ -46,7 +46,7 @@ ohos_executable("power-shell") { } if (build_variant == "user") { - defines = [ "POWER_SHELL_USER" ] + defines += [ "POWER_SHELL_USER" ] } install_enable = true diff --git a/utils/vibrator/BUILD.gn b/utils/vibrator/BUILD.gn index 458f42986c34c6035a792aa5c31f7bfccd20c6d7..422a9388445b9478e1aea70429eee23fb93c07e1 100644 --- a/utils/vibrator/BUILD.gn +++ b/utils/vibrator/BUILD.gn @@ -43,7 +43,7 @@ ohos_shared_library("power_vibrator") { ] if (defined(global_parts_info) && defined(global_parts_info.sensors_miscdevice)) { - defines = [ "POWER_VIBRATOR_MODE_ENABLE" ] + defines += [ "POWER_VIBRATOR_MODE_ENABLE" ] external_deps += [ "miscdevice:vibrator_interface_native" ] } subsystem_name = "powermgr"