summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java25
-rw-r--r--services/core/java/com/android/server/policy/WindowManagerPolicy.java3
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java4
-rw-r--r--services/tests/servicestests/src/com/android/server/policy/FakeWindowState.java3
4 files changed, 28 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index e6195b47a586..883e9392854c 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -631,8 +631,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int mPointerLocationMode = 0; // guarded by mLock
- // The last window we were told about in focusChanged.
+ // The windows we were told about in focusChanged.
WindowState mFocusedWindow;
+ WindowState mLastFocusedWindow;
+
IApplicationToken mFocusedApp;
PointerLocationView mPointerLocationView;
@@ -3334,6 +3336,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mNavigationBar = null;
mNavigationBarController.setWindow(null);
}
+ if (mLastFocusedWindow == win) {
+ mLastFocusedWindow = null;
+ }
mScreenDecorWindows.remove(win);
}
@@ -5879,7 +5884,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
@Override
public int focusChangedLw(WindowState lastFocus, WindowState newFocus) {
mFocusedWindow = newFocus;
- if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) {
+ mLastFocusedWindow = lastFocus;
+ if ((updateSystemUiVisibilityLw() & SYSTEM_UI_CHANGING_LAYOUT) != 0) {
// If the navigation bar has been hidden or shown, we need to do another
// layout pass to update that window.
return FINISH_LAYOUT_REDO_LAYOUT;
@@ -8105,10 +8111,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (winCandidate == null) {
return 0;
}
+
+ // The immersive mode confirmation should never affect the system bar visibility, otherwise
+ // it will unhide the navigation bar and hide itself.
if (winCandidate.getAttrs().token == mImmersiveModeConfirmation.getWindowToken()) {
- // The immersive mode confirmation should never affect the system bar visibility,
- // otherwise it will unhide the navigation bar and hide itself.
- winCandidate = isStatusBarKeyguard() ? mStatusBar : mTopFullscreenOpaqueWindowState;
+
+ // The immersive mode confirmation took the focus from mLastFocusedWindow which was
+ // controlling the system ui visibility. So if mLastFocusedWindow can still receive
+ // keys, we let it keep controlling the visibility.
+ final boolean lastFocusCanReceiveKeys =
+ (mLastFocusedWindow != null && mLastFocusedWindow.canReceiveKeys());
+ winCandidate = isStatusBarKeyguard() ? mStatusBar
+ : lastFocusCanReceiveKeys ? mLastFocusedWindow
+ : mTopFullscreenOpaqueWindowState;
if (winCandidate == null) {
return 0;
}
diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
index 1ebbe3ac36fa..7ea620039026 100644
--- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java
+++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java
@@ -491,6 +491,9 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
*/
boolean canAcquireSleepToken();
+ /** @return true if this window desires key events. */
+ boolean canReceiveKeys();
+
/**
* Writes {@link com.android.server.wm.IdentifierProto} to stream.
*/
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index c8c4b588f014..fb0c3bcb1e8f 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2493,8 +2493,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return getWindowConfiguration().keepVisibleDeadAppWindowOnScreen();
}
- /** @return true if this window desires key events. */
- boolean canReceiveKeys() {
+ @Override
+ public boolean canReceiveKeys() {
return isVisibleOrAdding()
&& (mViewVisibility == View.VISIBLE) && !mRemoveOnExit
&& ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0)
diff --git a/services/tests/servicestests/src/com/android/server/policy/FakeWindowState.java b/services/tests/servicestests/src/com/android/server/policy/FakeWindowState.java
index 7487d4490d9a..044186f39bfc 100644
--- a/services/tests/servicestests/src/com/android/server/policy/FakeWindowState.java
+++ b/services/tests/servicestests/src/com/android/server/policy/FakeWindowState.java
@@ -255,6 +255,9 @@ public class FakeWindowState implements WindowManagerPolicy.WindowState {
}
@Override
+ public boolean canReceiveKeys() { return false; }
+
+ @Override
public void writeIdentifierToProto(ProtoOutputStream proto, long fieldId){
throw new UnsupportedOperationException("not implemented");
}