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>
This commit is contained in:
@@ -27,6 +27,7 @@ import android.os.Handler;
|
|||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
|
import android.view.Choreographer;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
@@ -143,6 +144,25 @@ public abstract class WMShellConcurrencyModule {
|
|||||||
return sysuiMainExecutor;
|
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.
|
* Provide a Shell animation-thread Executor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.content.pm.LauncherApps;
|
import android.content.pm.LauncherApps;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.view.Choreographer;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.android.internal.jank.InteractionJankMonitor;
|
import com.android.internal.jank.InteractionJankMonitor;
|
||||||
@@ -173,12 +174,14 @@ public abstract class WMShellModule {
|
|||||||
static WindowDecorViewModel<?> provideWindowDecorViewModel(
|
static WindowDecorViewModel<?> provideWindowDecorViewModel(
|
||||||
Context context,
|
Context context,
|
||||||
@ShellMainThread Handler mainHandler,
|
@ShellMainThread Handler mainHandler,
|
||||||
|
@ShellMainThread Choreographer mainChoreographer,
|
||||||
ShellTaskOrganizer taskOrganizer,
|
ShellTaskOrganizer taskOrganizer,
|
||||||
DisplayController displayController,
|
DisplayController displayController,
|
||||||
SyncTransactionQueue syncQueue) {
|
SyncTransactionQueue syncQueue) {
|
||||||
return new CaptionWindowDecorViewModel(
|
return new CaptionWindowDecorViewModel(
|
||||||
context,
|
context,
|
||||||
mainHandler,
|
mainHandler,
|
||||||
|
mainChoreographer,
|
||||||
taskOrganizer,
|
taskOrganizer,
|
||||||
displayController,
|
displayController,
|
||||||
syncQueue);
|
syncQueue);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.app.ActivityManager.RunningTaskInfo;
|
|||||||
import android.app.ActivityTaskManager;
|
import android.app.ActivityTaskManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.view.Choreographer;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -45,17 +46,20 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
|
|||||||
private final ShellTaskOrganizer mTaskOrganizer;
|
private final ShellTaskOrganizer mTaskOrganizer;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Handler mMainHandler;
|
private final Handler mMainHandler;
|
||||||
|
private final Choreographer mMainChoreographer;
|
||||||
private final DisplayController mDisplayController;
|
private final DisplayController mDisplayController;
|
||||||
private final SyncTransactionQueue mSyncQueue;
|
private final SyncTransactionQueue mSyncQueue;
|
||||||
|
|
||||||
public CaptionWindowDecorViewModel(
|
public CaptionWindowDecorViewModel(
|
||||||
Context context,
|
Context context,
|
||||||
Handler mainHandler,
|
Handler mainHandler,
|
||||||
|
Choreographer mainChoreographer,
|
||||||
ShellTaskOrganizer taskOrganizer,
|
ShellTaskOrganizer taskOrganizer,
|
||||||
DisplayController displayController,
|
DisplayController displayController,
|
||||||
SyncTransactionQueue syncQueue) {
|
SyncTransactionQueue syncQueue) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mMainHandler = mainHandler;
|
mMainHandler = mainHandler;
|
||||||
|
mMainChoreographer = mainChoreographer;
|
||||||
mActivityTaskManager = mContext.getSystemService(ActivityTaskManager.class);
|
mActivityTaskManager = mContext.getSystemService(ActivityTaskManager.class);
|
||||||
mTaskOrganizer = taskOrganizer;
|
mTaskOrganizer = taskOrganizer;
|
||||||
mDisplayController = displayController;
|
mDisplayController = displayController;
|
||||||
@@ -72,6 +76,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
|
|||||||
taskInfo,
|
taskInfo,
|
||||||
taskSurface,
|
taskSurface,
|
||||||
mMainHandler,
|
mMainHandler,
|
||||||
|
mMainChoreographer,
|
||||||
mSyncQueue);
|
mSyncQueue);
|
||||||
TaskPositioner taskPositioner = new TaskPositioner(mTaskOrganizer, windowDecoration);
|
TaskPositioner taskPositioner = new TaskPositioner(mTaskOrganizer, windowDecoration);
|
||||||
CaptionTouchEventListener touchEventListener =
|
CaptionTouchEventListener touchEventListener =
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.graphics.drawable.VectorDrawable;
|
import android.graphics.drawable.VectorDrawable;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.view.Choreographer;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.window.WindowContainerTransaction;
|
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);
|
RESIZE_HANDLE_IN_DIP, RESIZE_HANDLE_IN_DIP, RESIZE_HANDLE_IN_DIP, RESIZE_HANDLE_IN_DIP);
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
|
private final Choreographer mChoreographer;
|
||||||
private final SyncTransactionQueue mSyncQueue;
|
private final SyncTransactionQueue mSyncQueue;
|
||||||
|
|
||||||
private View.OnClickListener mOnCaptionButtonClickListener;
|
private View.OnClickListener mOnCaptionButtonClickListener;
|
||||||
@@ -77,10 +79,12 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
|
|||||||
ActivityManager.RunningTaskInfo taskInfo,
|
ActivityManager.RunningTaskInfo taskInfo,
|
||||||
SurfaceControl taskSurface,
|
SurfaceControl taskSurface,
|
||||||
Handler handler,
|
Handler handler,
|
||||||
|
Choreographer choreographer,
|
||||||
SyncTransactionQueue syncQueue) {
|
SyncTransactionQueue syncQueue) {
|
||||||
super(context, displayController, taskOrganizer, taskInfo, taskSurface);
|
super(context, displayController, taskOrganizer, taskInfo, taskSurface);
|
||||||
|
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
|
mChoreographer = choreographer;
|
||||||
mSyncQueue = syncQueue;
|
mSyncQueue = syncQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +142,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
|
|||||||
mDragResizeListener = new DragResizeInputListener(
|
mDragResizeListener = new DragResizeInputListener(
|
||||||
mContext,
|
mContext,
|
||||||
mHandler,
|
mHandler,
|
||||||
|
mChoreographer,
|
||||||
mDisplay.getDisplayId(),
|
mDisplay.getDisplayId(),
|
||||||
mDecorationContainerSurface,
|
mDecorationContainerSurface,
|
||||||
mDragResizeCallback);
|
mDragResizeCallback);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
|
|
||||||
private final IWindowSession mWindowSession = WindowManagerGlobal.getWindowSession();
|
private final IWindowSession mWindowSession = WindowManagerGlobal.getWindowSession();
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
|
private final Choreographer mChoreographer;
|
||||||
private final InputManager mInputManager;
|
private final InputManager mInputManager;
|
||||||
|
|
||||||
private final int mDisplayId;
|
private final int mDisplayId;
|
||||||
@@ -68,11 +69,13 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
DragResizeInputListener(
|
DragResizeInputListener(
|
||||||
Context context,
|
Context context,
|
||||||
Handler handler,
|
Handler handler,
|
||||||
|
Choreographer choreographer,
|
||||||
int displayId,
|
int displayId,
|
||||||
SurfaceControl decorationSurface,
|
SurfaceControl decorationSurface,
|
||||||
DragResizeCallback callback) {
|
DragResizeCallback callback) {
|
||||||
mInputManager = context.getSystemService(InputManager.class);
|
mInputManager = context.getSystemService(InputManager.class);
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
|
mChoreographer = choreographer;
|
||||||
mDisplayId = displayId;
|
mDisplayId = displayId;
|
||||||
mDecorationSurface = decorationSurface;
|
mDecorationSurface = decorationSurface;
|
||||||
// Use a fake window as the backing surface is a container layer and we don't want to create
|
// 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();
|
e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
mInputEventReceiver = new TaskResizeInputEventReceiver(mInputChannel, mHandler);
|
mInputEventReceiver = new TaskResizeInputEventReceiver(
|
||||||
|
mInputChannel, mHandler, mChoreographer);
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,13 +175,10 @@ class DragResizeInputListener implements AutoCloseable {
|
|||||||
private final Runnable mConsumeBatchEventRunnable;
|
private final Runnable mConsumeBatchEventRunnable;
|
||||||
private boolean mConsumeBatchEventScheduled;
|
private boolean mConsumeBatchEventScheduled;
|
||||||
|
|
||||||
private TaskResizeInputEventReceiver(InputChannel inputChannel, Handler handler) {
|
private TaskResizeInputEventReceiver(
|
||||||
|
InputChannel inputChannel, Handler handler, Choreographer choreographer) {
|
||||||
super(inputChannel, handler.getLooper());
|
super(inputChannel, handler.getLooper());
|
||||||
|
mChoreographer = choreographer;
|
||||||
final Choreographer[] choreographer = new Choreographer[1];
|
|
||||||
handler.runWithScissors(
|
|
||||||
() -> choreographer[0] = Choreographer.getInstance(), 0);
|
|
||||||
mChoreographer = choreographer[0];
|
|
||||||
|
|
||||||
mConsumeBatchEventRunnable = () -> {
|
mConsumeBatchEventRunnable = () -> {
|
||||||
mConsumeBatchEventScheduled = false;
|
mConsumeBatchEventScheduled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user