Fix lockscreen notification launch animation
When launching a notification from the lockscreen, we immediately
start an app transition because the app is started in invisible
/stopped state. Then, we try to take a screenshot, but nothing
is visible yet because the AppWindowToken is hidden.
Furthermore this fixes a bug where we were starting a remote
animation too aggressively.
Test: Launch anything from lockscreen
Test: go/wm-smoke
Change-Id: Iea9366813fa5780460a9ab2738f2a17f65fbeb15
Fixes: 73187454
diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java
index 1170148..1575694 100644
--- a/services/core/java/com/android/server/wm/AppWindowContainerController.java
+++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java
@@ -617,7 +617,8 @@
if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Schedule remove starting " + mContainer
+ " startingWindow=" + mContainer.startingWindow
- + " startingView=" + mContainer.startingSurface);
+ + " startingView=" + mContainer.startingSurface
+ + " Callers=" + Debug.getCallers(5));
// Use the same thread to remove the window as we used to add it, as otherwise we end up
// with things in the view hierarchy being called from different threads.
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index fef615d..b70a8cd 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -2073,6 +2073,13 @@
super.prepareSurfaces();
}
+ /**
+ * @return Whether our {@link #getSurfaceControl} is currently showing.
+ */
+ boolean isSurfaceShowing() {
+ return mLastSurfaceShowing;
+ }
+
boolean isFreezingScreen() {
return mFreezingScreen;
}
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index 9310dc4..970a8d7 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -247,7 +247,8 @@
// Ensure at least one window for the top app is visible before attempting to take
// a screenshot. Visible here means that the WSA surface is shown and has an alpha
// greater than 0.
- ws -> ws.mWinAnimator != null && ws.mWinAnimator.getShown()
+ ws -> (ws.mAppToken == null || ws.mAppToken.isSurfaceShowing())
+ && ws.mWinAnimator != null && ws.mWinAnimator.getShown()
&& ws.mWinAnimator.mLastAlpha > 0f, true);
if (!hasVisibleChild) {