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

Commit a109bb2e authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Fix error handling for getDisplayVsyncPeriod

HWC errors were being converted to a status_t of NO_ERROR.

Bug: 241285876
Test: presubmit
Change-Id: I0fcfa426c795adf55a920729bc613a0cd140e87c
parent d940a013
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ public:
    MOCK_CONST_METHOD0(isUsingVrComposer, bool());
    MOCK_CONST_METHOD1(getDisplayConnectionType, ui::DisplayConnectionType(PhysicalDisplayId));
    MOCK_CONST_METHOD1(isVsyncPeriodSwitchSupported, bool(PhysicalDisplayId));
    MOCK_CONST_METHOD2(getDisplayVsyncPeriod, status_t(PhysicalDisplayId, nsecs_t*));
    MOCK_CONST_METHOD1(getDisplayVsyncPeriod, ftl::Expected<nsecs_t, status_t>(PhysicalDisplayId));
    MOCK_METHOD4(setActiveModeWithConstraints,
                 status_t(PhysicalDisplayId, hal::HWConfigId,
                          const hal::VsyncPeriodChangeConstraints&,
+2 −4
Original line number Diff line number Diff line
@@ -239,10 +239,8 @@ nsecs_t DisplayDevice::getVsyncPeriodFromHWC() const {
        return 0;
    }

    nsecs_t vsyncPeriod;
    const auto status = mHwComposer.getDisplayVsyncPeriod(physicalId, &vsyncPeriod);
    if (status == NO_ERROR) {
        return vsyncPeriod;
    if (const auto vsyncPeriodOpt = mHwComposer.getDisplayVsyncPeriod(physicalId).value_opt()) {
        return *vsyncPeriodOpt;
    }

    return refreshRateSelector().getActiveMode().modePtr->getVsyncRate().getPeriodNsecs();
+8 −8
Original line number Diff line number Diff line
@@ -380,20 +380,20 @@ bool HWComposer::isVsyncPeriodSwitchSupported(PhysicalDisplayId displayId) const
    return mDisplayData.at(displayId).hwcDisplay->isVsyncPeriodSwitchSupported();
}

status_t HWComposer::getDisplayVsyncPeriod(PhysicalDisplayId displayId,
                                           nsecs_t* outVsyncPeriod) const {
    RETURN_IF_INVALID_DISPLAY(displayId, 0);
ftl::Expected<nsecs_t, status_t> HWComposer::getDisplayVsyncPeriod(
        PhysicalDisplayId displayId) const {
    RETURN_IF_INVALID_DISPLAY(displayId, ftl::Unexpected(BAD_INDEX));

    if (!isVsyncPeriodSwitchSupported(displayId)) {
        return INVALID_OPERATION;
        return ftl::Unexpected(INVALID_OPERATION);
    }

    const auto hwcId = *fromPhysicalDisplayId(displayId);
    Hwc2::VsyncPeriodNanos vsyncPeriodNanos = 0;
    auto error =
    const auto error =
            static_cast<hal::Error>(mComposer->getDisplayVsyncPeriod(hwcId, &vsyncPeriodNanos));
    RETURN_IF_HWC_ERROR(error, displayId, 0);
    *outVsyncPeriod = static_cast<nsecs_t>(vsyncPeriodNanos);
    return NO_ERROR;
    RETURN_IF_HWC_ERROR(error, displayId, ftl::Unexpected(UNKNOWN_ERROR));
    return static_cast<nsecs_t>(vsyncPeriodNanos);
}

std::vector<ui::ColorMode> HWComposer::getColorModes(PhysicalDisplayId displayId) const {
+2 −4
Original line number Diff line number Diff line
@@ -248,8 +248,7 @@ public:
    // Composer 2.4
    virtual ui::DisplayConnectionType getDisplayConnectionType(PhysicalDisplayId) const = 0;
    virtual bool isVsyncPeriodSwitchSupported(PhysicalDisplayId) const = 0;
    virtual status_t getDisplayVsyncPeriod(PhysicalDisplayId displayId,
                                           nsecs_t* outVsyncPeriod) const = 0;
    virtual ftl::Expected<nsecs_t, status_t> getDisplayVsyncPeriod(PhysicalDisplayId) const = 0;
    virtual status_t setActiveModeWithConstraints(PhysicalDisplayId, hal::HWConfigId,
                                                  const hal::VsyncPeriodChangeConstraints&,
                                                  hal::VsyncPeriodChangeTimeline* outTimeline) = 0;
@@ -436,8 +435,7 @@ public:
    // Composer 2.4
    ui::DisplayConnectionType getDisplayConnectionType(PhysicalDisplayId) const override;
    bool isVsyncPeriodSwitchSupported(PhysicalDisplayId) const override;
    status_t getDisplayVsyncPeriod(PhysicalDisplayId displayId,
                                   nsecs_t* outVsyncPeriod) const override;
    ftl::Expected<nsecs_t, status_t> getDisplayVsyncPeriod(PhysicalDisplayId) const override;
    status_t setActiveModeWithConstraints(PhysicalDisplayId, hal::HWConfigId,
                                          const hal::VsyncPeriodChangeConstraints&,
                                          hal::VsyncPeriodChangeTimeline* outTimeline) override;
+1 −8
Original line number Diff line number Diff line
@@ -143,7 +143,6 @@ private:
    void invokeComposerHal2_2(Hwc2::AidlComposer*, Display, Hwc2::V2_4::hal::Layer);
    void invokeComposerHal2_3(Hwc2::AidlComposer*, Display, Hwc2::V2_4::hal::Layer);
    void invokeComposerHal2_4(Hwc2::AidlComposer*, Display, Hwc2::V2_4::hal::Layer);
    void getDisplayVsyncPeriod();
    void setActiveModeWithConstraints();
    void getDisplayIdentificationData();
    void dumpHwc();
@@ -202,11 +201,6 @@ Display DisplayHardwareFuzzer::createVirtualDisplay(Hwc2::AidlComposer* composer
    return display;
}

void DisplayHardwareFuzzer::getDisplayVsyncPeriod() {
    nsecs_t outVsyncPeriod;
    mHwc.getDisplayVsyncPeriod(mPhysicalDisplayId, &outVsyncPeriod);
}

void DisplayHardwareFuzzer::setActiveModeWithConstraints() {
    hal::VsyncPeriodChangeTimeline outTimeline;
    mHwc.setActiveModeWithConstraints(mPhysicalDisplayId, kActiveConfig, {} /*constraints*/,
@@ -617,8 +611,7 @@ void DisplayHardwareFuzzer::invokeComposer() {

    mHwc.getDisplayConnectionType(mPhysicalDisplayId);
    mHwc.isVsyncPeriodSwitchSupported(mPhysicalDisplayId);

    getDisplayVsyncPeriod();
    mHwc.getDisplayVsyncPeriod(mPhysicalDisplayId);

    setActiveModeWithConstraints();