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

Commit 896f3a25 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Introduce eCanOccludePresentation layer flag

Sets a property on a layer hierarchy indicating that its visible region
should be considered when computing TrustedPresentation
Thresholds. This property is set on a layer and inherited by all its
children. The property is then passed via windowinfos so the
TrustedPresentation controller can determine which windows to
use when computing the thresholds.

Test: presubmit
Bug: b/275574214
Change-Id: Ia59d5053a4e7fcbc725d7c54401c2038d0622558
parent e3b7288b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -161,6 +161,12 @@ public final class InputWindowHandle {
     */
    public float alpha;

    /**
     * Sets a property on this window indicating that its visible region should be considered when
     * computing TrustedPresentation Thresholds.
     */
    public boolean canOccludePresentation;

    /**
     * The input token for the window to which focus should be transferred when this input window
     * can be successfully focused. If null, this input window will not transfer its focus to
@@ -205,6 +211,7 @@ public final class InputWindowHandle {
        focusTransferTarget = other.focusTransferTarget;
        contentSize = new Size(other.contentSize.getWidth(), other.contentSize.getHeight());
        alpha = other.alpha;
        canOccludePresentation = other.canOccludePresentation;
    }

    @Override
@@ -219,6 +226,7 @@ public final class InputWindowHandle {
                .append(", isClone=").append((inputConfig & InputConfig.CLONE) != 0)
                .append(", contentSize=").append(contentSize)
                .append(", alpha=").append(alpha)
                .append(", canOccludePresentation=").append(canOccludePresentation)
                .toString();

    }
+47 −0
Original line number Diff line number Diff line
@@ -168,6 +168,8 @@ public final class SurfaceControl implements Parcelable {
            boolean isTrustedOverlay);
    private static native void nativeSetDropInputMode(
            long transactionObj, long nativeObject, int flags);
    private static native void nativeSetCanOccludePresentation(long transactionObj,
            long nativeObject, boolean canOccludePresentation);
    private static native void nativeSurfaceFlushJankData(long nativeSurfaceObject);
    private static native boolean nativeClearContentFrameStats(long nativeObject);
    private static native boolean nativeGetContentFrameStats(long nativeObject, WindowContentFrameStats outStats);
@@ -588,6 +590,28 @@ public final class SurfaceControl implements Parcelable {
     */
    public static final int DISPLAY_DECORATION = 0x00000200;

    /**
     * Ignore any destination frame set on the layer. This is used when the buffer scaling mode
     * is freeze and the destination frame is applied asynchronously with the buffer submission.
     * This is needed to maintain compatibility for SurfaceView scaling behavior.
     * See SurfaceView scaling behavior for more details.
     * @hide
     */
    public static final int IGNORE_DESTINATION_FRAME = 0x00000400;

    /**
     * Special casing for layer that is a refresh rate indicator
     * @hide
     */
    public static final int LAYER_IS_REFRESH_RATE_INDICATOR = 0x00000800;

    /**
     * Sets a property on this layer indicating that its visible region should be considered when
     * computing TrustedPresentation Thresholds
     * @hide
     */
    public static final int CAN_OCCLUDE_PRESENTATION = 0x00001000;

    /**
     * Surface creation flag: Creates a surface where color components are interpreted
     * as "non pre-multiplied" by their alpha channel. Of course this flag is
@@ -4162,6 +4186,29 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets a property on this SurfaceControl and all its children indicating that the visible
         * region of this SurfaceControl should be considered when computing TrustedPresentation
         * Thresholds.
         * <p>
         * API Guidance:
         * The goal of this API is to identify windows that can be used to occlude content on
         * another window. This includes windows controlled by the user or the system. If the window
         * is transient, like Toast or notification shade, the window should not set this flag since
         * the user or the app cannot use the window to occlude content in a persistent manner. All
         * apps should have this flag set.
         * <p>
         * The caller must hold the ACCESS_SURFACE_FLINGER permission.
         * @hide
         */
        public Transaction setCanOccludePresentation(SurfaceControl sc,
                boolean canOccludePresentation) {
            checkPreconditions(sc);
            final int value = (canOccludePresentation) ? CAN_OCCLUDE_PRESENTATION : 0;
            nativeSetFlags(mNativeObject, sc.mNativeObject, value, CAN_OCCLUDE_PRESENTATION);
            return this;
        }

        /**
         * Sends a flush jank data transaction for the given surface.
         * @hide
+6 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ static struct {
    jfieldID windowToken;
    jfieldID focusTransferTarget;
    jfieldID alpha;
    jfieldID canOccludePresentation;
} gInputWindowHandleClassInfo;

static struct {
@@ -327,6 +328,8 @@ jobject android_view_InputWindowHandle_fromWindowInfo(JNIEnv* env, gui::WindowIn
                        javaObjectForIBinder(env, windowInfo.windowToken));

    env->SetFloatField(inputWindowHandle, gInputWindowHandleClassInfo.alpha, windowInfo.alpha);
    env->SetBooleanField(inputWindowHandle, gInputWindowHandleClassInfo.canOccludePresentation,
                         windowInfo.canOccludePresentation);

    return inputWindowHandle;
}
@@ -451,6 +454,9 @@ int register_android_view_InputWindowHandle(JNIEnv* env) {

    GET_FIELD_ID(gInputWindowHandleClassInfo.alpha, clazz, "alpha", "F");

    GET_FIELD_ID(gInputWindowHandleClassInfo.canOccludePresentation, clazz,
                 "canOccludePresentation", "Z");

    jclass surfaceControlClazz;
    FIND_CLASS(surfaceControlClazz, "android/view/SurfaceControl");
    GET_FIELD_ID(gInputWindowHandleClassInfo.touchableRegionSurfaceControl.mNativeObject,