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

Commit fe423e31 authored by Kriti Dang's avatar Kriti Dang Committed by Android (Google) Code Review
Browse files

Merge "Correct error handling in getPreferredBootDisplayMode"

parents 9f9dccb2 16ca297c
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -59,9 +59,13 @@ void Display::setConfiguration(const compositionengine::DisplayCreationArgs& arg
    setName(args.name);
    bool isBootModeSupported = getCompositionEngine().getHwComposer().getBootDisplayModeSupport();
    const auto physicalId = PhysicalDisplayId::tryCast(mId);
    if (physicalId && isBootModeSupported) {
        mPreferredBootDisplayModeId = static_cast<int32_t>(
                getCompositionEngine().getHwComposer().getPreferredBootDisplayMode(*physicalId));
    if (!physicalId || !isBootModeSupported) {
        return;
    }
    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 Diff line number Diff line
@@ -108,7 +108,7 @@ public:
                          hal::VsyncPeriodChangeTimeline*));
    MOCK_METHOD2(setBootDisplayMode, status_t(PhysicalDisplayId, hal::HWConfigId));
    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_METHOD2(setAutoLowLatencyMode, status_t(PhysicalDisplayId, bool));
    MOCK_METHOD2(getSupportedContentTypes,
+7 −9
Original line number Diff line number Diff line
@@ -772,18 +772,16 @@ status_t HWComposer::clearBootDisplayMode(PhysicalDisplayId displayId) {
    return NO_ERROR;
}

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

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

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

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