From 011944c7598ea9524b0d38e7806ee2de1db3a04a Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 15 Dec 2017 15:44:55 -0800 Subject: Fix issue #70722141: Fix broken WindowTest.testSetLocalFocus We need to make sure to dispatch every focus change, even if the focus itself doesn't actually change. Bug: 70722141 Test: bit CtsViewTestCases:WindowTest\#testSetLocalFocus Change-Id: I12f4b18b93516f3bf03fb0d4a897a968cda65f41 --- core/java/android/view/ViewRootImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 3f8da093487b..2c82ac49c84e 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -327,6 +327,8 @@ public final class ViewRootImpl implements ViewParent, // This is used to reduce the race between window focus changes being dispatched from // the window manager and input events coming through the input system. @GuardedBy("this") + boolean mWindowFocusChanged; + @GuardedBy("this") boolean mUpcomingWindowFocus; @GuardedBy("this") boolean mUpcomingInTouchMode; @@ -2472,14 +2474,14 @@ public final class ViewRootImpl implements ViewParent, final boolean hasWindowFocus; final boolean inTouchMode; synchronized (this) { + if (!mWindowFocusChanged) { + return; + } + mWindowFocusChanged = false; hasWindowFocus = mUpcomingWindowFocus; inTouchMode = mUpcomingInTouchMode; } - if (mAttachInfo.mHasWindowFocus == hasWindowFocus) { - return; - } - if (mAdded) { profileRendering(hasWindowFocus); @@ -7181,6 +7183,7 @@ public final class ViewRootImpl implements ViewParent, public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) { synchronized (this) { + mWindowFocusChanged = true; mUpcomingWindowFocus = hasFocus; mUpcomingInTouchMode = inTouchMode; } -- cgit v1.2.3