Loading core/java/android/window/TaskFragmentOperation.java +5 −1 Original line number Diff line number Diff line Loading @@ -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. */ Loading services/core/java/com/android/server/wm/WindowOrganizerController.java +22 −15 Original line number Diff line number Diff line Loading @@ -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: { Loading services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 Loading @@ -1136,6 +1138,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase { mDisplayContent.setFocusedApp(activity1); assertApplyTransactionAllowed(mTransaction); waitHandlerIdle(mWm.mAtmService.mH); assertEquals(activity0, mDisplayContent.mFocusedApp); } Loading Loading
core/java/android/window/TaskFragmentOperation.java +5 −1 Original line number Diff line number Diff line Loading @@ -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. */ Loading
services/core/java/com/android/server/wm/WindowOrganizerController.java +22 −15 Original line number Diff line number Diff line Loading @@ -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: { Loading
services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 Loading @@ -1136,6 +1138,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase { mDisplayContent.setFocusedApp(activity1); assertApplyTransactionAllowed(mTransaction); waitHandlerIdle(mWm.mAtmService.mH); assertEquals(activity0, mDisplayContent.mFocusedApp); } Loading