Loading packages/SystemUI/shared/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimator.kt +1 −1 Original line number Diff line number Diff line Loading @@ -192,4 +192,4 @@ class UnfoldMoveFromCenterAnimator @JvmOverloads constructor( ) } private const val TRANSLATION_PERCENTAGE = 0.3f private const val TRANSLATION_PERCENTAGE = 0.08f packages/SystemUI/src/com/android/systemui/flags/Flags.kt +6 −0 Original line number Diff line number Diff line Loading @@ -694,6 +694,12 @@ object Flags { val ENABLE_DARK_VIGNETTE_WHEN_FOLDING = unreleasedFlag(2700, "enable_dark_vignette_when_folding") // TODO(b/265764985): Tracking Bug @Keep @JvmField val ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS = unreleasedFlag(2701, "enable_unfold_status_bar_animations") // TODO(b259590361): Tracking bug val EXPERIMENTAL_FLAG = unreleasedFlag(2, "exp_flag_release") Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +22 −11 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import android.view.ViewGroup import android.view.ViewTreeObserver import com.android.systemui.Gefingerpoken import com.android.systemui.R import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.shade.ShadeController import com.android.systemui.shade.ShadeLogger import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator Loading Loading @@ -215,6 +217,7 @@ class PhoneStatusBarViewController private constructor( private val unfoldComponent: Optional<SysUIUnfoldComponent>, @Named(UNFOLD_STATUS_BAR) private val progressProvider: Optional<ScopedUnfoldTransitionProgressProvider>, private val featureFlags: FeatureFlags, private val userChipViewModel: StatusBarUserChipViewModel, private val centralSurfaces: CentralSurfaces, private val shadeController: ShadeController, Loading @@ -224,17 +227,25 @@ class PhoneStatusBarViewController private constructor( ) { fun create( view: PhoneStatusBarView ) = PhoneStatusBarViewController( ): PhoneStatusBarViewController { val statusBarMoveFromCenterAnimationController = if (featureFlags.isEnabled(Flags.ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS)) { unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController() } else { null } return PhoneStatusBarViewController( view, progressProvider.getOrNull(), centralSurfaces, shadeController, shadeLogger, unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController(), statusBarMoveFromCenterAnimationController, userChipViewModel, viewUtil, configurationController ) } } } packages/SystemUI/src/com/android/systemui/unfold/UnfoldLightRevealOverlayAnimation.kt +34 −2 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ constructor( private var isFolded: Boolean = false private var isUnfoldHandled: Boolean = true private var overlayAddReason: AddOverlayReason? = null private var isTouchBlocked: Boolean = true private var currentRotation: Int = context.display!!.rotation Loading Loading @@ -253,7 +254,15 @@ constructor( params.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS params.fitInsetsTypes = 0 params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE val touchFlags = if (isTouchBlocked) { // Touchable by default, so it will block the touches 0 } else { WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE } params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or touchFlags params.setTrustedOverlay() val packageName: String = context.opPackageName Loading @@ -262,6 +271,24 @@ constructor( return params } private fun updateTouchBlockIfNeeded(progress: Float) { // When unfolding unblock touches a bit earlier than the animation end as the // interpolation has a long tail of very slight movement at the end which should not // affect much the usage of the device val shouldBlockTouches = if (overlayAddReason == UNFOLD) { progress < UNFOLD_BLOCK_TOUCHES_UNTIL_PROGRESS } else { true } if (isTouchBlocked != shouldBlockTouches) { isTouchBlocked = shouldBlockTouches traceSection("$TAG#relayoutToUpdateTouch") { root?.relayout(getLayoutParams()) } } } private fun createLightRevealEffect(): LightRevealEffect { val isVerticalFold = currentRotation == Surface.ROTATION_0 || currentRotation == Surface.ROTATION_180 Loading @@ -288,7 +315,10 @@ constructor( private inner class TransitionListener : TransitionProgressListener { override fun onTransitionProgress(progress: Float) { executeInBackground { scrimView?.revealAmount = calculateRevealAmount(progress) } executeInBackground { scrimView?.revealAmount = calculateRevealAmount(progress) updateTouchBlockIfNeeded(progress) } } override fun onTransitionFinished() { Loading Loading @@ -360,5 +390,7 @@ constructor( // constants for revealAmount. const val TRANSPARENT = 1f const val BLACK = 0f private const val UNFOLD_BLOCK_TOUCHES_UNTIL_PROGRESS = 0.8f } } packages/SystemUI/tests/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimatorTest.kt +9 −9 Original line number Diff line number Diff line Loading @@ -65,8 +65,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right // 10x10 view center is 25px from the center, // When progress is 0.5 it should be translated at: // 25 * 0.3 * (1 - 0.5) = 3.75px assertThat(view.translationX).isWithin(0.01f).of(3.75f) // 25 * 0.08 * (1 - 0.5) = 1px assertThat(view.translationX).isWithin(0.01f).of(1.0f) } @Test Loading @@ -81,8 +81,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right // 10x10 view center is 25px from the center, // When progress is 0 it should be translated at: // 25 * 0.3 * (1 - 0) = 7.5px assertThat(view.translationX).isWithin(0.01f).of(7.5f) // 25 * 0.08 * (1 - 0) = 7.5px assertThat(view.translationX).isWithin(0.01f).of(2f) } @Test Loading @@ -97,7 +97,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right // 10x10 view center is 25px from the center, // When progress is 1 it should be translated at: // 25 * 0.3 * 0 = 0px // 25 * 0.08 * 0 = 0px assertThat(view.translationX).isEqualTo(0f) } Loading @@ -113,8 +113,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right, original translation is ignored // 10x10 view center is 25px from the center, // When progress is 0.5 it should be translated at: // 25 * 0.3 * (1 - 0.5) = 3.75px assertThat(view.translationX).isWithin(0.01f).of(3.75f) // 25 * 0.08 * (1 - 0.5) = 1px assertThat(view.translationX).isWithin(0.01f).of(1.0f) } @Test Loading Loading @@ -154,7 +154,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { animator.onTransitionProgress(0.5f) // Positive translationY -> translated to the bottom assertThat(view.translationY).isWithin(0.01f).of(3.75f) assertThat(view.translationY).isWithin(0.01f).of(1f) } @Test Loading @@ -169,7 +169,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { animator.updateViewPositions() // Negative translationX -> translated to the left assertThat(view.translationX).isWithin(0.1f).of(-5.25f) assertThat(view.translationX).isWithin(0.1f).of(-1.4f) } private fun createView( Loading Loading
packages/SystemUI/shared/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimator.kt +1 −1 Original line number Diff line number Diff line Loading @@ -192,4 +192,4 @@ class UnfoldMoveFromCenterAnimator @JvmOverloads constructor( ) } private const val TRANSLATION_PERCENTAGE = 0.3f private const val TRANSLATION_PERCENTAGE = 0.08f
packages/SystemUI/src/com/android/systemui/flags/Flags.kt +6 −0 Original line number Diff line number Diff line Loading @@ -694,6 +694,12 @@ object Flags { val ENABLE_DARK_VIGNETTE_WHEN_FOLDING = unreleasedFlag(2700, "enable_dark_vignette_when_folding") // TODO(b/265764985): Tracking Bug @Keep @JvmField val ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS = unreleasedFlag(2701, "enable_unfold_status_bar_animations") // TODO(b259590361): Tracking bug val EXPERIMENTAL_FLAG = unreleasedFlag(2, "exp_flag_release") Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +22 −11 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ import android.view.ViewGroup import android.view.ViewTreeObserver import com.android.systemui.Gefingerpoken import com.android.systemui.R import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.shade.ShadeController import com.android.systemui.shade.ShadeLogger import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator Loading Loading @@ -215,6 +217,7 @@ class PhoneStatusBarViewController private constructor( private val unfoldComponent: Optional<SysUIUnfoldComponent>, @Named(UNFOLD_STATUS_BAR) private val progressProvider: Optional<ScopedUnfoldTransitionProgressProvider>, private val featureFlags: FeatureFlags, private val userChipViewModel: StatusBarUserChipViewModel, private val centralSurfaces: CentralSurfaces, private val shadeController: ShadeController, Loading @@ -224,17 +227,25 @@ class PhoneStatusBarViewController private constructor( ) { fun create( view: PhoneStatusBarView ) = PhoneStatusBarViewController( ): PhoneStatusBarViewController { val statusBarMoveFromCenterAnimationController = if (featureFlags.isEnabled(Flags.ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS)) { unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController() } else { null } return PhoneStatusBarViewController( view, progressProvider.getOrNull(), centralSurfaces, shadeController, shadeLogger, unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController(), statusBarMoveFromCenterAnimationController, userChipViewModel, viewUtil, configurationController ) } } }
packages/SystemUI/src/com/android/systemui/unfold/UnfoldLightRevealOverlayAnimation.kt +34 −2 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ constructor( private var isFolded: Boolean = false private var isUnfoldHandled: Boolean = true private var overlayAddReason: AddOverlayReason? = null private var isTouchBlocked: Boolean = true private var currentRotation: Int = context.display!!.rotation Loading Loading @@ -253,7 +254,15 @@ constructor( params.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS params.fitInsetsTypes = 0 params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE val touchFlags = if (isTouchBlocked) { // Touchable by default, so it will block the touches 0 } else { WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE } params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or touchFlags params.setTrustedOverlay() val packageName: String = context.opPackageName Loading @@ -262,6 +271,24 @@ constructor( return params } private fun updateTouchBlockIfNeeded(progress: Float) { // When unfolding unblock touches a bit earlier than the animation end as the // interpolation has a long tail of very slight movement at the end which should not // affect much the usage of the device val shouldBlockTouches = if (overlayAddReason == UNFOLD) { progress < UNFOLD_BLOCK_TOUCHES_UNTIL_PROGRESS } else { true } if (isTouchBlocked != shouldBlockTouches) { isTouchBlocked = shouldBlockTouches traceSection("$TAG#relayoutToUpdateTouch") { root?.relayout(getLayoutParams()) } } } private fun createLightRevealEffect(): LightRevealEffect { val isVerticalFold = currentRotation == Surface.ROTATION_0 || currentRotation == Surface.ROTATION_180 Loading @@ -288,7 +315,10 @@ constructor( private inner class TransitionListener : TransitionProgressListener { override fun onTransitionProgress(progress: Float) { executeInBackground { scrimView?.revealAmount = calculateRevealAmount(progress) } executeInBackground { scrimView?.revealAmount = calculateRevealAmount(progress) updateTouchBlockIfNeeded(progress) } } override fun onTransitionFinished() { Loading Loading @@ -360,5 +390,7 @@ constructor( // constants for revealAmount. const val TRANSPARENT = 1f const val BLACK = 0f private const val UNFOLD_BLOCK_TOUCHES_UNTIL_PROGRESS = 0.8f } }
packages/SystemUI/tests/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimatorTest.kt +9 −9 Original line number Diff line number Diff line Loading @@ -65,8 +65,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right // 10x10 view center is 25px from the center, // When progress is 0.5 it should be translated at: // 25 * 0.3 * (1 - 0.5) = 3.75px assertThat(view.translationX).isWithin(0.01f).of(3.75f) // 25 * 0.08 * (1 - 0.5) = 1px assertThat(view.translationX).isWithin(0.01f).of(1.0f) } @Test Loading @@ -81,8 +81,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right // 10x10 view center is 25px from the center, // When progress is 0 it should be translated at: // 25 * 0.3 * (1 - 0) = 7.5px assertThat(view.translationX).isWithin(0.01f).of(7.5f) // 25 * 0.08 * (1 - 0) = 7.5px assertThat(view.translationX).isWithin(0.01f).of(2f) } @Test Loading @@ -97,7 +97,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right // 10x10 view center is 25px from the center, // When progress is 1 it should be translated at: // 25 * 0.3 * 0 = 0px // 25 * 0.08 * 0 = 0px assertThat(view.translationX).isEqualTo(0f) } Loading @@ -113,8 +113,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { // Positive translationX -> translated to the right, original translation is ignored // 10x10 view center is 25px from the center, // When progress is 0.5 it should be translated at: // 25 * 0.3 * (1 - 0.5) = 3.75px assertThat(view.translationX).isWithin(0.01f).of(3.75f) // 25 * 0.08 * (1 - 0.5) = 1px assertThat(view.translationX).isWithin(0.01f).of(1.0f) } @Test Loading Loading @@ -154,7 +154,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { animator.onTransitionProgress(0.5f) // Positive translationY -> translated to the bottom assertThat(view.translationY).isWithin(0.01f).of(3.75f) assertThat(view.translationY).isWithin(0.01f).of(1f) } @Test Loading @@ -169,7 +169,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() { animator.updateViewPositions() // Negative translationX -> translated to the left assertThat(view.translationX).isWithin(0.1f).of(-5.25f) assertThat(view.translationX).isWithin(0.1f).of(-1.4f) } private fun createView( Loading