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

Commit d1f158dd authored by Kevin Chyn's avatar Kevin Chyn
Browse files

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
parent 3d038236
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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) {
+10 −3
Original line number Diff line number Diff line
@@ -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));