summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Chyn <kchyn@google.com> 2025-02-05 22:09:50 +0000
committer Kevin Chyn <kchyn@google.com> 2025-02-05 23:00:53 +0000
commitd1f158ddf5d0be65cd6eff58f87aea989293b735 (patch)
tree86b2d7aeb40e5606a112fd6f56e11ef89de81152
parent3d038236eb51facaec30eb63e81a7b9385d83c47 (diff)
Fall back to RDMV1 if needed and possible
In cases where RDMV2 is flag-enabled but not a RDM state with PROPERTY_FEATURE_REAR_DISPLAY_OUTER_DEFAULT is not found, fall back to RDMV1 if it exists on the device. Fixes: 393181436 Test: atest WindowAreaComponentImplTests Flag: EXEMPT bugfix Change-Id: Ia35425ed8f5ab763b8e245ad39984cb9fb3f06ee
-rw-r--r--libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java5
-rw-r--r--libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/area/WindowAreaComponentImplTests.java13
2 files changed, 14 insertions, 4 deletions
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java
index 76eb207a31c9..8e04855f7d14 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/area/WindowAreaComponentImpl.java
@@ -126,7 +126,10 @@ public class WindowAreaComponentImpl implements WindowAreaComponent,
return state.getIdentifier();
}
}
- return INVALID_DEVICE_STATE_IDENTIFIER;
+
+ // If RDMV2 flag is enabled but not properly configured, let's fall back to RDMV1 if
+ // possible.
+ return getRdmV1Identifier(currentSupportedDeviceStates);
}
public WindowAreaComponentImpl(@NonNull Context context) {
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/area/WindowAreaComponentImplTests.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/area/WindowAreaComponentImplTests.java
index d677fef5c22c..b7983bdaf4cf 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/area/WindowAreaComponentImplTests.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/area/WindowAreaComponentImplTests.java
@@ -143,13 +143,20 @@ public class WindowAreaComponentImplTests {
}
@Test
- public void testRdmV2Identifier_whenStateIsProperlyConfigured() {
+ public void testFallsBackToRdmV1() {
+ // Test that if we try to get RDMV2 but it's not available, that we get RDMV1 if it is
+ // available.
final List<DeviceState> supportedStates = new ArrayList<>();
-
supportedStates.add(REAR_DISPLAY_STATE_V1);
- assertEquals(INVALID_DEVICE_STATE_IDENTIFIER,
+ assertEquals(REAR_DISPLAY_STATE_V1.getIdentifier(),
WindowAreaComponentImpl.getRdmV2Identifier(supportedStates));
+ }
+ @Test
+ public void testRdmV2Identifier_whenStateIsProperlyConfigured() {
+ final List<DeviceState> supportedStates = new ArrayList<>();
+
+ supportedStates.add(REAR_DISPLAY_STATE_V1);
supportedStates.add(REAR_DISPLAY_STATE_V2);
assertEquals(REAR_DISPLAY_STATE_V2.getIdentifier(),
WindowAreaComponentImpl.getRdmV2Identifier(supportedStates));