Support default hbm metadata for non-internal displays
We currently have HBMController for all the displays irrespective of their type,
and each HBMController implicitly assumes that it has an associated metadata.
Bug: 265777465
Bug: 265186363
Test: Added a new unit test.
atest com.android.server.display.DisplayManagerServiceTest#testHighBrightnessModeMetadataNonNull
Manual testing with multiple device with virtual displays
to make sure SystemUI works as intended.
Change-Id: I492265b1385f6121196f18e8a4152f4e2fc6ef54
Merged-In: Idf45b87782a56bcbc09fc37c69fcc13531edf76f
This commit is contained in:
@@ -258,7 +258,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
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}.
|
||||
*/
|
||||
public final ArrayMap<String, HighBrightnessModeMetadata> mHighBrightnessModeMetadataMap =
|
||||
@@ -1525,6 +1525,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
final int displayId = display.getDisplayIdLocked();
|
||||
final boolean isDefault = displayId == Display.DEFAULT_DISPLAY;
|
||||
configureColorModeLocked(display, device);
|
||||
|
||||
if (!mAreUserDisabledHdrTypesAllowed) {
|
||||
display.setUserDisabledHdrTypes(mUserDisabledHdrTypes);
|
||||
}
|
||||
@@ -2636,7 +2637,8 @@ public final class DisplayManagerService extends SystemService {
|
||||
mLogicalDisplayMapper.forEachLocked(this::addDisplayPowerControllerLocked);
|
||||
}
|
||||
|
||||
private HighBrightnessModeMetadata getHighBrightnessModeMetadata(LogicalDisplay display) {
|
||||
@VisibleForTesting
|
||||
HighBrightnessModeMetadata getHighBrightnessModeMetadata(LogicalDisplay display) {
|
||||
final DisplayDevice device = display.getPrimaryDisplayDeviceLocked();
|
||||
if (device == null) {
|
||||
Slog.wtf(TAG, "Display Device is null in DisplayPowerController for display: "
|
||||
@@ -2644,11 +2646,6 @@ public final class DisplayManagerService extends SystemService {
|
||||
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();
|
||||
|
||||
if (mHighBrightnessModeMetadataMap.containsKey(uniqueId)) {
|
||||
@@ -2673,7 +2670,7 @@ public final class DisplayManagerService extends SystemService {
|
||||
final BrightnessSetting brightnessSetting = new BrightnessSetting(mPersistentDataStore,
|
||||
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.
|
||||
// We also need to pass a mapping of the HighBrightnessModeTimeInfoMap to
|
||||
// displayPowerController, so the hbm info can be correctly associated
|
||||
|
||||
@@ -21,10 +21,9 @@ import java.util.ArrayDeque;
|
||||
|
||||
/**
|
||||
* Represents High Brightness Mode metadata associated
|
||||
* with a specific internal physical display.
|
||||
* with a specific display.
|
||||
* Required for separately storing data like time information,
|
||||
* and related events when display was in HBM mode per
|
||||
* physical internal display.
|
||||
* and related events when display was in HBM mode per display.
|
||||
*/
|
||||
class HighBrightnessModeMetadata {
|
||||
/**
|
||||
|
||||
@@ -423,6 +423,37 @@ public class DisplayManagerServiceTest {
|
||||
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.
|
||||
*/
|
||||
@@ -1349,6 +1380,11 @@ public class DisplayManagerServiceTest {
|
||||
super(null, null, "", mContext);
|
||||
}
|
||||
|
||||
FakeDisplayDevice(String uniqueDeviceId) {
|
||||
super(null, null, uniqueDeviceId, mContext);
|
||||
}
|
||||
|
||||
|
||||
public void setDisplayDeviceInfo(DisplayDeviceInfo displayDeviceInfo) {
|
||||
mDisplayDeviceInfo = displayDeviceInfo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user