Merge "Allow switching to outer screen only after passing 90 degrees" into 24D1-dev
diff --git a/services/foldables/devicestateprovider/src/com/android/server/policy/BookStyleStateTransitions.java b/services/foldables/devicestateprovider/src/com/android/server/policy/BookStyleStateTransitions.java
index 16daacb..aa7532a 100644
--- a/services/foldables/devicestateprovider/src/com/android/server/policy/BookStyleStateTransitions.java
+++ b/services/foldables/devicestateprovider/src/com/android/server/policy/BookStyleStateTransitions.java
@@ -412,7 +412,7 @@
/* stickyKeepInnerUntil45Degrees */ true,
PreferredScreen.INNER,
/* setStickyKeepOuterUntil90Degrees */ null,
- /* setStickyKeepInnerUntil45Degrees */ false
+ /* setStickyKeepInnerUntil45Degrees */ null
));
DEFAULT_STATE_TRANSITIONS.add(new StateTransition(
HingeAngle.ANGLE_45_TO_90,
@@ -492,7 +492,7 @@
/* stickyKeepInnerUntil45Degrees */ true,
PreferredScreen.INNER,
/* setStickyKeepOuterUntil90Degrees */ null,
- /* setStickyKeepInnerUntil45Degrees */ false
+ /* setStickyKeepInnerUntil45Degrees */ null
));
DEFAULT_STATE_TRANSITIONS.add(new StateTransition(
HingeAngle.ANGLE_45_TO_90,
diff --git a/services/foldables/devicestateprovider/tests/src/com/android/server/policy/BookStyleDeviceStatePolicyTest.java b/services/foldables/devicestateprovider/tests/src/com/android/server/policy/BookStyleDeviceStatePolicyTest.java
index 9f07aa8..2d725d1 100644
--- a/services/foldables/devicestateprovider/tests/src/com/android/server/policy/BookStyleDeviceStatePolicyTest.java
+++ b/services/foldables/devicestateprovider/tests/src/com/android/server/policy/BookStyleDeviceStatePolicyTest.java
@@ -511,7 +511,7 @@
}
@Test
- public void test_unfoldTo60Degrees_andFoldTo10_switchesToClosedState() {
+ public void test_unfoldTo60Degrees_andFoldTo10_doesNotSwitchToClosedState() {
sendHingeAngle(0f);
sendRightSideFlatSensorEvent(false);
mProvider.setListener(mListener);
@@ -522,6 +522,36 @@
sendHingeAngle(10f);
+ verify(mListener, never()).onStateChanged(anyInt());
+ }
+
+ @Test
+ public void test_unfoldTo100Degrees_andFoldTo10_switchesToClosedState() {
+ sendHingeAngle(0f);
+ sendRightSideFlatSensorEvent(false);
+ mProvider.setListener(mListener);
+ assertLatestReportedState(DEVICE_STATE_CLOSED);
+ sendHingeAngle(100f);
+ assertLatestReportedState(DEVICE_STATE_HALF_OPENED);
+ clearInvocations(mListener);
+
+ sendHingeAngle(10f);
+
+ verify(mListener).onStateChanged(DEVICE_STATE_CLOSED);
+ }
+
+ @Test
+ public void test_unfoldTo10Degrees_andFoldTo0_switchesToClosedState() {
+ sendHingeAngle(0f);
+ sendRightSideFlatSensorEvent(false);
+ mProvider.setListener(mListener);
+ assertLatestReportedState(DEVICE_STATE_CLOSED);
+ sendHingeAngle(10f);
+ assertLatestReportedState(DEVICE_STATE_HALF_OPENED);
+ clearInvocations(mListener);
+
+ sendHingeAngle(0f);
+
verify(mListener).onStateChanged(DEVICE_STATE_CLOSED);
}