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

Commit f8db0e29 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11672362 from 442b5df4 to 24Q3-release

Change-Id: I98b8c8f4e8c9b012728beab9225dedb22ffe1391
parents 13fff930 442b5df4
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ void ASurfaceTransaction_reparent(ASurfaceTransaction* transaction,
/**
 * Parameter for ASurfaceTransaction_setVisibility().
 */
enum {
enum ASurfaceTransactionVisibility : int8_t {
    ASURFACE_TRANSACTION_VISIBILITY_HIDE = 0,
    ASURFACE_TRANSACTION_VISIBILITY_SHOW = 1,
};
@@ -319,7 +319,8 @@ enum {
 * Available since API level 29.
 */
void ASurfaceTransaction_setVisibility(ASurfaceTransaction* transaction,
                                       ASurfaceControl* surface_control, int8_t visibility)
                                       ASurfaceControl* surface_control,
                                       enum ASurfaceTransactionVisibility visibility)
                                       __INTRODUCED_IN(29);

/**
@@ -362,7 +363,7 @@ void ASurfaceTransaction_setBuffer(ASurfaceTransaction* transaction,
 */
void ASurfaceTransaction_setColor(ASurfaceTransaction* transaction,
                                  ASurfaceControl* surface_control, float r, float g, float b,
                                  float alpha, ADataSpace dataspace)
                                  float alpha, enum ADataSpace dataspace)
                                  __INTRODUCED_IN(29);

/**
@@ -440,7 +441,7 @@ void ASurfaceTransaction_setScale(ASurfaceTransaction* transaction,
/**
 * Parameter for ASurfaceTransaction_setBufferTransparency().
 */
enum {
enum ASurfaceTransactionTransparency : int8_t {
    ASURFACE_TRANSACTION_TRANSPARENCY_TRANSPARENT = 0,
    ASURFACE_TRANSACTION_TRANSPARENCY_TRANSLUCENT = 1,
    ASURFACE_TRANSACTION_TRANSPARENCY_OPAQUE = 2,
@@ -454,7 +455,7 @@ enum {
 */
void ASurfaceTransaction_setBufferTransparency(ASurfaceTransaction* transaction,
                                               ASurfaceControl* surface_control,
                                               int8_t transparency)
                                               enum ASurfaceTransactionTransparency transparency)
                                               __INTRODUCED_IN(29);

/**
@@ -501,7 +502,7 @@ void ASurfaceTransaction_setBufferAlpha(ASurfaceTransaction* transaction,
 * Available since API level 29.
 */
void ASurfaceTransaction_setBufferDataSpace(ASurfaceTransaction* transaction,
                                            ASurfaceControl* surface_control, ADataSpace data_space)
                                            ASurfaceControl* surface_control, enum ADataSpace data_space)
                                            __INTRODUCED_IN(29);

/**
+24 −7
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <binderthreadstateutilstest/1.0/IHidlStuff.h>
#include <gtest/gtest.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/ServiceManagement.h>
#include <hwbinder/IPCThreadState.h>

#include <thread>
@@ -37,6 +38,7 @@ using android::OK;
using android::sp;
using android::String16;
using android::binder::Status;
using android::hardware::isHidlSupported;
using android::hardware::Return;
using binderthreadstateutilstest::V1_0::IHidlStuff;

@@ -67,6 +69,7 @@ std::string id2name(size_t id) {
// complicated calls are possible, but this should do here.

static void callHidl(size_t id, int32_t idx) {
    CHECK_EQ(true, isHidlSupported()) << "We shouldn't be calling HIDL if it's not supported";
    auto stuff = IHidlStuff::getService(id2name(id));
    CHECK(stuff->call(idx).isOk());
}
@@ -174,6 +177,7 @@ TEST(BinderThreadState, DoesntInitializeBinderDriver) {
}

TEST(BindThreadState, RemoteHidlCall) {
    if (!isHidlSupported()) GTEST_SKIP() << "No  HIDL support on device";
    auto stuff = IHidlStuff::getService(id2name(kP1Id));
    ASSERT_NE(nullptr, stuff);
    ASSERT_TRUE(stuff->call(0).isOk());
@@ -186,11 +190,14 @@ TEST(BindThreadState, RemoteAidlCall) {
}

TEST(BindThreadState, RemoteNestedStartHidlCall) {
    if (!isHidlSupported()) GTEST_SKIP() << "No  HIDL support on device";
    auto stuff = IHidlStuff::getService(id2name(kP1Id));
    ASSERT_NE(nullptr, stuff);
    ASSERT_TRUE(stuff->call(100).isOk());
}
TEST(BindThreadState, RemoteNestedStartAidlCall) {
    // this test case is trying ot nest a HIDL call which requires HIDL support
    if (!isHidlSupported()) GTEST_SKIP() << "No  HIDL support on device";
    sp<IAidlStuff> stuff;
    ASSERT_EQ(OK, android::getService<IAidlStuff>(String16(id2name(kP1Id).c_str()), &stuff));
    ASSERT_NE(nullptr, stuff);
@@ -205,11 +212,15 @@ int server(size_t thisId, size_t otherId) {
             defaultServiceManager()->addService(String16(id2name(thisId).c_str()), aidlServer));
    android::ProcessState::self()->startThreadPool();

    if (isHidlSupported()) {
        // HIDL
        android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);
        sp<IHidlStuff> hidlServer = new HidlServer(thisId, otherId);
        CHECK_EQ(OK, hidlServer->registerAsService(id2name(thisId).c_str()));
        android::hardware::joinRpcThreadpool();
    } else {
        android::IPCThreadState::self()->joinThreadPool(true);
    }

    return EXIT_FAILURE;
}
@@ -227,9 +238,15 @@ int main(int argc, char** argv) {
    }

    android::waitForService<IAidlStuff>(String16(id2name(kP1Id).c_str()));
    android::hardware::details::waitForHwService(IHidlStuff::descriptor, id2name(kP1Id).c_str());
    if (isHidlSupported()) {
        android::hardware::details::waitForHwService(IHidlStuff::descriptor,
                                                     id2name(kP1Id).c_str());
    }
    android::waitForService<IAidlStuff>(String16(id2name(kP2Id).c_str()));
    android::hardware::details::waitForHwService(IHidlStuff::descriptor, id2name(kP2Id).c_str());
    if (isHidlSupported()) {
        android::hardware::details::waitForHwService(IHidlStuff::descriptor,
                                                     id2name(kP2Id).c_str());
    }

    return RUN_ALL_TESTS();
}
+0 −1
Original line number Diff line number Diff line
@@ -2443,7 +2443,6 @@ status_t SurfaceComposerClient::createSurfaceChecked(const String8& name, uint32
                                                     const sp<IBinder>& parentHandle,
                                                     LayerMetadata metadata,
                                                     uint32_t* outTransformHint) {
    sp<SurfaceControl> sur;
    status_t err = mStatus;

    if (mStatus == NO_ERROR) {
+6 −21
Original line number Diff line number Diff line
@@ -1265,7 +1265,12 @@ void RenderEngineTest::fillRedBufferWithPremultiplyAlpha() {

void RenderEngineTest::fillBufferWithPremultiplyAlpha() {
    fillRedBufferWithPremultiplyAlpha();
    expectBufferColor(fullscreenRect(), 128, 0, 0, 128);
    // Different backends and GPUs may round 255 * 0.5 = 127.5 differently, but
    // either 127 or 128 are acceptable. Checking both 127 and 128 with a
    // tolerance of 1 allows either 127 or 128 to pass, while preventing 126 or
    // 129 from erroneously passing.
    expectBufferColor(fullscreenRect(), 127, 0, 0, 127, 1);
    expectBufferColor(fullscreenRect(), 128, 0, 0, 128, 1);
}

void RenderEngineTest::fillRedBufferWithoutPremultiplyAlpha() {
@@ -1687,11 +1692,6 @@ TEST_P(RenderEngineTest, drawLayers_fillBufferColorTransform_sourceDataspace) {
}

TEST_P(RenderEngineTest, drawLayers_fillBufferColorTransform_outputDataspace) {
    // TODO: b/331445583 - Fix in Graphite and re-enable.
    if (GetParam()->skiaBackend() == renderengine::RenderEngine::SkiaBackend::GRAPHITE) {
        GTEST_SKIP();
    }

    const auto& renderEngineFactory = GetParam();
    // skip for non color management
    if (!renderEngineFactory->apiSupported()) {
@@ -1842,11 +1842,6 @@ TEST_P(RenderEngineTest, drawLayers_fillBufferColorTransformAndSourceDataspace_o
}

TEST_P(RenderEngineTest, drawLayers_fillBufferColorTransformAndOutputDataspace_opaqueBufferSource) {
    // TODO: b/331447131 - Fix in Graphite and re-enable.
    if (GetParam()->skiaBackend() == renderengine::RenderEngine::SkiaBackend::GRAPHITE) {
        GTEST_SKIP();
    }

    const auto& renderEngineFactory = GetParam();
    // skip for non color management
    if (!renderEngineFactory->apiSupported()) {
@@ -1997,11 +1992,6 @@ TEST_P(RenderEngineTest, drawLayers_fillBufferColorTransformAndSourceDataspace_b
}

TEST_P(RenderEngineTest, drawLayers_fillBufferColorTransformAndOutputDataspace_bufferSource) {
    // TODO: b/331446495 - Fix in Graphite and re-enable.
    if (GetParam()->skiaBackend() == renderengine::RenderEngine::SkiaBackend::GRAPHITE) {
        GTEST_SKIP();
    }

    const auto& renderEngineFactory = GetParam();
    // skip for non color management
    if (!renderEngineFactory->apiSupported()) {
@@ -2061,11 +2051,6 @@ TEST_P(RenderEngineTest, drawLayers_fillBufferTextureTransform) {
}

TEST_P(RenderEngineTest, drawLayers_fillBuffer_premultipliesAlpha) {
    // TODO: b/331446496 - Fix in Graphite and re-enable.
    if (GetParam()->skiaBackend() == renderengine::RenderEngine::SkiaBackend::GRAPHITE) {
        GTEST_SKIP();
    }

    if (!GetParam()->apiSupported()) {
        GTEST_SKIP();
    }
+152 −111
Original line number Diff line number Diff line
@@ -2073,10 +2073,17 @@ status_t SurfaceFlinger::getDisplayDecorationSupport(
sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection(
        gui::ISurfaceComposer::VsyncSource vsyncSource, EventRegistrationFlags eventRegistration,
        const sp<IBinder>& layerHandle) {
    const auto cycle = vsyncSource == gui::ISurfaceComposer::VsyncSource::eVsyncSourceSurfaceFlinger
    const auto cycle = [&] {
        if (FlagManager::getInstance().deprecate_vsync_sf()) {
            ALOGW_IF(vsyncSource == gui::ISurfaceComposer::VsyncSource::eVsyncSourceSurfaceFlinger,
                "requested unsupported config eVsyncSourceSurfaceFlinger");
            return scheduler::Cycle::Render;
        }

        return vsyncSource == gui::ISurfaceComposer::VsyncSource::eVsyncSourceSurfaceFlinger
              ? scheduler::Cycle::LastComposite
              : scheduler::Cycle::Render;

    }();
    return mScheduler->createDisplayEventConnection(cycle, eventRegistration, layerHandle);
}

@@ -3171,7 +3178,8 @@ void SurfaceFlinger::onCompositionPresented(PhysicalDisplayId pacesetterId,
            if (mLayerLifecycleManagerEnabled) {
                mLayerSnapshotBuilder.forEachVisibleSnapshot(
                        [&, compositionDisplay = compositionDisplay](
                                std::unique_ptr<frontend::LayerSnapshot>& snapshot) {
                                std::unique_ptr<frontend::LayerSnapshot>&
                                        snapshot) FTL_FAKE_GUARD(kMainThreadContext) {
                            auto it = mLegacyLayers.find(snapshot->sequence);
                            LLOG_ALWAYS_FATAL_WITH_TRACE_IF(it == mLegacyLayers.end(),
                                                            "Couldnt find layer object for %s",
@@ -3230,7 +3238,7 @@ void SurfaceFlinger::onCompositionPresented(PhysicalDisplayId pacesetterId,

    if (mNumTrustedPresentationListeners > 0) {
        // We avoid any reverse traversal upwards so this shouldn't be too expensive
        traverseLegacyLayers([&](Layer* layer) {
        traverseLegacyLayers([&](Layer* layer) FTL_FAKE_GUARD(kMainThreadContext) {
            if (!layer->hasTrustedPresentationListener()) {
                return;
            }
@@ -4143,7 +4151,7 @@ void SurfaceFlinger::buildWindowInfos(std::vector<WindowInfo>& outWindowInfos,
                    outWindowInfos.push_back(snapshot.inputInfo);
                });
    } else {
        mDrawingState.traverseInReverseZOrder([&](Layer* layer) {
        mDrawingState.traverseInReverseZOrder([&](Layer* layer) FTL_FAKE_GUARD(kMainThreadContext) {
            if (!layer->needsInputInfo()) return;
            const auto opt =
                    mFrontEndDisplayInfos.get(layer->getLayerStack())
@@ -4848,6 +4856,8 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                if (listener &&
                    (flushState.queueProcessTime - transaction.postTime) >
                            std::chrono::nanoseconds(4s).count()) {
                    // Used to add a stalled transaction which uses an internal lock.
                    ftl::FakeGuard guard(kMainThreadContext);
                    mTransactionHandler
                            .onTransactionQueueStalled(transaction.id,
                                                       {.pid = layer->getOwnerPid(),
@@ -4870,8 +4880,9 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
        const TransactionHandler::TransactionFlushState& flushState) {
    using TransactionReadiness = TransactionHandler::TransactionReadiness;
    auto ready = TransactionReadiness::Ready;
    flushState.transaction->traverseStatesWithBuffersWhileTrue([&](const ResolvedComposerState&
                                                                           resolvedState) -> bool {
    flushState.transaction->traverseStatesWithBuffersWhileTrue(
            [&](const ResolvedComposerState& resolvedState) FTL_FAKE_GUARD(
                    kMainThreadContext) -> bool {
                const frontend::RequestedLayerState* layer =
                        mLayerLifecycleManager.getLayerFromId(resolvedState.layerId);
                const auto& transaction = *flushState.transaction;
@@ -4879,16 +4890,18 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                // check for barrier frames
                if (s.bufferData->hasBarrier) {
                    // The current producerId is already a newer producer than the buffer that has a
            // barrier. This means the incoming buffer is older and we can release it here. We
            // don't wait on the barrier since we know that's stale information.
                    // barrier. This means the incoming buffer is older and we can release it here.
                    // We don't wait on the barrier since we know that's stale information.
                    if (layer->barrierProducerId > s.bufferData->producerId) {
                        if (s.bufferData->releaseBufferListener) {
                            uint32_t currentMaxAcquiredBufferCount =
                            getMaxAcquiredBufferCountForCurrentRefreshRate(layer->ownerUid.val());
                                    getMaxAcquiredBufferCountForCurrentRefreshRate(
                                            layer->ownerUid.val());
                            ATRACE_FORMAT_INSTANT("callReleaseBufferCallback %s - %" PRIu64,
                                                  layer->name.c_str(), s.bufferData->frameNumber);
                            s.bufferData->releaseBufferListener
                            ->onReleaseBuffer({resolvedState.externalTexture->getBuffer()->getId(),
                                    ->onReleaseBuffer({resolvedState.externalTexture->getBuffer()
                                                               ->getId(),
                                                       s.bufferData->frameNumber},
                                                      s.bufferData->acquireFence
                                                              ? s.bufferData->acquireFence
@@ -4896,10 +4909,12 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                                                      currentMaxAcquiredBufferCount);
                        }

                // Delete the entire state at this point and not just release the buffer because
                // everything associated with the Layer in this Transaction is now out of date.
                ATRACE_FORMAT("DeleteStaleBuffer %s barrierProducerId:%d > %d", layer->name.c_str(),
                              layer->barrierProducerId, s.bufferData->producerId);
                        // Delete the entire state at this point and not just release the buffer
                        // because everything associated with the Layer in this Transaction is now
                        // out of date.
                        ATRACE_FORMAT("DeleteStaleBuffer %s barrierProducerId:%d > %d",
                                      layer->name.c_str(), layer->barrierProducerId,
                                      s.bufferData->producerId);
                        return TraverseBuffersReturnValues::DELETE_AND_CONTINUE_TRAVERSAL;
                    }

@@ -4909,7 +4924,8 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                                ((flushState.bufferLayersReadyToPresent.get(s.surface.get()) >=
                                  s.bufferData->barrierFrameNumber));
                        if (!willApplyBarrierFrame) {
                    ATRACE_FORMAT("NotReadyBarrier %s barrierFrameNumber:%" PRId64 " > %" PRId64,
                            ATRACE_FORMAT("NotReadyBarrier %s barrierFrameNumber:%" PRId64
                                          " > %" PRId64,
                                          layer->name.c_str(), layer->barrierFrameNumber,
                                          s.bufferData->barrierFrameNumber);
                            ready = TransactionReadiness::NotReadyBarrier;
@@ -4922,7 +4938,8 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                // the transaction in the queue.
                const bool hasPendingBuffer =
                        flushState.bufferLayersReadyToPresent.contains(s.surface.get());
        if (layer->backpressureEnabled() && hasPendingBuffer && transaction.isAutoTimestamp) {
                if (layer->backpressureEnabled() && hasPendingBuffer &&
                    transaction.isAutoTimestamp) {
                    ATRACE_FORMAT("hasPendingBuffer %s", layer->name.c_str());
                    ready = TransactionReadiness::NotReady;
                    return TraverseBuffersReturnValues::STOP_TRAVERSAL;
@@ -4935,11 +4952,13 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                        s.bufferData->acquireFence->getStatus() != Fence::Status::Unsignaled;
                if (!fenceSignaled) {
                    // check fence status
            const bool allowLatchUnsignaled = shouldLatchUnsignaled(s, transaction.states.size(),
                    const bool allowLatchUnsignaled =
                            shouldLatchUnsignaled(s, transaction.states.size(),
                                                  flushState.firstTransaction) &&
                            layer->isSimpleBufferUpdate(s);
                    if (allowLatchUnsignaled) {
                ATRACE_FORMAT("fence unsignaled try allowLatchUnsignaled %s", layer->name.c_str());
                        ATRACE_FORMAT("fence unsignaled try allowLatchUnsignaled %s",
                                      layer->name.c_str());
                        ready = TransactionReadiness::NotReadyUnsignaled;
                    } else {
                        ready = TransactionReadiness::NotReady;
@@ -4953,7 +4972,8 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
                                                                .layerId = layer->id,
                                                                .layerName = layer->name,
                                                                .bufferId = s.bufferData->getId(),
                                                        .frameNumber = s.bufferData->frameNumber});
                                                                .frameNumber =
                                                                        s.bufferData->frameNumber});
                        }
                        ATRACE_FORMAT("fence unsignaled %s", layer->name.c_str());
                        return TraverseBuffersReturnValues::STOP_TRAVERSAL;
@@ -5181,7 +5201,13 @@ status_t SurfaceFlinger::setTransactionState(
    }(state.flags);

    const auto frameHint = state.isFrameActive() ? FrameHint::kActive : FrameHint::kNone;
    {
        // Transactions are added via a lockless queue and does not need to be added from the main
        // thread.
        ftl::FakeGuard guard(kMainThreadContext);
        mTransactionHandler.queueTransaction(std::move(state));
    }

    for (const auto& [displayId, data] : mNotifyExpectedPresentMap) {
        if (data.hintStatus.load() == NotifyExpectedPresentHintStatus::ScheduleOnTx) {
            scheduleNotifyExpectedPresentHint(displayId, VsyncId{frameTimelineInfo.vsyncId});
@@ -6023,7 +6049,11 @@ void SurfaceFlinger::onHandleDestroyed(BBinder* handle, sp<Layer>& layer, uint32
        mDestroyedHandles.emplace_back(layerId, layer->getDebugName());
    }

    {
        // Used to remove stalled transactions which uses an internal lock.
        ftl::FakeGuard guard(kMainThreadContext);
        mTransactionHandler.onLayerDestroyed(layerId);
    }

    Mutex::Autolock lock(mStateLock);
    markLayerPendingRemovalLocked(layer);
@@ -6675,7 +6705,11 @@ void SurfaceFlinger::dumpOffscreenLayersProto(perfetto::protos::LayersProto& lay
}

perfetto::protos::LayersProto SurfaceFlinger::dumpProtoFromMainThread(uint32_t traceFlags) {
    return mScheduler->schedule([=, this] { return dumpDrawingStateProto(traceFlags); }).get();
    return mScheduler
            ->schedule([=, this]() FTL_FAKE_GUARD(kMainThreadContext) {
                return dumpDrawingStateProto(traceFlags);
            })
            .get();
}

void SurfaceFlinger::dumpOffscreenLayers(std::string& result) {
@@ -6724,7 +6758,8 @@ void SurfaceFlinger::dumpHwcLayersMinidump(std::string& result) const {
        Layer::miniDumpHeader(result);

        const DisplayDevice& ref = *display;
        mLayerSnapshotBuilder.forEachVisibleSnapshot([&](const frontend::LayerSnapshot& snapshot) {
        mLayerSnapshotBuilder.forEachVisibleSnapshot(
                [&](const frontend::LayerSnapshot& snapshot) FTL_FAKE_GUARD(kMainThreadContext) {
                    if (!snapshot.hasSomethingToDraw() ||
                        ref.getLayerStack() != snapshot.outputFilter.layerStack) {
                        return;
@@ -8050,7 +8085,8 @@ void SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,
    }

    bool childrenOnly = args.childrenOnly;
    RenderAreaFuture renderAreaFuture = ftl::defer([=, this]() -> std::unique_ptr<RenderArea> {
    RenderAreaFuture renderAreaFuture = ftl::defer([=, this]() FTL_FAKE_GUARD(kMainThreadContext)
                                                           -> std::unique_ptr<RenderArea> {
        ui::Transform layerTransform;
        Rect layerBufferSize;
        if (mLayerLifecycleManagerEnabled) {
@@ -9022,6 +9058,8 @@ status_t SurfaceFlinger::removeWindowInfosListener(

status_t SurfaceFlinger::getStalledTransactionInfo(
        int pid, std::optional<TransactionHandler::StalledTransactionInfo>& result) {
    // Used to add a stalled transaction which uses an internal lock.
    ftl::FakeGuard guard(kMainThreadContext);
    result = mTransactionHandler.getStalledTransactionInfo(pid);
    return NO_ERROR;
}
@@ -9222,7 +9260,8 @@ std::vector<std::pair<Layer*, LayerFE*>> SurfaceFlinger::moveSnapshotsToComposit
    if (mLayerLifecycleManagerEnabled) {
        nsecs_t currentTime = systemTime();
        mLayerSnapshotBuilder.forEachVisibleSnapshot(
                [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) {
                [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) FTL_FAKE_GUARD(
                        kMainThreadContext) {
                    if (cursorOnly &&
                        snapshot->compositionType !=
                                aidl::android::hardware::graphics::composer3::Composition::CURSOR) {
@@ -9283,11 +9322,12 @@ SurfaceFlinger::getLayerSnapshotsForScreenshots(
        std::optional<ui::LayerStack> layerStack, uint32_t uid,
        std::function<bool(const frontend::LayerSnapshot&, bool& outStopTraversal)>
                snapshotFilterFn) {
    return [&, layerStack, uid]() {
    return [&, layerStack, uid]() FTL_FAKE_GUARD(kMainThreadContext) {
        std::vector<std::pair<Layer*, sp<LayerFE>>> layers;
        bool stopTraversal = false;
        mLayerSnapshotBuilder.forEachVisibleSnapshot(
                [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) {
                [&](std::unique_ptr<frontend::LayerSnapshot>& snapshot) FTL_FAKE_GUARD(
                        kMainThreadContext) {
                    if (stopTraversal) {
                        return;
                    }
@@ -9322,7 +9362,8 @@ std::function<std::vector<std::pair<Layer*, sp<LayerFE>>>()>
SurfaceFlinger::getLayerSnapshotsForScreenshots(std::optional<ui::LayerStack> layerStack,
                                                uint32_t uid,
                                                std::unordered_set<uint32_t> excludeLayerIds) {
    return [&, layerStack, uid, excludeLayerIds = std::move(excludeLayerIds)]() {
    return [&, layerStack, uid,
            excludeLayerIds = std::move(excludeLayerIds)]() FTL_FAKE_GUARD(kMainThreadContext) {
        if (excludeLayerIds.empty()) {
            auto getLayerSnapshotsFn =
                    getLayerSnapshotsForScreenshots(layerStack, uid, /*snapshotFilterFn=*/nullptr);
@@ -9364,7 +9405,7 @@ SurfaceFlinger::getLayerSnapshotsForScreenshots(uint32_t rootLayerId, uint32_t u
                                                bool childrenOnly,
                                                const std::optional<FloatRect>& parentCrop) {
    return [&, rootLayerId, uid, excludeLayerIds = std::move(excludeLayerIds), childrenOnly,
            parentCrop]() {
            parentCrop]() FTL_FAKE_GUARD(kMainThreadContext) {
        auto root = mLayerHierarchyBuilder.getPartialHierarchy(rootLayerId, childrenOnly);
        frontend::LayerSnapshotBuilder::Args
                args{.root = root,
Loading