Loading core/java/android/hardware/devicestate/DeviceState.java +4 −2 Original line number Diff line number Diff line Loading @@ -543,11 +543,13 @@ public final class DeviceState { int identifier = source.readInt(); String name = source.readString8(); ArraySet<@DeviceStateProperties Integer> systemProperties = new ArraySet<>(); for (int i = 0; i < source.readInt(); i++) { int systemPropertySize = source.readInt(); for (int i = 0; i < systemPropertySize; i++) { systemProperties.add(source.readInt()); } ArraySet<@DeviceStateProperties Integer> physicalProperties = new ArraySet<>(); for (int j = 0; j < source.readInt(); j++) { int physicalPropertySize = source.readInt(); for (int j = 0; j < physicalPropertySize; j++) { physicalProperties.add(source.readInt()); } return new DeviceState.Configuration(identifier, name, systemProperties, Loading core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateInfoTest.java +24 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package android.hardware.devicestate; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_CLOSED; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_HALF_OPEN; import static android.hardware.devicestate.DeviceState.PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; Loading @@ -33,6 +39,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import java.util.List; import java.util.Set; /** * Unit tests for {@link DeviceStateInfo}. Loading @@ -44,11 +51,25 @@ import java.util.List; public final class DeviceStateInfoTest { private static final DeviceState DEVICE_STATE_0 = new DeviceState( new DeviceState.Configuration.Builder(0, "STATE_0").build()); new DeviceState.Configuration.Builder(0, "STATE_0") .setSystemProperties( Set.of(PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS, PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY)) .setPhysicalProperties( Set.of(PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_CLOSED)) .build()); private static final DeviceState DEVICE_STATE_1 = new DeviceState( new DeviceState.Configuration.Builder(1, "STATE_1").build()); new DeviceState.Configuration.Builder(1, "STATE_1") .setSystemProperties( Set.of(PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY)) .setPhysicalProperties( Set.of(PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_HALF_OPEN)) .build()); private static final DeviceState DEVICE_STATE_2 = new DeviceState( new DeviceState.Configuration.Builder(2, "STATE_2").build()); new DeviceState.Configuration.Builder(2, "STATE_2") .setSystemProperties( Set.of(PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY)) .build()); @Test public void create() { Loading core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -93,4 +93,22 @@ public final class DeviceStateTest { Assert.assertEquals(originalState, new DeviceState(stateConfiguration)); } @Test public void writeToParcel_noPhysicalProperties() { final DeviceState originalState = new DeviceState( new DeviceState.Configuration.Builder(0, "TEST_STATE") .setSystemProperties(Set.of(PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS, PROPERTY_POLICY_AVAILABLE_FOR_APP_REQUEST)) .build()); final Parcel parcel = Parcel.obtain(); originalState.getConfiguration().writeToParcel(parcel, 0 /* flags */); parcel.setDataPosition(0); final DeviceState.Configuration stateConfiguration = DeviceState.Configuration.CREATOR.createFromParcel(parcel); Assert.assertEquals(originalState, new DeviceState(stateConfiguration)); } } Loading
core/java/android/hardware/devicestate/DeviceState.java +4 −2 Original line number Diff line number Diff line Loading @@ -543,11 +543,13 @@ public final class DeviceState { int identifier = source.readInt(); String name = source.readString8(); ArraySet<@DeviceStateProperties Integer> systemProperties = new ArraySet<>(); for (int i = 0; i < source.readInt(); i++) { int systemPropertySize = source.readInt(); for (int i = 0; i < systemPropertySize; i++) { systemProperties.add(source.readInt()); } ArraySet<@DeviceStateProperties Integer> physicalProperties = new ArraySet<>(); for (int j = 0; j < source.readInt(); j++) { int physicalPropertySize = source.readInt(); for (int j = 0; j < physicalPropertySize; j++) { physicalProperties.add(source.readInt()); } return new DeviceState.Configuration(identifier, name, systemProperties, Loading
core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateInfoTest.java +24 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ package android.hardware.devicestate; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_CLOSED; import static android.hardware.devicestate.DeviceState.PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_HALF_OPEN; import static android.hardware.devicestate.DeviceState.PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; Loading @@ -33,6 +39,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import java.util.List; import java.util.Set; /** * Unit tests for {@link DeviceStateInfo}. Loading @@ -44,11 +51,25 @@ import java.util.List; public final class DeviceStateInfoTest { private static final DeviceState DEVICE_STATE_0 = new DeviceState( new DeviceState.Configuration.Builder(0, "STATE_0").build()); new DeviceState.Configuration.Builder(0, "STATE_0") .setSystemProperties( Set.of(PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS, PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_OUTER_PRIMARY)) .setPhysicalProperties( Set.of(PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_CLOSED)) .build()); private static final DeviceState DEVICE_STATE_1 = new DeviceState( new DeviceState.Configuration.Builder(1, "STATE_1").build()); new DeviceState.Configuration.Builder(1, "STATE_1") .setSystemProperties( Set.of(PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY)) .setPhysicalProperties( Set.of(PROPERTY_FOLDABLE_HARDWARE_CONFIGURATION_FOLD_IN_HALF_OPEN)) .build()); private static final DeviceState DEVICE_STATE_2 = new DeviceState( new DeviceState.Configuration.Builder(2, "STATE_2").build()); new DeviceState.Configuration.Builder(2, "STATE_2") .setSystemProperties( Set.of(PROPERTY_FOLDABLE_DISPLAY_CONFIGURATION_INNER_PRIMARY)) .build()); @Test public void create() { Loading
core/tests/devicestatetests/src/android/hardware/devicestate/DeviceStateTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -93,4 +93,22 @@ public final class DeviceStateTest { Assert.assertEquals(originalState, new DeviceState(stateConfiguration)); } @Test public void writeToParcel_noPhysicalProperties() { final DeviceState originalState = new DeviceState( new DeviceState.Configuration.Builder(0, "TEST_STATE") .setSystemProperties(Set.of(PROPERTY_POLICY_CANCEL_OVERRIDE_REQUESTS, PROPERTY_POLICY_AVAILABLE_FOR_APP_REQUEST)) .build()); final Parcel parcel = Parcel.obtain(); originalState.getConfiguration().writeToParcel(parcel, 0 /* flags */); parcel.setDataPosition(0); final DeviceState.Configuration stateConfiguration = DeviceState.Configuration.CREATOR.createFromParcel(parcel); Assert.assertEquals(originalState, new DeviceState(stateConfiguration)); } }