fix: Conflict incoming changes from 15-dev

This commit is contained in:
Pun Butrach committed 2026-01-10 20:49:12 +07:00
1 parent 14e352c827
commit 2e76c99dad
1726 files changed
+146970 -95027

No files matched your search

@@ -18,23 +18,29 @@ package com.android.wm.shell.transition;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.window.DesktopModeFlags.ENABLE_DRAG_TO_DESKTOP_INCOMING_TRANSITIONS_BUGFIX;
import static android.window.TransitionInfo.FLAG_BACK_GESTURE_ANIMATED;
import static com.android.wm.shell.transition.Transitions.TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP;
import static com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_CONVERT_TO_BUBBLE;
import static com.android.wm.shell.transition.Transitions.TransitionObserver;
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.content.Context;
import android.os.IBinder;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.window.TransitionInfo;
import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SingleInstanceRemoteListener;
import com.android.wm.shell.shared.IHomeTransitionListener;
import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.shared.bubbles.BubbleAnythingFlagHelper;
import com.android.wm.shell.sysui.ShellInit;
/**
* The {@link TransitionObserver} that observes for transitions involving the home
@@ -48,10 +54,30 @@ public class HomeTransitionObserver implements TransitionObserver,
private @NonNull final Context mContext;
private @NonNull final ShellExecutor mMainExecutor;
private @NonNull final DisplayInsetsController mDisplayInsetsController;
private IBinder mPendingStartDragTransition;
private Boolean mPendingHomeVisibilityUpdate;
public HomeTransitionObserver(@NonNull Context context,
@NonNull ShellExecutor mainExecutor) {
@NonNull ShellExecutor mainExecutor,
@NonNull DisplayInsetsController displayInsetsController,
@NonNull ShellInit shellInit) {
mContext = context;
mMainExecutor = mainExecutor;
mDisplayInsetsController = displayInsetsController;
shellInit.addInitCallback(this::onInit, this);
}
private void onInit() {
mDisplayInsetsController.addInsetsChangedListener(DEFAULT_DISPLAY,
new DisplayInsetsController.OnInsetsChangedListener() {
@Override
public void insetsChanged(InsetsState insetsState) {
if (mListener == null) return;
mListener.call(l -> l.onDisplayInsetsChanged(insetsState));
}
});
}
@Override
@@ -59,23 +85,72 @@ public class HomeTransitionObserver implements TransitionObserver,
@NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction startTransaction,
@NonNull SurfaceControl.Transaction finishTransaction) {
Boolean homeVisibilityUpdate = getHomeVisibilityUpdate(info);
if (info.getType() == TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP) {
// Do not apply at the start of desktop drag as that updates launcher UI visibility.
// Store the value and apply with a next transition or when cancelling the
// desktop-drag transition.
storePendingHomeVisibilityUpdate(transition, homeVisibilityUpdate);
return;
}
if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()
&& info.getType() == TRANSIT_CONVERT_TO_BUBBLE
&& homeVisibilityUpdate == null) {
// We are converting to bubble and we did not get a change to home visibility in this
// transition. Apply the value from start of drag.
homeVisibilityUpdate = mPendingHomeVisibilityUpdate;
}
if (homeVisibilityUpdate != null) {
mPendingHomeVisibilityUpdate = null;
mPendingStartDragTransition = null;
notifyHomeVisibilityChanged(homeVisibilityUpdate);
}
}
private void storePendingHomeVisibilityUpdate(
IBinder transition, Boolean homeVisibilityUpdate) {
if (!BubbleAnythingFlagHelper.enableBubbleToFullscreen()
&& !ENABLE_DRAG_TO_DESKTOP_INCOMING_TRANSITIONS_BUGFIX.isTrue()) {
return;
}
mPendingHomeVisibilityUpdate = homeVisibilityUpdate;
mPendingStartDragTransition = transition;
}
private Boolean getHomeVisibilityUpdate(TransitionInfo info) {
Boolean homeVisibilityUpdate = null;
for (TransitionInfo.Change change : info.getChanges()) {
final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
if (info.getType() == TRANSIT_DESKTOP_MODE_START_DRAG_TO_DESKTOP
|| taskInfo == null
if (taskInfo == null
|| taskInfo.displayId != DEFAULT_DISPLAY
|| taskInfo.taskId == -1
|| !taskInfo.isRunning) {
continue;
}
final int mode = change.getMode();
final boolean isBackGesture = change.hasFlags(FLAG_BACK_GESTURE_ANIMATED);
if (taskInfo.getActivityType() == ACTIVITY_TYPE_HOME
&& (TransitionUtil.isOpenOrCloseMode(mode) || isBackGesture)) {
notifyHomeVisibilityChanged(TransitionUtil.isOpeningType(mode) || isBackGesture);
Boolean update = getHomeVisibilityUpdate(info, change, taskInfo);
if (update != null) {
homeVisibilityUpdate = update;
}
}
return homeVisibilityUpdate;
}
private Boolean getHomeVisibilityUpdate(TransitionInfo info,
TransitionInfo.Change change, ActivityManager.RunningTaskInfo taskInfo) {
final int mode = change.getMode();
final boolean isBackGesture = change.hasFlags(FLAG_BACK_GESTURE_ANIMATED);
if (taskInfo.getActivityType() == ACTIVITY_TYPE_HOME) {
final boolean gestureToHomeTransition = isBackGesture
&& TransitionUtil.isClosingType(info.getType());
if (gestureToHomeTransition || TransitionUtil.isClosingMode(mode)
|| (!isBackGesture && TransitionUtil.isOpeningMode(mode))) {
return gestureToHomeTransition || TransitionUtil.isOpeningType(mode);
}
}
return null;
}
@Override
@@ -87,7 +162,23 @@ public class HomeTransitionObserver implements TransitionObserver,
@Override
public void onTransitionFinished(@NonNull IBinder transition,
boolean aborted) {}
boolean aborted) {
if (!ENABLE_DRAG_TO_DESKTOP_INCOMING_TRANSITIONS_BUGFIX.isTrue()) {
return;
}
// Handle the case where the DragToDesktop START transition is interrupted and we never
// receive a CANCEL/END transition.
if (mPendingStartDragTransition == null
|| mPendingStartDragTransition != transition) {
return;
}
mPendingStartDragTransition = null;
if (mPendingHomeVisibilityUpdate != null) {
notifyHomeVisibilityChanged(mPendingHomeVisibilityUpdate);
mPendingHomeVisibilityUpdate = null;
}
}
/**
* Sets the home transition listener that receives any transitions resulting in a change of