Loading packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/updates/DeviceFoldStateProviderTest.kt +65 −0 Original line number Diff line number Diff line Loading @@ -615,6 +615,71 @@ class DeviceFoldStateProviderTest : SysuiTestCase() { assertThat(foldUpdates).containsExactly(FOLD_UPDATE_START_CLOSING) } @Test fun angleDecreaseAfterCancelAnimation_emitsStartClosingEvent() { setFoldState(folded = true) sendHingeAngleEvent(0) foldUpdates.clear() setFoldState(folded = false) rotationListener.value.onRotationChanged(1) sendHingeAngleEvent(180) screenOnStatusProvider.notifyScreenTurningOn() screenOnStatusProvider.notifyScreenTurnedOn() // Start folding (180 downTo 60).forEach { sendHingeAngleEvent(it) } // Stopped folding and simulate timeout in this posture simulateTimeout() assertThat(foldUpdates) .containsExactly( FOLD_UPDATE_START_OPENING, // unfolded FOLD_UPDATE_FINISH_HALF_OPEN, // force-finished the animation because of rotation FOLD_UPDATE_START_CLOSING, // start closing the device FOLD_UPDATE_FINISH_HALF_OPEN, // finished closing and timed-out in this state ) } @Test fun angleIncreaseDecreaseAfterHalfUnfold_emitsStartClosingEvent() { setFoldState(folded = true) sendHingeAngleEvent(0) foldUpdates.clear() setFoldState(folded = false) sendHingeAngleEvent(90) screenOnStatusProvider.notifyScreenTurningOn() screenOnStatusProvider.notifyScreenTurnedOn() // Stopped folding and simulate timeout in this posture simulateTimeout() // Unfold further (90 until 180).forEach { sendHingeAngleEvent(it) } // Start folding (180 downTo 90).forEach { sendHingeAngleEvent(it) } // Stopped folding and simulate timeout in this posture simulateTimeout() assertThat(foldUpdates) .containsExactly( FOLD_UPDATE_START_OPENING, // unfolded FOLD_UPDATE_FINISH_HALF_OPEN, // force-finished the animation because of rotation FOLD_UPDATE_START_CLOSING, // start closing the device FOLD_UPDATE_FINISH_HALF_OPEN, // finished closing and timed-out in this state ) } @Test fun onUnfold_onSmallScreen_emitsStartOpening() { // the new display state might arrive later, so it shouldn't be used to decide to send the Loading packages/SystemUI/unfold/src/com/android/systemui/unfold/updates/DeviceFoldStateProvider.kt +6 −2 Original line number Diff line number Diff line Loading @@ -128,7 +128,11 @@ constructor( val currentDirection = if (angle < lastHingeAngle) FOLD_UPDATE_START_CLOSING else FOLD_UPDATE_START_OPENING if (isTransitionInProgress && currentDirection != lastFoldUpdate) { val changedDirectionWhileInTransition = isTransitionInProgress && currentDirection != lastFoldUpdate val unfoldedPastThresholdSinceLastTransition = angle - lastHingeAngleBeforeTransition > HINGE_ANGLE_CHANGE_THRESHOLD_DEGREES if (changedDirectionWhileInTransition || unfoldedPastThresholdSinceLastTransition) { lastHingeAngleBeforeTransition = lastHingeAngle } Loading @@ -153,7 +157,7 @@ constructor( isOnLargeScreen // Avoids sending closing event when on small screen. // Start event is sent regardless due to hall sensor. ) { notifyFoldUpdate(transitionUpdate, lastHingeAngle) notifyFoldUpdate(transitionUpdate, angle) } if (isTransitionInProgress) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/updates/DeviceFoldStateProviderTest.kt +65 −0 Original line number Diff line number Diff line Loading @@ -615,6 +615,71 @@ class DeviceFoldStateProviderTest : SysuiTestCase() { assertThat(foldUpdates).containsExactly(FOLD_UPDATE_START_CLOSING) } @Test fun angleDecreaseAfterCancelAnimation_emitsStartClosingEvent() { setFoldState(folded = true) sendHingeAngleEvent(0) foldUpdates.clear() setFoldState(folded = false) rotationListener.value.onRotationChanged(1) sendHingeAngleEvent(180) screenOnStatusProvider.notifyScreenTurningOn() screenOnStatusProvider.notifyScreenTurnedOn() // Start folding (180 downTo 60).forEach { sendHingeAngleEvent(it) } // Stopped folding and simulate timeout in this posture simulateTimeout() assertThat(foldUpdates) .containsExactly( FOLD_UPDATE_START_OPENING, // unfolded FOLD_UPDATE_FINISH_HALF_OPEN, // force-finished the animation because of rotation FOLD_UPDATE_START_CLOSING, // start closing the device FOLD_UPDATE_FINISH_HALF_OPEN, // finished closing and timed-out in this state ) } @Test fun angleIncreaseDecreaseAfterHalfUnfold_emitsStartClosingEvent() { setFoldState(folded = true) sendHingeAngleEvent(0) foldUpdates.clear() setFoldState(folded = false) sendHingeAngleEvent(90) screenOnStatusProvider.notifyScreenTurningOn() screenOnStatusProvider.notifyScreenTurnedOn() // Stopped folding and simulate timeout in this posture simulateTimeout() // Unfold further (90 until 180).forEach { sendHingeAngleEvent(it) } // Start folding (180 downTo 90).forEach { sendHingeAngleEvent(it) } // Stopped folding and simulate timeout in this posture simulateTimeout() assertThat(foldUpdates) .containsExactly( FOLD_UPDATE_START_OPENING, // unfolded FOLD_UPDATE_FINISH_HALF_OPEN, // force-finished the animation because of rotation FOLD_UPDATE_START_CLOSING, // start closing the device FOLD_UPDATE_FINISH_HALF_OPEN, // finished closing and timed-out in this state ) } @Test fun onUnfold_onSmallScreen_emitsStartOpening() { // the new display state might arrive later, so it shouldn't be used to decide to send the Loading
packages/SystemUI/unfold/src/com/android/systemui/unfold/updates/DeviceFoldStateProvider.kt +6 −2 Original line number Diff line number Diff line Loading @@ -128,7 +128,11 @@ constructor( val currentDirection = if (angle < lastHingeAngle) FOLD_UPDATE_START_CLOSING else FOLD_UPDATE_START_OPENING if (isTransitionInProgress && currentDirection != lastFoldUpdate) { val changedDirectionWhileInTransition = isTransitionInProgress && currentDirection != lastFoldUpdate val unfoldedPastThresholdSinceLastTransition = angle - lastHingeAngleBeforeTransition > HINGE_ANGLE_CHANGE_THRESHOLD_DEGREES if (changedDirectionWhileInTransition || unfoldedPastThresholdSinceLastTransition) { lastHingeAngleBeforeTransition = lastHingeAngle } Loading @@ -153,7 +157,7 @@ constructor( isOnLargeScreen // Avoids sending closing event when on small screen. // Start event is sent regardless due to hall sensor. ) { notifyFoldUpdate(transitionUpdate, lastHingeAngle) notifyFoldUpdate(transitionUpdate, angle) } if (isTransitionInProgress) { Loading