Merge "[Unfold animation] Do not send start closing event before the inner display turned on" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
628acae60b
@@ -139,6 +139,40 @@ class DeviceFoldStateProviderTest : SysuiTestCase() {
|
|||||||
assertThat(foldUpdates).containsExactly(FOLD_UPDATE_START_OPENING)
|
assertThat(foldUpdates).containsExactly(FOLD_UPDATE_START_OPENING)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testOnUnfold_hingeAngleDecreasesBeforeInnerScreenAvailable_emitsOnlyStartAndInnerScreenAvailableEvents() {
|
||||||
|
setFoldState(folded = true)
|
||||||
|
foldUpdates.clear()
|
||||||
|
|
||||||
|
setFoldState(folded = false)
|
||||||
|
screenOnStatusProvider.notifyScreenTurningOn()
|
||||||
|
sendHingeAngleEvent(10)
|
||||||
|
sendHingeAngleEvent(20)
|
||||||
|
sendHingeAngleEvent(10)
|
||||||
|
screenOnStatusProvider.notifyScreenTurnedOn()
|
||||||
|
|
||||||
|
assertThat(foldUpdates).containsExactly(FOLD_UPDATE_START_OPENING,
|
||||||
|
FOLD_UPDATE_UNFOLDED_SCREEN_AVAILABLE)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testOnUnfold_hingeAngleDecreasesAfterInnerScreenAvailable_emitsStartInnerScreenAvailableAndStartClosingEvents() {
|
||||||
|
setFoldState(folded = true)
|
||||||
|
foldUpdates.clear()
|
||||||
|
|
||||||
|
setFoldState(folded = false)
|
||||||
|
screenOnStatusProvider.notifyScreenTurningOn()
|
||||||
|
sendHingeAngleEvent(10)
|
||||||
|
sendHingeAngleEvent(20)
|
||||||
|
screenOnStatusProvider.notifyScreenTurnedOn()
|
||||||
|
sendHingeAngleEvent(30)
|
||||||
|
sendHingeAngleEvent(40)
|
||||||
|
sendHingeAngleEvent(10)
|
||||||
|
|
||||||
|
assertThat(foldUpdates).containsExactly(FOLD_UPDATE_START_OPENING,
|
||||||
|
FOLD_UPDATE_UNFOLDED_SCREEN_AVAILABLE, FOLD_UPDATE_START_CLOSING)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testOnFolded_stopsHingeAngleProvider() {
|
fun testOnFolded_stopsHingeAngleProvider() {
|
||||||
setFoldState(folded = true)
|
setFoldState(folded = true)
|
||||||
@@ -237,7 +271,7 @@ class DeviceFoldStateProviderTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun startClosingEvent_afterTimeout_abortEmitted() {
|
fun startClosingEvent_afterTimeout_finishHalfOpenEventEmitted() {
|
||||||
sendHingeAngleEvent(90)
|
sendHingeAngleEvent(90)
|
||||||
sendHingeAngleEvent(80)
|
sendHingeAngleEvent(80)
|
||||||
|
|
||||||
@@ -269,7 +303,7 @@ class DeviceFoldStateProviderTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun startClosingEvent_timeoutAfterTimeoutRescheduled_abortEmitted() {
|
fun startClosingEvent_timeoutAfterTimeoutRescheduled_finishHalfOpenStateEmitted() {
|
||||||
sendHingeAngleEvent(180)
|
sendHingeAngleEvent(180)
|
||||||
sendHingeAngleEvent(90)
|
sendHingeAngleEvent(90)
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.systemui.unfold.progress
|
package com.android.systemui.unfold.progress
|
||||||
|
|
||||||
|
import android.os.Trace
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.dynamicanimation.animation.DynamicAnimation
|
import androidx.dynamicanimation.animation.DynamicAnimation
|
||||||
import androidx.dynamicanimation.animation.FloatPropertyCompat
|
import androidx.dynamicanimation.animation.FloatPropertyCompat
|
||||||
@@ -117,6 +118,7 @@ class PhysicsBasedUnfoldTransitionProgressProvider(
|
|||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onFoldUpdate = $update")
|
Log.d(TAG, "onFoldUpdate = $update")
|
||||||
|
Trace.traceCounter(Trace.TRACE_TAG_APP, "fold_update", update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package com.android.systemui.unfold.updates
|
package com.android.systemui.unfold.updates
|
||||||
|
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
import android.os.Trace
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.FloatRange
|
import androidx.annotation.FloatRange
|
||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
@@ -108,6 +109,7 @@ constructor(
|
|||||||
private fun onHingeAngle(angle: Float) {
|
private fun onHingeAngle(angle: Float) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "Hinge angle: $angle, lastHingeAngle: $lastHingeAngle")
|
Log.d(TAG, "Hinge angle: $angle, lastHingeAngle: $lastHingeAngle")
|
||||||
|
Trace.traceCounter(Trace.TRACE_TAG_APP, "hinge_angle", angle.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
val isClosing = angle < lastHingeAngle
|
val isClosing = angle < lastHingeAngle
|
||||||
@@ -115,8 +117,16 @@ constructor(
|
|||||||
val closingThresholdMet = closingThreshold == null || angle < closingThreshold
|
val closingThresholdMet = closingThreshold == null || angle < closingThreshold
|
||||||
val isFullyOpened = FULLY_OPEN_DEGREES - angle < FULLY_OPEN_THRESHOLD_DEGREES
|
val isFullyOpened = FULLY_OPEN_DEGREES - angle < FULLY_OPEN_THRESHOLD_DEGREES
|
||||||
val closingEventDispatched = lastFoldUpdate == FOLD_UPDATE_START_CLOSING
|
val closingEventDispatched = lastFoldUpdate == FOLD_UPDATE_START_CLOSING
|
||||||
|
val screenAvailableEventSent = isUnfoldHandled
|
||||||
|
|
||||||
if (isClosing && closingThresholdMet && !closingEventDispatched && !isFullyOpened) {
|
if (isClosing // hinge angle should be decreasing since last update
|
||||||
|
&& closingThresholdMet // hinge angle is below certain threshold
|
||||||
|
&& !closingEventDispatched // we haven't sent closing event already
|
||||||
|
&& !isFullyOpened // do not send closing event if we are in fully opened hinge
|
||||||
|
// angle range as closing threshold could overlap this range
|
||||||
|
&& screenAvailableEventSent // do not send closing event if we are still in
|
||||||
|
// the process of turning on the inner display
|
||||||
|
) {
|
||||||
notifyFoldUpdate(FOLD_UPDATE_START_CLOSING)
|
notifyFoldUpdate(FOLD_UPDATE_START_CLOSING)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user