Merge "Reduce display device log spam." into lmp-mr1-modular-dev

This commit is contained in:
Joe LaPenna
2015-05-13 01:26:25 +00:00
committed by Android (Google) Code Review
3 changed files with 65 additions and 29 deletions

View File

@ -47,6 +47,10 @@ abstract class DisplayDevice {
// within a transaction from performTraversalInTransactionLocked. // within a transaction from performTraversalInTransactionLocked.
private Surface mCurrentSurface; 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) { public DisplayDevice(DisplayAdapter displayAdapter, IBinder displayToken, String uniqueId) {
mDisplayAdapter = displayAdapter; mDisplayAdapter = displayAdapter;
mDisplayToken = displayToken; mDisplayToken = displayToken;

View File

@ -103,6 +103,16 @@ final class DisplayDeviceInfo {
*/ */
public static final int TOUCH_EXTERNAL = 2; 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 * 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. * other sources. The name may be localized and displayed to the user.
@ -238,26 +248,39 @@ final class DisplayDeviceInfo {
} }
public boolean equals(DisplayDeviceInfo other) { public boolean equals(DisplayDeviceInfo other) {
return other != null return other != null && diff(other) == 0;
&& Objects.equal(name, other.name) }
&& Objects.equal(uniqueId, other.uniqueId)
&& width == other.width /**
&& height == other.height * Computes the difference between display device infos.
&& refreshRate == other.refreshRate * Assumes other is not null.
&& Arrays.equals(supportedRefreshRates, other.supportedRefreshRates) */
&& densityDpi == other.densityDpi public int diff(DisplayDeviceInfo other) {
&& xDpi == other.xDpi int diff = 0;
&& yDpi == other.yDpi if (state != other.state) {
&& appVsyncOffsetNanos == other.appVsyncOffsetNanos diff |= DIFF_STATE;
&& presentationDeadlineNanos == other.presentationDeadlineNanos }
&& flags == other.flags if (!Objects.equal(name, other.name)
&& touch == other.touch || !Objects.equal(uniqueId, other.uniqueId)
&& rotation == other.rotation || width != other.width
&& type == other.type || height != other.height
&& Objects.equal(address, other.address) || refreshRate != other.refreshRate
&& state == other.state || !Arrays.equals(supportedRefreshRates, other.supportedRefreshRates)
&& ownerUid == other.ownerUid || densityDpi != other.densityDpi
&& Objects.equal(ownerPackageName, other.ownerPackageName); || 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 @Override

View File

@ -640,13 +640,14 @@ public final class DisplayManagerService extends SystemService {
} }
private void handleDisplayDeviceAddedLocked(DisplayDevice device) { private void handleDisplayDeviceAddedLocked(DisplayDevice device) {
DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
if (mDisplayDevices.contains(device)) { if (mDisplayDevices.contains(device)) {
Slog.w(TAG, "Attempted to add already added display device: " Slog.w(TAG, "Attempted to add already added display device: " + info);
+ device.getDisplayDeviceInfoLocked());
return; return;
} }
Slog.i(TAG, "Display device added: " + device.getDisplayDeviceInfoLocked()); Slog.i(TAG, "Display device added: " + info);
device.mDebugLastLoggedDeviceInfo = info;
mDisplayDevices.add(device); mDisplayDevices.add(device);
addLogicalDisplayLocked(device); addLogicalDisplayLocked(device);
@ -659,13 +660,20 @@ public final class DisplayManagerService extends SystemService {
private void handleDisplayDeviceChanged(DisplayDevice device) { private void handleDisplayDeviceChanged(DisplayDevice device) {
synchronized (mSyncRoot) { synchronized (mSyncRoot) {
DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
if (!mDisplayDevices.contains(device)) { if (!mDisplayDevices.contains(device)) {
Slog.w(TAG, "Attempted to change non-existent display device: " Slog.w(TAG, "Attempted to change non-existent display device: " + info);
+ device.getDisplayDeviceInfoLocked());
return; 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(); device.applyPendingDisplayDeviceInfoChangesLocked();
if (updateLogicalDisplaysLocked()) { if (updateLogicalDisplaysLocked()) {
@ -680,13 +688,14 @@ public final class DisplayManagerService extends SystemService {
} }
} }
private void handleDisplayDeviceRemovedLocked(DisplayDevice device) { private void handleDisplayDeviceRemovedLocked(DisplayDevice device) {
DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
if (!mDisplayDevices.remove(device)) { if (!mDisplayDevices.remove(device)) {
Slog.w(TAG, "Attempted to remove non-existent display device: " Slog.w(TAG, "Attempted to remove non-existent display device: " + info);
+ device.getDisplayDeviceInfoLocked());
return; return;
} }
Slog.i(TAG, "Display device removed: " + device.getDisplayDeviceInfoLocked()); Slog.i(TAG, "Display device removed: " + info);
device.mDebugLastLoggedDeviceInfo = info;
updateLogicalDisplaysLocked(); updateLogicalDisplaysLocked();
scheduleTraversalLocked(false); scheduleTraversalLocked(false);