Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c88a0c3 authored by Nick Chameyev's avatar Nick Chameyev
Browse files

Support hinge angle sensor in unfold animation

Allows to use real hinge angle sensor to drive
unfold animation. Adds starting folding animation
when reaching certain angle threshold.

Bug: 195404647
Test: manual
Change-Id: I94cdd5f8832eb6439408f8c2f8ff85da9788ee98
parent f8f5a07f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -660,6 +660,9 @@
    <!-- Indicates whether to enable an animation when unfolding a device or not -->
    <bool name="config_unfoldTransitionEnabled">false</bool>

    <!-- Indicates whether to enable hinge angle sensor when using unfold animation -->
    <bool name="config_unfoldTransitionHingeAngle">false</bool>

    <!-- Indicates that the device supports having more than one internal display on at the same
         time. Only applicable to devices with more than one internal display. If this option is
         set to false, DisplayManager will make additional effort to ensure no more than 1 internal
+1 −0
Original line number Diff line number Diff line
@@ -3842,6 +3842,7 @@
  <java-symbol type="string" name="config_foldedArea" />
  <java-symbol type="bool" name="config_supportsConcurrentInternalDisplays" />
  <java-symbol type="bool" name="config_unfoldTransitionEnabled" />
  <java-symbol type="bool" name="config_unfoldTransitionHingeAngle" />
  <java-symbol type="array" name="config_perDeviceStateRotationLockDefaults" />


+8 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.unfold.progress.FixedTimingTransitionProgressProvide
import com.android.systemui.unfold.progress.PhysicsBasedUnfoldTransitionProgressProvider
import com.android.systemui.unfold.updates.DeviceFoldStateProvider
import com.android.systemui.unfold.updates.hinge.EmptyHingeAngleProvider
import com.android.systemui.unfold.updates.hinge.HingeSensorAngleProvider
import com.android.systemui.unfold.updates.hinge.RotationSensorHingeAngleProvider
import java.lang.IllegalStateException
import java.util.concurrent.Executor
@@ -50,7 +51,13 @@ fun createUnfoldTransitionProgressProvider(

    val hingeAngleProvider =
        if (config.mode == ANIMATION_MODE_HINGE_ANGLE) {
            // TODO: after removing temporary "config.mode" we should just
            //       switch between fixed timing and hinge sensor based on this flag
            if (config.isHingeAngleEnabled) {
                HingeSensorAngleProvider(sensorManager)
            } else {
                RotationSensorHingeAngleProvider(sensorManager)
            }
        } else {
            EmptyHingeAngleProvider()
        }
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ internal class ResourceUnfoldTransitionConfig(
    override val isEnabled: Boolean
        get() = readIsEnabled() && mode != ANIMATION_MODE_DISABLED

    override val isHingeAngleEnabled: Boolean
        get() = readIsHingeAngleEnabled()

    @AnimationMode
    override val mode: Int
        get() = SystemProperties.getInt(UNFOLD_TRANSITION_MODE_PROPERTY_NAME,
@@ -32,6 +35,9 @@ internal class ResourceUnfoldTransitionConfig(

    private fun readIsEnabled(): Boolean = context.resources
        .getBoolean(com.android.internal.R.bool.config_unfoldTransitionEnabled)

    private fun readIsHingeAngleEnabled(): Boolean = context.resources
        .getBoolean(com.android.internal.R.bool.config_unfoldTransitionHingeAngle)
}

/**
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.annotation.IntDef

interface UnfoldTransitionConfig {
    val isEnabled: Boolean
    val isHingeAngleEnabled: Boolean

    @AnimationMode
    val mode: Int
Loading