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

Commit 6203f2d0 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 1/2" into main

parents 01a085ef bb217bc2
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.gui.DropInputMode;
import android.gui.StalledTransactionInfo;
import android.gui.TrustedOverlay;
import android.hardware.DataSpace;
import android.hardware.HardwareBuffer;
import android.hardware.OverlayProperties;
@@ -165,7 +166,7 @@ public final class SurfaceControl implements Parcelable {
            float maxStretchAmountX, float maxStretchAmountY, float childRelativeLeft,
            float childRelativeTop, float childRelativeRight, float childRelativeBottom);
    private static native void nativeSetTrustedOverlay(long transactionObj, long nativeObject,
            boolean isTrustedOverlay);
            int isTrustedOverlay);
    private static native void nativeSetDropInputMode(
            long transactionObj, long nativeObject, int flags);
    private static native void nativeSetCanOccludePresentation(long transactionObj,
@@ -4304,13 +4305,37 @@ public final class SurfaceControl implements Parcelable {
        }

        /**
         * Sets the trusted overlay state on this SurfaceControl and it is inherited to all the
         * children. The caller must hold the ACCESS_SURFACE_FLINGER permission.
         * @see Transaction#setTrustedOverlay(SurfaceControl, int)
         * @hide
         */
        public Transaction setTrustedOverlay(SurfaceControl sc, boolean isTrustedOverlay) {
            return setTrustedOverlay(sc,
                    isTrustedOverlay ? TrustedOverlay.ENABLED : TrustedOverlay.UNSET);
        }

        /**
         * Trusted overlay state prevents SurfaceControl from being considered as obscuring for
         * input occlusion detection purposes. The caller must hold the
         * ACCESS_SURFACE_FLINGER permission. See {@code TrustedOverlay}.
         * <p>
         * Arguments:
         * {@code TrustedOverlay.UNSET} - The default value, SurfaceControl will inherit the state
         * from its parents. If the parent state is also {@code TrustedOverlay.UNSET}, the layer
         * will be considered as untrusted.
         * <p>
         * {@code TrustedOverlay.DISABLED} - Treats this SurfaceControl and all its children as an
         * untrusted overlay. This will override any state set by its parent SurfaceControl.
         * <p>
         * {@code TrustedOverlay.ENABLED} - Treats this SurfaceControl and all its children as a
         * trusted overlay unless the child SurfaceControl explicitly disables its trusted state
         * via {@code TrustedOverlay.DISABLED}.
         * <p>
         * @hide
         */
        public Transaction setTrustedOverlay(SurfaceControl sc,
                                             @TrustedOverlay int trustedOverlay) {
            checkPreconditions(sc);
            nativeSetTrustedOverlay(mNativeObject, sc.mNativeObject, isTrustedOverlay);
            nativeSetTrustedOverlay(mNativeObject, sc.mNativeObject, trustedOverlay);
            return this;
        }

+3 −3
Original line number Diff line number Diff line
@@ -1008,11 +1008,11 @@ static void nativeSetShadowRadius(JNIEnv* env, jclass clazz, jlong transactionOb
}

static void nativeSetTrustedOverlay(JNIEnv* env, jclass clazz, jlong transactionObj,
                                    jlong nativeObject, jboolean isTrustedOverlay) {
                                    jlong nativeObject, jint trustedOverlay) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);

    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    transaction->setTrustedOverlay(ctrl, isTrustedOverlay);
    transaction->setTrustedOverlay(ctrl, static_cast<gui::TrustedOverlay>(trustedOverlay));
}

static void nativeSetFrameRate(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject,
@@ -2447,7 +2447,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetTransformHint },
    {"nativeGetTransformHint", "(J)I",
            (void*)nativeGetTransformHint },
    {"nativeSetTrustedOverlay", "(JJZ)V",
    {"nativeSetTrustedOverlay", "(JJI)V",
            (void*)nativeSetTrustedOverlay },
    {"nativeGetLayerId", "(J)I",
            (void*)nativeGetLayerId },