From 07a7b9659bc905b43ba3e3579601e5b948d6335c Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 3 Aug 2017 16:59:44 +0200 Subject: [PATCH] Fix issue when launching Camera Imagine the following: HostPhotoActivity is above CameraActivity, in the same task, and not visible. Now, we launch the Camera again with STILL_IMAGE_CAPTURE, which launches a Trampoline activity in the same task, which later starts CameraActivity with CLEAR_TASK. However, in the meantime, since Trampoline activity is translucent (r.fullscreen == false), we make HostPhotoActivity visible. Now, since we bring the task to the front, we also create a snapshot starting window, for which mViewVisibility == VISIBLE always. When the previous activity has finished pausing we make HostPhotoActivity's starting window visible because of the following: - TrampolineActivity is on top of HostPhotoActivity, but in AM sense it's "translucent", - TrampolineActivity hasn't managed to start CameraActivity yet. - HostPhotoActivity.hasContentToDisplay returns true so when we set the Dummy animation we set the transformation.alpha=1, making the starting window visible. We also need to fix a that HostPhotoActivity's starting window can't affect SystemUI visibiltiy yet. Test: Above flow Test: go/wm-smoke Change-Id: I4a62aaafab4d40e975bc86b53abd0c55c84911c2 Fixes: 64270512 --- .../core/java/com/android/server/wm/AppWindowAnimator.java | 4 ++-- services/core/java/com/android/server/wm/WindowState.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppWindowAnimator.java b/services/core/java/com/android/server/wm/AppWindowAnimator.java index ddbbde1eb4218..2b3901b1febb6 100644 --- a/services/core/java/com/android/server/wm/AppWindowAnimator.java +++ b/services/core/java/com/android/server/wm/AppWindowAnimator.java @@ -148,7 +148,7 @@ public class AppWindowAnimator { } // Start out animation gone if window is gone, or visible if window is visible. transformation.clear(); - transformation.setAlpha(mAppToken.hasContentToDisplay() ? 1 : 0); + transformation.setAlpha(mAppToken.isVisible() ? 1 : 0); hasTransformation = true; mStackClip = stackClip; @@ -172,7 +172,7 @@ public class AppWindowAnimator { animation = sDummyAnimation; hasTransformation = true; transformation.clear(); - transformation.setAlpha(mAppToken.hasContentToDisplay() ? 1 : 0); + transformation.setAlpha(mAppToken.isVisible() ? 1 : 0); } void setNullAnimation() { diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 12abe39b082b1..2b258c9d0fcc1 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1479,7 +1479,7 @@ class WindowState extends WindowContainer implements WindowManagerP // TODO: Another visibility method that was added late in the release to minimize risk. @Override public boolean canAffectSystemUiFlags() { - final boolean shown = mWinAnimator.getShown(); + final boolean shown = mWinAnimator.getShown() && mWinAnimator.mShownAlpha > 0f; // We only consider the app to be exiting when the animation has started. After the app // transition is executed the windows are marked exiting before the new windows have been