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

Commit a48361eb authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Allow child layers to unset trusted overlay state 2/2" into main

parents 9bad9d41 9e0017e9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ filegroup {
        "android/gui/DropInputMode.aidl",
        "android/gui/StalledTransactionInfo.aidl",
        "android/**/TouchOcclusionMode.aidl",
        "android/gui/TrustedOverlay.aidl",
    ],
}

+7 −5
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ layer_state_t::layer_state_t()
        frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_PROPAGATE),
        fixedTransformHint(ui::Transform::ROT_INVALID),
        autoRefresh(false),
        isTrustedOverlay(false),
        trustedOverlay(gui::TrustedOverlay::UNSET),
        bufferCrop(Rect::INVALID_RECT),
        destinationFrame(Rect::INVALID_RECT),
        dropInputMode(gui::DropInputMode::NONE) {
@@ -179,7 +179,7 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.write, stretchEffect);
    SAFE_PARCEL(output.write, bufferCrop);
    SAFE_PARCEL(output.write, destinationFrame);
    SAFE_PARCEL(output.writeBool, isTrustedOverlay);
    SAFE_PARCEL(output.writeInt32, static_cast<uint32_t>(trustedOverlay));

    SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));

@@ -308,7 +308,9 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.read, stretchEffect);
    SAFE_PARCEL(input.read, bufferCrop);
    SAFE_PARCEL(input.read, destinationFrame);
    SAFE_PARCEL(input.readBool, &isTrustedOverlay);
    uint32_t trustedOverlayInt;
    SAFE_PARCEL(input.readUint32, &trustedOverlayInt);
    trustedOverlay = static_cast<gui::TrustedOverlay>(trustedOverlayInt);

    uint32_t mode;
    SAFE_PARCEL(input.readUint32, &mode);
@@ -674,7 +676,7 @@ void layer_state_t::merge(const layer_state_t& other) {
    }
    if (other.what & eTrustedOverlayChanged) {
        what |= eTrustedOverlayChanged;
        isTrustedOverlay = other.isTrustedOverlay;
        trustedOverlay = other.trustedOverlay;
    }
    if (other.what & eStretchChanged) {
        what |= eStretchChanged;
@@ -779,7 +781,7 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
    CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
    CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
    CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
    CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay);
    CHECK_DIFF(diff, eTrustedOverlayChanged, other, trustedOverlay);
    CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
    CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
    CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
+8 −1
Original line number Diff line number Diff line
@@ -2179,6 +2179,13 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAutoR

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrustedOverlay(
        const sp<SurfaceControl>& sc, bool isTrustedOverlay) {
    return setTrustedOverlay(sc,
                             isTrustedOverlay ? gui::TrustedOverlay::ENABLED
                                              : gui::TrustedOverlay::UNSET);
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrustedOverlay(
        const sp<SurfaceControl>& sc, gui::TrustedOverlay trustedOverlay) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
@@ -2186,7 +2193,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrust
    }

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

+45 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2024, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.gui;


/**
  * Trusted overlay state prevents layers from being considered as obscuring for
  * input occlusion detection purposes.
  *
  * @hide
  */
@Backing(type="int")
enum TrustedOverlay {
    /**
      * The default, layer will inherit the state from its parents. If the parent state is also
      * unset, the layer will be considered as untrusted.
      */
    UNSET,

    /**
      * Treats this layer and all its children as an untrusted overlay. This will override any
      * state set by its parent layers.
      */
    DISABLED,

    /**
      * Treats this layer and all its children as a trusted overlay unless the child layer
      * explicitly disables its trusted state.
      */
    ENABLED
}
+2 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@

#include <android/gui/DropInputMode.h>
#include <android/gui/FocusRequest.h>
#include <android/gui/TrustedOverlay.h>

#include <ftl/flags.h>
#include <gui/DisplayCaptureArgs.h>
@@ -385,7 +386,7 @@ struct layer_state_t {

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

    // Stretch effect to be applied to this layer
    StretchEffect stretchEffect;
Loading