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

Commit d3aecab2 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Set trusted overlay on SurfaceControl instead of InputWindow" into main

parents 7ddc262b 113e9e1f
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.view;

import static com.android.window.flags.Flags.surfaceTrustedOverlay;

import android.annotation.IntDef;
import android.annotation.Nullable;
import android.graphics.Matrix;
@@ -35,7 +37,6 @@ import java.lang.ref.WeakReference;
 * @hide
 */
public final class InputWindowHandle {

    /**
     * An internal annotation for all the {@link android.os.InputConfig} flags that can be
     * specified to {@link #inputConfig} to control the behavior of an input window. Only the
@@ -59,7 +60,6 @@ public final class InputWindowHandle {
            InputConfig.DUPLICATE_TOUCH_TO_WALLPAPER,
            InputConfig.IS_WALLPAPER,
            InputConfig.PAUSE_DISPATCHING,
            InputConfig.TRUSTED_OVERLAY,
            InputConfig.WATCH_OUTSIDE_TOUCH,
            InputConfig.SLIPPERY,
            InputConfig.DISABLE_USER_ACTIVITY,
@@ -272,4 +272,13 @@ public final class InputWindowHandle {
        }
        this.inputConfig &= ~inputConfig;
    }

    public void setTrustedOverlay(SurfaceControl.Transaction t, SurfaceControl sc,
            boolean isTrusted) {
        if (surfaceTrustedOverlay()) {
            t.setTrustedOverlay(sc, isTrusted);
        } else if (isTrusted) {
            inputConfig |= InputConfig.TRUSTED_OVERLAY;
        }
    }
}
+11 −0
Original line number Diff line number Diff line
package: "com.android.window.flags"

# Project link: https://gantry.corp.google.com/projects/android_platform_window_surfaces/changes

flag {
    namespace: "window_surfaces"
    name: "surface_trusted_overlay"
    description: "Whether to add trusted overlay flag on the SurfaceControl or the InputWindow"
    is_fixed_read_only: true
    bug: "292032926"
}
+2 −2
Original line number Diff line number Diff line
@@ -62,10 +62,10 @@ class GestureMonitorSpyWindow {
        mWindowHandle.ownerUid = uid;
        mWindowHandle.scaleFactor = 1.0f;
        mWindowHandle.replaceTouchableRegionWithCrop(null /* use this surface's bounds */);
        mWindowHandle.inputConfig =
                InputConfig.NOT_FOCUSABLE | InputConfig.SPY | InputConfig.TRUSTED_OVERLAY;
        mWindowHandle.inputConfig = InputConfig.NOT_FOCUSABLE | InputConfig.SPY;

        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        mWindowHandle.setTrustedOverlay(t, mInputSurface, true);
        t.setInputWindowInfo(mInputSurface, mWindowHandle);
        t.setLayer(mInputSurface, InputManagerService.INPUT_OVERLAY_LAYER_GESTURE_MONITOR);
        t.setPosition(mInputSurface, 0, 0);
+2 −2
Original line number Diff line number Diff line
@@ -57,13 +57,13 @@ final class HandwritingEventReceiverSurface {
                InputConfig.NOT_FOCUSABLE
                        | InputConfig.NOT_TOUCHABLE
                        | InputConfig.SPY
                        | InputConfig.INTERCEPTS_STYLUS
                        | InputConfig.TRUSTED_OVERLAY;
                        | InputConfig.INTERCEPTS_STYLUS;

        // Configure the surface to receive stylus events across the entire display.
        mWindowHandle.replaceTouchableRegionWithCrop(null /* use this surface's bounds */);

        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        mWindowHandle.setTrustedOverlay(t, mInputSurface, true);
        t.setInputWindowInfo(mInputSurface, mWindowHandle);
        t.setLayer(mInputSurface, InputManagerService.INPUT_OVERLAY_LAYER_HANDWRITING_SURFACE);
        t.setPosition(mInputSurface, 0, 0);
+4 −6
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import android.hardware.input.InputManagerGlobal;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.InputConfig;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
@@ -186,6 +185,10 @@ class DragState {
        // Crop the input surface to the display size.
        mTmpClipRect.set(0, 0, mDisplaySize.x, mDisplaySize.y);

        // Make trusted overlay to not block any touches while D&D ongoing and allowing
        // touches to pass through to windows underneath. This allows user to interact with the
        // UI to navigate while dragging.
        h.setTrustedOverlay(mTransaction, mInputSurface, true);
        mTransaction.show(mInputSurface)
                .setInputWindowInfo(mInputSurface, h)
                .setLayer(mInputSurface, Integer.MAX_VALUE)
@@ -377,11 +380,6 @@ class DragState {
            mDragWindowHandle.ownerUid = MY_UID;
            mDragWindowHandle.scaleFactor = 1.0f;

            // InputConfig.TRUSTED_OVERLAY: To not block any touches while D&D ongoing and allowing
            // touches to pass through to windows underneath. This allows user to interact with the
            // UI to navigate while dragging.
            mDragWindowHandle.inputConfig = InputConfig.TRUSTED_OVERLAY;

            // The drag window cannot receive new touches.
            mDragWindowHandle.touchableRegion.setEmpty();

Loading