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

Commit 71f829c8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes from topic "Fix WindowFocusTests Flaky-rvc-dev" into rvc-dev am: dcea9181

Change-Id: Ib22d59a6ff3cd1a1d25519bdbcfc458be82c5744
parents 1f4ff812 dcea9181
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ import android.view.InputChannel;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.InputMonitor;
import android.view.InputWindowHandle;
import android.view.KeyEvent;
import android.view.PointerIcon;
import android.view.Surface;
@@ -221,8 +220,7 @@ public class InputManagerService extends IInputManager.Stub
            int policyFlags);
    private static native VerifiedInputEvent nativeVerifyInputEvent(long ptr, InputEvent event);
    private static native void nativeToggleCapsLock(long ptr, int deviceId);
    private static native void nativeSetInputWindows(long ptr, InputWindowHandle[] windowHandles,
            int displayId);
    private static native void nativeDisplayRemoved(long ptr, int displayId);
    private static native void nativeSetInputDispatchMode(long ptr, boolean enabled, boolean frozen);
    private static native void nativeSetSystemUiVisibility(long ptr, int visibility);
    private static native void nativeSetFocusedApplication(long ptr,
@@ -1536,7 +1534,7 @@ public class InputManagerService extends IInputManager.Stub

    /** Clean up input window handles of the given display. */
    public void onDisplayRemoved(int displayId) {
        nativeSetInputWindows(mPtr, null /* windowHandles */, displayId);
        nativeDisplayRemoved(mPtr, displayId);
    }

    @Override
+12 −9
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ final class InputMonitor {
    // When true, need to call updateInputWindowsLw().
    private boolean mUpdateInputWindowsNeeded = true;
    private boolean mUpdateInputWindowsPending;
    private boolean mApplyImmediately;
    private boolean mUpdateInputWindowsImmediately;

    // Currently focused input window handle.
    private InputWindowHandle mFocusedInputWindowHandle;
@@ -347,14 +347,20 @@ final class InputMonitor {
        }
    }

    void updateInputWindowsImmediately() {
    /**
     * Immediately update the input transaction and merge into the passing Transaction that could be
     * collected and applied later.
     */
    void updateInputWindowsImmediately(SurfaceControl.Transaction t) {
        mHandler.removeCallbacks(mUpdateInputWindows);
        mApplyImmediately = true;
        mUpdateInputWindowsImmediately = true;
        mUpdateInputWindows.run();
        mApplyImmediately = false;
        mUpdateInputWindowsImmediately = false;
        t.merge(mInputTransaction);
    }

    /* Called when the current input focus changes.
    /**
     * Called when the current input focus changes.
     * Layer assignment is assumed to be complete by the time this is called.
     */
    public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) {
@@ -465,10 +471,7 @@ final class InputMonitor {
            if (mAddWallpaperInputConsumerHandle) {
                mWallpaperInputConsumer.show(mInputTransaction, 0);
            }

            if (mApplyImmediately) {
                mInputTransaction.apply();
            } else {
            if (!mUpdateInputWindowsImmediately) {
                mDisplayContent.getPendingTransaction().merge(mInputTransaction);
                mDisplayContent.scheduleAnimation();
            }
+3 −2
Original line number Diff line number Diff line
@@ -268,8 +268,9 @@ class TaskPositioner implements IBinder.DeathRecipient {
        mDisplayContent.getDisplayRotation().pause();

        // Notify InputMonitor to take mDragWindowHandle.
        mDisplayContent.getInputMonitor().updateInputWindowsImmediately();
        new SurfaceControl.Transaction().syncInputWindows().apply(true);
        final SurfaceControl.Transaction t = mService.mTransactionFactory.get();
        mDisplayContent.getInputMonitor().updateInputWindowsImmediately(t);
        t.syncInputWindows().apply();

        final DisplayMetrics displayMetrics = displayContent.getDisplayMetrics();
        mMinVisibleWidth = dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, displayMetrics);
+4 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class WindowAnimator {
     * vsync-app and then schedule the animation tick at the right time (vsync-sf).
     */
    private boolean mAnimationFrameCallbackScheduled;
    boolean mNotifyWhenNoAnimation = false;

    /**
     * A list of runnable that need to be run after {@link WindowContainer#prepareSurfaces} is
@@ -97,6 +98,9 @@ public class WindowAnimator {
            synchronized (mService.mGlobalLock) {
                mAnimationFrameCallbackScheduled = false;
                animate(frameTimeNs);
                if (mNotifyWhenNoAnimation && !mLastRootAnimating) {
                    mService.mGlobalLock.notifyAll();
                }
            }
        };
    }
+18 −6
Original line number Diff line number Diff line
@@ -193,7 +193,6 @@ import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.MergedConfiguration;
import android.util.Slog;
import android.util.SparseArray;
@@ -7734,19 +7733,30 @@ public class WindowManagerService extends IWindowManager.Stub
    public void syncInputTransactions() {
        waitForAnimationsToComplete();

        // Collect all input transactions from all displays to make sure we could sync all input
        // windows at same time.
        final SurfaceControl.Transaction t = mTransactionFactory.get();
        synchronized (mGlobalLock) {
            mWindowPlacerLocked.performSurfacePlacementIfScheduled();
            mRoot.forAllDisplays(displayContent ->
                    displayContent.getInputMonitor().updateInputWindowsImmediately());
                    displayContent.getInputMonitor().updateInputWindowsImmediately(t));
        }

        mTransactionFactory.get().syncInputWindows().apply(true);
        t.syncInputWindows().apply();
    }

    /**
     * Wait until all container animations and surface operations behalf of WindowManagerService
     * complete.
     */
    private void waitForAnimationsToComplete() {
        synchronized (mGlobalLock) {
            long timeoutRemaining = ANIMATION_COMPLETED_TIMEOUT_MS;
            while (mRoot.isAnimating(TRANSITION | CHILDREN) && timeoutRemaining > 0) {
            // This could prevent if there is no container animation, we still have to apply the
            // pending transaction and exit waiting.
            mAnimator.mNotifyWhenNoAnimation = true;
            while ((mAnimator.isAnimationScheduled()
                    || mRoot.isAnimating(TRANSITION | CHILDREN)) && timeoutRemaining > 0) {
                long startTime = System.currentTimeMillis();
                try {
                    mGlobalLock.wait(timeoutRemaining);
@@ -7754,9 +7764,11 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                timeoutRemaining -= (System.currentTimeMillis() - startTime);
            }
            mAnimator.mNotifyWhenNoAnimation = false;

            if (mRoot.isAnimating(TRANSITION | CHILDREN)) {
                Log.w(TAG, "Timed out waiting for animations to complete.");
            if (mAnimator.isAnimationScheduled()
                    || mRoot.isAnimating(TRANSITION | CHILDREN)) {
                Slog.w(TAG, "Timed out waiting for animations to complete.");
            }
        }
    }
Loading