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

Commit 72c7db4c authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Sets the focused TaskFragment after WCT is applied" into main

parents e73b6699 bf88de2a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -62,7 +62,11 @@ public final class TaskFragmentOperation implements Parcelable {
    /** Clears the adjacent TaskFragments relationship. */
    public static final int OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS = 5;

    /** Requests focus on the top running Activity in the given TaskFragment. */
    /**
     * Requests focus on the top running Activity in the given TaskFragment. Note that this
     * executes after all the operations in the same {@link WindowContainerTransaction} are
     * applied.
     */
    public static final int OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT = 6;

    /** Sets a given TaskFragment to have a companion TaskFragment. */
+22 −15
Original line number Diff line number Diff line
@@ -1784,21 +1784,28 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                break;
            }
            case OP_TYPE_REQUEST_FOCUS_ON_TASK_FRAGMENT: {
                final ActivityRecord curFocus = taskFragment.getDisplayContent().mFocusedApp;
                mService.mH.post(() -> {
                    synchronized (mService.mGlobalLock) {
                        final ActivityRecord curFocus =
                                taskFragment.getDisplayContent().mFocusedApp;
                        if (curFocus != null && curFocus.getTaskFragment() == taskFragment) {
                            Slog.d(TAG, "The requested TaskFragment already has the focus.");
                    break;
                            return;
                        }
                        if (curFocus != null && curFocus.getTask() != taskFragment.getTask()) {
                    Slog.d(TAG, "The Task of the requested TaskFragment doesn't have focus.");
                    break;
                            Slog.d(TAG,
                                    "The Task of the requested TaskFragment doesn't have focus.");
                            return;
                        }
                        final ActivityRecord targetFocus = taskFragment.getTopResumedActivity();
                        if (targetFocus == null) {
                    Slog.d(TAG, "There is no resumed activity in the requested TaskFragment.");
                    break;
                            Slog.d(TAG,
                                    "There is no resumed activity in the requested TaskFragment.");
                            return;
                        }
                        taskFragment.getDisplayContent().setFocusedApp(targetFocus);
                    }
                });
                break;
            }
            case OP_TYPE_SET_COMPANION_TASK_FRAGMENT: {
+3 −0
Original line number Diff line number Diff line
@@ -1120,6 +1120,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
        mTransaction.requestFocusOnTaskFragment(token0);
        assertApplyTransactionAllowed(mTransaction);

        waitHandlerIdle(mWm.mAtmService.mH);
        assertEquals(activityInOtherTask, mDisplayContent.mFocusedApp);

        // No effect if there is no resumed activity in the request TaskFragment.
@@ -1128,6 +1129,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
        mDisplayContent.setFocusedApp(activity1);
        assertApplyTransactionAllowed(mTransaction);

        waitHandlerIdle(mWm.mAtmService.mH);
        assertEquals(activity1, mDisplayContent.mFocusedApp);

        // Set focus to the request TaskFragment when the current focus is in the same Task, and it
@@ -1136,6 +1138,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase {
        mDisplayContent.setFocusedApp(activity1);
        assertApplyTransactionAllowed(mTransaction);

        waitHandlerIdle(mWm.mAtmService.mH);
        assertEquals(activity0, mDisplayContent.mFocusedApp);
    }