Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db96662e authored by Ady Abraham's avatar Ady Abraham Committed by Android (Google) Code Review
Browse files

Merge "DisplayManagerGlobal: suppress redundant onDisplayChanged events" into sc-dev

parents 640b18bd 6f1cac99
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -391,8 +391,9 @@ public final class DisplayManagerGlobal {
            }

            final int numListeners = mDisplayListeners.size();
            DisplayInfo info = getDisplayInfo(displayId);
            for (int i = 0; i < numListeners; i++) {
                mDisplayListeners.get(i).sendDisplayEvent(displayId, event);
                mDisplayListeners.get(i).sendDisplayEvent(displayId, event, info);
            }
            if (event == EVENT_DISPLAY_CHANGED && mDispatchNativeCallbacks) {
                // Choreographer only supports a single display, so only dispatch refresh rate
@@ -894,6 +895,8 @@ public final class DisplayManagerGlobal {
        public final DisplayListener mListener;
        public long mEventsMask;

        private final DisplayInfo mDisplayInfo = new DisplayInfo();

        DisplayListenerDelegate(DisplayListener listener, @NonNull Looper looper,
                @EventsMask long eventsMask) {
            super(looper, null, true /*async*/);
@@ -901,8 +904,8 @@ public final class DisplayManagerGlobal {
            mEventsMask = eventsMask;
        }

        public void sendDisplayEvent(int displayId, @DisplayEvent int event) {
            Message msg = obtainMessage(event, displayId, 0);
        public void sendDisplayEvent(int displayId, @DisplayEvent int event, DisplayInfo info) {
            Message msg = obtainMessage(event, displayId, 0, info);
            sendMessage(msg);
        }

@@ -924,8 +927,12 @@ public final class DisplayManagerGlobal {
                    break;
                case EVENT_DISPLAY_CHANGED:
                    if ((mEventsMask & DisplayManager.EVENT_FLAG_DISPLAY_CHANGED) != 0) {
                        DisplayInfo newInfo = (DisplayInfo) msg.obj;
                        if (newInfo != null && !newInfo.equals(mDisplayInfo)) {
                            mDisplayInfo.copyFrom(newInfo);
                            mListener.onDisplayChanged(msg.arg1);
                        }
                    }
                    break;
                case EVENT_DISPLAY_REMOVED:
                    if ((mEventsMask & DisplayManager.EVENT_FLAG_DISPLAY_REMOVED) != 0) {
+1 −1
Original line number Diff line number Diff line
@@ -377,7 +377,7 @@ public final class DisplayInfo implements Parcelable {
                && ownerUid == other.ownerUid
                && Objects.equals(ownerPackageName, other.ownerPackageName)
                && removeMode == other.removeMode
                && refreshRateOverride == other.refreshRateOverride
                && getRefreshRate() == other.getRefreshRate()
                && brightnessMinimum == other.brightnessMinimum
                && brightnessMaximum == other.brightnessMaximum
                && brightnessDefault == other.brightnessDefault
+3 −0
Original line number Diff line number Diff line
@@ -346,6 +346,9 @@ public class DisplayManagerServiceTest {
        DisplayDeviceInfo displayDeviceInfo = new DisplayDeviceInfo();
        displayDeviceInfo.width = 100;
        displayDeviceInfo.height = 200;
        displayDeviceInfo.supportedModes = new Display.Mode[1];
        displayDeviceInfo.supportedModes[0] = new Display.Mode(1, 100, 200, 60f);
        displayDeviceInfo.modeId = 1;
        final Rect zeroRect = new Rect();
        displayDeviceInfo.displayCutout = new DisplayCutout(
                Insets.of(0, 10, 0, 0),
+3 −0
Original line number Diff line number Diff line
@@ -239,6 +239,9 @@ public class LogicalDisplayMapperTest {
        displayDeviceInfo.width = width;
        displayDeviceInfo.height = height;
        displayDeviceInfo.flags = flags;
        displayDeviceInfo.supportedModes = new Display.Mode[1];
        displayDeviceInfo.supportedModes[0] = new Display.Mode(1, width, height, 60f);
        displayDeviceInfo.modeId = 1;
        displayDeviceInfo.address = new DisplayAddressImpl();
        return device;
    }