diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index ce1a9135a..76ca26097 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -64,8 +64,8 @@ AppsContainer::AppsContainer() : #elif EPSILON_BOOT_PROMPT == EPSILON_UPDATE_PROMPT m_promptController(sPromptMessages, sPromptColors, 6), #endif - m_batteryTimer(BatteryTimer(this)), - m_suspendTimer(SuspendTimer(this)), + m_batteryTimer(), + m_suspendTimer(), m_backlightDimmingTimer(), m_homeSnapshot(), m_onBoardingSnapshot(), diff --git a/apps/battery_timer.cpp b/apps/battery_timer.cpp index ced5c1896..db53d7c90 100644 --- a/apps/battery_timer.cpp +++ b/apps/battery_timer.cpp @@ -1,16 +1,16 @@ #include "battery_timer.h" #include "apps_container.h" -BatteryTimer::BatteryTimer(AppsContainer * container) : - Timer(1), - m_container(container) +BatteryTimer::BatteryTimer() : + Timer(1) { } bool BatteryTimer::fire() { - bool needRedrawing = m_container->updateBatteryState(); + AppsContainer * container = AppsContainer::sharedAppsContainer(); + bool needRedrawing = container->updateBatteryState(); if (Ion::Battery::level() == Ion::Battery::Charge::EMPTY) { - m_container->shutdownDueToLowBattery(); + container->shutdownDueToLowBattery(); } return needRedrawing; } diff --git a/apps/battery_timer.h b/apps/battery_timer.h index ccc7d0c46..90ad16c11 100644 --- a/apps/battery_timer.h +++ b/apps/battery_timer.h @@ -3,14 +3,11 @@ #include -class AppsContainer; - class BatteryTimer : public Timer { public: - BatteryTimer(AppsContainer * container); + BatteryTimer(); private: bool fire() override; - AppsContainer * m_container; }; #endif diff --git a/apps/suspend_timer.cpp b/apps/suspend_timer.cpp index 4984be1cf..34562d819 100644 --- a/apps/suspend_timer.cpp +++ b/apps/suspend_timer.cpp @@ -1,16 +1,16 @@ #include "suspend_timer.h" #include "apps_container.h" -SuspendTimer::SuspendTimer(AppsContainer * container) : - Timer(k_idleBeforeSuspendDuration/Timer::TickDuration), - m_container(container) +SuspendTimer::SuspendTimer() : + Timer(k_idleBeforeSuspendDuration/Timer::TickDuration) { } bool SuspendTimer::fire() { - /* We could just call m_container->suspend(), but we want to notify all + /* We could just call container->suspend(), but we want to notify all * responders in the responder chain that the calculator will be switched off, * so we use an event to switch off the calculator. */ - m_container->dispatchEvent(Ion::Events::OnOff); + AppsContainer * container = AppsContainer::sharedAppsContainer(); + container->dispatchEvent(Ion::Events::OnOff); return false; } diff --git a/apps/suspend_timer.h b/apps/suspend_timer.h index c63c97ad3..0a7b735d6 100644 --- a/apps/suspend_timer.h +++ b/apps/suspend_timer.h @@ -3,15 +3,12 @@ #include -class AppsContainer; - class SuspendTimer : public Timer { public: - SuspendTimer(AppsContainer * container); + SuspendTimer(); private: constexpr static int k_idleBeforeSuspendDuration = 5*60*1000; // In miliseconds bool fire() override; - AppsContainer * m_container; }; #endif