Merge "Support default hbm metadata for non-internal displays" into tm-qpr-dev am: 214b946297

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21027240

Change-Id: I2456627ea74c12d93101f1f7d5977d716b1ea1f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2023-01-23 19:30:32 +00:00
committed by Automerger Merge Worker
3 changed files with 43 additions and 11 deletions

View File

@@ -258,7 +258,7 @@ public final class DisplayManagerService extends SystemService {
mDisplayWindowPolicyControllers = new SparseArray<>(); mDisplayWindowPolicyControllers = new SparseArray<>();
/** /**
* Map of every internal primary display device {@link HighBrightnessModeMetadata}s indexed by * Map of every display device {@link HighBrightnessModeMetadata}s indexed by
* {@link DisplayDevice#mUniqueId}. * {@link DisplayDevice#mUniqueId}.
*/ */
public final ArrayMap<String, HighBrightnessModeMetadata> mHighBrightnessModeMetadataMap = public final ArrayMap<String, HighBrightnessModeMetadata> mHighBrightnessModeMetadataMap =
@@ -1525,6 +1525,7 @@ public final class DisplayManagerService extends SystemService {
final int displayId = display.getDisplayIdLocked(); final int displayId = display.getDisplayIdLocked();
final boolean isDefault = displayId == Display.DEFAULT_DISPLAY; final boolean isDefault = displayId == Display.DEFAULT_DISPLAY;
configureColorModeLocked(display, device); configureColorModeLocked(display, device);
if (!mAreUserDisabledHdrTypesAllowed) { if (!mAreUserDisabledHdrTypesAllowed) {
display.setUserDisabledHdrTypes(mUserDisabledHdrTypes); display.setUserDisabledHdrTypes(mUserDisabledHdrTypes);
} }
@@ -2636,7 +2637,8 @@ public final class DisplayManagerService extends SystemService {
mLogicalDisplayMapper.forEachLocked(this::addDisplayPowerControllerLocked); mLogicalDisplayMapper.forEachLocked(this::addDisplayPowerControllerLocked);
} }
private HighBrightnessModeMetadata getHighBrightnessModeMetadata(LogicalDisplay display) { @VisibleForTesting
HighBrightnessModeMetadata getHighBrightnessModeMetadata(LogicalDisplay display) {
final DisplayDevice device = display.getPrimaryDisplayDeviceLocked(); final DisplayDevice device = display.getPrimaryDisplayDeviceLocked();
if (device == null) { if (device == null) {
Slog.wtf(TAG, "Display Device is null in DisplayPowerController for display: " Slog.wtf(TAG, "Display Device is null in DisplayPowerController for display: "
@@ -2644,11 +2646,6 @@ public final class DisplayManagerService extends SystemService {
return null; return null;
} }
// HBM brightness mode is only applicable to internal physical displays.
if (display.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
return null;
}
final String uniqueId = device.getUniqueId(); final String uniqueId = device.getUniqueId();
if (mHighBrightnessModeMetadataMap.containsKey(uniqueId)) { if (mHighBrightnessModeMetadataMap.containsKey(uniqueId)) {
@@ -2673,7 +2670,7 @@ public final class DisplayManagerService extends SystemService {
final BrightnessSetting brightnessSetting = new BrightnessSetting(mPersistentDataStore, final BrightnessSetting brightnessSetting = new BrightnessSetting(mPersistentDataStore,
display, mSyncRoot); display, mSyncRoot);
// If display is internal and has a HighBrightnessModeMetadata mapping, use that. // If display already has a HighBrightnessModeMetadata mapping, use that.
// Or create a new one and use that. // Or create a new one and use that.
// We also need to pass a mapping of the HighBrightnessModeTimeInfoMap to // We also need to pass a mapping of the HighBrightnessModeTimeInfoMap to
// displayPowerController, so the hbm info can be correctly associated // displayPowerController, so the hbm info can be correctly associated

View File

@@ -21,10 +21,9 @@ import java.util.ArrayDeque;
/** /**
* Represents High Brightness Mode metadata associated * Represents High Brightness Mode metadata associated
* with a specific internal physical display. * with a specific display.
* Required for separately storing data like time information, * Required for separately storing data like time information,
* and related events when display was in HBM mode per * and related events when display was in HBM mode per display.
* physical internal display.
*/ */
class HighBrightnessModeMetadata { class HighBrightnessModeMetadata {
/** /**

View File

@@ -423,6 +423,37 @@ public class DisplayManagerServiceTest {
assertTrue(callback.mDisplayChangedCalled); assertTrue(callback.mDisplayChangedCalled);
} }
/**
* Tests that HighBrightnessModeMetadata is non-null on all display devices.
*/
@Test
public void testHighBrightnessModeMetadataNonNull() throws Exception {
DisplayManagerService displayManager =
new DisplayManagerService(mContext, mShortMockedInjector);
registerDefaultDisplays(displayManager);
displayManager.onBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);
// Add the FakeDisplayDevice
FakeDisplayDevice displayDevice = new FakeDisplayDevice("unique_hbm_device");
DisplayDeviceInfo displayDeviceInfo = new DisplayDeviceInfo();
displayDevice.setDisplayDeviceInfo(displayDeviceInfo);
LogicalDisplay logicalDisplay = new LogicalDisplay(1, 1, displayDevice);
HighBrightnessModeMetadata hbmMeta =
displayManager.getHighBrightnessModeMetadata(logicalDisplay);
assertNotNull(hbmMeta);
// Check is Hbm metadata is correctly added for the display device.
String uniqueId = displayDevice.getUniqueId();
assertTrue(uniqueId.equals("unique_hbm_device"));
assertTrue(displayManager.mHighBrightnessModeMetadataMap.containsKey(uniqueId));
HighBrightnessModeMetadata hbmMetaFromMap =
displayManager.mHighBrightnessModeMetadataMap.get(uniqueId);
assertEquals(hbmMeta, hbmMetaFromMap);
}
/** /**
* Tests that we get a Runtime exception when we cannot initialize the default display. * Tests that we get a Runtime exception when we cannot initialize the default display.
*/ */
@@ -1349,6 +1380,11 @@ public class DisplayManagerServiceTest {
super(null, null, "", mContext); super(null, null, "", mContext);
} }
FakeDisplayDevice(String uniqueDeviceId) {
super(null, null, uniqueDeviceId, mContext);
}
public void setDisplayDeviceInfo(DisplayDeviceInfo displayDeviceInfo) { public void setDisplayDeviceInfo(DisplayDeviceInfo displayDeviceInfo) {
mDisplayDeviceInfo = displayDeviceInfo; mDisplayDeviceInfo = displayDeviceInfo;
} }