mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Merge "Prevent adding duplicate TaskAnimationManager launcher destroyed callbacks" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
27312fa26d
@@ -16,6 +16,7 @@
|
||||
package com.android.quickstep;
|
||||
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
@@ -26,7 +27,6 @@ import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_INITIAL
|
||||
import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_STARTED;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityOptions;
|
||||
@@ -86,6 +86,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
private boolean mShouldIgnoreMotionEvents = false;
|
||||
private final int mDisplayId;
|
||||
|
||||
private boolean mLauncherDestroyCallbackSet = false;
|
||||
|
||||
public static final DaggerSingletonObject<PerDisplayRepository<TaskAnimationManager>>
|
||||
REPOSITORY_INSTANCE = new DaggerSingletonObject<>(
|
||||
QuickstepBaseAppComponent::getTaskAnimationManagerRepository);
|
||||
@@ -180,6 +182,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
RecentsAnimationCallbacks newCallbacks = new RecentsAnimationCallbacks(
|
||||
containerInterface.getCreatedContainer());
|
||||
mCallbacks = newCallbacks;
|
||||
mLauncherDestroyCallbackSet = false;
|
||||
mCallbacks.addListener(new RecentsAnimationCallbacks.RecentsAnimationListener() {
|
||||
@Override
|
||||
public void onRecentsAnimationStart(RecentsAnimationController controller,
|
||||
@@ -509,7 +512,11 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
if (mCallbacks == null) {
|
||||
return;
|
||||
}
|
||||
if (mLauncherDestroyCallbackSet) {
|
||||
return;
|
||||
}
|
||||
ActiveGestureProtoLogProxy.logQueuingForceFinishRecentsAnimation();
|
||||
mLauncherDestroyCallbackSet = true;
|
||||
mCallbacks.addListener(new RecentsAnimationCallbacks.RecentsAnimationListener() {
|
||||
@Override
|
||||
public void onRecentsAnimationStart(
|
||||
@@ -521,6 +528,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
/* forceFinish= */ true,
|
||||
/* forceFinishCb= */ null,
|
||||
controller);
|
||||
mLauncherDestroyCallbackSet = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -552,6 +560,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn
|
||||
|
||||
mController = null;
|
||||
mCallbacks = null;
|
||||
mLauncherDestroyCallbackSet = false;
|
||||
mTargets = null;
|
||||
mTransitionInfo = null;
|
||||
mLastGestureState = null;
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package com.android.quickstep;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
@@ -148,6 +146,10 @@ public class TaskAnimationManagerTest {
|
||||
gestureState,
|
||||
new Intent(),
|
||||
mock(RecentsAnimationCallbacks.RecentsAnimationListener.class));
|
||||
|
||||
// Simulate multiple launcher destroyed events before the recents animation start
|
||||
mTaskAnimationManager.onLauncherDestroyed();
|
||||
mTaskAnimationManager.onLauncherDestroyed();
|
||||
mTaskAnimationManager.onLauncherDestroyed();
|
||||
listenerCaptor.getValue().onAnimationStart(
|
||||
controllerCompat,
|
||||
@@ -158,6 +160,8 @@ public class TaskAnimationManagerTest {
|
||||
new Bundle(),
|
||||
new TransitionInfo(0, 0));
|
||||
});
|
||||
|
||||
// Verify checks that finish was only called once
|
||||
runOnMainSync(() -> verify(controllerCompat)
|
||||
.finish(/* toHome= */ eq(false), anyBoolean(), any()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user