diff --git a/services/java/com/android/server/wm/InputMonitor.java b/services/java/com/android/server/wm/InputMonitor.java index ea3af26349edd..2e13fe2e50eeb 100644 --- a/services/java/com/android/server/wm/InputMonitor.java +++ b/services/java/com/android/server/wm/InputMonitor.java @@ -345,7 +345,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen); } - + /* Provides an opportunity for the window manager policy to intercept early key * processing as soon as the key has been read from the device. */ @Override @@ -370,7 +370,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { WindowState windowState = focus != null ? (WindowState) focus.windowState : null; return mService.mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags); } - + /* Provides an opportunity for the window manager policy to process a key that * the application did not handle. */ @Override @@ -392,7 +392,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { * Layer assignment is assumed to be complete by the time this is called. */ public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) { - if (WindowManagerService.DEBUG_INPUT) { + if (WindowManagerService.DEBUG_FOCUS_LIGHT || WindowManagerService.DEBUG_INPUT) { Slog.d(WindowManagerService.TAG, "Input focus has changed to " + newWindow); } @@ -412,7 +412,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { } } } - + public void setFocusedAppLw(AppWindowToken newApp) { // Focused app has changed. if (newApp == null) { @@ -425,7 +425,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { mService.mInputManager.setFocusedApplication(handle); } } - + public void pauseDispatchingLw(WindowToken window) { if (! window.paused) { if (WindowManagerService.DEBUG_INPUT) { diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java index 25b042c8e6bad..ca87b4ffa440f 100644 --- a/services/java/com/android/server/wm/WindowAnimator.java +++ b/services/java/com/android/server/wm/WindowAnimator.java @@ -293,6 +293,8 @@ public class WindowAnimator { // We are showing on to of the current // focus, so re-evaluate focus to make // sure it is correct. + if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.v(TAG, + "updateWindowsLocked: setting mFocusMayChange true"); mService.mFocusMayChange = true; } } diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index f5e05315550e5..dbd42afd5ec17 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -160,6 +160,7 @@ public class WindowManagerService extends IWindowManager.Stub static final boolean DEBUG = false; static final boolean DEBUG_ADD_REMOVE = false; static final boolean DEBUG_FOCUS = false; + static final boolean DEBUG_FOCUS_LIGHT = DEBUG_FOCUS || true; static final boolean DEBUG_ANIM = false; static final boolean DEBUG_LAYOUT = false; static final boolean DEBUG_RESIZE = false; @@ -921,7 +922,7 @@ public class WindowManagerService extends IWindowManager.Stub //apptoken note that the window could be a floating window //that was created later or a window at the top of the list of //windows associated with this token. - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, + if (DEBUG_FOCUS_LIGHT || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding window " + win + " at " + (newIdx + 1) + " of " + N); windows.add(newIdx + 1, win); if (newIdx < 0) { @@ -1042,7 +1043,7 @@ public class WindowManagerService extends IWindowManager.Stub break; } } - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, + if (DEBUG_FOCUS_LIGHT || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding window " + win + " at " + i + " of " + N); windows.add(i, win); mWindowsChanged = true; @@ -1061,7 +1062,7 @@ public class WindowManagerService extends IWindowManager.Stub } } i++; - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, + if (DEBUG_FOCUS_LIGHT || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding window " + win + " at " + i + " of " + windows.size()); windows.add(i, win); mWindowsChanged = true; @@ -2353,7 +2354,7 @@ public class WindowManagerService extends IWindowManager.Stub public void removeWindowLocked(Session session, WindowState win) { - if (localLOGV || DEBUG_FOCUS) Slog.v( + if (localLOGV || DEBUG_FOCUS || DEBUG_FOCUS_LIGHT && win==mCurrentFocus) Slog.v( TAG, "Remove " + win + " client=" + Integer.toHexString(System.identityHashCode(win.mClient.asBinder())) + ", surface=" + win.mWinAnimator.mSurfaceControl, @@ -3771,7 +3772,7 @@ public class WindowManagerService extends IWindowManager.Stub synchronized(mWindowMap) { boolean changed = false; if (token == null) { - if (DEBUG_FOCUS) Slog.v(TAG, "Clearing focused app, was " + mFocusedApp); + if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "Clearing focused app, was " + mFocusedApp); changed = mFocusedApp != null; mFocusedApp = null; if (changed) { @@ -3784,9 +3785,9 @@ public class WindowManagerService extends IWindowManager.Stub return; } changed = mFocusedApp != newFocus; + if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "Set focused app to: " + newFocus + + " old focus=" + mFocusedApp + " moveFocusNow=" + moveFocusNow); mFocusedApp = newFocus; - if (DEBUG_FOCUS) Slog.v(TAG, "Set focused app to: " + mFocusedApp - + " moveFocusNow=" + moveFocusNow); if (changed) { mInputMonitor.setFocusedAppLw(newFocus); } @@ -4508,7 +4509,7 @@ public class WindowManagerService extends IWindowManager.Stub } unsetAppFreezingScreenLocked(wtoken, true, true); if (mFocusedApp == wtoken) { - if (DEBUG_FOCUS) Slog.v(TAG, "Removing focused app token:" + wtoken); + if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "Removing focused app token:" + wtoken); mFocusedApp = null; updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/); mInputMonitor.setFocusedAppLw(null); @@ -7070,8 +7071,8 @@ public class WindowManagerService extends IWindowManager.Stub return; } mLastFocus = newFocus; - //Slog.i(TAG, "Focus moving from " + lastFocus - // + " to " + newFocus); + if (DEBUG_FOCUS_LIGHT) Slog.i(TAG, "Focus moving from " + lastFocus + + " to " + newFocus); if (newFocus != null && lastFocus != null && !newFocus.isDisplayedLw()) { //Slog.i(TAG, "Delaying loss of focus..."); @@ -7084,13 +7085,13 @@ public class WindowManagerService extends IWindowManager.Stub //System.out.println("Changing focus from " + lastFocus // + " to " + newFocus); if (newFocus != null) { - //Slog.i(TAG, "Gaining focus: " + newFocus); + if (DEBUG_FOCUS_LIGHT) Slog.i(TAG, "Gaining focus: " + newFocus); newFocus.reportFocusChangedSerialized(true, mInTouchMode); notifyFocusChanged(); } if (lastFocus != null) { - //Slog.i(TAG, "Losing focus: " + lastFocus); + if (DEBUG_FOCUS_LIGHT) Slog.i(TAG, "Losing focus: " + lastFocus); lastFocus.reportFocusChangedSerialized(false, mInTouchMode); } } @@ -7106,7 +7107,8 @@ public class WindowManagerService extends IWindowManager.Stub final int N = losers.size(); for (int i=0; i= 0; --tokenNdx) { if (nextApp == mFocusedApp) { - // Whoops, we are below the focused app... no focus - // for you! + // Whoops, we are below the focused app... no focus for you! if (localLOGV || DEBUG_FOCUS) Slog.v( - TAG, "Reached focused app: " + mFocusedApp); + TAG, "findFocusedWindow: Reached focused app=" + mFocusedApp); return null; } nextApp = tokens.get(tokenNdx); @@ -9844,11 +9845,12 @@ public class WindowManagerService extends IWindowManager.Stub // Dispatch to this window if it is wants key events. if (win.canReceiveKeys()) { - if (DEBUG_FOCUS) Slog.v( - TAG, "Found focus @ " + i + " = " + win); + if (DEBUG_FOCUS_LIGHT) Slog.v( + TAG, "findFocusedWindow: Found new focus @ " + i + " = " + win); return win; } } + if (DEBUG_FOCUS_LIGHT) Slog.v(TAG, "findFocusedWindow: No focusable windows."); return null; } diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 21445d34c071c..64b5a09c5ea70 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -1142,6 +1142,8 @@ final class WindowState implements WindowManagerPolicy.WindowState { // we allow the display to be enabled now. mService.enableScreenIfNeededLocked(); if (mService.mCurrentFocus == this) { + if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.i(TAG, + "WindowState.hideLw: setting mFocusMayChange true"); mService.mFocusMayChange = true; } } diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 9245542178abf..533f626f7f727 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -340,6 +340,8 @@ class WindowStateAnimator { mWin.mDisplayContent.layoutNeeded = true; if (!mWin.mPolicyVisibility) { if (mService.mCurrentFocus == mWin) { + if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.i(TAG, + "setAnimationLocked: setting mFocusMayChange true"); mService.mFocusMayChange = true; } // Window is no longer visible -- make sure if we were waiting