From 396b5d5dc86c038cc7f065834d3537f4f95a7c75 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Fri, 7 Aug 2020 09:21:26 -0700 Subject: [PATCH] Remove losing focus window list The list was used to delay reporting focus lost to the client until the new focused window has been displayed. This is no logic is no longer needed in WM as focus is now dispatched from ID. Bug: 151179149 Test: go/wm-smoke Change-Id: I661a8d3ffa9c233d5f57a0037cb1317f50fa599e --- .../com/android/server/wm/DisplayContent.java | 27 ------------------- .../server/wm/WindowManagerService.java | 24 ----------------- 2 files changed, 51 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index fc170538994c5..9461f1e2d4526 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -117,7 +117,6 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.H.REPORT_FOCUS_CHANGE; import static com.android.server.wm.WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE; -import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS; import static com.android.server.wm.WindowManagerService.H.UPDATE_MULTI_WINDOW_STACKS; import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT; import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD; @@ -468,12 +467,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp */ WindowState mLastFocus = null; - /** - * Windows that have lost input focus and are waiting for the new focus window to be displayed - * before they are told about this. - */ - ArrayList mLosingFocus = new ArrayList<>(); - /** * The foreground app of this display. Windows below this app cannot be the focused window. If * the user taps on the area outside of the task of the focused app, we will notify AM about the @@ -899,10 +892,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } } - if (!mLosingFocus.isEmpty() && w.isFocused() && w.isDisplayedLw()) { - mWmService.mH.obtainMessage(REPORT_LOSING_FOCUS, this).sendToTarget(); - } - w.updateResizingWindowIfNeeded(); }; @@ -2919,21 +2908,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (mLastFocus != mCurrentFocus) { pw.print(" mLastFocus="); pw.println(mLastFocus); } - if (mLosingFocus.size() > 0) { - pw.println(); - pw.println(" Windows losing focus:"); - for (int i = mLosingFocus.size() - 1; i >= 0; i--) { - final WindowState w = mLosingFocus.get(i); - pw.print(" Losing #"); pw.print(i); pw.print(' '); - pw.print(w); - if (dumpAll) { - pw.println(":"); - w.dump(pw, " ", true); - } else { - pw.println(); - } - } - } pw.print(" mFocusedApp="); pw.println(mFocusedApp); if (mLastStatusBarVisibility != 0) { pw.print(" mLastStatusBarVisibility=0x"); @@ -3152,7 +3126,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mCurrentFocus, newFocus, getDisplayId(), Debug.getCallers(4)); final WindowState oldFocus = mCurrentFocus; mCurrentFocus = newFocus; - mLosingFocus.remove(newFocus); if (newFocus != null) { mWinAddedSinceNullFocus.clear(); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 0b1d6bc0adfdf..2b74d4a8daa07 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -4740,7 +4740,6 @@ public class WindowManagerService extends IWindowManager.Stub final class H extends android.os.Handler { public static final int REPORT_FOCUS_CHANGE = 2; - public static final int REPORT_LOSING_FOCUS = 3; public static final int WINDOW_FREEZE_TIMEOUT = 11; public static final int PERSIST_ANIMATION_SCALE = 14; @@ -4815,11 +4814,6 @@ public class WindowManagerService extends IWindowManager.Stub ProtoLog.i(WM_DEBUG_FOCUS_LIGHT, "Focus moving from %s" + " to %s displayId=%d", lastFocus, newFocus, displayContent.getDisplayId()); - if (newFocus != null && lastFocus != null && !newFocus.isDisplayedLw()) { - ProtoLog.i(WM_DEBUG_FOCUS_LIGHT, "Delaying loss of focus..."); - displayContent.mLosingFocus.add(lastFocus); - lastFocus = null; - } } // First notify the accessibility manager for the change so it has @@ -4842,24 +4836,6 @@ public class WindowManagerService extends IWindowManager.Stub break; } - case REPORT_LOSING_FOCUS: { - final DisplayContent displayContent = (DisplayContent) msg.obj; - ArrayList losers; - - synchronized (mGlobalLock) { - losers = displayContent.mLosingFocus; - displayContent.mLosingFocus = new ArrayList<>(); - } - - final int N = losers.size(); - for (int i = 0; i < N; i++) { - ProtoLog.i(WM_DEBUG_FOCUS_LIGHT, "Losing delayed focus: %s", - losers.get(i)); - losers.get(i).reportFocusChangedSerialized(false); - } - break; - } - case WINDOW_FREEZE_TIMEOUT: { final DisplayContent displayContent = (DisplayContent) msg.obj; synchronized (mGlobalLock) {