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

Commit 0874d2b9 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Checking nullptr for HWC layer.

There were several places where we didn't check nullptr when accessing HWC
layer, which results in function call on nullptr when external display was
disconnected. This patch makes sure we check HWC layer before calling functions
on it.

BUG: 80325674
Test: Build, flash, boot
Change-Id: I302ad4eeea5c196daadcdccb596dac60b02d3845
Merged-In: I302ad4eeea5c196daadcdccb596dac60b02d3845
parent 2a1310d0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -622,6 +622,9 @@ void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice)
    const auto& viewport = displayDevice->getViewport();
    Region visible = tr.transform(visibleRegion.intersect(viewport));
    auto hwcId = displayDevice->getHwcDisplayId();
    if (!hasHwcLayer(hwcId)) {
        return;
    }
    auto& hwcInfo = getBE().mHwcLayers[hwcId];
    auto& hwcLayer = hwcInfo.layer;
    auto error = hwcLayer->setVisibleRegion(visible);
+3 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@ void ColorLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
    const auto& viewport = displayDevice->getViewport();
    Region visible = tr.transform(visibleRegion.intersect(viewport));
    auto hwcId = displayDevice->getHwcDisplayId();
    if (!hasHwcLayer(hwcId)) {
        return;
    }
    auto& hwcInfo = getBE().mHwcLayers[hwcId];
    auto& hwcLayer = hwcInfo.layer;
    auto error = hwcLayer->setVisibleRegion(visible);
+6 −0
Original line number Diff line number Diff line
@@ -486,6 +486,9 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z)
{
    const auto hwcId = displayDevice->getHwcDisplayId();
    if (!hasHwcLayer(hwcId)) {
        return;
    }
    auto& hwcInfo = getBE().mHwcLayers[hwcId];

    // enable this layer
@@ -1977,6 +1980,9 @@ void Layer::writeToProto(LayerProto* layerInfo, LayerVector::StateSet stateSet)
}

void Layer::writeToProto(LayerProto* layerInfo, int32_t hwcId) {
    if (!hasHwcLayer(hwcId)) {
        return;
    }
    writeToProto(layerInfo, LayerVector::StateSet::Drawing);

    const auto& hwcInfo = getBE().mHwcLayers.at(hwcId);