Improve debugging setup for window manager package.
This moves debug flags to a dedicated class and also provides a
mechanism to either have fine grained tags or one common tag for easier
grepping the logcat. This mimicks the approach in activity manager
package.
Change-Id: Ie8c08b9a3d8b182335ee5547ee05d21b5933db6b
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 6e2e830..1b6957d 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -16,12 +16,11 @@
package com.android.server.wm;
-import android.view.IWindowId;
-import android.view.IWindowSessionCallback;
-import com.android.internal.view.IInputContext;
-import com.android.internal.view.IInputMethodClient;
-import com.android.internal.view.IInputMethodManager;
-import com.android.server.wm.WindowManagerService.H;
+import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
+import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
+import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
+import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS;
+import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.content.ClipData;
import android.content.Context;
@@ -39,13 +38,20 @@
import android.util.Slog;
import android.view.Display;
import android.view.IWindow;
+import android.view.IWindowId;
import android.view.IWindowSession;
+import android.view.IWindowSessionCallback;
import android.view.InputChannel;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
import android.view.WindowManager;
+import com.android.internal.view.IInputContext;
+import com.android.internal.view.IInputMethodClient;
+import com.android.internal.view.IInputMethodManager;
+import com.android.server.wm.WindowManagerService.H;
+
import java.io.PrintWriter;
/**
@@ -131,7 +137,7 @@
} catch (RuntimeException e) {
// Log all 'real' exceptions thrown to the caller
if (!(e instanceof SecurityException)) {
- Slog.wtf(WindowManagerService.TAG, "Window Session Crash", e);
+ Slog.wtf(TAG_WM, "Window Session Crash", e);
}
throw e;
}
@@ -200,13 +206,13 @@
Rect outVisibleInsets, Rect outStableInsets, Rect outsets, Configuration
outConfig,
Surface outSurface) {
- if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from "
+ if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from "
+ Binder.getCallingPid());
int res = mService.relayoutWindow(this, window, seq, attrs,
requestedWidth, requestedHeight, viewFlags, flags,
outFrame, outOverscanInsets, outContentInsets, outVisibleInsets,
outStableInsets, outsets, outConfig, outSurface);
- if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to "
+ if (false) Slog.d(TAG_WM, "<<<<<< EXITING relayout to "
+ Binder.getCallingPid());
return res;
}
@@ -235,7 +241,7 @@
public void finishDrawing(IWindow window) {
if (WindowManagerService.localLOGV) Slog.v(
- WindowManagerService.TAG, "IWindow finishDrawing called for " + window);
+ TAG_WM, "IWindow finishDrawing called for " + window);
mService.finishDrawingWindow(this, window);
}
@@ -275,24 +281,24 @@
public boolean performDrag(IWindow window, IBinder dragToken,
float touchX, float touchY, float thumbCenterX, float thumbCenterY,
ClipData data) {
- if (WindowManagerService.DEBUG_DRAG) {
- Slog.d(WindowManagerService.TAG, "perform drag: win=" + window + " data=" + data);
+ if (DEBUG_DRAG) {
+ Slog.d(TAG_WM, "perform drag: win=" + window + " data=" + data);
}
synchronized (mService.mWindowMap) {
if (mService.mDragState == null) {
- Slog.w(WindowManagerService.TAG, "No drag prepared");
+ Slog.w(TAG_WM, "No drag prepared");
throw new IllegalStateException("performDrag() without prepareDrag()");
}
if (dragToken != mService.mDragState.mToken) {
- Slog.w(WindowManagerService.TAG, "Performing mismatched drag");
+ Slog.w(TAG_WM, "Performing mismatched drag");
throw new IllegalStateException("performDrag() does not match prepareDrag()");
}
WindowState callingWin = mService.windowForClientLocked(null, window, false);
if (callingWin == null) {
- Slog.w(WindowManagerService.TAG, "Bad requesting window " + window);
+ Slog.w(TAG_WM, "Bad requesting window " + window);
return false; // !!! TODO: throw here?
}
@@ -317,7 +323,7 @@
mService.mInputMonitor.updateInputWindowsLw(true /*force*/);
if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel,
mService.mDragState.mServerChannel)) {
- Slog.e(WindowManagerService.TAG, "Unable to transfer touch focus");
+ Slog.e(TAG_WM, "Unable to transfer touch focus");
mService.mDragState.unregister();
mService.mDragState = null;
mService.mInputMonitor.updateInputWindowsLw(true /*force*/);
@@ -333,8 +339,8 @@
// Make the surface visible at the proper location
final SurfaceControl surfaceControl = mService.mDragState.mSurfaceControl;
- if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS) Slog.i(
- WindowManagerService.TAG, ">>> OPEN TRANSACTION performDrag");
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(
+ TAG_WM, ">>> OPEN TRANSACTION performDrag");
SurfaceControl.openTransaction();
try {
surfaceControl.setPosition(touchX - thumbCenterX,
@@ -344,8 +350,8 @@
surfaceControl.show();
} finally {
SurfaceControl.closeTransaction();
- if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS) Slog.i(
- WindowManagerService.TAG, "<<< CLOSE TRANSACTION performDrag");
+ if (SHOW_LIGHT_TRANSACTIONS) Slog.i(
+ TAG_WM, "<<< CLOSE TRANSACTION performDrag");
}
}
@@ -353,16 +359,16 @@
}
public boolean startMovingTask(IWindow window, float startX, float startY) {
- if (WindowManagerService.DEBUG_TASK_POSITIONING) Slog.d(
- WindowManagerService.TAG, "startMovingTask: {" + startX + "," + startY + "}");
+ if (DEBUG_TASK_POSITIONING) Slog.d(
+ TAG_WM, "startMovingTask: {" + startX + "," + startY + "}");
return mService.startMovingTask(window, startX, startY);
}
public void reportDropResult(IWindow window, boolean consumed) {
IBinder token = window.asBinder();
- if (WindowManagerService.DEBUG_DRAG) {
- Slog.d(WindowManagerService.TAG, "Drop result=" + consumed + " reported by " + token);
+ if (DEBUG_DRAG) {
+ Slog.d(TAG_WM, "Drop result=" + consumed + " reported by " + token);
}
synchronized (mService.mWindowMap) {
@@ -371,13 +377,13 @@
if (mService.mDragState == null) {
// Most likely the drop recipient ANRed and we ended the drag
// out from under it. Log the issue and move on.
- Slog.w(WindowManagerService.TAG, "Drop result given but no drag in progress");
+ Slog.w(TAG_WM, "Drop result given but no drag in progress");
return;
}
if (mService.mDragState.mToken != token) {
// We're in a drag, but the wrong window has responded.
- Slog.w(WindowManagerService.TAG, "Invalid drop-result claim by " + window);
+ Slog.w(TAG_WM, "Invalid drop-result claim by " + window);
throw new IllegalStateException("reportDropResult() by non-recipient");
}
@@ -387,7 +393,7 @@
mService.mH.removeMessages(H.DRAG_END_TIMEOUT, window.asBinder());
WindowState callingWin = mService.windowForClientLocked(null, window, false);
if (callingWin == null) {
- Slog.w(WindowManagerService.TAG, "Bad result-reporting window " + window);
+ Slog.w(TAG_WM, "Bad result-reporting window " + window);
return; // !!! TODO: throw here?
}
@@ -400,20 +406,20 @@
}
public void cancelDragAndDrop(IBinder dragToken) {
- if (WindowManagerService.DEBUG_DRAG) {
- Slog.d(WindowManagerService.TAG, "cancelDragAndDrop");
+ if (DEBUG_DRAG) {
+ Slog.d(TAG_WM, "cancelDragAndDrop");
}
synchronized (mService.mWindowMap) {
long ident = Binder.clearCallingIdentity();
try {
if (mService.mDragState == null) {
- Slog.w(WindowManagerService.TAG, "cancelDragAndDrop() without prepareDrag()");
+ Slog.w(TAG_WM, "cancelDragAndDrop() without prepareDrag()");
throw new IllegalStateException("cancelDragAndDrop() without prepareDrag()");
}
if (mService.mDragState.mToken != dragToken) {
- Slog.w(WindowManagerService.TAG,
+ Slog.w(TAG_WM,
"cancelDragAndDrop() does not match prepareDrag()");
throw new IllegalStateException(
"cancelDragAndDrop() does not match prepareDrag()");
@@ -428,14 +434,14 @@
}
public void dragRecipientEntered(IWindow window) {
- if (WindowManagerService.DEBUG_DRAG) {
- Slog.d(WindowManagerService.TAG, "Drag into new candidate view @ " + window.asBinder());
+ if (DEBUG_DRAG) {
+ Slog.d(TAG_WM, "Drag into new candidate view @ " + window.asBinder());
}
}
public void dragRecipientExited(IWindow window) {
- if (WindowManagerService.DEBUG_DRAG) {
- Slog.d(WindowManagerService.TAG, "Drag from old candidate view @ " + window.asBinder());
+ if (DEBUG_DRAG) {
+ Slog.d(TAG_WM, "Drag from old candidate view @ " + window.asBinder());
}
}
@@ -518,10 +524,10 @@
void windowAddedLocked() {
if (mSurfaceSession == null) {
if (WindowManagerService.localLOGV) Slog.v(
- WindowManagerService.TAG, "First window added to " + this + ", creating SurfaceSession");
+ TAG_WM, "First window added to " + this + ", creating SurfaceSession");
mSurfaceSession = new SurfaceSession();
- if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(
- WindowManagerService.TAG, " NEW SURFACE SESSION " + mSurfaceSession);
+ if (SHOW_TRANSACTIONS) Slog.i(
+ TAG_WM, " NEW SURFACE SESSION " + mSurfaceSession);
mService.mSessions.add(this);
if (mLastReportedAnimatorScale != mService.getCurrentAnimatorScale()) {
mService.dispatchNewAnimatorScaleLocked(this);
@@ -540,14 +546,14 @@
mService.mSessions.remove(this);
if (mSurfaceSession != null) {
if (WindowManagerService.localLOGV) Slog.v(
- WindowManagerService.TAG, "Last window removed from " + this
+ TAG_WM, "Last window removed from " + this
+ ", destroying " + mSurfaceSession);
- if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(
- WindowManagerService.TAG, " KILL SURFACE SESSION " + mSurfaceSession);
+ if (SHOW_TRANSACTIONS) Slog.i(
+ TAG_WM, " KILL SURFACE SESSION " + mSurfaceSession);
try {
mSurfaceSession.kill();
} catch (Exception e) {
- Slog.w(WindowManagerService.TAG, "Exception thrown when killing surface session "
+ Slog.w(TAG_WM, "Exception thrown when killing surface session "
+ mSurfaceSession + " in session " + this
+ ": " + e.toString());
}