summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Garfield Tan <xutan@google.com> 2022-07-25 16:43:08 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-07-25 16:43:08 +0000
commit80ddbcc9c6e21292c157d175b72108fcfcb8af7c (patch)
tree405a70a555cf3f1389304906d97aad3b26b71555
parentfa50a425bf408ffc80b52de5212c6e6ca677e098 (diff)
parent7560f94eb3a68ac72f1638a915ccf680a5ae8d03 (diff)
Merge "Inject Choreographer of the shell main thread" into tm-qpr-dev am: 7560f94eb3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19397623 Change-Id: Ic54b752a5e0f16c4e056fa4831a0b639ca5cfaf3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellConcurrencyModule.java20
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java3
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java5
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java5
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java15
5 files changed, 41 insertions, 7 deletions
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;
@@ -144,6 +145,25 @@ public abstract class WMShellConcurrencyModule {
}
/**
+ * 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.
*/
@WMSingleton
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<Caption
private final ShellTaskOrganizer mTaskOrganizer;
private final Context mContext;
private final Handler mMainHandler;
+ private final Choreographer mMainChoreographer;
private final DisplayController mDisplayController;
private final SyncTransactionQueue mSyncQueue;
public CaptionWindowDecorViewModel(
Context context,
Handler mainHandler,
+ Choreographer mainChoreographer,
ShellTaskOrganizer taskOrganizer,
DisplayController displayController,
SyncTransactionQueue syncQueue) {
mContext = context;
mMainHandler = mainHandler;
+ mMainChoreographer = mainChoreographer;
mActivityTaskManager = mContext.getSystemService(ActivityTaskManager.class);
mTaskOrganizer = taskOrganizer;
mDisplayController = displayController;
@@ -72,6 +76,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
taskInfo,
taskSurface,
mMainHandler,
+ mMainChoreographer,
mSyncQueue);
TaskPositioner taskPositioner = new TaskPositioner(mTaskOrganizer, windowDecoration);
CaptionTouchEventListener touchEventListener =
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java
index cdca051a4ee5..2df71041595d 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java
@@ -25,6 +25,7 @@ import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.VectorDrawable;
import android.os.Handler;
+import android.view.Choreographer;
import android.view.SurfaceControl;
import android.view.View;
import android.window.WindowContainerTransaction;
@@ -59,6 +60,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
RESIZE_HANDLE_IN_DIP, RESIZE_HANDLE_IN_DIP, RESIZE_HANDLE_IN_DIP, RESIZE_HANDLE_IN_DIP);
private final Handler mHandler;
+ private final Choreographer mChoreographer;
private final SyncTransactionQueue mSyncQueue;
private View.OnClickListener mOnCaptionButtonClickListener;
@@ -77,10 +79,12 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
ActivityManager.RunningTaskInfo taskInfo,
SurfaceControl taskSurface,
Handler handler,
+ Choreographer choreographer,
SyncTransactionQueue syncQueue) {
super(context, displayController, taskOrganizer, taskInfo, taskSurface);
mHandler = handler;
+ mChoreographer = choreographer;
mSyncQueue = syncQueue;
}
@@ -138,6 +142,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
mDragResizeListener = new DragResizeInputListener(
mContext,
mHandler,
+ mChoreographer,
mDisplay.getDisplayId(),
mDecorationContainerSurface,
mDragResizeCallback);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
index 9869d2e53979..f512b0d4fe10 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
@@ -49,6 +49,7 @@ class DragResizeInputListener implements AutoCloseable {
private final IWindowSession mWindowSession = WindowManagerGlobal.getWindowSession();
private final Handler mHandler;
+ private final Choreographer mChoreographer;
private final InputManager mInputManager;
private final int mDisplayId;
@@ -68,11 +69,13 @@ class DragResizeInputListener implements AutoCloseable {
DragResizeInputListener(
Context context,
Handler handler,
+ Choreographer choreographer,
int displayId,
SurfaceControl decorationSurface,
DragResizeCallback callback) {
mInputManager = context.getSystemService(InputManager.class);
mHandler = handler;
+ mChoreographer = choreographer;
mDisplayId = displayId;
mDecorationSurface = decorationSurface;
// Use a fake window as the backing surface is a container layer and we don't want to create
@@ -97,7 +100,8 @@ class DragResizeInputListener implements AutoCloseable {
e.rethrowFromSystemServer();
}
- mInputEventReceiver = new TaskResizeInputEventReceiver(mInputChannel, mHandler);
+ mInputEventReceiver = new TaskResizeInputEventReceiver(
+ mInputChannel, mHandler, mChoreographer);
mCallback = callback;
}
@@ -171,13 +175,10 @@ class DragResizeInputListener implements AutoCloseable {
private final Runnable mConsumeBatchEventRunnable;
private boolean mConsumeBatchEventScheduled;
- private TaskResizeInputEventReceiver(InputChannel inputChannel, Handler handler) {
+ private TaskResizeInputEventReceiver(
+ InputChannel inputChannel, Handler handler, Choreographer choreographer) {
super(inputChannel, handler.getLooper());
-
- final Choreographer[] choreographer = new Choreographer[1];
- handler.runWithScissors(
- () -> choreographer[0] = Choreographer.getInstance(), 0);
- mChoreographer = choreographer[0];
+ mChoreographer = choreographer;
mConsumeBatchEventRunnable = () -> {
mConsumeBatchEventScheduled = false;