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

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

Excluding pip Task while trying to move Activity on Top

In ActivityEmbedding, touching on the embedded and non-current-focused
Activity will make the Activity focused if the parent Task is not moving
to top. However, it doesn't work when there's a pip Task. That's because
the pip Task is always-on-top and also focusable. The touched Task is
therefore not the top focusable Task and was requested to move to top
(though it is a no-op since it cannot be moved above pip).

Bug: 311984433
Test: ActivityRecordTests
Change-Id: Ib3f92d81b5a2daf9bb6dc4b7dbdfa53f9d45c7bd
parent ac4089a9
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -3386,7 +3386,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (currentFocusedApp != null && currentFocusedApp.task == task
        if (currentFocusedApp != null && currentFocusedApp.task == task
                && topFocusedDisplayId == mDisplayContent.getDisplayId()) {
                && topFocusedDisplayId == mDisplayContent.getDisplayId()) {
            final Task topFocusableTask = mDisplayContent.getTask(
            final Task topFocusableTask = mDisplayContent.getTask(
                    (t) -> t.isLeafTask() && t.isFocusable(), true /*  traverseTopToBottom */);
                    (t) -> t.isLeafTask() && t.isFocusable() && !t.inPinnedWindowingMode(),
                    true /*  traverseTopToBottom */);
            if (task == topFocusableTask) {
            if (task == topFocusableTask) {
                if (currentFocusedApp == this) {
                if (currentFocusedApp == this) {
                    ProtoLog.d(WM_DEBUG_FOCUS, "moveFocusableActivityToTop: already on top "
                    ProtoLog.d(WM_DEBUG_FOCUS, "moveFocusableActivityToTop: already on top "
+18 −0
Original line number Original line Diff line number Diff line
@@ -3717,6 +3717,24 @@ public class ActivityRecordTests extends WindowTestsBase {
        verify(task).moveTaskToBack(any());
        verify(task).moveTaskToBack(any());
    }
    }


    /**
     * Verifies the {@link ActivityRecord#moveFocusableActivityToTop} returns {@code false} if
     * there's a PIP task on top.
     */
    @Test
    public void testMoveFocusableActivityToTop() {
        // Create a Task
        final Task task = createTask(mDisplayContent);
        final ActivityRecord ar = createActivityRecord(task);

        // Create a PIP Task on top
        final Task pipTask = createTask(mDisplayContent);
        doReturn(true).when(pipTask).inPinnedWindowingMode();

        // Verifies that the Task is not moving-to-top.
        assertFalse(ar.moveFocusableActivityToTop("test"));
    }

    private ICompatCameraControlCallback getCompatCameraControlCallback() {
    private ICompatCameraControlCallback getCompatCameraControlCallback() {
        return new ICompatCameraControlCallback.Stub() {
        return new ICompatCameraControlCallback.Stub() {
            @Override
            @Override