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

Commit 14131fdd authored by wilsonshih's avatar wilsonshih
Browse files

Do not predictive back to translucent task, which could be trampoline.

Skip predictive back to translucent task, because it could be
trampoline task, and could be finish with current top task.

Also fix the check translucent condition for the previous activity, as
the previous activity does not require visibility when predicting,
there should check WindowState#hasWallpaper instead of showWallpaper.

Bug: 336149696
Test: atest BackNavigationControllerTests
Change-Id: I5384fc96c83c6f95ee19a04e8fc84211380f06a3
parent 4a897f6b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -308,7 +308,9 @@ class BackNavigationController {
                    // another task.
                    final Task prevParent = prevTask.getParent().asTask();
                    final Task currParent = currentTask.getParent().asTask();
                    if (prevTask.inMultiWindowMode() && prevParent != currParent) {
                    if ((prevTask.inMultiWindowMode() && prevParent != currParent)
                            // Do not animate to translucent task, it could be trampoline.
                            || hasTranslucentActivity(currentActivity, prevActivities)) {
                        backType = BackNavigationInfo.TYPE_CALLBACK;
                    } else {
                        removedWindowContainer = prevTask;
@@ -523,7 +525,7 @@ class BackNavigationController {
        }
        for (int i = prevActivities.size() - 1; i >= 0; --i) {
            final ActivityRecord test = prevActivities.get(i);
            if (!test.occludesParent() || test.showWallpaper()) {
            if (!test.occludesParent() || test.hasWallpaper()) {
                return true;
            }
        }
+12 −0
Original line number Diff line number Diff line
@@ -3889,6 +3889,18 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return false;
    }


    /** @return {@code true} if this container wants to show wallpaper. */
    boolean hasWallpaper() {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final WindowContainer child = mChildren.get(i);
            if (child.hasWallpaper()) {
                return true;
            }
        }
        return false;
    }

    @Nullable
    static WindowContainer fromBinder(IBinder binder) {
        return RemoteToken.fromBinder(binder).getContainer();
+1 −0
Original line number Diff line number Diff line
@@ -5857,6 +5857,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return hasWallpaper();
    }

    @Override
    boolean hasWallpaper() {
        return (mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0 || hasWallpaperForLetterboxBackground();
    }
+10 −0
Original line number Diff line number Diff line
@@ -167,8 +167,18 @@ public class BackNavigationControllerTests extends WindowTestsBase {
        assertThat(typeToString(backNavigationInfo.getType()))
                .isEqualTo(typeToString(BackNavigationInfo.TYPE_CALLBACK));

        // reset drawing status to test if previous task is translucent activity
        backNavigationInfo.onBackNavigationFinished(false);
        mBackNavigationController.clearBackAnimations();
        // simulate translucent
        recordA.setOccludesParent(false);
        backNavigationInfo = startBackNavigation();
        assertThat(typeToString(backNavigationInfo.getType()))
                .isEqualTo(typeToString(BackNavigationInfo.TYPE_CALLBACK));

        // reset drawing status to test keyguard occludes
        topActivity.setOccludesParent(true);
        recordA.setOccludesParent(true);
        backNavigationInfo.onBackNavigationFinished(false);
        mBackNavigationController.clearBackAnimations();
        makeWindowVisibleAndDrawn(topActivity.findMainWindow());