Merge "Update activeMode when it changes from SF"

This commit is contained in:
Marin Shalamanov
2020-10-28 11:55:35 +00:00
committed by Android (Google) Code Review
2 changed files with 49 additions and 3 deletions

View File

@@ -300,10 +300,16 @@ final class LocalDisplayAdapter extends DisplayAdapter {
}
}
// Check whether surface flinger spontaneously changed modes out from under us.
// Schedule traversals to ensure that the correct state is reapplied if necessary.
boolean activeModeChanged = false;
// Check whether SurfaceFlinger or the display device changed the active mode out from
// under us.
if (mActiveModeId != NO_DISPLAY_MODE_ID
&& mActiveModeId != activeRecord.mMode.getModeId()) {
Slog.d(TAG, "The active mode was changed from SurfaceFlinger or the display"
+ "device.");
mActiveModeId = activeRecord.mMode.getModeId();
activeModeChanged = true;
sendTraversalRequestLocked();
}
@@ -333,7 +339,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
boolean recordsChanged = records.size() != mSupportedModes.size() || modesAdded;
// If the records haven't changed then we're done here.
if (!recordsChanged) {
return false;
return activeModeChanged;
}
mSupportedModes.clear();

View File

@@ -251,6 +251,46 @@ public class LocalDisplayAdapterTest {
addedDisplayInfo.refreshRate)).isTrue();
}
@Test
public void testAfterDisplayChange_ActiveModeIsUpdated() throws Exception {
SurfaceControl.DisplayConfig[] configs = new SurfaceControl.DisplayConfig[]{
createFakeDisplayConfig(1920, 1080, 60f),
createFakeDisplayConfig(1920, 1080, 50f)
};
FakeDisplay display = new FakeDisplay(PORT_A, configs, /* activeConfig */ 0);
setUpDisplay(display);
updateAvailableDisplays();
mAdapter.registerLocked();
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
assertThat(mListener.addedDisplays.size()).isEqualTo(1);
assertThat(mListener.changedDisplays).isEmpty();
DisplayDeviceInfo displayDeviceInfo = mListener.addedDisplays.get(0)
.getDisplayDeviceInfoLocked();
Display.Mode activeMode = getModeById(displayDeviceInfo, displayDeviceInfo.modeId);
assertThat(activeMode.matches(1920, 1080, 60f)).isTrue();
// Change the display
display.activeConfig = 1;
setUpDisplay(display);
mInjector.getTransmitter().sendHotplug(display, /* connected */ true);
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
assertThat(SurfaceControl.getActiveConfig(display.token)).isEqualTo(1);
assertThat(mListener.addedDisplays.size()).isEqualTo(1);
assertThat(mListener.changedDisplays.size()).isEqualTo(1);
DisplayDevice displayDevice = mListener.changedDisplays.get(0);
displayDevice.applyPendingDisplayDeviceInfoChangesLocked();
displayDeviceInfo = displayDevice.getDisplayDeviceInfoLocked();
activeMode = getModeById(displayDeviceInfo, displayDeviceInfo.modeId);
assertThat(activeMode.matches(1920, 1080, 50f)).isTrue();
}
@Test
public void testAfterDisplayChange_HdrCapabilitiesAreUpdated() throws Exception {
FakeDisplay display = new FakeDisplay(PORT_A);