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

Commit 16ca297c authored by Kriti Dang's avatar Kriti Dang
Browse files

Correct error handling in getPreferredBootDisplayMode

Bug: 217335654
Test: verified on forrest
Change-Id: I685a2e3b4f80c0898f778a170a30f882f640adb4
parent a27a2108
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -59,9 +59,13 @@ void Display::setConfiguration(const compositionengine::DisplayCreationArgs& arg
    setName(args.name);
    setName(args.name);
    bool isBootModeSupported = getCompositionEngine().getHwComposer().getBootDisplayModeSupport();
    bool isBootModeSupported = getCompositionEngine().getHwComposer().getBootDisplayModeSupport();
    const auto physicalId = PhysicalDisplayId::tryCast(mId);
    const auto physicalId = PhysicalDisplayId::tryCast(mId);
    if (physicalId && isBootModeSupported) {
    if (!physicalId || !isBootModeSupported) {
        mPreferredBootDisplayModeId = static_cast<int32_t>(
        return;
                getCompositionEngine().getHwComposer().getPreferredBootDisplayMode(*physicalId));
    }
    std::optional<hal::HWConfigId> preferredBootModeId =
            getCompositionEngine().getHwComposer().getPreferredBootDisplayMode(*physicalId);
    if (preferredBootModeId.has_value()) {
        mPreferredBootDisplayModeId = static_cast<int32_t>(preferredBootModeId.value());
    }
    }
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -108,7 +108,7 @@ public:
                          hal::VsyncPeriodChangeTimeline*));
                          hal::VsyncPeriodChangeTimeline*));
    MOCK_METHOD2(setBootDisplayMode, status_t(PhysicalDisplayId, hal::HWConfigId));
    MOCK_METHOD2(setBootDisplayMode, status_t(PhysicalDisplayId, hal::HWConfigId));
    MOCK_METHOD1(clearBootDisplayMode, status_t(PhysicalDisplayId));
    MOCK_METHOD1(clearBootDisplayMode, status_t(PhysicalDisplayId));
    MOCK_METHOD1(getPreferredBootDisplayMode, hal::HWConfigId(PhysicalDisplayId));
    MOCK_METHOD1(getPreferredBootDisplayMode, std::optional<hal::HWConfigId>(PhysicalDisplayId));
    MOCK_METHOD0(getBootDisplayModeSupport, bool());
    MOCK_METHOD0(getBootDisplayModeSupport, bool());
    MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
    MOCK_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
    MOCK_METHOD2(getSupportedContentTypes,
    MOCK_METHOD2(getSupportedContentTypes,
+7 −9
Original line number Original line Diff line number Diff line
@@ -772,18 +772,16 @@ status_t HWComposer::clearBootDisplayMode(PhysicalDisplayId displayId) {
    return NO_ERROR;
    return NO_ERROR;
}
}


hal::HWConfigId HWComposer::getPreferredBootDisplayMode(PhysicalDisplayId displayId) {
std::optional<hal::HWConfigId> HWComposer::getPreferredBootDisplayMode(
    RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
        PhysicalDisplayId displayId) {
    hal::HWConfigId displayModeId = -1;
    RETURN_IF_INVALID_DISPLAY(displayId, std::nullopt);
    hal::HWConfigId displayModeId;
    const auto error =
    const auto error =
            mDisplayData[displayId].hwcDisplay->getPreferredBootDisplayConfig(&displayModeId);
            mDisplayData[displayId].hwcDisplay->getPreferredBootDisplayConfig(&displayModeId);
    if (error == hal::Error::UNSUPPORTED) {
    if (error != hal::Error::NONE) {
        RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
        LOG_DISPLAY_ERROR(displayId, to_string(error).c_str());
    }
        return std::nullopt;
    if (error == hal::Error::BAD_PARAMETER) {
        RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
    }
    }
    RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
    return displayModeId;
    return displayModeId;
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -260,7 +260,7 @@ public:
    virtual bool getBootDisplayModeSupport() = 0;
    virtual bool getBootDisplayModeSupport() = 0;
    virtual status_t setBootDisplayMode(PhysicalDisplayId, hal::HWConfigId) = 0;
    virtual status_t setBootDisplayMode(PhysicalDisplayId, hal::HWConfigId) = 0;
    virtual status_t clearBootDisplayMode(PhysicalDisplayId) = 0;
    virtual status_t clearBootDisplayMode(PhysicalDisplayId) = 0;
    virtual hal::HWConfigId getPreferredBootDisplayMode(PhysicalDisplayId) = 0;
    virtual std::optional<hal::HWConfigId> getPreferredBootDisplayMode(PhysicalDisplayId) = 0;
};
};


namespace impl {
namespace impl {
@@ -391,7 +391,7 @@ public:
    bool getBootDisplayModeSupport() override;
    bool getBootDisplayModeSupport() override;
    status_t setBootDisplayMode(PhysicalDisplayId, hal::HWConfigId) override;
    status_t setBootDisplayMode(PhysicalDisplayId, hal::HWConfigId) override;
    status_t clearBootDisplayMode(PhysicalDisplayId) override;
    status_t clearBootDisplayMode(PhysicalDisplayId) override;
    hal::HWConfigId getPreferredBootDisplayMode(PhysicalDisplayId) override;
    std::optional<hal::HWConfigId> getPreferredBootDisplayMode(PhysicalDisplayId) override;


    // for debugging ----------------------------------------------------------
    // for debugging ----------------------------------------------------------
    void dump(std::string& out) const override;
    void dump(std::string& out) const override;