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

Commit 2771c9ea authored by Linus Tufvesson's avatar Linus Tufvesson
Browse files

Give ActivityRecordInputSink its own surface

LetterboxSurface uses a z value of -1 and since it is a direct child
of the ActivityRecords SurfaceControl it get placed below the
ActivityRecords surface. This caused AcitivtyRecordInputSink to receive
touches that previously went to the LetterboxSurface. To solve this
ActivityRecordInputSink is assigned its own surface that is set as a
child of the AcitivtyRecord. By using Integer.MIN_VALUE for the Z value
it is ensured that it is behind all Activity related windows and only
consume touches that would otherwise pass through.

Test: Manually verified that that layers are correctly ordered (with
winscope and adb shell dumpsys input)
Bug: 194480991
Bug: 210593865

Change-Id: Ib4122948f19c144c455343e53f29af0e70197c00
parent 6ba962a9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -6905,8 +6905,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                getSyncTransaction().hide(mSurfaceControl);
            }
            if (show) {
                mActivityRecordInputSink.applyChangesToSurfaceIfChanged(
                        getSyncTransaction(), mSurfaceControl);
                mActivityRecordInputSink.applyChangesToSurfaceIfChanged(getSyncTransaction());
            }
        }
        if (mThumbnail != null) {
+17 −4
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ class ActivityRecordInputSink {
    // Hold on to InputEventReceiver to prevent it from getting GCd.
    private InputEventReceiver mInputEventReceiver;
    private InputWindowHandleWrapper mInputWindowHandleWrapper;

    private SurfaceControl mSurfaceControl;
    private int mRapidTouchCount = 0;
    private IBinder mToken;
    private boolean mDisabled = false;
@@ -73,14 +73,27 @@ class ActivityRecordInputSink {
                + mActivityRecord.mActivityComponent.getShortClassName();
    }

    public void applyChangesToSurfaceIfChanged(
            SurfaceControl.Transaction transaction, SurfaceControl surfaceControl) {
    public void applyChangesToSurfaceIfChanged(SurfaceControl.Transaction transaction) {
        InputWindowHandleWrapper inputWindowHandleWrapper = getInputWindowHandleWrapper();
        if (mSurfaceControl == null) {
            mSurfaceControl = createSurface(transaction);
        }
        if (inputWindowHandleWrapper.isChanged()) {
            inputWindowHandleWrapper.applyChangesToSurface(transaction, surfaceControl);
            inputWindowHandleWrapper.applyChangesToSurface(transaction, mSurfaceControl);
        }
    }

    private SurfaceControl createSurface(SurfaceControl.Transaction t) {
        SurfaceControl surfaceControl = mActivityRecord.makeChildSurface(null)
                .setName(mName)
                .setHidden(false)
                .setCallsite("ActivityRecordInputSink.createSurface")
                .build();
        // Put layer below all siblings (and the parent surface too)
        t.setLayer(surfaceControl, Integer.MIN_VALUE);
        return surfaceControl;
    }

    private InputWindowHandleWrapper getInputWindowHandleWrapper() {
        if (mInputWindowHandleWrapper == null) {
            mInputWindowHandleWrapper = new InputWindowHandleWrapper(createInputWindowHandle());