Loading services/core/java/com/android/server/input/InputManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading Loading @@ -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 Loading services/core/java/com/android/server/wm/InputMonitor.java +12 −9 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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(); } Loading services/core/java/com/android/server/wm/TaskPositioner.java +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading services/core/java/com/android/server/wm/WindowAnimator.java +4 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -97,6 +98,9 @@ public class WindowAnimator { synchronized (mService.mGlobalLock) { mAnimationFrameCallbackScheduled = false; animate(frameTimeNs); if (mNotifyWhenNoAnimation && !mLastRootAnimating) { mService.mGlobalLock.notifyAll(); } } }; } Loading services/core/java/com/android/server/wm/WindowManagerService.java +18 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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 Loading
services/core/java/com/android/server/input/InputManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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, Loading Loading @@ -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 Loading
services/core/java/com/android/server/wm/InputMonitor.java +12 −9 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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(); } Loading
services/core/java/com/android/server/wm/TaskPositioner.java +3 −2 Original line number Diff line number Diff line Loading @@ -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); Loading
services/core/java/com/android/server/wm/WindowAnimator.java +4 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -97,6 +98,9 @@ public class WindowAnimator { synchronized (mService.mGlobalLock) { mAnimationFrameCallbackScheduled = false; animate(frameTimeNs); if (mNotifyWhenNoAnimation && !mLastRootAnimating) { mService.mGlobalLock.notifyAll(); } } }; } Loading
services/core/java/com/android/server/wm/WindowManagerService.java +18 −6 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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