Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a96967d4 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Only apply wallpaper anim if top most app is wallpaper target

If it's not the top app it doesn't make a lot of sense to use
that animation, as it doesn't really work for these other
use-cases when Launcher is behind a translucent activity.

Fix: 78995541
Test: go/wm-smoke
Test: Open Assistant, click explore button, click back, observe
no freeze.
Change-Id: I0bc0f4e066f55c545ac2d3254b7391ec97db425f
parent 6df95fa0
Loading
Loading
Loading
Loading
+33 −1
Original line number Diff line number Diff line
@@ -644,6 +644,11 @@ class WindowSurfacePlacer {
                ? null : wallpaperTarget;
        final ArraySet<AppWindowToken> openingApps = mService.mOpeningApps;
        final ArraySet<AppWindowToken> closingApps = mService.mClosingApps;
        final AppWindowToken topOpeningApp = getTopApp(mService.mOpeningApps,
                false /* ignoreHidden */);
        final AppWindowToken topClosingApp = getTopApp(mService.mClosingApps,
                true /* ignoreHidden */);

        boolean openingCanBeWallpaperTarget = canBeWallpaperTarget(openingApps);
        if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
                "New wallpaper target=" + wallpaperTarget
@@ -677,13 +682,15 @@ class WindowSurfacePlacer {
                        "New transit: " + AppTransition.appTransitionToString(transit));
            } else if (oldWallpaper != null && !mService.mOpeningApps.isEmpty()
                    && !openingApps.contains(oldWallpaper.mAppToken)
                    && closingApps.contains(oldWallpaper.mAppToken)) {
                    && closingApps.contains(oldWallpaper.mAppToken)
                    && topClosingApp == oldWallpaper.mAppToken) {
                // We are transitioning from an activity with a wallpaper to one without.
                transit = TRANSIT_WALLPAPER_CLOSE;
                if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "New transit away from wallpaper: "
                        + AppTransition.appTransitionToString(transit));
            } else if (wallpaperTarget != null && wallpaperTarget.isVisibleLw()
                    && openingApps.contains(wallpaperTarget.mAppToken)
                    && topOpeningApp == wallpaperTarget.mAppToken
                    && transit != TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE) {
                // We are transitioning from an activity without
                // a wallpaper to now showing the wallpaper
@@ -748,6 +755,31 @@ class WindowSurfacePlacer {
        return false;
    }

    /**
     * Finds the top app in a list of apps, using its {@link AppWindowToken#getPrefixOrderIndex} to
     * compare z-order.
     *
     * @param apps The list of apps to search.
     * @param ignoreHidden If set to true, ignores apps that are {@link AppWindowToken#isHidden}.
     * @return The top {@link AppWindowToken}.
     */
    private AppWindowToken getTopApp(ArraySet<AppWindowToken> apps, boolean ignoreHidden) {
        int topPrefixOrderIndex = Integer.MIN_VALUE;
        AppWindowToken topApp = null;
        for (int i = apps.size() - 1; i >= 0; i--) {
            final AppWindowToken app = apps.valueAt(i);
            if (ignoreHidden && app.isHidden()) {
                continue;
            }
            final int prefixOrderIndex = app.getPrefixOrderIndex();
            if (prefixOrderIndex > topPrefixOrderIndex) {
                topPrefixOrderIndex = prefixOrderIndex;
                topApp = app;
            }
        }
        return topApp;
    }

    private void processApplicationsAnimatingInPlace(int transit) {
        if (transit == TRANSIT_TASK_IN_PLACE) {
            // Find the focused window