From 8c67051b9797e5ebe42b54a81072c78507ac0a04 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Fri, 16 Jul 2021 22:31:31 -0700 Subject: [PATCH] Do not preload recents activity if it will be visible Before, even if the launcher was not launched, RecentsAnimation would start the activity in background as invisible. It would cause issue because ensureVisibility would make it visible because there is no opaque activity on top, while that may not be collected in any app transition. Now, in case the recents activity should be visible, we ignore the preload recents activity. Bug: 193565751 Test: pass failed launcher test Change-Id: I93f5a716177bcbf69f5e4d5915826bd9f61f53a4 --- data/etc/services.core.protolog.json | 6 ++++++ .../core/java/com/android/server/wm/RecentsAnimation.java | 5 +++++ services/core/java/com/android/server/wm/Task.java | 2 ++ services/core/java/com/android/server/wm/Transition.java | 8 ++++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 3e37237628004..8caff23539c31 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -3139,6 +3139,12 @@ "group": "WM_DEBUG_WINDOW_TRANSITIONS", "at": "com\/android\/server\/wm\/Transition.java" }, + "1494644409": { + "message": " Rejecting as detached: %s", + "level": "VERBOSE", + "group": "WM_DEBUG_WINDOW_TRANSITIONS", + "at": "com\/android\/server\/wm\/Transition.java" + }, "1495525537": { "message": "createWallpaperAnimations()", "level": "DEBUG", diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java index 47129c242e84b..ba1cf8ae06df3 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimation.java +++ b/services/core/java/com/android/server/wm/RecentsAnimation.java @@ -125,6 +125,11 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS, "Updated config=%s", targetActivity.getConfiguration()); } + } else if (mDefaultTaskDisplayArea.getActivity( + ActivityRecord::occludesParent, false /* traverseTopToBottom */) == null) { + // Skip because none of above activities can occlude the target activity. The preload + // should be done silently in background without being visible. + return; } else { // Create the activity record. Because the activity is invisible, this doesn't really // start the client. diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index bd3b0745f8965..7da7922ac1b6d 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -3568,6 +3568,8 @@ class Task extends TaskFragment { } sb.append(" visible="); sb.append(shouldBeVisible(null /* starting */)); + sb.append(" visibleRequested="); + sb.append(isVisibleRequested()); sb.append(" mode="); sb.append(windowingModeToString(getWindowingMode())); sb.append(" translucent="); diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 1ac16664244fa..11324d2c89c14 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -352,7 +352,7 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe final WallpaperWindowToken wt = mParticipants.valueAt(i).asWallpaperToken(); if (wt != null && !wt.isVisibleRequested()) { ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, - " Commit wallpaper becoming invisible: %s", ar); + " Commit wallpaper becoming invisible: %s", wt); wt.commitVisibility(false /* visible */); } } @@ -808,7 +808,11 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe // of participants that should always be reported even if they aren't top. for (WindowContainer wc : participants) { // Don't include detached windows. - if (!wc.isAttached()) continue; + if (!wc.isAttached()) { + ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, + " Rejecting as detached: %s", wc); + continue; + } final ChangeInfo changeInfo = changes.get(wc);