Update activeMode when it changes from SF
Update activeMode when after hotplug it has changed and the change was not requested from display manager. This happens when the mode has changed from the display device. This is similar to what we currently do when the list of supported modes has changed after hotplug. Bug: 170298716 Test: atest LocalDisplayAdapterTest Change-Id: I78d89fe85ae50ae3d6b1d0d60214f5b91f2e3ed7
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user