summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rupesh Bansal <brup@google.com> 2024-12-17 07:16:36 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2024-12-17 07:16:36 -0800
commit5f07d0a5efb810c2873e99c7bd9af5c628ae1868 (patch)
treee6f2bc7a7c635cd1f87312fb6fd49a09d8c47e88
parent695f6d6cfbe0f1458f58c648e86eb4662ba8eeed (diff)
parent245a3503b2c6c0da5b40d45ac716b307b1e7c2ed (diff)
Merge "Split display change event into display basic + RR" into main
-rw-r--r--core/java/android/hardware/display/DisplayManagerGlobal.java33
-rw-r--r--core/java/android/view/Display.java4
-rw-r--r--core/java/android/view/DisplayInfo.java22
-rw-r--r--core/java/android/view/ViewRootImpl.java3
-rw-r--r--core/java/com/android/internal/jank/DisplayResolutionTracker.java4
-rw-r--r--core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java3
-rw-r--r--core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java18
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java17
-rw-r--r--services/core/java/com/android/server/display/LogicalDisplayMapper.java38
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java33
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java16
11 files changed, 118 insertions, 73 deletions
diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java
index ffa546067eff..9030810a1c1a 100644
--- a/core/java/android/hardware/display/DisplayManagerGlobal.java
+++ b/core/java/android/hardware/display/DisplayManagerGlobal.java
@@ -106,7 +106,7 @@ public final class DisplayManagerGlobal {
@IntDef(prefix = {"EVENT_DISPLAY_"}, flag = true, value = {
EVENT_DISPLAY_ADDED,
- EVENT_DISPLAY_CHANGED,
+ EVENT_DISPLAY_BASIC_CHANGED,
EVENT_DISPLAY_REMOVED,
EVENT_DISPLAY_BRIGHTNESS_CHANGED,
EVENT_DISPLAY_HDR_SDR_RATIO_CHANGED,
@@ -119,7 +119,8 @@ public final class DisplayManagerGlobal {
public @interface DisplayEvent {}
public static final int EVENT_DISPLAY_ADDED = 1;
- public static final int EVENT_DISPLAY_CHANGED = 2;
+ public static final int EVENT_DISPLAY_BASIC_CHANGED = 2;
+
public static final int EVENT_DISPLAY_REMOVED = 3;
public static final int EVENT_DISPLAY_BRIGHTNESS_CHANGED = 4;
public static final int EVENT_DISPLAY_HDR_SDR_RATIO_CHANGED = 5;
@@ -130,7 +131,7 @@ public final class DisplayManagerGlobal {
@LongDef(prefix = {"INTERNAL_EVENT_FLAG_"}, flag = true, value = {
INTERNAL_EVENT_FLAG_DISPLAY_ADDED,
- INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
+ INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED,
INTERNAL_EVENT_FLAG_DISPLAY_REMOVED,
INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED,
INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED,
@@ -143,7 +144,7 @@ public final class DisplayManagerGlobal {
public @interface InternalEventFlag {}
public static final long INTERNAL_EVENT_FLAG_DISPLAY_ADDED = 1L << 0;
- public static final long INTERNAL_EVENT_FLAG_DISPLAY_CHANGED = 1L << 1;
+ public static final long INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED = 1L << 1;
public static final long INTERNAL_EVENT_FLAG_DISPLAY_REMOVED = 1L << 2;
public static final long INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED = 1L << 3;
public static final long INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED = 1L << 4;
@@ -485,7 +486,7 @@ public final class DisplayManagerGlobal {
// There can be racing condition between DMS and WMS callbacks, so force triggering the
// listener to make sure the client can get the onDisplayChanged callback even if
// DisplayInfo is not changed (Display read from both DisplayInfo and WindowConfiguration).
- handleDisplayEvent(displayId, EVENT_DISPLAY_CHANGED, true /* forceUpdate */);
+ handleDisplayEvent(displayId, EVENT_DISPLAY_BASIC_CHANGED, true /* forceUpdate */);
}
private static Looper getLooperForHandler(@Nullable Handler handler) {
@@ -518,7 +519,8 @@ public final class DisplayManagerGlobal {
}
if (mDispatchNativeCallbacks) {
mask |= INTERNAL_EVENT_FLAG_DISPLAY_ADDED
- | INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE
| INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
}
if (!mTopologyListeners.isEmpty()) {
@@ -571,7 +573,8 @@ public final class DisplayManagerGlobal {
}
info = getDisplayInfoLocked(displayId);
- if (event == EVENT_DISPLAY_CHANGED && mDispatchNativeCallbacks) {
+ if ((event == EVENT_DISPLAY_BASIC_CHANGED
+ || event == EVENT_DISPLAY_REFRESH_RATE_CHANGED) && mDispatchNativeCallbacks) {
// Choreographer only supports a single display, so only dispatch refresh rate
// changes for the default display.
if (displayId == Display.DEFAULT_DISPLAY) {
@@ -1492,9 +1495,9 @@ public final class DisplayManagerGlobal {
mListener.onDisplayAdded(displayId);
}
break;
- case EVENT_DISPLAY_CHANGED:
- if ((mInternalEventFlagsMask & INTERNAL_EVENT_FLAG_DISPLAY_CHANGED)
- != 0) {
+ case EVENT_DISPLAY_BASIC_CHANGED:
+ if ((mInternalEventFlagsMask
+ & INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED) != 0) {
if (info != null && (forceUpdate || !info.equals(mDisplayInfo))) {
if (extraLogging()) {
Slog.i(TAG, "Sending onDisplayChanged: Display Changed. Info: "
@@ -1691,8 +1694,8 @@ public final class DisplayManagerGlobal {
switch (event) {
case EVENT_DISPLAY_ADDED:
return "ADDED";
- case EVENT_DISPLAY_CHANGED:
- return "CHANGED";
+ case EVENT_DISPLAY_BASIC_CHANGED:
+ return "BASIC_CHANGED";
case EVENT_DISPLAY_REMOVED:
return "REMOVED";
case EVENT_DISPLAY_BRIGHTNESS_CHANGED:
@@ -1763,7 +1766,11 @@ public final class DisplayManagerGlobal {
}
if ((eventFlags & DisplayManager.EVENT_FLAG_DISPLAY_CHANGED) != 0) {
- baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_CHANGED;
+ // For backward compatibility, a client subscribing to
+ // DisplayManager.EVENT_FLAG_DISPLAY_CHANGED will be enrolled to both Basic and
+ // RR changes
+ baseEventMask |= INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE;
}
if ((eventFlags
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 0c8a0d60a96a..ca0959af3ff8 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -1597,7 +1597,9 @@ public final class Display {
// Although we only care about the HDR/SDR ratio changing, that can also come in the
// form of the larger DISPLAY_CHANGED event
mGlobal.registerDisplayListener(toRegister, executor,
- DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ DisplayManagerGlobal
+ .INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE
| DisplayManagerGlobal
.INTERNAL_EVENT_FLAG_DISPLAY_HDR_SDR_RATIO_CHANGED,
ActivityThread.currentPackageName());
diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java
index ba098eb53246..e75b1b0bd17a 100644
--- a/core/java/android/view/DisplayInfo.java
+++ b/core/java/android/view/DisplayInfo.java
@@ -447,7 +447,18 @@ public final class DisplayInfo implements Parcelable {
}
public boolean equals(DisplayInfo other) {
- return other != null
+ return equals(other, /* compareRefreshRate */ true);
+ }
+
+ /**
+ * Compares if the two DisplayInfo objects are equal or not
+ * @param other The other DisplayInfo against which the comparison is to be done
+ * @param compareRefreshRate Indicates if the refresh rate is also to be considered in
+ * comparison
+ * @return
+ */
+ public boolean equals(DisplayInfo other, boolean compareRefreshRate) {
+ boolean isEqualWithoutRefreshRate = other != null
&& layerStack == other.layerStack
&& flags == other.flags
&& type == other.type
@@ -466,7 +477,6 @@ public final class DisplayInfo implements Parcelable {
&& logicalHeight == other.logicalHeight
&& Objects.equals(displayCutout, other.displayCutout)
&& rotation == other.rotation
- && modeId == other.modeId
&& hasArrSupport == other.hasArrSupport
&& Objects.equals(frameRateCategoryRate, other.frameRateCategoryRate)
&& Arrays.equals(supportedRefreshRates, other.supportedRefreshRates)
@@ -490,7 +500,6 @@ public final class DisplayInfo implements Parcelable {
&& ownerUid == other.ownerUid
&& Objects.equals(ownerPackageName, other.ownerPackageName)
&& removeMode == other.removeMode
- && getRefreshRate() == other.getRefreshRate()
&& brightnessMinimum == other.brightnessMinimum
&& brightnessMaximum == other.brightnessMaximum
&& brightnessDefault == other.brightnessDefault
@@ -504,6 +513,13 @@ public final class DisplayInfo implements Parcelable {
&& Objects.equals(
thermalBrightnessThrottlingDataId, other.thermalBrightnessThrottlingDataId)
&& canHostTasks == other.canHostTasks;
+
+ if (compareRefreshRate) {
+ return isEqualWithoutRefreshRate
+ && (getRefreshRate() == other.getRefreshRate())
+ && (modeId == other.modeId);
+ }
+ return isEqualWithoutRefreshRate;
}
@Override
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 1d27574eca8c..ec1650947aec 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1828,7 +1828,8 @@ public final class ViewRootImpl implements ViewParent,
| DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_STATE
| DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED
: DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
- | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE
| DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
DisplayManagerGlobal
.getInstance()
diff --git a/core/java/com/android/internal/jank/DisplayResolutionTracker.java b/core/java/com/android/internal/jank/DisplayResolutionTracker.java
index 0c2fd4bbd7ae..5d66b3c10197 100644
--- a/core/java/com/android/internal/jank/DisplayResolutionTracker.java
+++ b/core/java/com/android/internal/jank/DisplayResolutionTracker.java
@@ -148,8 +148,8 @@ public class DisplayResolutionTracker {
public void registerDisplayListener(DisplayManager.DisplayListener listener) {
manager.registerDisplayListener(listener, handler,
DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
- | DisplayManagerGlobal
- .INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE,
ActivityThread.currentPackageName());
}
diff --git a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java
index 911b7ce22741..10a85bcbf488 100644
--- a/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java
+++ b/core/tests/coretests/src/android/app/servertransaction/ClientTransactionListenerControllerTest.java
@@ -120,7 +120,8 @@ public class ClientTransactionListenerControllerTest {
doReturn(newDisplayInfo).when(mIDisplayManager).getDisplayInfo(123);
mDisplayManager.registerDisplayListener(mListener, mHandler,
- DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE,
null /* packageName */);
mController.onDisplayChanged(123);
diff --git a/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java b/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java
index 7a5b3064b3a3..a270848b98a3 100644
--- a/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java
+++ b/core/tests/coretests/src/android/hardware/display/DisplayManagerGlobalTest.java
@@ -73,9 +73,13 @@ public class DisplayManagerGlobalTest {
public final CheckFlagsRule mCheckFlagsRule =
DeviceFlagsValueProvider.createCheckFlagsRule();
+ private static final long DISPLAY_CHANGE_EVENTS =
+ DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE;
+
private static final long ALL_DISPLAY_EVENTS =
DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
- | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DISPLAY_CHANGE_EVENTS
| DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
@Mock
@@ -127,7 +131,7 @@ public class DisplayManagerGlobalTest {
final DisplayInfo newDisplayInfo = new DisplayInfo();
newDisplayInfo.rotation++;
doReturn(newDisplayInfo).when(mDisplayManager).getDisplayInfo(displayId);
- callback.onDisplayEvent(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
+ callback.onDisplayEvent(displayId, DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED);
waitForHandler();
Mockito.verify(mDisplayListener).onDisplayChanged(eq(displayId));
Mockito.verifyNoMoreInteractions(mDisplayListener);
@@ -186,8 +190,8 @@ public class DisplayManagerGlobalTest {
mDisplayManagerGlobal.registerDisplayListener(mDisplayListener, mHandler,
ALL_DISPLAY_EVENTS
- & ~DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED, null);
- callback.onDisplayEvent(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
+ & ~DISPLAY_CHANGE_EVENTS, null);
+ callback.onDisplayEvent(displayId, DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED);
waitForHandler();
Mockito.verifyZeroInteractions(mDisplayListener);
@@ -257,8 +261,7 @@ public class DisplayManagerGlobalTest {
| DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED,
null /* packageName */);
mDisplayManagerGlobal.registerDisplayListener(mDisplayListener2, mHandler,
- DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
- null /* packageName */);
+ DISPLAY_CHANGE_EVENTS, null /* packageName */);
mDisplayManagerGlobal.handleDisplayChangeFromWindowManager(321);
waitForHandler();
@@ -304,8 +307,7 @@ public class DisplayManagerGlobalTest {
assertEquals(DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED,
mDisplayManagerGlobal
.mapFlagsToInternalEventFlag(DisplayManager.EVENT_FLAG_DISPLAY_ADDED, 0));
- assertEquals(DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED,
- mDisplayManagerGlobal
+ assertEquals(DISPLAY_CHANGE_EVENTS, mDisplayManagerGlobal
.mapFlagsToInternalEventFlag(DisplayManager.EVENT_FLAG_DISPLAY_CHANGED, 0));
assertEquals(DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED,
mDisplayManagerGlobal
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index bad5b8b9567a..2985ad330bc6 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -2397,7 +2397,7 @@ public final class DisplayManagerService extends SystemService {
// We don't bother invalidating the display info caches here because any changes to the
// display info will trigger a cache invalidation inside of LogicalDisplay before we hit
// this point.
- sendDisplayEventIfEnabledLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
+ sendDisplayEventIfEnabledLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED);
applyDisplayChangedLocked(display);
}
@@ -2643,7 +2643,8 @@ public final class DisplayManagerService extends SystemService {
private void updateCanHostTasksIfNeededLocked(LogicalDisplay display) {
if (display.setCanHostTasksLocked(!mMirrorBuiltInDisplay)) {
- sendDisplayEventIfEnabledLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
+ sendDisplayEventIfEnabledLocked(display,
+ DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED);
}
}
@@ -3474,7 +3475,7 @@ public final class DisplayManagerService extends SystemService {
private void sendDisplayEventFrameRateOverrideLocked(int displayId) {
Message msg = mHandler.obtainMessage(MSG_DELIVER_DISPLAY_EVENT_FRAME_RATE_OVERRIDE,
- displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
+ displayId, DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED);
mHandler.sendMessage(msg);
}
@@ -4061,7 +4062,7 @@ public final class DisplayManagerService extends SystemService {
handleLogicalDisplayAddedLocked(display);
break;
- case LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_CHANGED:
+ case LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_BASIC_CHANGED:
handleLogicalDisplayChangedLocked(display);
break;
@@ -4286,8 +4287,9 @@ public final class DisplayManagerService extends SystemService {
switch (event) {
case DisplayManagerGlobal.EVENT_DISPLAY_ADDED:
return (mask & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED) != 0;
- case DisplayManagerGlobal.EVENT_DISPLAY_CHANGED:
- return (mask & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED) != 0;
+ case DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED:
+ return (mask & DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED)
+ != 0;
case DisplayManagerGlobal.EVENT_DISPLAY_BRIGHTNESS_CHANGED:
return (mask
& DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BRIGHTNESS_CHANGED)
@@ -4542,7 +4544,8 @@ public final class DisplayManagerService extends SystemService {
public void registerCallback(IDisplayManagerCallback callback) {
registerCallbackWithEventMask(callback,
DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
- | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE
| DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED);
}
diff --git a/services/core/java/com/android/server/display/LogicalDisplayMapper.java b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
index 79592a656409..006921572977 100644
--- a/services/core/java/com/android/server/display/LogicalDisplayMapper.java
+++ b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
@@ -81,7 +81,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
public static final int LOGICAL_DISPLAY_EVENT_BASE = 0;
public static final int LOGICAL_DISPLAY_EVENT_ADDED = 1 << 0;
- public static final int LOGICAL_DISPLAY_EVENT_CHANGED = 1 << 1;
+ public static final int LOGICAL_DISPLAY_EVENT_BASIC_CHANGED = 1 << 1;
public static final int LOGICAL_DISPLAY_EVENT_REMOVED = 1 << 2;
public static final int LOGICAL_DISPLAY_EVENT_SWAPPED = 1 << 3;
public static final int LOGICAL_DISPLAY_EVENT_FRAME_RATE_OVERRIDES_CHANGED = 1 << 4;
@@ -172,9 +172,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
/**
* Has an entry for every logical display that the rest of the system has been notified about.
- * Any entry in here requires us to send a {@link LOGICAL_DISPLAY_EVENT_REMOVED} event when it
- * is deleted or {@link LOGICAL_DISPLAY_EVENT_CHANGED} when it is changed. The values are any
- * of the {@code UPDATE_STATE_*} constant types.
+ * The values are any of the {@code UPDATE_STATE_*} constant types.
*/
private final SparseIntArray mUpdatedLogicalDisplays = new SparseIntArray();
@@ -811,7 +809,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
final boolean isCurrentlyEnabled = display.isEnabledLocked();
int logicalDisplayEventMask = mLogicalDisplaysToUpdate
.get(displayId, LOGICAL_DISPLAY_EVENT_BASE);
-
+ boolean hasBasicInfoChanged =
+ !mTempDisplayInfo.equals(newDisplayInfo, /* compareRefreshRate */ false);
// The display is no longer valid and needs to be removed.
if (!display.isValidLocked()) {
// Remove from group
@@ -863,19 +862,28 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
int event = isCurrentlyEnabled ? LOGICAL_DISPLAY_EVENT_ADDED :
LOGICAL_DISPLAY_EVENT_REMOVED;
logicalDisplayEventMask |= event;
- } else if (wasDirty || !mTempDisplayInfo.equals(newDisplayInfo)) {
+ } else if (wasDirty) {
// If only the hdr/sdr ratio changed, then send just the event for that case
if ((diff == DisplayDeviceInfo.DIFF_HDR_SDR_RATIO)) {
logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_HDR_SDR_RATIO_CHANGED;
} else {
- logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_CHANGED;
+ logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_BASIC_CHANGED
+ | LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED
+ | LOGICAL_DISPLAY_EVENT_STATE_CHANGED;
}
+ } else if (hasBasicInfoChanged
+ || mTempDisplayInfo.getRefreshRate() != newDisplayInfo.getRefreshRate()) {
+ // If only the hdr/sdr ratio changed, then send just the event for that case
+ if ((diff == DisplayDeviceInfo.DIFF_HDR_SDR_RATIO)) {
+ logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_HDR_SDR_RATIO_CHANGED;
+ } else {
- if (mFlags.isDisplayListenerPerformanceImprovementsEnabled()) {
+ if (hasBasicInfoChanged) {
+ logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_BASIC_CHANGED;
+ }
logicalDisplayEventMask
|= updateAndGetMaskForDisplayPropertyChanges(newDisplayInfo);
}
-
// The display is involved in a display layout transition
} else if (updateState == UPDATE_STATE_TRANSITION) {
logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_DEVICE_STATE_TRANSITION;
@@ -891,7 +899,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
// things like display cutouts.
display.getNonOverrideDisplayInfoLocked(mTempDisplayInfo);
if (!mTempNonOverrideDisplayInfo.equals(mTempDisplayInfo)) {
- logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_CHANGED;
+ logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_BASIC_CHANGED
+ | LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED;
}
}
mLogicalDisplaysToUpdate.put(displayId, logicalDisplayEventMask);
@@ -930,7 +939,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
if (mFlags.isConnectedDisplayManagementEnabled()) {
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_DISCONNECTED);
}
- sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_CHANGED);
+ sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_BASIC_CHANGED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_STATE_CHANGED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_FRAME_RATE_OVERRIDES_CHANGED);
@@ -962,7 +971,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
mask |= LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED;
}
- if (mTempDisplayInfo.state != newDisplayInfo.state) {
+ if (mFlags.isDisplayListenerPerformanceImprovementsEnabled()
+ && mTempDisplayInfo.state != newDisplayInfo.state) {
mask |= LOGICAL_DISPLAY_EVENT_STATE_CHANGED;
}
return mask;
@@ -1357,8 +1367,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
return "added";
case LOGICAL_DISPLAY_EVENT_DEVICE_STATE_TRANSITION:
return "transition";
- case LOGICAL_DISPLAY_EVENT_CHANGED:
- return "changed";
case LOGICAL_DISPLAY_EVENT_FRAME_RATE_OVERRIDES_CHANGED:
return "framerate_override";
case LOGICAL_DISPLAY_EVENT_SWAPPED:
@@ -1375,6 +1383,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
return "state_changed";
case LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED:
return "refresh_rate_changed";
+ case LOGICAL_DISPLAY_EVENT_BASIC_CHANGED:
+ return "basic_changed";
}
return null;
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
index f96294ed4ca8..b7b4f0424165 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
@@ -214,7 +214,8 @@ public class DisplayManagerServiceTest {
private static final String PACKAGE_NAME = "com.android.frameworks.displayservicetests";
private static final long STANDARD_DISPLAY_EVENTS =
DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
- | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_BASIC_CHANGED
+ | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REFRESH_RATE
| DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
private static final long STANDARD_AND_CONNECTION_DISPLAY_EVENTS =
STANDARD_DISPLAY_EVENTS
@@ -222,7 +223,7 @@ public class DisplayManagerServiceTest {
private static final String EVENT_DISPLAY_ADDED = "EVENT_DISPLAY_ADDED";
private static final String EVENT_DISPLAY_REMOVED = "EVENT_DISPLAY_REMOVED";
- private static final String EVENT_DISPLAY_CHANGED = "EVENT_DISPLAY_CHANGED";
+ private static final String EVENT_DISPLAY_BASIC_CHANGED = "EVENT_DISPLAY_BASIC_CHANGED";
private static final String EVENT_DISPLAY_BRIGHTNESS_CHANGED =
"EVENT_DISPLAY_BRIGHTNESS_CHANGED";
private static final String EVENT_DISPLAY_HDR_SDR_RATIO_CHANGED =
@@ -889,7 +890,6 @@ public class DisplayManagerServiceTest {
FakeDisplayManagerCallback callback = registerDisplayListenerCallback(
displayManager, bs, displayDevice);
-
// Simulate DisplayDevice change
DisplayDeviceInfo displayDeviceInfo2 = new DisplayDeviceInfo();
displayDeviceInfo2.copyFrom(displayDeviceInfo);
@@ -900,7 +900,8 @@ public class DisplayManagerServiceTest {
Handler handler = displayManager.getDisplayHandler();
waitForIdleHandler(handler);
- assertThat(callback.receivedEvents()).containsExactly(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).containsExactly(EVENT_DISPLAY_BASIC_CHANGED,
+ EVENT_DISPLAY_REFRESH_RATE_CHANGED);
}
/**
@@ -2145,7 +2146,7 @@ public class DisplayManagerServiceTest {
new DisplayEventReceiver.FrameRateOverride(myUid, 30f),
});
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_BASIC_CHANGED);
callback.clear();
updateFrameRateOverride(displayManager, displayDevice,
@@ -2154,7 +2155,7 @@ public class DisplayManagerServiceTest {
new DisplayEventReceiver.FrameRateOverride(1234, 30f),
});
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_BASIC_CHANGED);
updateFrameRateOverride(displayManager, displayDevice,
new DisplayEventReceiver.FrameRateOverride[]{
@@ -2163,7 +2164,7 @@ public class DisplayManagerServiceTest {
new DisplayEventReceiver.FrameRateOverride(5678, 30f),
});
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_BASIC_CHANGED);
callback.clear();
updateFrameRateOverride(displayManager, displayDevice,
@@ -2172,7 +2173,7 @@ public class DisplayManagerServiceTest {
new DisplayEventReceiver.FrameRateOverride(5678, 30f),
});
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_BASIC_CHANGED);
callback.clear();
updateFrameRateOverride(displayManager, displayDevice,
@@ -2180,7 +2181,7 @@ public class DisplayManagerServiceTest {
new DisplayEventReceiver.FrameRateOverride(5678, 30f),
});
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_BASIC_CHANGED);
}
/**
@@ -2303,16 +2304,16 @@ public class DisplayManagerServiceTest {
updateRenderFrameRate(displayManager, displayDevice, 30f);
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_REFRESH_RATE_CHANGED);
callback.clear();
updateRenderFrameRate(displayManager, displayDevice, 30f);
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_REFRESH_RATE_CHANGED);
updateRenderFrameRate(displayManager, displayDevice, 20f);
waitForIdleHandler(displayManager.getDisplayHandler());
- assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_REFRESH_RATE_CHANGED);
callback.clear();
}
@@ -3888,7 +3889,7 @@ public class DisplayManagerServiceTest {
observer.onChange(false, Settings.Secure.getUriFor(MIRROR_BUILT_IN_DISPLAY));
waitForIdleHandler(handler);
- assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).doesNotContain(EVENT_DISPLAY_BASIC_CHANGED);
}
@Test
@@ -3919,7 +3920,7 @@ public class DisplayManagerServiceTest {
observer.onChange(false, Settings.Secure.getUriFor(MIRROR_BUILT_IN_DISPLAY));
waitForIdleHandler(handler);
- assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_CHANGED);
+ assertThat(callback.receivedEvents()).contains(EVENT_DISPLAY_BASIC_CHANGED);
}
private void initDisplayPowerController(DisplayManagerInternal localService) {
@@ -4389,8 +4390,8 @@ public class DisplayManagerServiceTest {
return EVENT_DISPLAY_ADDED;
case DisplayManagerGlobal.EVENT_DISPLAY_REMOVED:
return EVENT_DISPLAY_REMOVED;
- case DisplayManagerGlobal.EVENT_DISPLAY_CHANGED:
- return EVENT_DISPLAY_CHANGED;
+ case DisplayManagerGlobal.EVENT_DISPLAY_BASIC_CHANGED:
+ return EVENT_DISPLAY_BASIC_CHANGED;
case DisplayManagerGlobal.EVENT_DISPLAY_BRIGHTNESS_CHANGED:
return EVENT_DISPLAY_BRIGHTNESS_CHANGED;
case DisplayManagerGlobal.EVENT_DISPLAY_HDR_SDR_RATIO_CHANGED:
diff --git a/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java b/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java
index ad30f22fe060..0dbb6ba58b3c 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java
@@ -36,9 +36,9 @@ import static com.android.server.display.DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DE
import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_ADDED;
import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_CONNECTED;
import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_DISCONNECTED;
-import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED;
import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_REMOVED;
import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_STATE_CHANGED;
+import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED;
import static com.android.server.display.layout.Layout.Display.POSITION_REAR;
import static com.android.server.display.layout.Layout.Display.POSITION_UNKNOWN;
import static com.android.server.utils.FoldSettingProvider.SETTING_VALUE_SELECTIVE_STAY_AWAKE;
@@ -1170,18 +1170,20 @@ public class LogicalDisplayMapperTest {
@Test
public void updateAndGetMaskForDisplayPropertyChanges_getsPropertyChangedFlags() {
- // Change the display state
+ // Change the refresh rate override
DisplayInfo newDisplayInfo = new DisplayInfo();
- newDisplayInfo.state = STATE_OFF;
- assertEquals(LOGICAL_DISPLAY_EVENT_STATE_CHANGED,
+ newDisplayInfo.refreshRateOverride = 30;
+ assertEquals(LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED,
mLogicalDisplayMapper.updateAndGetMaskForDisplayPropertyChanges(newDisplayInfo));
- // Change the refresh rate override
+ // Change the display state
+ when(mFlagsMock.isDisplayListenerPerformanceImprovementsEnabled()).thenReturn(true);
newDisplayInfo = new DisplayInfo();
- newDisplayInfo.refreshRateOverride = 30;
- assertEquals(LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED,
+ newDisplayInfo.state = STATE_OFF;
+ assertEquals(LOGICAL_DISPLAY_EVENT_STATE_CHANGED,
mLogicalDisplayMapper.updateAndGetMaskForDisplayPropertyChanges(newDisplayInfo));
+
// Change multiple properties
newDisplayInfo = new DisplayInfo();
newDisplayInfo.refreshRateOverride = 30;