From b813936017757f466db959e13df1476fce21bc82 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Fri, 22 Jul 2022 14:00:29 -0700 Subject: Inject Choreographer of the shell main thread Also use the injected Choreographer for drag resizing. Bug: 239973193 Test: Drag resizing still works. Change-Id: Ia58f2de285a4f18d8a84098142bc793803cd4aec --- .../wm/shell/dagger/WMShellConcurrencyModule.java | 20 ++++++++++++++++++++ .../com/android/wm/shell/dagger/WMShellModule.java | 3 +++ .../windowdecor/CaptionWindowDecorViewModel.java | 5 +++++ .../shell/windowdecor/CaptionWindowDecoration.java | 5 +++++ .../shell/windowdecor/DragResizeInputListener.java | 15 ++++++++------- 5 files changed, 41 insertions(+), 7 deletions(-) (limited to 'libs') diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellConcurrencyModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellConcurrencyModule.java index cc741d3896a2..35a309a8352c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellConcurrencyModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellConcurrencyModule.java @@ -27,6 +27,7 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Trace; +import android.view.Choreographer; import androidx.annotation.Nullable; @@ -143,6 +144,25 @@ public abstract class WMShellConcurrencyModule { return sysuiMainExecutor; } + /** + * Provide a Shell main-thread {@link Choreographer} with the app vsync. + * + * @param executor the executor of the shell main thread + */ + @WMSingleton + @Provides + @ShellMainThread + public static Choreographer provideShellMainChoreographer( + @ShellMainThread ShellExecutor executor) { + try { + final Choreographer[] choreographer = new Choreographer[1]; + executor.executeBlocking(() -> choreographer[0] = Choreographer.getInstance()); + return choreographer[0]; + } catch (InterruptedException e) { + throw new RuntimeException("Failed to obtain main Choreographer.", e); + } + } + /** * Provide a Shell animation-thread Executor. */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java index 0f33f4c08e9c..0dc293b0265f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.pm.LauncherApps; import android.os.Handler; import android.os.UserManager; +import android.view.Choreographer; import android.view.WindowManager; import com.android.internal.jank.InteractionJankMonitor; @@ -173,12 +174,14 @@ public abstract class WMShellModule { static WindowDecorViewModel provideWindowDecorViewModel( Context context, @ShellMainThread Handler mainHandler, + @ShellMainThread Choreographer mainChoreographer, ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue) { return new CaptionWindowDecorViewModel( context, mainHandler, + mainChoreographer, taskOrganizer, displayController, syncQueue); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java index 6d28d73996f0..fe3724b4ec1b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java @@ -25,6 +25,7 @@ import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityTaskManager; import android.content.Context; import android.os.Handler; +import android.view.Choreographer; import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.View; @@ -45,17 +46,20 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel choreographer[0] = Choreographer.getInstance(), 0); - mChoreographer = choreographer[0]; + mChoreographer = choreographer; mConsumeBatchEventRunnable = () -> { mConsumeBatchEventScheduled = false; -- cgit v1.2.3-59-g8ed1b