Loading services/core/java/com/android/server/display/DisplayDevice.java +4 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,10 @@ abstract class DisplayDevice { // within a transaction from performTraversalInTransactionLocked. private Surface mCurrentSurface; // DEBUG STATE: Last device info which was written to the log, or null if none. // Do not use for any other purpose. DisplayDeviceInfo mDebugLastLoggedDeviceInfo; public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId) { mDisplayAdapter = displayAdapter; mDisplayToken = displayToken; Loading services/core/java/com/android/server/display/DisplayDeviceInfo.java +43 −20 Original line number Diff line number Diff line Loading @@ -103,6 +103,16 @@ final class DisplayDeviceInfo { */ public static final int TOUCH_EXTERNAL = 2; /** * Diff result: The {@link #state} fields differ. */ public static final int DIFF_STATE = 1 << 0; /** * Diff result: Other fields differ. */ public static final int DIFF_OTHER = 1 << 1; /** * Gets the name of the display device, which may be derived from EDID or * other sources. The name may be localized and displayed to the user. Loading Loading @@ -238,26 +248,39 @@ final class DisplayDeviceInfo { } public boolean equals(DisplayDeviceInfo other) { return other != null && Objects.equal(name, other.name) && Objects.equal(uniqueId, other.uniqueId) && width == other.width && height == other.height && refreshRate == other.refreshRate && Arrays.equals(supportedRefreshRates, other.supportedRefreshRates) && densityDpi == other.densityDpi && xDpi == other.xDpi && yDpi == other.yDpi && appVsyncOffsetNanos == other.appVsyncOffsetNanos && presentationDeadlineNanos == other.presentationDeadlineNanos && flags == other.flags && touch == other.touch && rotation == other.rotation && type == other.type && Objects.equal(address, other.address) && state == other.state && ownerUid == other.ownerUid && Objects.equal(ownerPackageName, other.ownerPackageName); return other != null && diff(other) == 0; } /** * Computes the difference between display device infos. * Assumes other is not null. */ public int diff(DisplayDeviceInfo other) { int diff = 0; if (state != other.state) { diff |= DIFF_STATE; } if (!Objects.equal(name, other.name) || !Objects.equal(uniqueId, other.uniqueId) || width != other.width || height != other.height || refreshRate != other.refreshRate || !Arrays.equals(supportedRefreshRates, other.supportedRefreshRates) || densityDpi != other.densityDpi || xDpi != other.xDpi || yDpi != other.yDpi || appVsyncOffsetNanos != other.appVsyncOffsetNanos || presentationDeadlineNanos != other.presentationDeadlineNanos || flags != other.flags || touch != other.touch || rotation != other.rotation || type != other.type || !Objects.equal(address, other.address) || ownerUid != other.ownerUid || !Objects.equal(ownerPackageName, other.ownerPackageName)) { diff |= DIFF_OTHER; } return diff; } @Override Loading services/core/java/com/android/server/display/DisplayManagerService.java +18 −9 Original line number Diff line number Diff line Loading @@ -668,13 +668,14 @@ public final class DisplayManagerService extends SystemService { } private void handleDisplayDeviceAddedLocked(DisplayDevice device) { DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); if (mDisplayDevices.contains(device)) { Slog.w(TAG, "Attempted to add already added display device: " + device.getDisplayDeviceInfoLocked()); Slog.w(TAG, "Attempted to add already added display device: " + info); return; } Slog.i(TAG, "Display device added: " + device.getDisplayDeviceInfoLocked()); Slog.i(TAG, "Display device added: " + info); device.mDebugLastLoggedDeviceInfo = info; mDisplayDevices.add(device); addLogicalDisplayLocked(device); Loading @@ -687,13 +688,20 @@ public final class DisplayManagerService extends SystemService { private void handleDisplayDeviceChanged(DisplayDevice device) { synchronized (mSyncRoot) { DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); if (!mDisplayDevices.contains(device)) { Slog.w(TAG, "Attempted to change non-existent display device: " + device.getDisplayDeviceInfoLocked()); Slog.w(TAG, "Attempted to change non-existent display device: " + info); return; } Slog.i(TAG, "Display device changed: " + device.getDisplayDeviceInfoLocked()); int diff = device.mDebugLastLoggedDeviceInfo.diff(info); if (diff == DisplayDeviceInfo.DIFF_STATE) { Slog.i(TAG, "Display device changed state: \"" + info.name + "\", " + Display.stateToString(info.state)); } else if (diff != 0) { Slog.i(TAG, "Display device changed: " + info); } device.mDebugLastLoggedDeviceInfo = info; device.applyPendingDisplayDeviceInfoChangesLocked(); if (updateLogicalDisplaysLocked()) { Loading @@ -708,13 +716,14 @@ public final class DisplayManagerService extends SystemService { } } private void handleDisplayDeviceRemovedLocked(DisplayDevice device) { DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); if (!mDisplayDevices.remove(device)) { Slog.w(TAG, "Attempted to remove non-existent display device: " + device.getDisplayDeviceInfoLocked()); Slog.w(TAG, "Attempted to remove non-existent display device: " + info); return; } Slog.i(TAG, "Display device removed: " + device.getDisplayDeviceInfoLocked()); Slog.i(TAG, "Display device removed: " + info); device.mDebugLastLoggedDeviceInfo = info; updateLogicalDisplaysLocked(); scheduleTraversalLocked(false); Loading Loading
services/core/java/com/android/server/display/DisplayDevice.java +4 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,10 @@ abstract class DisplayDevice { // within a transaction from performTraversalInTransactionLocked. private Surface mCurrentSurface; // DEBUG STATE: Last device info which was written to the log, or null if none. // Do not use for any other purpose. DisplayDeviceInfo mDebugLastLoggedDeviceInfo; public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId) { mDisplayAdapter = displayAdapter; mDisplayToken = displayToken; Loading
services/core/java/com/android/server/display/DisplayDeviceInfo.java +43 −20 Original line number Diff line number Diff line Loading @@ -103,6 +103,16 @@ final class DisplayDeviceInfo { */ public static final int TOUCH_EXTERNAL = 2; /** * Diff result: The {@link #state} fields differ. */ public static final int DIFF_STATE = 1 << 0; /** * Diff result: Other fields differ. */ public static final int DIFF_OTHER = 1 << 1; /** * Gets the name of the display device, which may be derived from EDID or * other sources. The name may be localized and displayed to the user. Loading Loading @@ -238,26 +248,39 @@ final class DisplayDeviceInfo { } public boolean equals(DisplayDeviceInfo other) { return other != null && Objects.equal(name, other.name) && Objects.equal(uniqueId, other.uniqueId) && width == other.width && height == other.height && refreshRate == other.refreshRate && Arrays.equals(supportedRefreshRates, other.supportedRefreshRates) && densityDpi == other.densityDpi && xDpi == other.xDpi && yDpi == other.yDpi && appVsyncOffsetNanos == other.appVsyncOffsetNanos && presentationDeadlineNanos == other.presentationDeadlineNanos && flags == other.flags && touch == other.touch && rotation == other.rotation && type == other.type && Objects.equal(address, other.address) && state == other.state && ownerUid == other.ownerUid && Objects.equal(ownerPackageName, other.ownerPackageName); return other != null && diff(other) == 0; } /** * Computes the difference between display device infos. * Assumes other is not null. */ public int diff(DisplayDeviceInfo other) { int diff = 0; if (state != other.state) { diff |= DIFF_STATE; } if (!Objects.equal(name, other.name) || !Objects.equal(uniqueId, other.uniqueId) || width != other.width || height != other.height || refreshRate != other.refreshRate || !Arrays.equals(supportedRefreshRates, other.supportedRefreshRates) || densityDpi != other.densityDpi || xDpi != other.xDpi || yDpi != other.yDpi || appVsyncOffsetNanos != other.appVsyncOffsetNanos || presentationDeadlineNanos != other.presentationDeadlineNanos || flags != other.flags || touch != other.touch || rotation != other.rotation || type != other.type || !Objects.equal(address, other.address) || ownerUid != other.ownerUid || !Objects.equal(ownerPackageName, other.ownerPackageName)) { diff |= DIFF_OTHER; } return diff; } @Override Loading
services/core/java/com/android/server/display/DisplayManagerService.java +18 −9 Original line number Diff line number Diff line Loading @@ -668,13 +668,14 @@ public final class DisplayManagerService extends SystemService { } private void handleDisplayDeviceAddedLocked(DisplayDevice device) { DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); if (mDisplayDevices.contains(device)) { Slog.w(TAG, "Attempted to add already added display device: " + device.getDisplayDeviceInfoLocked()); Slog.w(TAG, "Attempted to add already added display device: " + info); return; } Slog.i(TAG, "Display device added: " + device.getDisplayDeviceInfoLocked()); Slog.i(TAG, "Display device added: " + info); device.mDebugLastLoggedDeviceInfo = info; mDisplayDevices.add(device); addLogicalDisplayLocked(device); Loading @@ -687,13 +688,20 @@ public final class DisplayManagerService extends SystemService { private void handleDisplayDeviceChanged(DisplayDevice device) { synchronized (mSyncRoot) { DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); if (!mDisplayDevices.contains(device)) { Slog.w(TAG, "Attempted to change non-existent display device: " + device.getDisplayDeviceInfoLocked()); Slog.w(TAG, "Attempted to change non-existent display device: " + info); return; } Slog.i(TAG, "Display device changed: " + device.getDisplayDeviceInfoLocked()); int diff = device.mDebugLastLoggedDeviceInfo.diff(info); if (diff == DisplayDeviceInfo.DIFF_STATE) { Slog.i(TAG, "Display device changed state: \"" + info.name + "\", " + Display.stateToString(info.state)); } else if (diff != 0) { Slog.i(TAG, "Display device changed: " + info); } device.mDebugLastLoggedDeviceInfo = info; device.applyPendingDisplayDeviceInfoChangesLocked(); if (updateLogicalDisplaysLocked()) { Loading @@ -708,13 +716,14 @@ public final class DisplayManagerService extends SystemService { } } private void handleDisplayDeviceRemovedLocked(DisplayDevice device) { DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); if (!mDisplayDevices.remove(device)) { Slog.w(TAG, "Attempted to remove non-existent display device: " + device.getDisplayDeviceInfoLocked()); Slog.w(TAG, "Attempted to remove non-existent display device: " + info); return; } Slog.i(TAG, "Display device removed: " + device.getDisplayDeviceInfoLocked()); Slog.i(TAG, "Display device removed: " + info); device.mDebugLastLoggedDeviceInfo = info; updateLogicalDisplaysLocked(); scheduleTraversalLocked(false); Loading