Loading quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +37 −21 Original line number Original line Diff line number Diff line Loading @@ -150,6 +150,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, protected Runnable mGestureEndCallback; protected Runnable mGestureEndCallback; protected MultiStateCallback mStateCallback; protected MultiStateCallback mStateCallback; protected boolean mCanceled; protected boolean mCanceled; // One time flag set when onConsumerAboutToBeSwitched() is called, indicating that certain // shared animations should not be canceled when this handler is invalidated private boolean mConsumerIsSwitching; private boolean mRecentsViewScrollLinked = false; private boolean mRecentsViewScrollLinked = false; private static int getFlagForIndex(int index, String name) { private static int getFlagForIndex(int index, String name) { Loading Loading @@ -1002,7 +1005,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity); animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity); } } private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTask) { private int getLogGestureTaskIndex(@Nullable TaskView targetTask) { return mRecentsView == null || targetTask == null ? LOG_NO_OP_PAGE_INDEX : mRecentsView.indexOfChild(targetTask); } private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTask, int pageIndex) { StatsLogManager.EventEnum event; StatsLogManager.EventEnum event; switch (endTarget) { switch (endTarget) { case HOME: case HOME: Loading Loading @@ -1031,9 +1041,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, // We probably never received an animation controller, skip logging. // We probably never received an animation controller, skip logging. return; return; } } int pageIndex = endTarget == LAST_TASK ? LOG_NO_OP_PAGE_INDEX : mRecentsView.getNextPage(); // TODO: set correct container using the pageIndex // TODO: set correct container using the pageIndex logger.log(event); logger.log(event); } } Loading Loading @@ -1278,18 +1285,18 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, } } public void onConsumerAboutToBeSwitched() { public void onConsumerAboutToBeSwitched() { mConsumerIsSwitching = true; if (mActivity != null) { if (mActivity != null) { // In the off chance that the gesture ends before Launcher is started, we should clear // In the off chance that the gesture ends before Launcher is started, we should clear // the callback here so that it doesn't update with the wrong state // the callback here so that it doesn't update with the wrong state mActivity.clearRunOnceOnStartCallback(); mActivity.clearRunOnceOnStartCallback(); resetLauncherListeners(); } } if (mGestureState.getEndTarget() != null && !mGestureState.isRunningAnimationToLauncher()) { if (mGestureState.getEndTarget() != null && !mGestureState.isRunningAnimationToLauncher()) { cancelCurrentAnimation(); cancelCurrentAnimation(); } else { } else { mStateCallback.setStateOnUiThread(STATE_FINISH_WITH_NO_END); mStateCallback.setStateOnUiThread(STATE_FINISH_WITH_NO_END); reset(); } } reset(); } } public boolean isCanceled() { public boolean isCanceled() { Loading @@ -1300,13 +1307,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, private void resumeLastTask() { private void resumeLastTask() { mRecentsAnimationController.finish(false /* toRecents */, null); mRecentsAnimationController.finish(false /* toRecents */, null); ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false); ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false); doLogGesture(LAST_TASK, null); doLogGesture(LAST_TASK, null, getLogGestureTaskIndex(null)); reset(); reset(); } } @UiThread @UiThread private void startNewTask() { private void startNewTask() { TaskView taskToLaunch = mRecentsView == null ? null : mRecentsView.getNextPageTaskView(); TaskView taskToLaunch = mRecentsView == null ? null : mRecentsView.getNextPageTaskView(); int taskPageIndex = getLogGestureTaskIndex(taskToLaunch); startNewTask(success -> { startNewTask(success -> { if (!success) { if (!success) { reset(); reset(); Loading @@ -1315,7 +1323,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, endLauncherTransitionController(); endLauncherTransitionController(); updateSysUiFlags(1 /* windowProgress == overview */); updateSysUiFlags(1 /* windowProgress == overview */); } } doLogGesture(NEW_TASK, taskToLaunch); doLogGesture(NEW_TASK, taskToLaunch, taskPageIndex); }); }); } } Loading Loading @@ -1349,32 +1357,38 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, } } private void invalidateHandler() { private void invalidateHandler() { if (!mConsumerIsSwitching) { if (!LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() if (!LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() || mGestureState.getEndTarget() != RECENTS) { || mGestureState.getEndTarget() != RECENTS) { mInputConsumerProxy.destroy(); mInputConsumerProxy.destroy(); mTaskAnimationManager.setLiveTileCleanUpHandler(null); mTaskAnimationManager.setLiveTileCleanUpHandler(null); } } mInputConsumerProxy.unregisterCallback(); endRunningWindowAnim(false /* cancel */); endRunningWindowAnim(false /* cancel */); if (mGestureEndCallback != null) { if (mGestureEndCallback != null) { mGestureEndCallback.run(); mGestureEndCallback.run(); } } } mInputConsumerProxy.unregisterCallback(); mActivityInitListener.unregister(); mActivityInitListener.unregister(); ActivityManagerWrapper.getInstance().unregisterTaskStackListener(mActivityRestartListener); ActivityManagerWrapper.getInstance().unregisterTaskStackListener(mActivityRestartListener); mTaskSnapshot = null; mTaskSnapshot = null; mHandler.post(() -> { mHandler.post(() -> { // Defer clearing the activity since invalidation can happen over multiple callbacks // Defer clearing the activity since invalidation can happen over multiple callbacks // ie. invalidateHandlerWithLauncher() mActivity = null; mActivity = null; mRecentsView = null; }); }); } } private void invalidateHandlerWithLauncher() { private void invalidateHandlerWithLauncher() { if (!mConsumerIsSwitching) { endLauncherTransitionController(); endLauncherTransitionController(); mRecentsView.onGestureAnimationEnd(); } mRecentsView.removeOnScrollChangedListener(mOnRecentsScrollListener); mRecentsView.removeOnScrollChangedListener(mOnRecentsScrollListener); mRecentsView.onGestureAnimationEnd(); resetLauncherListeners(); resetLauncherListeners(); } } Loading Loading @@ -1499,7 +1513,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); } } ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); doLogGesture(HOME, mRecentsView == null ? null : mRecentsView.getCurrentPageTaskView()); TaskView taskToLaunch = mRecentsView == null ? null : mRecentsView.getCurrentPageTaskView(); doLogGesture(HOME, taskToLaunch, getLogGestureTaskIndex(taskToLaunch)); } } /** /** Loading Loading @@ -1530,7 +1545,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, } } SystemUiProxy.INSTANCE.get(mContext).onOverviewShown(false, TAG); SystemUiProxy.INSTANCE.get(mContext).onOverviewShown(false, TAG); doLogGesture(RECENTS, mRecentsView.getCurrentPageTaskView()); TaskView taskToLaunch = mRecentsView.getCurrentPageTaskView(); doLogGesture(RECENTS, taskToLaunch, getLogGestureTaskIndex(taskToLaunch)); reset(); reset(); } } Loading Loading
quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +37 −21 Original line number Original line Diff line number Diff line Loading @@ -150,6 +150,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, protected Runnable mGestureEndCallback; protected Runnable mGestureEndCallback; protected MultiStateCallback mStateCallback; protected MultiStateCallback mStateCallback; protected boolean mCanceled; protected boolean mCanceled; // One time flag set when onConsumerAboutToBeSwitched() is called, indicating that certain // shared animations should not be canceled when this handler is invalidated private boolean mConsumerIsSwitching; private boolean mRecentsViewScrollLinked = false; private boolean mRecentsViewScrollLinked = false; private static int getFlagForIndex(int index, String name) { private static int getFlagForIndex(int index, String name) { Loading Loading @@ -1002,7 +1005,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity); animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity); } } private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTask) { private int getLogGestureTaskIndex(@Nullable TaskView targetTask) { return mRecentsView == null || targetTask == null ? LOG_NO_OP_PAGE_INDEX : mRecentsView.indexOfChild(targetTask); } private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTask, int pageIndex) { StatsLogManager.EventEnum event; StatsLogManager.EventEnum event; switch (endTarget) { switch (endTarget) { case HOME: case HOME: Loading Loading @@ -1031,9 +1041,6 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, // We probably never received an animation controller, skip logging. // We probably never received an animation controller, skip logging. return; return; } } int pageIndex = endTarget == LAST_TASK ? LOG_NO_OP_PAGE_INDEX : mRecentsView.getNextPage(); // TODO: set correct container using the pageIndex // TODO: set correct container using the pageIndex logger.log(event); logger.log(event); } } Loading Loading @@ -1278,18 +1285,18 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, } } public void onConsumerAboutToBeSwitched() { public void onConsumerAboutToBeSwitched() { mConsumerIsSwitching = true; if (mActivity != null) { if (mActivity != null) { // In the off chance that the gesture ends before Launcher is started, we should clear // In the off chance that the gesture ends before Launcher is started, we should clear // the callback here so that it doesn't update with the wrong state // the callback here so that it doesn't update with the wrong state mActivity.clearRunOnceOnStartCallback(); mActivity.clearRunOnceOnStartCallback(); resetLauncherListeners(); } } if (mGestureState.getEndTarget() != null && !mGestureState.isRunningAnimationToLauncher()) { if (mGestureState.getEndTarget() != null && !mGestureState.isRunningAnimationToLauncher()) { cancelCurrentAnimation(); cancelCurrentAnimation(); } else { } else { mStateCallback.setStateOnUiThread(STATE_FINISH_WITH_NO_END); mStateCallback.setStateOnUiThread(STATE_FINISH_WITH_NO_END); reset(); } } reset(); } } public boolean isCanceled() { public boolean isCanceled() { Loading @@ -1300,13 +1307,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, private void resumeLastTask() { private void resumeLastTask() { mRecentsAnimationController.finish(false /* toRecents */, null); mRecentsAnimationController.finish(false /* toRecents */, null); ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false); ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false); doLogGesture(LAST_TASK, null); doLogGesture(LAST_TASK, null, getLogGestureTaskIndex(null)); reset(); reset(); } } @UiThread @UiThread private void startNewTask() { private void startNewTask() { TaskView taskToLaunch = mRecentsView == null ? null : mRecentsView.getNextPageTaskView(); TaskView taskToLaunch = mRecentsView == null ? null : mRecentsView.getNextPageTaskView(); int taskPageIndex = getLogGestureTaskIndex(taskToLaunch); startNewTask(success -> { startNewTask(success -> { if (!success) { if (!success) { reset(); reset(); Loading @@ -1315,7 +1323,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, endLauncherTransitionController(); endLauncherTransitionController(); updateSysUiFlags(1 /* windowProgress == overview */); updateSysUiFlags(1 /* windowProgress == overview */); } } doLogGesture(NEW_TASK, taskToLaunch); doLogGesture(NEW_TASK, taskToLaunch, taskPageIndex); }); }); } } Loading Loading @@ -1349,32 +1357,38 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, } } private void invalidateHandler() { private void invalidateHandler() { if (!mConsumerIsSwitching) { if (!LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() if (!LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode() || mGestureState.getEndTarget() != RECENTS) { || mGestureState.getEndTarget() != RECENTS) { mInputConsumerProxy.destroy(); mInputConsumerProxy.destroy(); mTaskAnimationManager.setLiveTileCleanUpHandler(null); mTaskAnimationManager.setLiveTileCleanUpHandler(null); } } mInputConsumerProxy.unregisterCallback(); endRunningWindowAnim(false /* cancel */); endRunningWindowAnim(false /* cancel */); if (mGestureEndCallback != null) { if (mGestureEndCallback != null) { mGestureEndCallback.run(); mGestureEndCallback.run(); } } } mInputConsumerProxy.unregisterCallback(); mActivityInitListener.unregister(); mActivityInitListener.unregister(); ActivityManagerWrapper.getInstance().unregisterTaskStackListener(mActivityRestartListener); ActivityManagerWrapper.getInstance().unregisterTaskStackListener(mActivityRestartListener); mTaskSnapshot = null; mTaskSnapshot = null; mHandler.post(() -> { mHandler.post(() -> { // Defer clearing the activity since invalidation can happen over multiple callbacks // Defer clearing the activity since invalidation can happen over multiple callbacks // ie. invalidateHandlerWithLauncher() mActivity = null; mActivity = null; mRecentsView = null; }); }); } } private void invalidateHandlerWithLauncher() { private void invalidateHandlerWithLauncher() { if (!mConsumerIsSwitching) { endLauncherTransitionController(); endLauncherTransitionController(); mRecentsView.onGestureAnimationEnd(); } mRecentsView.removeOnScrollChangedListener(mOnRecentsScrollListener); mRecentsView.removeOnScrollChangedListener(mOnRecentsScrollListener); mRecentsView.onGestureAnimationEnd(); resetLauncherListeners(); resetLauncherListeners(); } } Loading Loading @@ -1499,7 +1513,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); } } ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); doLogGesture(HOME, mRecentsView == null ? null : mRecentsView.getCurrentPageTaskView()); TaskView taskToLaunch = mRecentsView == null ? null : mRecentsView.getCurrentPageTaskView(); doLogGesture(HOME, taskToLaunch, getLogGestureTaskIndex(taskToLaunch)); } } /** /** Loading Loading @@ -1530,7 +1545,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>, } } SystemUiProxy.INSTANCE.get(mContext).onOverviewShown(false, TAG); SystemUiProxy.INSTANCE.get(mContext).onOverviewShown(false, TAG); doLogGesture(RECENTS, mRecentsView.getCurrentPageTaskView()); TaskView taskToLaunch = mRecentsView.getCurrentPageTaskView(); doLogGesture(RECENTS, taskToLaunch, getLogGestureTaskIndex(taskToLaunch)); reset(); reset(); } } Loading