SF: Adding Idle Timer, to detect when devices are idle.
If SF has not received request for the next vsync in 30ms, the device is
considered idle.
The timeout ms can be set via setprop flag: debug.sf.set_idle_timer_ms
see go/surface-flinger-scheduler for more info.
Test: Adding tests for new class.
Bug: 113612090
Change-Id: I5dae075012f3fef9bb8ed48121367c80dff39de0
diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h
index 15b5bba..0773c05 100644
--- a/services/surfaceflinger/Scheduler/EventThread.h
+++ b/services/surfaceflinger/Scheduler/EventThread.h
@@ -107,13 +107,15 @@
public:
using ResyncWithRateLimitCallback = std::function<void()>;
using InterceptVSyncsCallback = std::function<void(nsecs_t)>;
+ using ResetIdleTimerCallback = std::function<void()>;
// TODO(b/113612090): Once the Scheduler is complete this constructor will become obsolete.
EventThread(VSyncSource* src, ResyncWithRateLimitCallback resyncWithRateLimitCallback,
InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName);
EventThread(std::unique_ptr<VSyncSource> src,
- ResyncWithRateLimitCallback resyncWithRateLimitCallback,
- InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName);
+ const ResyncWithRateLimitCallback& resyncWithRateLimitCallback,
+ const InterceptVSyncsCallback& interceptVSyncsCallback,
+ const ResetIdleTimerCallback& resetIdleTimerCallback, const char* threadName);
~EventThread();
sp<BnDisplayEventConnection> createEventConnection() const override;
@@ -177,6 +179,9 @@
// for debugging
bool mDebugVsyncEnabled GUARDED_BY(mMutex) = false;
+
+ // Callback that resets the idle timer when the next vsync is received.
+ ResetIdleTimerCallback mResetIdleTimer;
};
// ---------------------------------------------------------------------------