Merge branch 'heads/android-14.0.0_r18' into 14-dev

This commit is contained in:
MrSluffy committed 2023-12-16 17:18:13 +08:00
1 parent 32700b0100
commit cc8f9828ab
756 files changed
+23785 -12235

No files matched your search

@@ -58,7 +58,8 @@ import java.util.HashMap;
import java.util.StringJoiner;
/**
* Track LauncherState, RecentsAnimation, resumed state for task bar in one place here and animate
* Track LauncherState, RecentsAnimation, resumed state for task bar in one
* place here and animate
* the task bar accordingly.
*/
public class TaskbarLauncherStateController {
@@ -70,12 +71,14 @@ public class TaskbarLauncherStateController {
public static final int FLAG_RESUMED = 1 << 0;
/**
* A external transition / animation is running that will result in FLAG_RESUMED being set.
* A external transition / animation is running that will result in FLAG_RESUMED
* being set.
**/
public static final int FLAG_TRANSITION_TO_RESUMED = 1 << 1;
/**
* Set while the launcher state machine is performing a state transition, see {@link
* Set while the launcher state machine is performing a state transition, see
* {@link
* StateManager.StateListener}.
*/
public static final int FLAG_LAUNCHER_IN_STATE_TRANSITION = 1 << 2;
@@ -88,11 +91,14 @@ public class TaskbarLauncherStateController {
private static final int FLAG_AWAKE = 1 << 3;
/**
* Captures whether the launcher was active at the time the FLAG_AWAKE was cleared.
* Captures whether the launcher was active at the time the FLAG_AWAKE was
* cleared.
* Always cleared when FLAG_AWAKE is set.
* <p>
* FLAG_RESUMED will be cleared when the device is asleep, since all apps get paused at this
* point. Thus, this flag indicates whether the launcher will be shown when the device wakes up
* FLAG_RESUMED will be cleared when the device is asleep, since all apps get
* paused at this
* point. Thus, this flag indicates whether the launcher will be shown when the
* device wakes up
* again.
*/
private static final int FLAG_LAUNCHER_WAS_ACTIVE_WHILE_AWAKE = 1 << 4;
@@ -100,18 +106,23 @@ public class TaskbarLauncherStateController {
/**
* Whether the device is currently locked.
* <ul>
* <li>While locked, the taskbar is always stashed.<li/>
* <li>Navbar animations on FLAG_DEVICE_LOCKED transitions will get special treatment.</li>
* <li>While locked, the taskbar is always stashed.
* <li/>
* <li>Navbar animations on FLAG_DEVICE_LOCKED transitions will get special
* treatment.</li>
* </ul>
*/
private static final int FLAG_DEVICE_LOCKED = 1 << 5;
/**
* Whether the complete taskbar is completely hidden (neither visible stashed or unstashed).
* This is tracked to allow a nice transition of the taskbar before SysUI forces it away by
* Whether the complete taskbar is completely hidden (neither visible stashed or
* unstashed).
* This is tracked to allow a nice transition of the taskbar before SysUI forces
* it away by
* hiding the inset.
*
* This flag is predominanlty set while FLAG_DEVICE_LOCKED is set, thus the taskbar's invisible
* This flag is predominanlty set while FLAG_DEVICE_LOCKED is set, thus the
* taskbar's invisible
* resting state while hidden is stashed.
*/
private static final int FLAG_TASKBAR_HIDDEN = 1 << 6;
@@ -127,14 +138,15 @@ public class TaskbarLauncherStateController {
/**
* Delay for the taskbar fade-in.
*
* Helps to avoid visual noise when unlocking successfully via SFPS, and the device transitions
* to launcher directly. The delay avoids the navbar to become briefly visible. The duration
* Helps to avoid visual noise when unlocking successfully via SFPS, and the
* device transitions
* to launcher directly. The delay avoids the navbar to become briefly visible.
* The duration
* is the same as in SysUI, see http://shortn/_uNSbDoRUSr.
*/
private static final long TASKBAR_SHOW_DELAY_MS = 250;
private final AnimatedFloat mIconAlignment =
new AnimatedFloat(this::onIconAlignmentRatioChanged);
private final AnimatedFloat mIconAlignment = new AnimatedFloat(this::onIconAlignmentRatioChanged);
private TaskbarControllers mControllers;
private AnimatedFloat mTaskbarBackgroundAlpha;
@@ -147,7 +159,8 @@ public class TaskbarLauncherStateController {
private int mState;
private LauncherState mLauncherState = LauncherState.NORMAL;
// Time when FLAG_TASKBAR_HIDDEN was last cleared, SystemClock.elapsedRealtime (milliseconds).
// Time when FLAG_TASKBAR_HIDDEN was last cleared, SystemClock.elapsedRealtime
// (milliseconds).
private long mLastUnlockTimeMs = 0;
private @Nullable TaskBarRecentsAnimationListener mTaskBarRecentsAnimationListener;
@@ -161,61 +174,62 @@ public class TaskbarLauncherStateController {
private boolean mIsQsbInline;
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
new DeviceProfile.OnDeviceProfileChangeListener() {
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
if (mIsQsbInline && !dp.isQsbInline) {
// We only modify QSB alpha if isQsbInline = true. If we switch to a DP
// where isQsbInline = false, then we need to reset the alpha.
mLauncher.getHotseat().setQsbAlpha(1f);
}
mIsQsbInline = dp.isQsbInline;
TaskbarLauncherStateController.this.updateIconAlphaForHome(
mIconAlphaForHome.getValue());
}
};
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener = new DeviceProfile.OnDeviceProfileChangeListener() {
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
if (mIsQsbInline && !dp.isQsbInline) {
// We only modify QSB alpha if isQsbInline = true. If we switch to a DP
// where isQsbInline = false, then we need to reset the alpha.
mLauncher.getHotseat().setQsbAlpha(1f);
}
mIsQsbInline = dp.isQsbInline;
TaskbarLauncherStateController.this.updateIconAlphaForHome(
mIconAlphaForHome.getValue());
}
};
private final StateManager.StateListener<LauncherState> mStateListener =
new StateManager.StateListener<LauncherState>() {
private final StateManager.StateListener<LauncherState> mStateListener = new StateManager.StateListener<LauncherState>() {
@Override
public void onStateTransitionStart(LauncherState toState) {
if (toState != mLauncherState) {
// Treat FLAG_LAUNCHER_IN_STATE_TRANSITION as a changed flag even if a
// previous state transition was already running, so we update the new
// target.
mPrevState &= ~FLAG_LAUNCHER_IN_STATE_TRANSITION;
mLauncherState = toState;
}
updateStateForFlag(FLAG_LAUNCHER_IN_STATE_TRANSITION, true);
if (!mShouldDelayLauncherStateAnim) {
if (toState == LauncherState.NORMAL) {
applyState(QuickstepTransitionManager.TASKBAR_TO_HOME_DURATION);
} else {
applyState();
}
}
}
@Override
public void onStateTransitionComplete(LauncherState finalState) {
mLauncherState = finalState;
updateStateForFlag(FLAG_LAUNCHER_IN_STATE_TRANSITION, false);
// TODO(b/279514548) Cleans up bad state that can occur when user interacts with
// taskbar on top of transparent activity.
if (finalState == LauncherState.NORMAL && mLauncher.isResumed()) {
updateStateForFlag(FLAG_RESUMED, true);
}
@Override
public void onStateTransitionStart(LauncherState toState) {
if (toState != mLauncherState) {
// Treat FLAG_LAUNCHER_IN_STATE_TRANSITION as a changed flag even if a
// previous state transition was already running, so we update the new
// target.
mPrevState &= ~FLAG_LAUNCHER_IN_STATE_TRANSITION;
mLauncherState = toState;
}
updateStateForFlag(FLAG_LAUNCHER_IN_STATE_TRANSITION, true);
if (!mShouldDelayLauncherStateAnim) {
if (toState == LauncherState.NORMAL) {
applyState(QuickstepTransitionManager.TASKBAR_TO_HOME_DURATION);
} else {
applyState();
boolean disallowLongClick = finalState == LauncherState.OVERVIEW_SPLIT_SELECT;
com.android.launcher3.taskbar.Utilities.setOverviewDragState(
mControllers, finalState.disallowTaskbarGlobalDrag(),
disallowLongClick, finalState.allowTaskbarInitialSplitSelection());
}
};
}
}
/** Initializes the controller instance, and applies the initial state immediately. */
@Override
public void onStateTransitionComplete(LauncherState finalState) {
mLauncherState = finalState;
updateStateForFlag(FLAG_LAUNCHER_IN_STATE_TRANSITION, false);
// TODO(b/279514548) Cleans up bad state that can occur when user interacts with
// taskbar on top of transparent activity.
if (finalState == LauncherState.NORMAL && mLauncher.hasBeenResumed()) {
updateStateForFlag(FLAG_RESUMED, true);
}
applyState();
boolean disallowLongClick = finalState == LauncherState.OVERVIEW_SPLIT_SELECT;
com.android.launcher3.taskbar.Utilities.setOverviewDragState(
mControllers, finalState.disallowTaskbarGlobalDrag(),
disallowLongClick, finalState.allowTaskbarInitialSplitSelection());
}
};
/**
* Initializes the controller instance, and applies the initial state
* immediately.
*/
public void init(TaskbarControllers controllers, QuickstepLauncher launcher,
int sysuiStateFlags) {
mCanSyncViews = false;
@@ -236,7 +250,7 @@ public class TaskbarLauncherStateController {
mLauncher.getStateManager().addStateListener(mStateListener);
mLauncherState = launcher.getStateManager().getState();
updateStateForSysuiFlags(sysuiStateFlags, /*applyState*/ false);
updateStateForSysuiFlags(sysuiStateFlags, /* applyState */ false);
applyState(0);
@@ -249,7 +263,6 @@ public class TaskbarLauncherStateController {
mIconAlignment.finishAnimation();
Log.d("b/260135164", "onDestroy - updateIconAlphaForHome(1)");
mLauncher.getHotseat().setIconsAlpha(1f);
mLauncher.getStateManager().removeStateListener(mStateListener);
@@ -260,7 +273,8 @@ public class TaskbarLauncherStateController {
/**
* Creates a transition animation to the launcher activity.
*
* Warning: the resulting animation must be played, since this method has side effects on this
* Warning: the resulting animation must be played, since this method has side
* effects on this
* controller's state.
*/
public Animator createAnimToLauncher(@NonNull LauncherState toState,
@@ -269,7 +283,8 @@ public class TaskbarLauncherStateController {
// If going home, align the icons to hotseat
AnimatorSet animatorSet = new AnimatorSet();
// Update stashed flags first to ensure goingToUnstashedLauncherState() returns correctly.
// Update stashed flags first to ensure goingToUnstashedLauncherState() returns
// correctly.
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
toState.isTaskbarStashed(mLauncher));
@@ -288,8 +303,8 @@ public class TaskbarLauncherStateController {
}
mTaskBarRecentsAnimationListener = new TaskBarRecentsAnimationListener(callbacks);
callbacks.addListener(mTaskBarRecentsAnimationListener);
((RecentsView) mLauncher.getOverviewPanel()).setTaskLaunchListener(() ->
mTaskBarRecentsAnimationListener.endGestureStateOverride(true));
((RecentsView) mLauncher.getOverviewPanel())
.setTaskLaunchListener(() -> mTaskBarRecentsAnimationListener.endGestureStateOverride(true));
return animatorSet;
}
@@ -299,7 +314,8 @@ public class TaskbarLauncherStateController {
public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) {
if (!shouldDelayLauncherStateAnim && mShouldDelayLauncherStateAnim) {
// Animate the animation we have delayed immediately. This is usually triggered when
// Animate the animation we have delayed immediately. This is usually triggered
// when
// the user has released their finger.
applyState();
}
@@ -311,7 +327,7 @@ public class TaskbarLauncherStateController {
updateStateForSysuiFlags(systemUiStateFlags, /* applyState */ true);
}
private void updateStateForSysuiFlags(int systemUiStateFlags, boolean applyState) {
private void updateStateForSysuiFlags(int systemUiStateFlags, boolean applyState) {
final boolean prevIsAwake = hasAnyFlag(FLAG_AWAKE);
final boolean currIsAwake = hasAnyFlag(systemUiStateFlags, SYSUI_STATE_AWAKE);
@@ -326,10 +342,14 @@ public class TaskbarLauncherStateController {
boolean isDeviceLocked = hasAnyFlag(systemUiStateFlags, MASK_ANY_SYSUI_LOCKED);
updateStateForFlag(FLAG_DEVICE_LOCKED, isDeviceLocked);
// Taskbar is hidden whenever the device is dreaming. The dreaming state includes the
// interactive dreams, AoD, screen off. Since the SYSUI_STATE_DEVICE_DREAMING only kicks in
// when the device is asleep, the second condition extends ensures that the transition from
// and to the WAKEFULNESS_ASLEEP state also hide the taskbar, and improves the taskbar
// Taskbar is hidden whenever the device is dreaming. The dreaming state
// includes the
// interactive dreams, AoD, screen off. Since the SYSUI_STATE_DEVICE_DREAMING
// only kicks in
// when the device is asleep, the second condition extends ensures that the
// transition from
// and to the WAKEFULNESS_ASLEEP state also hide the taskbar, and improves the
// taskbar
// hide/reveal animation timings.
boolean isTaskbarHidden = hasAnyFlag(systemUiStateFlags, SYSUI_STATE_DEVICE_DREAMING)
|| (systemUiStateFlags & SYSUI_STATE_WAKEFULNESS_MASK) != WAKEFULNESS_AWAKE;
@@ -343,7 +363,8 @@ public class TaskbarLauncherStateController {
/**
* Updates the proper flag to change the state of the task bar.
*
* Note that this only updates the flag. {@link #applyState()} needs to be called separately.
* Note that this only updates the flag. {@link #applyState()} needs to be
* called separately.
*
* @param flag The flag to update.
* @param enabled Whether to enable the flag
@@ -409,6 +430,14 @@ public class TaskbarLauncherStateController {
+ ", mLauncherState: " + mLauncherState
+ ", toAlignment: " + toAlignment);
}
mControllers.bubbleControllers.ifPresent(controllers -> {
// Show the bubble bar when on launcher home or in overview.
boolean onHome = isInLauncher && mLauncherState == LauncherState.NORMAL;
boolean onOverview = mLauncherState == LauncherState.OVERVIEW;
controllers.bubbleStashController.setBubblesShowingOnHome(onHome);
controllers.bubbleStashController.setBubblesShowingOnOverview(onOverview);
});
AnimatorSet animatorSet = new AnimatorSet();
if (hasAnyFlag(changedFlags, FLAG_LAUNCHER_IN_STATE_TRANSITION)) {
@@ -426,7 +455,8 @@ public class TaskbarLauncherStateController {
handleOpenFloatingViews = true;
}
if (mLauncherState == LauncherState.OVERVIEW) {
// Calling to update the insets in TaskbarInsetController#updateInsetsTouchability
// Calling to update the insets in
// TaskbarInsetController#updateInsetsTouchability
mControllers.taskbarActivityContext.notifyUpdateLayoutParams();
}
}
@@ -437,8 +467,7 @@ public class TaskbarLauncherStateController {
public void onAnimationStart(Animator animation) {
mIsAnimatingToLauncher = isInLauncher;
TaskbarStashController stashController =
mControllers.taskbarStashController;
TaskbarStashController stashController = mControllers.taskbarStashController;
if (DEBUG) {
Log.d(TAG, "onAnimationStart - FLAG_IN_APP: " + !isInLauncher);
}
@@ -477,13 +506,14 @@ public class TaskbarLauncherStateController {
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
TaskbarStashController stashController =
mControllers.taskbarStashController;
stashController.updateAndAnimateTransientTaskbar(/* stash */ true);
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateAndAnimateTransientTaskbar(
/* stash */ true, /* bubblesShouldFollow */ true);
}
});
} else {
// delay the fade in animation a bit to reduce visual noise when waking up a device
// delay the fade in animation a bit to reduce visual noise when waking up a
// device
// with a fingerprint reader. This should only be done when the device was woken
// up via fingerprint reader, however since this information is currently not
// available, opting to always delay the fade-in a bit.
@@ -511,7 +541,8 @@ public class TaskbarLauncherStateController {
boolean isInLauncherIconIsAligned = isInLauncher && isIconAlignedWithHotseat;
float startDelay = 0;
// We want to delay the background from fading in so that the icons have time to move
// We want to delay the background from fading in so that the icons have time to
// move
// into the bounds of the background before it appears.
if (isInLauncherIconNotAligned) {
startDelay = duration * TASKBAR_BG_ALPHA_LAUNCHER_NOT_ALIGNED_DELAY_MULT;
@@ -547,13 +578,14 @@ public class TaskbarLauncherStateController {
// Keep isUnlockTransition in sync with its counterpart in
// TaskbarStashController#createAnimToIsStashed.
boolean isUnlockTransition =
hasAnyFlag(changedFlags, FLAG_DEVICE_LOCKED) && !hasAnyFlag(FLAG_DEVICE_LOCKED);
boolean isUnlockTransition = hasAnyFlag(changedFlags, FLAG_DEVICE_LOCKED) && !hasAnyFlag(FLAG_DEVICE_LOCKED);
if (isUnlockTransition) {
// When transitioning to unlocked, ensure the hotseat is fully visible from the
// beginning. The hotseat itself is animated by LauncherUnlockAnimationController.
// beginning. The hotseat itself is animated by
// LauncherUnlockAnimationController.
mIconAlignment.cancelAnimation();
// updateValue ensures onIconAlignmentRatioChanged will be called if there is an actual
// updateValue ensures onIconAlignmentRatioChanged will be called if there is an
// actual
// change in value
mIconAlignment.updateValue(toAlignment);
@@ -589,9 +621,11 @@ public class TaskbarLauncherStateController {
}
/**
* Whether the taskbar is aligned with the hotseat in the current/target launcher state.
* Whether the taskbar is aligned with the hotseat in the current/target
* launcher state.
*
* This refers to the intended state - a transition to this state might be in progress.
* This refers to the intended state - a transition to this state might be in
* progress.
*/
public boolean isTaskbarAlignedWithHotseat() {
return mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
@@ -605,8 +639,7 @@ public class TaskbarLauncherStateController {
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
boolean willStashVisually = isInStashedState
&& mControllers.taskbarStashController.supportsVisualStashing();
boolean isTaskbarAlignedWithHotseat =
mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
boolean isTaskbarAlignedWithHotseat = mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
return isTaskbarAlignedWithHotseat && !willStashVisually;
} else {
return false;
@@ -636,8 +669,6 @@ public class TaskbarLauncherStateController {
public void onAnimationEnd(Animator animation) {
if (isInStashedState && committed) {
// Reset hotseat alpha to default
Log.d("b/260135164",
"playStateTransitionAnim#onAnimationEnd - setIconsAlpha(1)");
mLauncher.getHotseat().setIconsAlpha(1);
}
}
@@ -652,9 +683,12 @@ public class TaskbarLauncherStateController {
animatorSet.play(stashAnimator);
}
// Translate back to 0 at a shorter or same duration as the icon alignment animation.
// This ensures there is no jump after switching to hotseat, e.g. when swiping up from
// overview to home. When not in app, we do duration / 2 just to make it feel snappier.
// Translate back to 0 at a shorter or same duration as the icon alignment
// animation.
// This ensures there is no jump after switching to hotseat, e.g. when swiping
// up from
// overview to home. When not in app, we do duration / 2 just to make it feel
// snappier.
long resetDuration = mControllers.taskbarStashController.isInApp()
? duration
: duration / 2;
@@ -705,21 +739,16 @@ public class TaskbarLauncherStateController {
private void updateIconAlphaForHome(float alpha) {
if (mControllers.taskbarActivityContext.isDestroyed()) {
Log.e("b/260135164", "updateIconAlphaForHome is called after Taskbar is destroyed",
new Exception());
return;
}
mIconAlphaForHome.setValue(alpha);
boolean hotseatVisible = alpha == 0
|| (!mControllers.uiController.isHotseatIconOnTopWhenAligned()
&& mIconAlignment.value > 0);
&& mIconAlignment.value > 0);
/*
* Hide Launcher Hotseat icons when Taskbar icons have opacity. Both icon sets
* should not be visible at the same time.
*/
Log.d("b/260135164",
"updateIconAlphaForHome - setIconsAlpha(" + (hotseatVisible ? 1 : 0)
+ "), isTaskbarPresent: " + mLauncher.getDeviceProfile().isTaskbarPresent);
mLauncher.getHotseat().setIconsAlpha(hotseatVisible ? 1 : 0);
if (mIsQsbInline) {
mLauncher.getHotseat().setQsbAlpha(hotseatVisible ? 1 : 0);