diff options
| author | 2024-01-29 10:38:43 +0000 | |
|---|---|---|
| committer | 2024-01-30 07:51:07 +0000 | |
| commit | 6a9ebce1762f53e635f8c1d03d15da3b4aa7bfdf (patch) | |
| tree | 2d6d09dd60e4fe591aaf9361bf8fedfd4a72346f | |
| parent | 703fd3da6c184a4fc18ecb010afdaf54b1a36f4a (diff) | |
Force update the surface of opening targets to visible
The transaction status may be un-synced from core and shell.
After an open app transition, shell would hide the close target with
finish transition, but in core the status needs to update while
WindowContainer#prepareSurfaces. If core start back navigation just
before surface placement, the mLastSurfaceShowing of the opening target
may still be visible, which cause it's stay hide.
Bug: 321967213
Bug: 321965173
Test: repeat run 50+ times open/close to verify the opening target must
be visible.
Change-Id: I11090c3f80e39a2a5dbea7e2ec036b98ec7c96a0
3 files changed, 31 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java index 83ccbdc1a4d1..13f6a5f1a27b 100644 --- a/services/core/java/com/android/server/wm/BackNavigationController.java +++ b/services/core/java/com/android/server/wm/BackNavigationController.java @@ -1527,6 +1527,12 @@ class BackNavigationController {                          setLaunchBehind(visibleOpenActivities[i]);                      }                  } +                // Force update mLastSurfaceShowing for opening activity and its task. +                if (mWindowManagerService.mRoot.mTransitionController.isShellTransitionsEnabled()) { +                    for (int i = visibleOpenActivities.length - 1; i >= 0; --i) { +                        WindowContainer.enforceSurfaceVisible(visibleOpenActivities[i]); +                    } +                }              }              @Nullable Runnable build() { diff --git a/services/core/java/com/android/server/wm/TransitionController.java b/services/core/java/com/android/server/wm/TransitionController.java index d7b4a399514d..e025c706b989 100644 --- a/services/core/java/com/android/server/wm/TransitionController.java +++ b/services/core/java/com/android/server/wm/TransitionController.java @@ -989,39 +989,18 @@ class TransitionController {          Slog.e(TAG, "Set visible without transition " + wc + " playing=" + isPlaying                  + " caller=" + caller);          if (!isPlaying) { -            enforceSurfaceVisible(wc); +            WindowContainer.enforceSurfaceVisible(wc);              return;          }          // Update surface visibility after the playing transitions are finished, so the last          // visibility won't be replaced by the finish transaction of transition.          mStateValidators.add(() -> {              if (wc.isVisibleRequested()) { -                enforceSurfaceVisible(wc); +                WindowContainer.enforceSurfaceVisible(wc);              }          });      } -    private void enforceSurfaceVisible(WindowContainer<?> wc) { -        if (wc.mSurfaceControl == null) return; -        wc.getSyncTransaction().show(wc.mSurfaceControl); -        final ActivityRecord ar = wc.asActivityRecord(); -        if (ar != null) { -            ar.mLastSurfaceShowing = true; -        } -        // Force showing the parents because they may be hidden by previous transition. -        for (WindowContainer<?> p = wc.getParent(); p != null && p != wc.mDisplayContent; -                p = p.getParent()) { -            if (p.mSurfaceControl != null) { -                p.getSyncTransaction().show(p.mSurfaceControl); -                final Task task = p.asTask(); -                if (task != null) { -                    task.mLastSurfaceShowing = true; -                } -            } -        } -        wc.scheduleAnimation(); -    } -      /**       * Called when the transition has a complete set of participants for its operation. In other       * words, it is when the transition is "ready" but is still waiting for participants to draw. diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 286182eedf44..2d2857aba781 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3625,6 +3625,29 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<          return mSurfaceControl.getHeight();      } +    static void enforceSurfaceVisible(@NonNull WindowContainer<?> wc) { +        if (wc.mSurfaceControl == null) { +            return; +        } +        wc.getSyncTransaction().show(wc.mSurfaceControl); +        final ActivityRecord ar = wc.asActivityRecord(); +        if (ar != null) { +            ar.mLastSurfaceShowing = true; +        } +        // Force showing the parents because they may be hidden by previous transition. +        for (WindowContainer<?> p = wc.getParent(); p != null && p != wc.mDisplayContent; +                p = p.getParent()) { +            if (p.mSurfaceControl != null) { +                p.getSyncTransaction().show(p.mSurfaceControl); +                final Task task = p.asTask(); +                if (task != null) { +                    task.mLastSurfaceShowing = true; +                } +            } +        } +        wc.scheduleAnimation(); +    } +      @CallSuper      void dump(PrintWriter pw, String prefix, boolean dumpAll) {          if (mSurfaceAnimator.isAnimating()) {  |