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

Commit 858a3b4c authored by Vishnu Nair's avatar Vishnu Nair
Browse files

SF: Allow privileged clients to create layers offscreen

If the caller is privileged and a new layer has a null parent,
the new layer will be added to root. When recreating layer
state, we create layers as a privileged client so we need to
specify if a layer need to be added offscreen.

Test: presubmit
Bug: 200284593
Change-Id: If07953b401020b115b0e364ff03ac65503bdc0ed
parent d4fd4a1a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ struct LayerCreationArgs {
    uid_t callingUid;
    uint32_t textureName;
    std::optional<uint32_t> sequence = std::nullopt;
    bool addToRoot = true;
};

class Layer : public virtual RefBase, compositionengine::LayerFE {
+2 −2
Original line number Diff line number Diff line
@@ -4571,7 +4571,7 @@ status_t SurfaceFlinger::mirrorLayer(const LayerCreationArgs& args,
                                                args.name, mirrorFrom->sequence);
    }
    return addClientLayer(args.client, *outHandle, mirrorLayer /* layer */, nullptr /* parent */,
                          false /* addAsRoot */, nullptr /* outTransformHint */);
                          false /* addToRoot */, nullptr /* outTransformHint */);
}

status_t SurfaceFlinger::createLayer(LayerCreationArgs& args, sp<IBinder>* outHandle,
@@ -4611,7 +4611,7 @@ status_t SurfaceFlinger::createLayer(LayerCreationArgs& args, sp<IBinder>* outHa
        return result;
    }

    bool addToRoot = callingThreadHasUnscopedSurfaceFlingerAccess();
    bool addToRoot = args.addToRoot && callingThreadHasUnscopedSurfaceFlingerAccess();
    wp<Layer> parent(parentHandle != nullptr ? fromHandle(parentHandle) : parentLayer);
    if (parentHandle != nullptr && parent == nullptr) {
        ALOGE("Invalid parent handle %p.", parentHandle.get());