diff --git a/health/2.0/default/healthd_common_adapter.cpp b/health/2.0/default/healthd_common_adapter.cpp index 8fc689d50c..0b5d869496 100644 --- a/health/2.0/default/healthd_common_adapter.cpp +++ b/health/2.0/default/healthd_common_adapter.cpp @@ -49,11 +49,14 @@ class HealthLoopAdapter : public HealthLoop { static std::unique_ptr health_loop; int healthd_register_event(int fd, void (*handler)(uint32_t), EventWakeup wakeup) { + if (!health_loop) return -1; + auto wrapped_handler = [handler](auto*, uint32_t epevents) { handler(epevents); }; return health_loop->RegisterEvent(fd, wrapped_handler, wakeup); } void healthd_battery_update_internal(bool charger_online) { + if (!health_loop) return; health_loop->AdjustWakealarmPeriods(charger_online); }