Update display info on hotplug
Test: manually conect DUT to a display, then to
a different display
Bug: 158220266
Change-Id: I44eead97e0a09a0370a3eb674d207d1c9d0e92cc
This commit is contained in:
@@ -49,7 +49,6 @@ import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.Trace;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.SparseIntArray;
|
||||
@@ -1455,6 +1454,22 @@ public final class SurfaceControl implements Parcelable {
|
||||
+ ", secure=" + secure
|
||||
+ ", deviceProductInfo=" + deviceProductInfo + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DisplayInfo that = (DisplayInfo) o;
|
||||
return isInternal == that.isInternal
|
||||
&& density == that.density
|
||||
&& secure == that.secure
|
||||
&& Objects.equals(deviceProductInfo, that.deviceProductInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(isInternal, density, secure, deviceProductInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -134,7 +134,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
hdrCapabilities, isDefaultDisplay);
|
||||
mDevices.put(physicalDisplayId, device);
|
||||
sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED);
|
||||
} else if (device.updateDisplayPropertiesLocked(configs, activeConfig,
|
||||
} else if (device.updateDisplayPropertiesLocked(info, configs, activeConfig,
|
||||
configSpecs, colorModes, activeColorMode, hdrCapabilities)) {
|
||||
sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
|
||||
}
|
||||
@@ -212,8 +212,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
super(LocalDisplayAdapter.this, displayToken, UNIQUE_ID_PREFIX + physicalDisplayId);
|
||||
mPhysicalDisplayId = physicalDisplayId;
|
||||
mIsDefaultDisplay = isDefaultDisplay;
|
||||
mDisplayInfo = info;
|
||||
updateDisplayPropertiesLocked(configs, activeConfigId, configSpecs, colorModes,
|
||||
updateDisplayPropertiesLocked(info, configs, activeConfigId, configSpecs, colorModes,
|
||||
activeColorMode, hdrCapabilities);
|
||||
mSidekickInternal = LocalServices.getService(SidekickInternal.class);
|
||||
if (mIsDefaultDisplay) {
|
||||
@@ -238,12 +237,15 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
/**
|
||||
* Returns true if there is a change.
|
||||
**/
|
||||
public boolean updateDisplayPropertiesLocked(SurfaceControl.DisplayConfig[] configs,
|
||||
public boolean updateDisplayPropertiesLocked(SurfaceControl.DisplayInfo info,
|
||||
SurfaceControl.DisplayConfig[] configs,
|
||||
int activeConfigId, SurfaceControl.DesiredDisplayConfigSpecs configSpecs,
|
||||
int[] colorModes, int activeColorMode, Display.HdrCapabilities hdrCapabilities) {
|
||||
boolean changed = updateDisplayConfigsLocked(configs, activeConfigId, configSpecs);
|
||||
changed |= updateDisplayInfo(info);
|
||||
changed |= updateColorModesLocked(colorModes, activeColorMode);
|
||||
changed |= updateHdrCapabilitiesLocked(hdrCapabilities);
|
||||
|
||||
if (changed) {
|
||||
mHavePendingChanges = true;
|
||||
}
|
||||
@@ -420,6 +422,14 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
mSystemBrightnessToNits = sysToNits;
|
||||
}
|
||||
|
||||
private boolean updateDisplayInfo(SurfaceControl.DisplayInfo info) {
|
||||
if (Objects.equals(mDisplayInfo, info)) {
|
||||
return false;
|
||||
}
|
||||
mDisplayInfo = info;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean updateColorModesLocked(int[] colorModes, int activeColorMode) {
|
||||
if (colorModes == null) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user