Merge "Fix the blank PiP window when unlock" into tm-dev
This commit is contained in:
@@ -43,11 +43,6 @@ public interface Pip {
|
||||
default void expandPip() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the PIP menu.
|
||||
*/
|
||||
default void hidePipMenu(Runnable onStartCallback, Runnable onEndCallback) {}
|
||||
|
||||
/**
|
||||
* Called when configuration is changed.
|
||||
*/
|
||||
@@ -124,6 +119,23 @@ public interface Pip {
|
||||
*/
|
||||
default void removePipExclusionBoundsChangeListener(Consumer<Rect> listener) { }
|
||||
|
||||
/**
|
||||
* Called when the visibility of keyguard is changed.
|
||||
* @param showing {@code true} if keyguard is now showing, {@code false} otherwise.
|
||||
* @param animating {@code true} if system is animating between keyguard and surface behind,
|
||||
* this only makes sense when showing is {@code false}.
|
||||
*/
|
||||
default void onKeyguardVisibilityChanged(boolean showing, boolean animating) { }
|
||||
|
||||
/**
|
||||
* Called when the dismissing animation keyguard and surfaces behind is finished.
|
||||
* See also {@link #onKeyguardVisibilityChanged(boolean, boolean)}.
|
||||
*
|
||||
* TODO(b/206741900) deprecate this path once we're able to animate the PiP window as part of
|
||||
* keyguard dismiss animation.
|
||||
*/
|
||||
default void onKeyguardDismissAnimationFinished() { }
|
||||
|
||||
/**
|
||||
* Dump the current state and information if need.
|
||||
*
|
||||
|
||||
@@ -965,6 +965,17 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
||||
mDeferredAnimEndTransaction = null;
|
||||
}
|
||||
|
||||
/** Explicitly set the visibility of PiP window. */
|
||||
public void setPipVisibility(boolean visible) {
|
||||
if (!isInPip()) {
|
||||
return;
|
||||
}
|
||||
final SurfaceControl.Transaction tx =
|
||||
mSurfaceControlTransactionFactory.getTransaction();
|
||||
mSurfaceTransactionHelper.alpha(tx, mLeash, visible ? 1f : 0f);
|
||||
tx.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
|
||||
mCurrentRotation = newConfig.windowConfiguration.getRotation();
|
||||
|
||||
@@ -129,6 +129,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
protected PinnedStackListenerForwarder.PinnedTaskListener mPinnedTaskListener =
|
||||
new PipControllerPinnedTaskListener();
|
||||
|
||||
private boolean mIsKeyguardShowingOrAnimating;
|
||||
|
||||
private interface PipAnimationListener {
|
||||
/**
|
||||
* Notifies the listener that the Pip animation is started.
|
||||
@@ -592,6 +594,33 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
mTouchHandler.showPictureInPictureMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* If {@param keyguardShowing} is {@code false} and {@param animating} is {@code true},
|
||||
* we would wait till the dismissing animation of keyguard and surfaces behind to be
|
||||
* finished first to reset the visibility of PiP window.
|
||||
* See also {@link #onKeyguardDismissAnimationFinished()}
|
||||
*/
|
||||
private void onKeyguardVisibilityChanged(boolean keyguardShowing, boolean animating) {
|
||||
if (!mPipTaskOrganizer.isInPip()) {
|
||||
return;
|
||||
}
|
||||
if (keyguardShowing) {
|
||||
mIsKeyguardShowingOrAnimating = true;
|
||||
hidePipMenu(null /* onStartCallback */, null /* onEndCallback */);
|
||||
mPipTaskOrganizer.setPipVisibility(false);
|
||||
} else if (!animating) {
|
||||
mIsKeyguardShowingOrAnimating = false;
|
||||
mPipTaskOrganizer.setPipVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void onKeyguardDismissAnimationFinished() {
|
||||
if (mPipTaskOrganizer.isInPip()) {
|
||||
mIsKeyguardShowingOrAnimating = false;
|
||||
mPipTaskOrganizer.setPipVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a customized touch gesture that replaces the default one.
|
||||
*/
|
||||
@@ -603,7 +632,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
* Sets both shelf visibility and its height.
|
||||
*/
|
||||
private void setShelfHeight(boolean visible, int height) {
|
||||
setShelfHeightLocked(visible, height);
|
||||
if (!mIsKeyguardShowingOrAnimating) {
|
||||
setShelfHeightLocked(visible, height);
|
||||
}
|
||||
}
|
||||
|
||||
private void setShelfHeightLocked(boolean visible, int height) {
|
||||
@@ -833,13 +864,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
return mIPip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePipMenu(Runnable onStartCallback, Runnable onEndCallback) {
|
||||
mMainExecutor.execute(() -> {
|
||||
PipController.this.hidePipMenu(onStartCallback, onEndCallback);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expandPip() {
|
||||
mMainExecutor.execute(() -> {
|
||||
@@ -917,6 +941,18 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardVisibilityChanged(boolean showing, boolean animating) {
|
||||
mMainExecutor.execute(() -> {
|
||||
PipController.this.onKeyguardVisibilityChanged(showing, animating);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardDismissAnimationFinished() {
|
||||
mMainExecutor.execute(PipController.this::onKeyguardDismissAnimationFinished);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(PrintWriter pw) {
|
||||
try {
|
||||
|
||||
@@ -188,6 +188,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
private static final int MSG_KEYGUARD_GOING_AWAY = 342;
|
||||
private static final int MSG_TIME_FORMAT_UPDATE = 344;
|
||||
private static final int MSG_REQUIRE_NFC_UNLOCK = 345;
|
||||
private static final int MSG_KEYGUARD_DISMISS_ANIMATION_FINISHED = 346;
|
||||
|
||||
/** Biometric authentication state: Not listening. */
|
||||
private static final int BIOMETRIC_STATE_STOPPED = 0;
|
||||
@@ -2005,6 +2006,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
case MSG_REQUIRE_NFC_UNLOCK:
|
||||
handleRequireUnlockForNfc();
|
||||
break;
|
||||
case MSG_KEYGUARD_DISMISS_ANIMATION_FINISHED:
|
||||
handleKeyguardDismissAnimationFinished();
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
break;
|
||||
@@ -3276,6 +3280,19 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle {@link #MSG_KEYGUARD_DISMISS_ANIMATION_FINISHED}
|
||||
*/
|
||||
private void handleKeyguardDismissAnimationFinished() {
|
||||
Assert.isMainThread();
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onKeyguardDismissAnimationFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle {@link #MSG_REPORT_EMERGENCY_CALL_ACTION}
|
||||
*/
|
||||
@@ -3614,6 +3631,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_KEYGUARD_GOING_AWAY, goingAway));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to notify the keyguard dismiss animation is finished.
|
||||
*/
|
||||
public void dispatchKeyguardDismissAnimationFinished() {
|
||||
mHandler.sendEmptyMessage(MSG_KEYGUARD_DISMISS_ANIMATION_FINISHED);
|
||||
}
|
||||
|
||||
public boolean isDeviceInteractive() {
|
||||
return mDeviceInteractive;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,14 @@ public class KeyguardUpdateMonitorCallback {
|
||||
*/
|
||||
public void onKeyguardBouncerFullyShowingChanged(boolean bouncerIsFullyShowing) { }
|
||||
|
||||
/**
|
||||
* Called when the dismissing animation of keyguard and surfaces behind is finished.
|
||||
* If the surface behind is the Launcher, we may still be playing in-window animations
|
||||
* when this is called (since it's only called once we dismiss the keyguard and end the
|
||||
* remote animation).
|
||||
*/
|
||||
public void onKeyguardDismissAnimationFinished() { }
|
||||
|
||||
/**
|
||||
* Called when visibility of lockscreen clock changes, such as when
|
||||
* obscured by a widget.
|
||||
|
||||
@@ -856,6 +856,13 @@ class KeyguardUnlockAnimationController @Inject constructor(
|
||||
return KeyguardService.sEnableRemoteKeyguardGoingAwayAnimation
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the RemoteAnimation on the app/launcher surface behind the keyguard is 'running'.
|
||||
*/
|
||||
fun isAnimatingBetweenKeyguardAndSurfaceBehind(): Boolean {
|
||||
return keyguardViewMediator.get().isAnimatingBetweenKeyguardAndSurfaceBehind
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we are playing a canned unlock animation, vs. unlocking from a touch gesture such as
|
||||
* a swipe.
|
||||
|
||||
@@ -2625,6 +2625,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
|
||||
|
||||
// The remote animation is over, so we're not going away anymore.
|
||||
mKeyguardStateController.notifyKeyguardGoingAway(false);
|
||||
|
||||
// Dispatch the callback on animation finishes.
|
||||
mUpdateMonitor.dispatchKeyguardDismissAnimationFinished();
|
||||
});
|
||||
|
||||
mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation(
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.policy;
|
||||
|
||||
import android.app.IActivityTaskManager;
|
||||
|
||||
import com.android.systemui.keyguard.KeyguardViewMediator;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController.Callback;
|
||||
|
||||
@@ -93,6 +94,15 @@ public interface KeyguardStateController extends CallbackController<Callback> {
|
||||
*/
|
||||
boolean isKeyguardGoingAway();
|
||||
|
||||
/**
|
||||
* Whether we're currently animating between the keyguard and the app/launcher surface behind
|
||||
* it, or will be shortly (which happens if we started a fling to dismiss the keyguard).
|
||||
* @see {@link KeyguardViewMediator#isAnimatingBetweenKeyguardAndSurfaceBehind()}
|
||||
*/
|
||||
default boolean isAnimatingBetweenKeyguardAndSurfaceBehind() {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return a shortened fading away duration similar to
|
||||
* {{@link #getKeyguardFadingAwayDuration()}} which may only span half of the duration, unless
|
||||
|
||||
@@ -278,6 +278,11 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum
|
||||
return mKeyguardGoingAway;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnimatingBetweenKeyguardAndSurfaceBehind() {
|
||||
return mUnlockAnimationControllerLazy.get().isAnimatingBetweenKeyguardAndSurfaceBehind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBypassFadingAnimation() {
|
||||
return mBypassFadingAnimation;
|
||||
|
||||
@@ -200,9 +200,13 @@ public final class WMShell extends CoreStartable
|
||||
mPipKeyguardCallback = new KeyguardUpdateMonitorCallback() {
|
||||
@Override
|
||||
public void onKeyguardVisibilityChanged(boolean showing) {
|
||||
if (showing) {
|
||||
pip.hidePipMenu(null, null);
|
||||
}
|
||||
pip.onKeyguardVisibilityChanged(showing,
|
||||
mKeyguardStateController.isAnimatingBetweenKeyguardAndSurfaceBehind());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyguardDismissAnimationFinished() {
|
||||
pip.onKeyguardDismissAnimationFinished();
|
||||
}
|
||||
};
|
||||
mKeyguardUpdateMonitor.registerCallback(mPipKeyguardCallback);
|
||||
|
||||
Reference in New Issue
Block a user