Merge "Let animations of insets controller can be disabled" into rvc-dev

This commit is contained in:
Tiger Huang
2020-06-16 14:31:41 +00:00
committed by Android (Google) Code Review
5 changed files with 49 additions and 4 deletions

View File

@@ -260,6 +260,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
private final boolean mHasAnimationCallbacks; private final boolean mHasAnimationCallbacks;
private final @InsetsType int mRequestedTypes; private final @InsetsType int mRequestedTypes;
private final long mDurationMs; private final long mDurationMs;
private final boolean mDisable;
private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal = private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal =
new ThreadLocal<AnimationHandler>() { new ThreadLocal<AnimationHandler>() {
@@ -272,11 +273,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
}; };
public InternalAnimationControlListener(boolean show, boolean hasAnimationCallbacks, public InternalAnimationControlListener(boolean show, boolean hasAnimationCallbacks,
int requestedTypes) { int requestedTypes, boolean disable) {
mShow = show; mShow = show;
mHasAnimationCallbacks = hasAnimationCallbacks; mHasAnimationCallbacks = hasAnimationCallbacks;
mRequestedTypes = requestedTypes; mRequestedTypes = requestedTypes;
mDurationMs = calculateDurationMs(); mDurationMs = calculateDurationMs();
mDisable = disable;
} }
@Override @Override
@@ -284,6 +286,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
mController = controller; mController = controller;
if (DEBUG) Log.d(TAG, "default animation onReady types: " + types); if (DEBUG) Log.d(TAG, "default animation onReady types: " + types);
if (mDisable) {
onAnimationFinish();
return;
}
mAnimator = ValueAnimator.ofFloat(0f, 1f); mAnimator = ValueAnimator.ofFloat(0f, 1f);
mAnimator.setDuration(mDurationMs); mAnimator.setDuration(mDurationMs);
mAnimator.setInterpolator(new LinearInterpolator()); mAnimator.setInterpolator(new LinearInterpolator());
@@ -477,6 +483,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
private DisplayCutout mLastDisplayCutout; private DisplayCutout mLastDisplayCutout;
private boolean mStartingAnimation; private boolean mStartingAnimation;
private int mCaptionInsetsHeight = 0; private int mCaptionInsetsHeight = 0;
private boolean mAnimationsDisabled;
private Runnable mPendingControlTimeout = this::abortPendingImeControlRequest; private Runnable mPendingControlTimeout = this::abortPendingImeControlRequest;
private final ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners private final ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners
@@ -1213,8 +1220,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
} }
boolean hasAnimationCallbacks = mHost.hasAnimationCallbacks(); boolean hasAnimationCallbacks = mHost.hasAnimationCallbacks();
final InternalAnimationControlListener listener = final InternalAnimationControlListener listener = new InternalAnimationControlListener(
new InternalAnimationControlListener(show, hasAnimationCallbacks, types); show, hasAnimationCallbacks, types, mAnimationsDisabled);
// Show/hide animations always need to be relative to the display frame, in order that shown // Show/hide animations always need to be relative to the display frame, in order that shown
// and hidden state insets are correct. // and hidden state insets are correct.
@@ -1329,6 +1336,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
return mHost.getSystemBarsBehavior(); return mHost.getSystemBarsBehavior();
} }
@Override
public void setAnimationsDisabled(boolean disable) {
mAnimationsDisabled = disable;
}
private @InsetsType int calculateControllableTypes() { private @InsetsType int calculateControllableTypes() {
@InsetsType int result = 0; @InsetsType int result = 0;
for (int i = mSourceConsumers.size() - 1; i >= 0; i--) { for (int i = mSourceConsumers.size() - 1; i >= 0; i--) {

View File

@@ -38,6 +38,7 @@ public class PendingInsetsController implements WindowInsetsController {
private @Appearance int mAppearance; private @Appearance int mAppearance;
private @Appearance int mAppearanceMask; private @Appearance int mAppearanceMask;
private @Behavior int mBehavior = KEEP_BEHAVIOR; private @Behavior int mBehavior = KEEP_BEHAVIOR;
private boolean mAnimationsDisabled;
private final InsetsState mDummyState = new InsetsState(); private final InsetsState mDummyState = new InsetsState();
private InsetsController mReplayedInsetsController; private InsetsController mReplayedInsetsController;
private ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners private ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners
@@ -102,6 +103,15 @@ public class PendingInsetsController implements WindowInsetsController {
return mBehavior; return mBehavior;
} }
@Override
public void setAnimationsDisabled(boolean disable) {
if (mReplayedInsetsController != null) {
mReplayedInsetsController.setAnimationsDisabled(disable);
} else {
mAnimationsDisabled = disable;
}
}
@Override @Override
public InsetsState getState() { public InsetsState getState() {
return mDummyState; return mDummyState;
@@ -151,6 +161,9 @@ public class PendingInsetsController implements WindowInsetsController {
if (mCaptionInsetsHeight != 0) { if (mCaptionInsetsHeight != 0) {
controller.setCaptionInsetsHeight(mCaptionInsetsHeight); controller.setCaptionInsetsHeight(mCaptionInsetsHeight);
} }
if (mAnimationsDisabled) {
controller.setAnimationsDisabled(true);
}
int size = mRequests.size(); int size = mRequests.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
mRequests.get(i).replay(controller); mRequests.get(i).replay(controller);
@@ -167,6 +180,7 @@ public class PendingInsetsController implements WindowInsetsController {
mBehavior = KEEP_BEHAVIOR; mBehavior = KEEP_BEHAVIOR;
mAppearance = 0; mAppearance = 0;
mAppearanceMask = 0; mAppearanceMask = 0;
mAnimationsDisabled = false;
// After replaying, we forward everything directly to the replayed instance. // After replaying, we forward everything directly to the replayed instance.
mReplayedInsetsController = controller; mReplayedInsetsController = controller;

View File

@@ -221,6 +221,13 @@ public interface WindowInsetsController {
*/ */
@Behavior int getSystemBarsBehavior(); @Behavior int getSystemBarsBehavior();
/**
* Disables or enables the animations.
*
* @hide
*/
void setAnimationsDisabled(boolean disable);
/** /**
* @hide * @hide
*/ */

View File

@@ -459,6 +459,18 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
} }
@Override
public void onStartedWakingUp() {
mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
.setAnimationsDisabled(false);
}
@Override
public void onStartedGoingToSleep() {
mStatusBar.getNotificationShadeWindowView().getWindowInsetsController()
.setAnimationsDisabled(true);
}
@Override @Override
public void onFinishedGoingToSleep() { public void onFinishedGoingToSleep() {
mBouncer.onScreenTurnedOff(); mBouncer.onScreenTurnedOff();

View File

@@ -384,7 +384,7 @@ class InsetsPolicy {
InsetsPolicyAnimationControlCallbacks mControlCallbacks; InsetsPolicyAnimationControlCallbacks mControlCallbacks;
InsetsPolicyAnimationControlListener(boolean show, Runnable finishCallback, int types) { InsetsPolicyAnimationControlListener(boolean show, Runnable finishCallback, int types) {
super(show, false /* hasCallbacks */, types); super(show, false /* hasCallbacks */, types, false /* disable */);
mFinishCallback = finishCallback; mFinishCallback = finishCallback;
mControlCallbacks = new InsetsPolicyAnimationControlCallbacks(this); mControlCallbacks = new InsetsPolicyAnimationControlCallbacks(this);
} }