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

Commit 1ea3ce83 authored by Garfield Tan's avatar Garfield Tan Committed by Android (Google) Code Review
Browse files

Merge "Set root task focused if one of its children is focused"

parents a4bd59ab 9724b537
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -4291,13 +4291,14 @@ class Task extends TaskFragment {
    }

    /**
     * @return true if the task is currently focused.
     * @return {@code true} if the task is currently focused or one of its children is focused.
     */
    boolean isFocused() {
        if (mDisplayContent == null || mDisplayContent.mFocusedApp == null) {
            return false;
        }
        return mDisplayContent.mFocusedApp.getTask() == this;
        final Task focusedTask = mDisplayContent.mFocusedApp.getTask();
        return focusedTask == this || (focusedTask != null && focusedTask.getParent() == this);
    }

    /**
@@ -4317,6 +4318,8 @@ class Task extends TaskFragment {
     */
    void onAppFocusChanged(boolean hasFocus) {
        dispatchTaskInfoChangedIfNeeded(false /* force */);
        final Task parentTask = getParent().asTask();
        if (parentTask != null) parentTask.dispatchTaskInfoChangedIfNeeded(false /* force */);
    }

    void onPictureInPictureParamsChanged() {
+18 −0
Original line number Diff line number Diff line
@@ -432,6 +432,24 @@ public class TaskTests extends WindowTestsBase {
        Assert.assertThat(info.baseIntent, not(sameInstance(task.getBaseIntent())));
    }

    @Test
    public void testPropagateFocusedStateToRootTask() {
        final Task rootTask = createTask(mDefaultDisplay);
        final Task leafTask = createTaskInRootTask(rootTask, 0 /* userId */);

        final ActivityRecord activity = createActivityRecord(leafTask);

        leafTask.getDisplayContent().setFocusedApp(activity);

        assertTrue(leafTask.getTaskInfo().isFocused);
        assertTrue(rootTask.getTaskInfo().isFocused);

        leafTask.getDisplayContent().setFocusedApp(null);

        assertFalse(leafTask.getTaskInfo().isFocused);
        assertFalse(rootTask.getTaskInfo().isFocused);
    }

    @Test
    public void testReturnsToHomeRootTask() throws Exception {
        final Task task = createTask(1);