Loading core/java/android/view/DisplayInfo.java +19 −9 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.internal.display.BrightnessSynchronizer; import com.android.server.display.feature.flags.Flags; import java.util.Arrays; import java.util.EnumSet; import java.util.Objects; /** Loading Loading @@ -958,6 +959,23 @@ public final class DisplayInfo implements Parcelable { } } /** * Same as {@link #getBasicChangedGroups(DisplayInfo)} except here we only compare * the specified groups i.e. if changes happen to other groups they will not be identified. */ public int getBasicChangedGroups(@Nullable DisplayInfo other, EnumSet<DisplayInfoGroup> groupsToCompare) { int changedGroups = 0; for (DisplayInfoGroup group : groupsToCompare) { if (hasDisplayInfoGroupChanged(group, other)) { changedGroups |= group.getMask(); } } return changedGroups; } /** * Compares this {@link DisplayInfo} with another for "basic" changes * (i.e. when a {@link android.hardware.display.DisplayManager.EVENT_TYPE_DISPLAY_CHANGED} Loading @@ -970,15 +988,7 @@ public final class DisplayInfo implements Parcelable { * changed. If none have changed, the bitmask will be 0. */ public int getBasicChangedGroups(@Nullable DisplayInfo other) { int changedGroups = 0; for (DisplayInfoGroup group : DisplayInfoGroup.values()) { if (hasDisplayInfoGroupChanged(group, other)) { changedGroups |= group.getMask(); } } return changedGroups; return getBasicChangedGroups(other, EnumSet.allOf(DisplayInfoGroup.class)); } /** Loading core/tests/coretests/src/android/view/DisplayInfoTest.java +64 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import java.util.EnumSet; @RunWith(AndroidJUnit4.class) @SmallTest public class DisplayInfoTest { Loading Loading @@ -318,6 +320,68 @@ public class DisplayInfoTest { ); } @Test public void getBasicChangedGroups_otherIsNull_returns_some_groups() { DisplayInfo base = new DisplayInfo(); int changedGroups = base.getBasicChangedGroups(null, EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES, DisplayInfo.DisplayInfoGroup.ORIENTATION_AND_ROTATION)); assertThat(changedGroups).isEqualTo( DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES.getMask() | DisplayInfo.DisplayInfoGroup.ORIENTATION_AND_ROTATION.getMask() ); } @Test public void getBasicChangedGroups_withGroupsToCompare_singleGroupChanged_Matches() { DisplayInfo base = new DisplayInfo(); DisplayInfo other = new DisplayInfo(base); other.logicalWidth = 1440; // Belongs to DIMENSIONS_AND_SHAPES EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare = EnumSet.of(DisplayInfo.DisplayInfoGroup.DIMENSIONS_AND_SHAPES); int changedGroups = base.getBasicChangedGroups(other, groupsToCompare); assertThat(changedGroups) .isEqualTo(DisplayInfo.DisplayInfoGroup.DIMENSIONS_AND_SHAPES.getMask()); } @Test public void getBasicChangedGroups_withGroupsToCompare_singleGroupChanged_DoesNotMatch() { DisplayInfo base = new DisplayInfo(); DisplayInfo other = new DisplayInfo(base); other.logicalWidth = 1440; // Belongs to DIMENSIONS_AND_SHAPES // Compare a different group that has not changed. EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare = EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES); int changedGroups = base.getBasicChangedGroups(other, groupsToCompare); assertThat(changedGroups).isEqualTo(0); } @Test public void getBasicChangedGroups_withGroupsToCompare_multipleGroupsChanged() { DisplayInfo base = new DisplayInfo(); DisplayInfo other = new DisplayInfo(base); other.flags = Display.FLAG_PRIVATE; // BASIC_PROPERTIES other.rotation = Surface.ROTATION_180; // ORIENTATION_AND_ROTATION other.state = Display.STATE_VR; // STATE // Only compare two of the three changed groups. EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare = EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES, DisplayInfo.DisplayInfoGroup.STATE); int changedGroups = base.getBasicChangedGroups(other, groupsToCompare); assertThat(changedGroups).isEqualTo( DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES.getMask() | DisplayInfo.DisplayInfoGroup.STATE.getMask()); } private void setSupportedModes(DisplayInfo info, Display.Mode[] modes, int modeId) { info.supportedModes = modes; info.modeId = modeId; Loading services/core/java/com/android/server/display/DisplayManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -6469,7 +6469,7 @@ public final class DisplayManagerService extends SystemService { .setDeviceStateLocked(deviceState); } } }; } private static class BrightnessPair { public float brightness; Loading services/core/java/com/android/server/display/LogicalDisplay.java +0 −1 Original line number Diff line number Diff line Loading @@ -1096,7 +1096,6 @@ final class LogicalDisplay { * Swap the underlying {@link DisplayDevice} with the specified LogicalDisplay. * * @param targetDisplay The display with which to swap display-devices. * @return {@code true} if the displays were swapped, {@code false} otherwise. */ public void swapDisplaysLocked(@NonNull LogicalDisplay targetDisplay) { final DisplayDevice oldTargetDevice = Loading Loading
core/java/android/view/DisplayInfo.java +19 −9 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.internal.display.BrightnessSynchronizer; import com.android.server.display.feature.flags.Flags; import java.util.Arrays; import java.util.EnumSet; import java.util.Objects; /** Loading Loading @@ -958,6 +959,23 @@ public final class DisplayInfo implements Parcelable { } } /** * Same as {@link #getBasicChangedGroups(DisplayInfo)} except here we only compare * the specified groups i.e. if changes happen to other groups they will not be identified. */ public int getBasicChangedGroups(@Nullable DisplayInfo other, EnumSet<DisplayInfoGroup> groupsToCompare) { int changedGroups = 0; for (DisplayInfoGroup group : groupsToCompare) { if (hasDisplayInfoGroupChanged(group, other)) { changedGroups |= group.getMask(); } } return changedGroups; } /** * Compares this {@link DisplayInfo} with another for "basic" changes * (i.e. when a {@link android.hardware.display.DisplayManager.EVENT_TYPE_DISPLAY_CHANGED} Loading @@ -970,15 +988,7 @@ public final class DisplayInfo implements Parcelable { * changed. If none have changed, the bitmask will be 0. */ public int getBasicChangedGroups(@Nullable DisplayInfo other) { int changedGroups = 0; for (DisplayInfoGroup group : DisplayInfoGroup.values()) { if (hasDisplayInfoGroupChanged(group, other)) { changedGroups |= group.getMask(); } } return changedGroups; return getBasicChangedGroups(other, EnumSet.allOf(DisplayInfoGroup.class)); } /** Loading
core/tests/coretests/src/android/view/DisplayInfoTest.java +64 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import java.util.EnumSet; @RunWith(AndroidJUnit4.class) @SmallTest public class DisplayInfoTest { Loading Loading @@ -318,6 +320,68 @@ public class DisplayInfoTest { ); } @Test public void getBasicChangedGroups_otherIsNull_returns_some_groups() { DisplayInfo base = new DisplayInfo(); int changedGroups = base.getBasicChangedGroups(null, EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES, DisplayInfo.DisplayInfoGroup.ORIENTATION_AND_ROTATION)); assertThat(changedGroups).isEqualTo( DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES.getMask() | DisplayInfo.DisplayInfoGroup.ORIENTATION_AND_ROTATION.getMask() ); } @Test public void getBasicChangedGroups_withGroupsToCompare_singleGroupChanged_Matches() { DisplayInfo base = new DisplayInfo(); DisplayInfo other = new DisplayInfo(base); other.logicalWidth = 1440; // Belongs to DIMENSIONS_AND_SHAPES EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare = EnumSet.of(DisplayInfo.DisplayInfoGroup.DIMENSIONS_AND_SHAPES); int changedGroups = base.getBasicChangedGroups(other, groupsToCompare); assertThat(changedGroups) .isEqualTo(DisplayInfo.DisplayInfoGroup.DIMENSIONS_AND_SHAPES.getMask()); } @Test public void getBasicChangedGroups_withGroupsToCompare_singleGroupChanged_DoesNotMatch() { DisplayInfo base = new DisplayInfo(); DisplayInfo other = new DisplayInfo(base); other.logicalWidth = 1440; // Belongs to DIMENSIONS_AND_SHAPES // Compare a different group that has not changed. EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare = EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES); int changedGroups = base.getBasicChangedGroups(other, groupsToCompare); assertThat(changedGroups).isEqualTo(0); } @Test public void getBasicChangedGroups_withGroupsToCompare_multipleGroupsChanged() { DisplayInfo base = new DisplayInfo(); DisplayInfo other = new DisplayInfo(base); other.flags = Display.FLAG_PRIVATE; // BASIC_PROPERTIES other.rotation = Surface.ROTATION_180; // ORIENTATION_AND_ROTATION other.state = Display.STATE_VR; // STATE // Only compare two of the three changed groups. EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare = EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES, DisplayInfo.DisplayInfoGroup.STATE); int changedGroups = base.getBasicChangedGroups(other, groupsToCompare); assertThat(changedGroups).isEqualTo( DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES.getMask() | DisplayInfo.DisplayInfoGroup.STATE.getMask()); } private void setSupportedModes(DisplayInfo info, Display.Mode[] modes, int modeId) { info.supportedModes = modes; info.modeId = modeId; Loading
services/core/java/com/android/server/display/DisplayManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -6469,7 +6469,7 @@ public final class DisplayManagerService extends SystemService { .setDeviceStateLocked(deviceState); } } }; } private static class BrightnessPair { public float brightness; Loading
services/core/java/com/android/server/display/LogicalDisplay.java +0 −1 Original line number Diff line number Diff line Loading @@ -1096,7 +1096,6 @@ final class LogicalDisplay { * Swap the underlying {@link DisplayDevice} with the specified LogicalDisplay. * * @param targetDisplay The display with which to swap display-devices. * @return {@code true} if the displays were swapped, {@code false} otherwise. */ public void swapDisplaysLocked(@NonNull LogicalDisplay targetDisplay) { final DisplayDevice oldTargetDevice = Loading