[Bouncer] Apply interpolation to udfps

Apply interpolation to udfps view controller when boucer is in transit.
Also rename the function so that it implies that it affects all elements
that need to hide in order to show the bouncer.

Bug: 228282858
Test: Manual
Change-Id: I27d192fb2576c8e02ac193eaee2836da4027c88f
This commit is contained in:
Aaron Liu
2022-04-08 16:34:55 +00:00
parent 0ba48fea68
commit caa6359dbe
11 changed files with 43 additions and 38 deletions

View File

@@ -23,7 +23,7 @@ object BouncerPanelExpansionCalculator {
* Scale the alpha/position of the host view. * Scale the alpha/position of the host view.
*/ */
@JvmStatic @JvmStatic
fun getHostViewScaledExpansion(fraction: Float): Float { fun showBouncerProgress(fraction: Float): Float {
return when { return when {
fraction >= 0.9f -> 1f fraction >= 0.9f -> 1f
fraction < 0.6 -> 0f fraction < 0.6 -> 0f
@@ -35,7 +35,7 @@ object BouncerPanelExpansionCalculator {
* Scale the alpha/tint of the back scrim. * Scale the alpha/tint of the back scrim.
*/ */
@JvmStatic @JvmStatic
fun getBackScrimScaledExpansion(fraction: Float): Float { fun aboutToShowBouncerProgress(fraction: Float): Float {
return MathUtils.constrain((fraction - 0.9f) / 0.1f, 0f, 1f) return MathUtils.constrain((fraction - 0.9f) / 0.1f, 0f, 1f)
} }

View File

@@ -327,7 +327,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
* @param fraction amount of the screen that should show. * @param fraction amount of the screen that should show.
*/ */
public void setExpansion(float fraction) { public void setExpansion(float fraction) {
float scaledFraction = BouncerPanelExpansionCalculator.getHostViewScaledExpansion(fraction); float scaledFraction = BouncerPanelExpansionCalculator.showBouncerProgress(fraction);
mView.setAlpha(MathUtils.constrain(1 - scaledFraction, 0f, 1f)); mView.setAlpha(MathUtils.constrain(1 - scaledFraction, 0f, 1f));
mView.setTranslationY(scaledFraction * mTranslationY); mView.setTranslationY(scaledFraction * mTranslationY);
} }

View File

@@ -25,6 +25,7 @@ import android.util.Log;
import android.util.MathUtils; import android.util.MathUtils;
import android.view.MotionEvent; import android.view.MotionEvent;
import com.android.keyguard.BouncerPanelExpansionCalculator;
import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.animation.ActivityLaunchAnimator;
@@ -71,7 +72,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
private float mTransitionToFullShadeProgress; private float mTransitionToFullShadeProgress;
private float mLastDozeAmount; private float mLastDozeAmount;
private long mLastUdfpsBouncerShowTime = -1; private long mLastUdfpsBouncerShowTime = -1;
private float mStatusBarExpansion; private float mPanelExpansionFraction;
private boolean mLaunchTransitionFadingAway; private boolean mLaunchTransitionFadingAway;
private boolean mIsLaunchingActivity; private boolean mIsLaunchingActivity;
private float mActivityLaunchProgress; private float mActivityLaunchProgress;
@@ -188,7 +189,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
pw.println("mQsExpanded=" + mQsExpanded); pw.println("mQsExpanded=" + mQsExpanded);
pw.println("mIsBouncerVisible=" + mIsBouncerVisible); pw.println("mIsBouncerVisible=" + mIsBouncerVisible);
pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount); pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount);
pw.println("mStatusBarExpansion=" + mStatusBarExpansion); pw.println("mPanelExpansionFraction=" + mPanelExpansionFraction);
pw.println("unpausedAlpha=" + mView.getUnpausedAlpha()); pw.println("unpausedAlpha=" + mView.getUnpausedAlpha());
pw.println("mUdfpsRequested=" + mUdfpsRequested); pw.println("mUdfpsRequested=" + mUdfpsRequested);
pw.println("mView.mUdfpsRequested=" + mView.mUdfpsRequested); pw.println("mView.mUdfpsRequested=" + mView.mUdfpsRequested);
@@ -324,14 +325,16 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
*/ */
@Override @Override
public void updateAlpha() { public void updateAlpha() {
// fade icon on transitions to showing the status bar, but if mUdfpsRequested, then // Fade icon on transitions to showing the status bar or bouncer, but if mUdfpsRequested,
// the keyguard is occluded by some application - so instead use the input bouncer // then the keyguard is occluded by some application - so instead use the input bouncer
// hidden amount to determine the fade // hidden amount to determine the fade.
float expansion = mUdfpsRequested ? mInputBouncerHiddenAmount : mStatusBarExpansion; float expansion = mUdfpsRequested ? mInputBouncerHiddenAmount : mPanelExpansionFraction;
int alpha = mShowingUdfpsBouncer ? 255 int alpha = mShowingUdfpsBouncer ? 255
: (int) MathUtils.constrain( : (int) MathUtils.constrain(
MathUtils.map(.5f, .9f, 0f, 255f, expansion), MathUtils.map(.5f, .9f, 0f, 255f, expansion),
0f, 255f); 0f, 255f);
if (!mShowingUdfpsBouncer) { if (!mShowingUdfpsBouncer) {
alpha *= (1.0f - mTransitionToFullShadeProgress); alpha *= (1.0f - mTransitionToFullShadeProgress);
@@ -471,7 +474,9 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
@Override @Override
public void onPanelExpansionChanged( public void onPanelExpansionChanged(
float fraction, boolean expanded, boolean tracking) { float fraction, boolean expanded, boolean tracking) {
mStatusBarExpansion = fraction; mPanelExpansionFraction =
mKeyguardViewManager.bouncerIsInTransit() ? BouncerPanelExpansionCalculator
.aboutToShowBouncerProgress(fraction) : fraction;
updateAlpha(); updateAlpha();
} }
}; };

View File

@@ -16,7 +16,7 @@
package com.android.systemui.dreams; package com.android.systemui.dreams;
import static com.android.keyguard.BouncerPanelExpansionCalculator.getBackScrimScaledExpansion; import static com.android.keyguard.BouncerPanelExpansionCalculator.aboutToShowBouncerProgress;
import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamAlphaScaledExpansion; import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamAlphaScaledExpansion;
import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamYPositionScaledExpansion; import static com.android.keyguard.BouncerPanelExpansionCalculator.getDreamYPositionScaledExpansion;
import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset;
@@ -217,19 +217,19 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
mBlurUtils.applyBlur(mView.getViewRootImpl(), mBlurUtils.applyBlur(mView.getViewRootImpl(),
(int) mBlurUtils.blurRadiusOfRatio( (int) mBlurUtils.blurRadiusOfRatio(
1 - getBackScrimScaledExpansion(bouncerHideAmount)), false); 1 - aboutToShowBouncerProgress(bouncerHideAmount)), false);
} }
private static float getAlpha(int position, float expansion) { private static float getAlpha(int position, float expansion) {
return Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation( return Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation(
position == POSITION_TOP ? getDreamAlphaScaledExpansion(expansion) position == POSITION_TOP ? getDreamAlphaScaledExpansion(expansion)
: getBackScrimScaledExpansion(expansion + 0.03f)); : aboutToShowBouncerProgress(expansion + 0.03f));
} }
private float getTranslationY(int position, float expansion) { private float getTranslationY(int position, float expansion) {
final float fraction = Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation( final float fraction = Interpolators.LINEAR_OUT_SLOW_IN.getInterpolation(
position == POSITION_TOP ? getDreamYPositionScaledExpansion(expansion) position == POSITION_TOP ? getDreamYPositionScaledExpansion(expansion)
: getBackScrimScaledExpansion(expansion + 0.03f)); : aboutToShowBouncerProgress(expansion + 0.03f));
return MathUtils.lerp(-mDreamOverlayMaxTranslationY, 0, fraction); return MathUtils.lerp(-mDreamOverlayMaxTranslationY, 0, fraction);
} }
} }

View File

@@ -610,7 +610,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
view.setVisibility((View.VISIBLE)); view.setVisibility((View.VISIBLE));
} }
float alpha = mQSPanelController.bouncerInTransit() float alpha = mQSPanelController.bouncerInTransit()
? BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(progress) ? BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(progress)
: ShadeInterpolation.getContentAlpha(progress); : ShadeInterpolation.getContentAlpha(progress);
view.setAlpha(alpha); view.setAlpha(alpha);
} }

View File

@@ -797,7 +797,7 @@ public abstract class PanelViewController {
mExpandedFraction = Math.min(1f, mExpandedFraction = Math.min(1f,
maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight); maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight);
mAmbientState.setExpansionFraction(mStatusBarKeyguardViewManager.bouncerIsInTransit() mAmbientState.setExpansionFraction(mStatusBarKeyguardViewManager.bouncerIsInTransit()
? BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(mExpandedFraction) ? BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(mExpandedFraction)
: mExpandedFraction); : mExpandedFraction);
onHeightUpdated(mExpandedHeight); onHeightUpdated(mExpandedHeight);
updatePanelExpansionAndVisibility(); updatePanelExpansionAndVisibility();

View File

@@ -790,7 +790,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
if (mBouncerHiddenFraction != KeyguardBouncer.EXPANSION_HIDDEN) { if (mBouncerHiddenFraction != KeyguardBouncer.EXPANSION_HIDDEN) {
final float interpolatedFraction = final float interpolatedFraction =
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion( BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(
mBouncerHiddenFraction); mBouncerHiddenFraction);
mBehindAlpha = MathUtils.lerp(mDefaultScrimAlpha, mBehindAlpha, mBehindAlpha = MathUtils.lerp(mDefaultScrimAlpha, mBehindAlpha,
interpolatedFraction); interpolatedFraction);
@@ -1076,7 +1076,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
private float getInterpolatedFraction() { private float getInterpolatedFraction() {
if (mStatusBarKeyguardViewManager.bouncerIsInTransit()) { if (mStatusBarKeyguardViewManager.bouncerIsInTransit()) {
return BouncerPanelExpansionCalculator return BouncerPanelExpansionCalculator
.getBackScrimScaledExpansion(mPanelExpansionFraction); .aboutToShowBouncerProgress(mPanelExpansionFraction);
} }
return ShadeInterpolation.getNotificationScrimAlpha(mPanelExpansionFraction); return ShadeInterpolation.getNotificationScrimAlpha(mPanelExpansionFraction);
} }

View File

@@ -29,29 +29,29 @@ import org.junit.runner.RunWith
class BouncerPanelExpansionCalculatorTest : SysuiTestCase() { class BouncerPanelExpansionCalculatorTest : SysuiTestCase() {
@Test @Test
fun testGetHostViewScaledExpansion() { fun testGetHostViewScaledExpansion() {
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(1f)) assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(1f))
.isEqualTo(1f) .isEqualTo(1f)
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0.9f)) assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0.9f))
.isEqualTo(1f) .isEqualTo(1f)
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0.59f)) assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0.59f))
.isEqualTo(0f) .isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getHostViewScaledExpansion(0f)) assertThat(BouncerPanelExpansionCalculator.showBouncerProgress(0f))
.isEqualTo(0f) .isEqualTo(0f)
assertEquals(BouncerPanelExpansionCalculator assertEquals(BouncerPanelExpansionCalculator
.getHostViewScaledExpansion(0.8f), 2f / 3f, 0.01f) .showBouncerProgress(0.8f), 2f / 3f, 0.01f)
} }
@Test @Test
fun testGetBackScrimScaledExpansion() { fun testGetBackScrimScaledExpansion() {
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(1f)) assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(1f))
.isEqualTo(1f) .isEqualTo(1f)
assertEquals(BouncerPanelExpansionCalculator assertEquals(BouncerPanelExpansionCalculator
.getBackScrimScaledExpansion(0.95f), 1f / 2f, 0.01f) .aboutToShowBouncerProgress(0.95f), 1f / 2f, 0.01f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.9f)) assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.9f))
.isEqualTo(0f) .isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.5f)) assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.5f))
.isEqualTo(0f) .isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0f)) assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0f))
.isEqualTo(0f) .isEqualTo(0f)
} }
@@ -63,9 +63,9 @@ class BouncerPanelExpansionCalculatorTest : SysuiTestCase() {
.getKeyguardClockScaledExpansion(0.8f), 1f / 3f, 0.01f) .getKeyguardClockScaledExpansion(0.8f), 1f / 3f, 0.01f)
assertThat(BouncerPanelExpansionCalculator.getKeyguardClockScaledExpansion(0.7f)) assertThat(BouncerPanelExpansionCalculator.getKeyguardClockScaledExpansion(0.7f))
.isEqualTo(0f) .isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0.5f)) assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0.5f))
.isEqualTo(0f) .isEqualTo(0f)
assertThat(BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(0f)) assertThat(BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(0f))
.isEqualTo(0f) .isEqualTo(0f)
} }
} }

View File

@@ -177,7 +177,7 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
final float bouncerHideAmount = 0.05f; final float bouncerHideAmount = 0.05f;
final float scaledFraction = final float scaledFraction =
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(bouncerHideAmount); BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(bouncerHideAmount);
bouncerExpansionCaptor.getValue().onExpansionChanged(bouncerHideAmount); bouncerExpansionCaptor.getValue().onExpansionChanged(bouncerHideAmount);
verify(mBlurUtils).blurRadiusOfRatio(1 - scaledFraction); verify(mBlurUtils).blurRadiusOfRatio(1 - scaledFraction);

View File

@@ -214,7 +214,7 @@ public class QSFragmentTest extends SysuiBaseFragmentTest {
assertThat(mQsFragmentView.getAlpha()) assertThat(mQsFragmentView.getAlpha())
.isEqualTo( .isEqualTo(
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion( BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(
transitionProgress)); transitionProgress));
} }

View File

@@ -1244,11 +1244,11 @@ public class ScrimControllerTest extends SysuiTestCase {
float expansion = 0.8f; float expansion = 0.8f;
float expectedAlpha = float expectedAlpha =
BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion); assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion);
expansion = 0.2f; expansion = 0.2f;
expectedAlpha = BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); expectedAlpha = BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion); assertAlphaAfterExpansion(mNotificationsScrim, expectedAlpha, expansion);
} }
@@ -1284,7 +1284,7 @@ public class ScrimControllerTest extends SysuiTestCase {
// Verify normal behavior after // Verify normal behavior after
mScrimController.setUnocclusionAnimationRunning(false); mScrimController.setUnocclusionAnimationRunning(false);
float expansion = 0.4f; float expansion = 0.4f;
float alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); float alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
} }
@@ -1316,15 +1316,15 @@ public class ScrimControllerTest extends SysuiTestCase {
mScrimController.transitionTo(ScrimState.KEYGUARD); mScrimController.transitionTo(ScrimState.KEYGUARD);
float expansion = 0.8f; float expansion = 0.8f;
float alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); float alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
expansion = 0.4f; expansion = 0.4f;
alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
expansion = 0.2f; expansion = 0.2f;
alpha = 1 - BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(expansion); alpha = 1 - BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansion);
assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion); assertAlphaAfterExpansion(mNotificationsScrim, alpha, expansion);
} }