SF: Clean up Scheduler
Remove dynamic allocation for Scheduler::{Connection,ConnectionHandle},
as well as ref-counting for the latter. Also, remove dead code and make
members private.
Bug: 130554049
Test: libsurfaceflinger_unittest
Change-Id: Ibb9dc8d4cb66451a4172c852a36032bbc0a54411
diff --git a/services/surfaceflinger/tests/unittests/TestableScheduler.h b/services/surfaceflinger/tests/unittests/TestableScheduler.h
index 5157cc4..780b608 100644
--- a/services/surfaceflinger/tests/unittests/TestableScheduler.h
+++ b/services/surfaceflinger/tests/unittests/TestableScheduler.h
@@ -19,6 +19,7 @@
#include <gmock/gmock.h>
#include <gui/ISurfaceComposer.h>
+#include "Scheduler/DispSync.h"
#include "Scheduler/EventThread.h"
#include "Scheduler/Scheduler.h"
@@ -26,24 +27,17 @@
class TestableScheduler : public Scheduler {
public:
+ explicit TestableScheduler(const scheduler::RefreshRateConfigs& configs)
+ : Scheduler([](bool) {}, configs) {}
+
TestableScheduler(std::unique_ptr<DispSync> primaryDispSync,
std::unique_ptr<EventControlThread> eventControlThread,
const scheduler::RefreshRateConfigs& configs)
: Scheduler(std::move(primaryDispSync), std::move(eventControlThread), configs) {}
- // Creates EventThreadConnection with the given eventThread. Creates Scheduler::Connection
- // and adds it to the list of connectins. Returns the ConnectionHandle for the
- // Scheduler::Connection. This allows plugging in mock::EventThread.
- sp<Scheduler::ConnectionHandle> addConnection(std::unique_ptr<EventThread> eventThread) {
- sp<EventThreadConnection> eventThreadConnection =
- new EventThreadConnection(eventThread.get(), ResyncCallback(),
- ISurfaceComposer::eConfigChangedSuppress);
- const int64_t id = sNextId++;
- mConnections.emplace(id,
- std::make_unique<Scheduler::Connection>(new ConnectionHandle(id),
- eventThreadConnection,
- std::move(eventThread)));
- return mConnections[id]->handle;
+ // Used to inject mock event thread.
+ ConnectionHandle createConnection(std::unique_ptr<EventThread> eventThread) {
+ return Scheduler::createConnection(std::move(eventThread), ResyncCallback());
}
/* ------------------------------------------------------------------------