From d1a010f279447bbf2b186e4c24ff6bdb8ecedbf0 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Thu, 7 Apr 2016 22:36:22 -0700 Subject: [PATCH] Replace secondary app windows across activity relaunch. Windows of TYPE_APPLICATION (as opposed to TYPE_BASE_APPLICATION) are not child windows in the sense of SurfaceView, etc, as they are independent windows like Modal Dialogs rather than embedded parts of other windows. Still though, we expect them to reappear following activity relaunch, and they won't be covered by window preservation, so we need to mark them for replacement. Bug: 26668339 Change-Id: I652b4137085f6ef4d6c9d54de609727f966ef4d6 --- .../java/com/android/server/wm/AppWindowToken.java | 2 +- .../java/com/android/server/wm/WindowState.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 4ec297e310152..e513713895e0f 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -499,7 +499,7 @@ class AppWindowToken extends WindowToken { + " with replacing child windows."); for (int i = allAppWindows.size() - 1; i >= 0; i--) { final WindowState w = allAppWindows.get(i); - if (w.isChildWindow()) { + if (w.shouldBeReplacedWithChildren()) { w.setReplacing(false /* animate */); } } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index c991130b55e76..1dc486c3182be 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -82,6 +82,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; +import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; @@ -2704,4 +2705,16 @@ final class WindowState implements WindowManagerPolicy.WindowState { } return winY; } + + // During activity relaunch due to resize, we sometimes use window replacement + // for only child windows (as the main window is handled by window preservation) + // and the big surface. + // + // Though windows of TYPE_APPLICATION (as opposed to TYPE_BASE_APPLICATION) + // are not children in the sense of an attached window, we also want to replace + // them at such phases, as they won't be covered by window preservation, + // and in general we expect them to return following relaunch. + boolean shouldBeReplacedWithChildren() { + return isChildWindow() || mAttrs.type == TYPE_APPLICATION; + } }