Merge "Use SysUI/Shell's transaction apply token in Launcher"

This commit is contained in:
Evan Rosky
2022-08-24 15:02:47 +00:00
committed by Android (Google) Code Review
2 changed files with 53 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ import static com.android.launcher3.statehandlers.DepthController.DEPTH;
import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.launcher3.views.FloatingIconView.getFloatingIconView;
import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS;
import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
import static com.android.systemui.shared.system.QuickStepContract.getWindowCornerRadius;
import static com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows;
@@ -1119,6 +1120,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
* Registers remote animations used when closing apps to home screen.
*/
public void registerRemoteTransitions() {
if (ENABLE_SHELL_TRANSITIONS) {
SystemUiProxy.INSTANCE.get(mLauncher).shareTransactionQueue();
}
if (SEPARATE_RECENTS_ACTIVITY.get()) {
return;
}
@@ -1158,6 +1162,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
}
private void unregisterRemoteTransitions() {
if (ENABLE_SHELL_TRANSITIONS) {
SystemUiProxy.INSTANCE.get(mLauncher).unshareTransactionQueue();
}
if (SEPARATE_RECENTS_ACTIVITY.get()) {
return;
}

View File

@@ -28,7 +28,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Insets;
import android.graphics.Rect;
import android.os.Bundle;
@@ -101,6 +100,7 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
private ILauncherUnlockAnimationController mLauncherUnlockAnimationController;
private IRecentTasksListener mRecentTasksListener;
private final ArrayList<RemoteTransitionCompat> mRemoteTransitions = new ArrayList<>();
private IBinder mOriginalTransactionToken = null;
private IOnBackInvokedCallback mBackToLauncherCallback;
// Used to dedupe calls to SystemUI
@@ -199,6 +199,7 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
for (int i = mRemoteTransitions.size() - 1; i >= 0; --i) {
registerRemoteTransition(mRemoteTransitions.get(i));
}
setupTransactionQueue();
if (mRecentTasksListener != null && mRecentTasks != null) {
registerRecentTasksListener(mRecentTasksListener);
}
@@ -721,6 +722,50 @@ public class SystemUiProxy implements ISystemUiProxy, DisplayController.DisplayI
mRemoteTransitions.remove(remoteTransition);
}
/**
* Use SystemUI's transaction-queue instead of Launcher's independent one. This is necessary
* if Launcher and SystemUI need to coordinate transactions (eg. for shell transitions).
*/
public void shareTransactionQueue() {
if (mOriginalTransactionToken == null) {
mOriginalTransactionToken = SurfaceControl.Transaction.getDefaultApplyToken();
}
setupTransactionQueue();
}
/**
* Switch back to using Launcher's independent transaction queue.
*/
public void unshareTransactionQueue() {
if (mOriginalTransactionToken == null) {
return;
}
SurfaceControl.Transaction.setDefaultApplyToken(mOriginalTransactionToken);
mOriginalTransactionToken = null;
}
private void setupTransactionQueue() {
if (mOriginalTransactionToken == null) {
return;
}
if (mShellTransitions == null) {
SurfaceControl.Transaction.setDefaultApplyToken(mOriginalTransactionToken);
return;
}
final IBinder shellApplyToken;
try {
shellApplyToken = mShellTransitions.getShellApplyToken();
} catch (RemoteException e) {
Log.e(TAG, "Error getting Shell's apply token", e);
return;
}
if (shellApplyToken == null) {
Log.e(TAG, "Didn't receive apply token from Shell");
return;
}
SurfaceControl.Transaction.setDefaultApplyToken(shellApplyToken);
}
//
// Starting window
//