Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66c40c4d authored by Leon Scroggins's avatar Leon Scroggins Committed by Android (Google) Code Review
Browse files

Merge "Scheduler: Prevent removing the last display"

parents 33476239 da21f422
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -127,6 +127,11 @@ void Scheduler::unregisterDisplay(PhysicalDisplayId displayId) {
    std::scoped_lock lock(mDisplayLock);
    mRefreshRateSelectors.erase(displayId);

    // Do not allow removing the final display. Code in the scheduler expects
    // there to be at least one display. (This may be relaxed in the future with
    // headless virtual display.)
    LOG_ALWAYS_FATAL_IF(mRefreshRateSelectors.empty(), "Cannot unregister all displays!");

    promoteLeaderDisplay();
}

+0 −3
Original line number Diff line number Diff line
@@ -301,9 +301,6 @@ TEST_F(SchedulerTest, chooseDisplayModesSingleDisplay) {
    choice = modeChoices.get(kDisplayId1);
    ASSERT_TRUE(choice);
    EXPECT_EQ(choice->get(), DisplayModeChoice({120_Hz, kDisplay1Mode120}, globalSignals));

    mScheduler->unregisterDisplay(kDisplayId1);
    EXPECT_FALSE(mScheduler->hasRefreshRateSelectors());
}

TEST_F(SchedulerTest, chooseDisplayModesMultipleDisplays) {
+0 −2
Original line number Diff line number Diff line
@@ -79,8 +79,6 @@ public:
        return mRefreshRateSelectors;
    }

    bool hasRefreshRateSelectors() const { return !refreshRateSelectors().empty(); }

    void registerDisplay(PhysicalDisplayId displayId, RefreshRateSelectorPtr selectorPtr) {
        ftl::FakeGuard guard(kMainThreadContext);
        Scheduler::registerDisplay(displayId, std::move(selectorPtr));