Revert "Revert^2 "Check if all apps are translucent when finishing recents animation.""

This reverts commit 73797f8188.
Also reverts commit I82717747408f5776a50aa239c384f87927b54832

Fixes: 406244612
Fixes: 406238331
Bug: 354627538 (reopening)
Test: opening App Info from Overview mutiple times
      opening App, enter Overview, open Split App Pair
Flag: EXEMPT bugfix
Change-Id: Ief81f826cf17ae9ef369eb97d353ebadda8077e3
This commit is contained in:
Jon Miranda
2025-04-07 16:26:36 -07:00
parent 8899e43c8a
commit a898bfaee4
3 changed files with 10 additions and 71 deletions
@@ -1072,12 +1072,7 @@ public class TaskbarLauncherStateController {
@Override
public void onRecentsAnimationFinished(RecentsAnimationController controller) {
endGestureStateOverride(!controller.getFinishTargetIsLauncher(),
controller.getLauncherIsVisibleAtFinish(), false /*canceled*/);
}
private void endGestureStateOverride(boolean finishedToApp, boolean canceled) {
endGestureStateOverride(finishedToApp, finishedToApp, canceled);
endGestureStateOverride(!controller.getFinishTargetIsLauncher(), false /*canceled*/);
}
/**
@@ -1087,13 +1082,11 @@ public class TaskbarLauncherStateController {
*
* @param finishedToApp {@code true} if the recents animation finished to showing an app and
* not workspace or overview
* @param launcherIsVisible {code true} if launcher is visible at finish
* @param canceled {@code true} if the recents animation was canceled instead of
* finishing
* to completion
*/
private void endGestureStateOverride(boolean finishedToApp, boolean launcherIsVisible,
boolean canceled) {
private void endGestureStateOverride(boolean finishedToApp, boolean canceled) {
mCallbacks.removeListener(this);
mTaskBarRecentsAnimationListener = null;
RecentsView recentsView = mControllers.uiController.getRecentsView();
@@ -1105,27 +1098,18 @@ public class TaskbarLauncherStateController {
mSkipNextRecentsAnimEnd = false;
return;
}
updateStateForUserFinishedToApp(finishedToApp, launcherIsVisible);
updateStateForUserFinishedToApp(finishedToApp);
}
}
/**
* @see #updateStateForUserFinishedToApp(boolean, boolean)
*/
private void updateStateForUserFinishedToApp(boolean finishedToApp) {
updateStateForUserFinishedToApp(finishedToApp, !finishedToApp);
}
/**
* Updates the visible state immediately to ensure a seamless handoff.
*
* @param finishedToApp True iff user is in an app.
* @param launcherIsVisible True iff launcher is still visible (ie. transparent app)
*/
private void updateStateForUserFinishedToApp(boolean finishedToApp,
boolean launcherIsVisible) {
private void updateStateForUserFinishedToApp(boolean finishedToApp) {
// Update the visible state immediately to ensure a seamless handoff
boolean launcherVisible = !finishedToApp || launcherIsVisible;
boolean launcherVisible = !finishedToApp;
updateStateForFlag(FLAG_TRANSITION_TO_VISIBLE, false);
updateStateForFlag(FLAG_VISIBLE, launcherVisible);
applyState();
@@ -1134,7 +1118,7 @@ public class TaskbarLauncherStateController {
if (DEBUG) {
Log.d(TAG, "endGestureStateOverride - FLAG_IN_APP: " + finishedToApp);
}
controller.updateStateForFlag(FLAG_IN_APP, finishedToApp && !launcherIsVisible);
controller.updateStateForFlag(FLAG_IN_APP, finishedToApp);
controller.applyState();
}
@@ -57,8 +57,6 @@ public class RecentsAnimationController {
private boolean mFinishRequested = false;
// Only valid when mFinishRequested == true.
private boolean mFinishTargetIsLauncher;
// Only valid when mFinishRequested == true
private boolean mLauncherIsVisibleAtFinish;
private RunnableList mPendingFinishCallbacks = new RunnableList();
public RecentsAnimationController(RecentsAnimationControllerCompat controller,
@@ -132,28 +130,14 @@ public class RecentsAnimationController {
finishController(toRecents, onFinishComplete, sendUserLeaveHint);
}
@UiThread
public void finish(boolean toRecents, boolean launcherIsVisibleAtFinish,
Runnable onFinishComplete, boolean sendUserLeaveHint) {
Preconditions.assertUIThread();
finishController(toRecents, launcherIsVisibleAtFinish, onFinishComplete, sendUserLeaveHint,
false);
}
@UiThread
public void finishController(boolean toRecents, Runnable callback, boolean sendUserLeaveHint) {
finishController(toRecents, false, callback, sendUserLeaveHint, false /* forceFinish */);
finishController(toRecents, callback, sendUserLeaveHint, false /* forceFinish */);
}
@UiThread
public void finishController(boolean toRecents, Runnable callback, boolean sendUserLeaveHint,
boolean forceFinish) {
finishController(toRecents, toRecents, callback, sendUserLeaveHint, forceFinish);
}
@UiThread
public void finishController(boolean toRecents, boolean launcherIsVisibleAtFinish,
Runnable callback, boolean sendUserLeaveHint, boolean forceFinish) {
mPendingFinishCallbacks.add(callback);
if (!forceFinish && mFinishRequested) {
// If finish has already been requested, then add the callback to the pending list.
@@ -165,7 +149,6 @@ public class RecentsAnimationController {
// Finish not yet requested
mFinishRequested = true;
mFinishTargetIsLauncher = toRecents;
mLauncherIsVisibleAtFinish = launcherIsVisibleAtFinish;
mOnFinishedListener.accept(this);
Runnable finishCb = () -> {
mController.finish(toRecents, sendUserLeaveHint, new IResultReceiver.Stub() {
@@ -242,14 +225,6 @@ public class RecentsAnimationController {
return mFinishTargetIsLauncher;
}
/**
* RecentsAnimationListeners can check this in onRecentsAnimationFinished() to determine whether
* the animation was finished to launcher vs an app.
*/
public boolean getLauncherIsVisibleAtFinish() {
return mLauncherIsVisibleAtFinish;
}
public void dump(String prefix, PrintWriter pw) {
pw.println(prefix + "RecentsAnimationController:");
@@ -1474,8 +1474,7 @@ public abstract class RecentsView<
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
finishRecentsAnimation(false /* toRecents */, true /*shouldPip*/,
allAppsAreTranslucent(apps), null);
finishRecentsAnimation(false /* toRecents */, true /*shouldPip*/, null);
}
});
} else {
@@ -1486,18 +1485,6 @@ public abstract class RecentsView<
anim.start();
}
private boolean allAppsAreTranslucent(RemoteAnimationTarget[] apps) {
if (apps == null) {
return false;
}
for (int i = apps.length - 1; i >= 0; --i) {
if (!apps[i].isTranslucent) {
return false;
}
}
return true;
}
public boolean isTaskViewVisible(TaskView tv) {
if (showAsGrid()) {
int screenStart = getPagedOrientationHandler().getPrimaryScroll(this);
@@ -5973,19 +5960,12 @@ public abstract class RecentsView<
finishRecentsAnimation(toRecents, true /* shouldPip */, onFinishComplete);
}
/**
* Finish recents animation.
*/
public void finishRecentsAnimation(boolean toRecents, boolean shouldPip,
@Nullable Runnable onFinishComplete) {
finishRecentsAnimation(toRecents, shouldPip, false, onFinishComplete);
}
/**
* NOTE: Whatever value gets passed through to the toRecents param may need to also be set on
* {@link #mRecentsAnimationController#setWillFinishToHome}.
*/
public void finishRecentsAnimation(boolean toRecents, boolean shouldPip,
boolean allAppTargetsAreTranslucent, @Nullable Runnable onFinishComplete) {
@Nullable Runnable onFinishComplete) {
Log.d(TAG, "finishRecentsAnimation - mRecentsAnimationController: "
+ mRecentsAnimationController);
// TODO(b/197232424#comment#10) Move this back into onRecentsAnimationComplete(). Maybe?
@@ -6018,7 +5998,7 @@ public abstract class RecentsView<
tx, null /* overlay */);
}
}
mRecentsAnimationController.finish(toRecents, allAppTargetsAreTranslucent, () -> {
mRecentsAnimationController.finish(toRecents, () -> {
if (onFinishComplete != null) {
onFinishComplete.run();
}