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

Commit 58417995 authored by Louis Chang's avatar Louis Chang
Browse files

Moves focus to the adjacent embedded activity on back nav

In order to provide a consistent back behavior in AE, the
system now finish the most recently active activity when
back pressed, regardless whether the activity is the top-most
activity on the Task.

This is done by comparing the creation time of the Activity.
Or the creation time of the additional app window if any.

Also removes TF#mDimmerSurfaceBoosted since it is no longer
needed.

Bug: 240575809
Test: atest TaskFragmentTest
Test: atest BackNavigationControllerTests

Change-Id: Iad1c8a92f12596dc83e3cc8d7aa044c507f07733
parent db65f732
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4727,7 +4727,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                if (down) {
                    // There may have other embedded activities on the same Task. Try to move the
                    // focus before processing the back event.
                    mWindowManagerInternal.moveFocusToTopEmbeddedWindowIfNeeded();
                    mWindowManagerInternal.moveFocusToAdjacentEmbeddedActivityIfNeeded();
                    mBackKeyHandled = false;
                } else {
                    if (!hasLongPressOnBackBehavior()) {
+14 −0
Original line number Diff line number Diff line
@@ -11011,6 +11011,20 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return new Point(windowLayout.minWidth, windowLayout.minHeight);
    }

    /**
     * Returns the {@link #createTime} if the top window is the `base` window. Note that do not
     * use the window creation time because the window could be re-created when the activity
     * relaunched if configuration changed.
     * <p>
     * Otherwise, return the creation time of the top window.
     */
    long getLastWindowCreateTime() {
        final WindowState window = getWindow(win -> true);
        return window != null && window.mAttrs.type != TYPE_BASE_APPLICATION
                ? window.getCreateTime()
                : createTime;
    }

    /**
     * Adjust the source rect hint in {@link #pictureInPictureArgs} by window bounds since
     * it is relative to its root view (see also b/235599028).
+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ class BackNavigationController {
            }

            // Move focus to the top embedded window if possible
            if (mWindowManagerService.moveFocusToTopEmbeddedWindow(window)) {
            if (mWindowManagerService.moveFocusToAdjacentEmbeddedWindow(window)) {
                window = wmService.getFocusedWindowLocked();
                if (window == null) {
                    Slog.e(TAG, "New focused window is null, returning null.");
+0 −2
Original line number Diff line number Diff line
@@ -3753,11 +3753,9 @@ class Task extends TaskFragment {
                // Boost the adjacent TaskFragment for dimmer if needed.
                final TaskFragment taskFragment = wc.asTaskFragment();
                if (taskFragment != null && taskFragment.isEmbedded()) {
                    taskFragment.mDimmerSurfaceBoosted = false;
                    final TaskFragment adjacentTf = taskFragment.getAdjacentTaskFragment();
                    if (adjacentTf != null && adjacentTf.shouldBoostDimmer()) {
                        adjacentTf.assignLayer(t, layer++);
                        adjacentTf.mDimmerSurfaceBoosted = true;
                    }
                }

+0 −3
Original line number Diff line number Diff line
@@ -216,9 +216,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
    Dimmer mDimmer = Dimmer.DIMMER_REFACTOR
            ? new SmoothDimmer(this) : new LegacyDimmer(this);

    /** {@code true} if the dimmer surface is boosted. {@code false} otherwise. */
    boolean mDimmerSurfaceBoosted;

    /** Apply the dim layer on the embedded TaskFragment. */
    static final int EMBEDDED_DIM_AREA_TASK_FRAGMENT = 0;

Loading