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

Commit 7605fb42 authored by Winson Chung's avatar Winson Chung
Browse files

Add mechanism for a task's windows to be trusted overlays (SF)

- Add a layer state to indicate that this layer and its children
  in the hierarchy are trusted. This can only be set by callers
  holding ACCESS_SURFACE_FLINGER, and will be used for the PIP
  task layer to indicate that activities in PIP are trusted (as
  they are controlled only by the user and SystemUI)

Bug: 191529039
Bug: 196389741
Test: TBD

Change-Id: Id92ccb087bd0d8dbaeeef3ba50b67fe015e53db8
Merged-In: Id92ccb087bd0d8dbaeeef3ba50b67fe015e53db8
parent 39bc6117
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ message SurfaceChange {
        ReparentChildrenChange      reparent_children       = 20;
        BackgroundBlurRadiusChange  background_blur_radius  = 21;
        ShadowRadiusChange          shadow_radius           = 22;
        TrustedOverlayChange        trusted_overlay         = 23;
    }
}

@@ -209,3 +210,7 @@ message DetachChildrenChange {
message ShadowRadiusChange {
    required float radius = 1;
}

message TrustedOverlayChange {
    required float is_trusted_overlay = 1;
}
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ status_t layer_state_t::write(Parcel& output) const
    output.writeFloat(frameRate);
    output.writeByte(frameRateCompatibility);
    output.writeUint32(fixedTransformHint);
    output.writeBool(isTrustedOverlay);

    return NO_ERROR;
}

@@ -200,6 +202,8 @@ status_t layer_state_t::read(const Parcel& input)
    frameRate = input.readFloat();
    frameRateCompatibility = input.readByte();
    fixedTransformHint = static_cast<ui::Transform::RotationFlags>(input.readUint32());
    isTrustedOverlay = input.readBool();

    return NO_ERROR;
}

@@ -439,6 +443,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eFixedTransformHintChanged;
        fixedTransformHint = other.fixedTransformHint;
    }
    if (other.what & eTrustedOverlayChanged) {
        what |= eTrustedOverlayChanged;
        isTrustedOverlay = other.isTrustedOverlay;
    }
    if ((other.what & what) != other.what) {
        ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
              "other.what=0x%" PRIu64 " what=0x%" PRIu64,
+13 −0
Original line number Diff line number Diff line
@@ -1484,6 +1484,19 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixed
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrustedOverlay(
        const sp<SurfaceControl>& sc, bool isTrustedOverlay) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }

    s->what |= layer_state_t::eTrustedOverlayChanged;
    s->isTrustedOverlay = isTrustedOverlay;
    return *this;
}

// ---------------------------------------------------------------------------

DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
+7 −1
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ struct layer_state_t {
        eBackgroundBlurRadiusChanged = 0x80'00000000,
        eProducerDisconnect = 0x100'00000000,
        eFixedTransformHintChanged = 0x200'00000000,
        eTrustedOverlayChanged = 0x400'00000000,
    };

    layer_state_t()
@@ -139,7 +140,8 @@ struct layer_state_t {
            frameRateSelectionPriority(-1),
            frameRate(0.0f),
            frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
            fixedTransformHint(ui::Transform::ROT_INVALID) {
            fixedTransformHint(ui::Transform::ROT_INVALID),
            isTrustedOverlay(false) {
        matrix.dsdx = matrix.dtdy = 1.0f;
        matrix.dsdy = matrix.dtdx = 0.0f;
        hdrMetadata.validTypes = 0;
@@ -237,6 +239,10 @@ struct layer_state_t {
    // a buffer of a different size. -1 means the transform hint is not set,
    // otherwise the value will be a valid ui::Rotation.
    ui::Transform::RotationFlags fixedTransformHint;

    // An inherited state that indicates that this surface control and its children
    // should be trusted for input occlusion detection purposes
    bool isTrustedOverlay;
};

struct ComposerState {
+3 −0
Original line number Diff line number Diff line
@@ -529,6 +529,9 @@ public:
        // a buffer of a different size.
        Transaction& setFixedTransformHint(const sp<SurfaceControl>& sc, int32_t transformHint);

        // Sets that this surface control and its children are trusted overlays for input
        Transaction& setTrustedOverlay(const sp<SurfaceControl>& sc, bool isTrustedOverlay);
        
        status_t setDisplaySurface(const sp<IBinder>& token,
                const sp<IGraphicBufferProducer>& bufferProducer);

Loading