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

Commit 29e7bdfc authored by Dan Stoza's avatar Dan Stoza
Browse files

PowerAdvisor: Wait for boot finished

Adds a call to PowerAdvisor so it can gate calls to
notifyDisplayUpdateImminent until the boot has finished. This prevents
PowerAdvisor from attempting to connect to the Power HAL, which can
delay the boot animation if SF comes up first.

Bug: 152131148
Test: libsurfaceflinger_unittest
Test: libcompositionengine_test
Test: Manual, check that boot is not delayed
Change-Id: Idf59e9bb62a03360925aa06d95a7b4caea36be83
parent e636f3fe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public:
    PowerAdvisor();
    ~PowerAdvisor() override;

    MOCK_METHOD0(onBootFinished, void());
    MOCK_METHOD2(setExpensiveRenderingExpected, void(DisplayId displayId, bool expected));
    MOCK_METHOD0(notifyDisplayUpdateImminent, void());
};
+10 −0
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ PowerAdvisor::PowerAdvisor()
    }
}

void PowerAdvisor::onBootFinished() {
    mBootFinished.store(true);
}

void PowerAdvisor::setExpensiveRenderingExpected(DisplayId displayId, bool expected) {
    if (expected) {
        mExpensiveDisplays.insert(displayId);
@@ -97,6 +101,12 @@ void PowerAdvisor::setExpensiveRenderingExpected(DisplayId displayId, bool expec
}

void PowerAdvisor::notifyDisplayUpdateImminent() {
    // Only start sending this notification once the system has booted so we don't introduce an
    // early-boot dependency on Power HAL
    if (!mBootFinished.load()) {
        return;
    }

    if (mSendUpdateImminent.load()) {
        HalWrapper* const halWrapper = getPowerHal();
        if (halWrapper == nullptr) {
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ class PowerAdvisor {
public:
    virtual ~PowerAdvisor();

    virtual void onBootFinished() = 0;
    virtual void setExpensiveRenderingExpected(DisplayId displayId, bool expected) = 0;
    virtual void notifyDisplayUpdateImminent() = 0;
};
@@ -56,12 +57,14 @@ public:
    PowerAdvisor();
    ~PowerAdvisor() override;

    void onBootFinished() override;
    void setExpensiveRenderingExpected(DisplayId displayId, bool expected) override;
    void notifyDisplayUpdateImminent() override;

private:
    HalWrapper* getPowerHal();

    std::atomic_bool mBootFinished = false;
    bool mReconnectPowerHal = false;

    std::unordered_set<DisplayId> mExpensiveDisplays;
+1 −0
Original line number Diff line number Diff line
@@ -567,6 +567,7 @@ void SurfaceFlinger::bootFinished()

    postMessageAsync(new LambdaMessage([this]() NO_THREAD_SAFETY_ANALYSIS {
        readPersistentProperties();
        mPowerAdvisor.onBootFinished();
        mBootStage = BootStage::FINISHED;

        if (property_get_bool("sf.debug.show_refresh_rate_overlay", false)) {
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public:
    PowerAdvisor();
    ~PowerAdvisor() override;

    MOCK_METHOD0(onBootFinished, void());
    MOCK_METHOD2(setExpensiveRenderingExpected, void(DisplayId displayId, bool expected));
    MOCK_METHOD0(notifyDisplayUpdateImminent, void());
};