Merge "Supporting independent back nav while task embedded" into sc-v2-dev

This commit is contained in:
Louis Chang
2021-08-06 01:42:47 +00:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 13 deletions

View File

@@ -1909,17 +1909,17 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
if (r.moveFocusableActivityToTop("setFocusedTask")) { if (r.moveFocusableActivityToTop("setFocusedTask")) {
mRootWindowContainer.resumeFocusedTasksTopActivities(); mRootWindowContainer.resumeFocusedTasksTopActivities();
} else if (touchedActivity != null && touchedActivity != r } else if (touchedActivity != null && touchedActivity.isFocusable()) {
&& touchedActivity.getTask() == r.getTask() final TaskFragment parent = touchedActivity.getTaskFragment();
&& touchedActivity.getTaskFragment() != r.getTaskFragment()) { if (parent != null && parent.isEmbedded()) {
// Set the focused app directly since the focused window is not on the // Set the focused app directly if the focused window is currently embedded
// top-most TaskFragment of the top-most Task
final DisplayContent displayContent = touchedActivity.getDisplayContent(); final DisplayContent displayContent = touchedActivity.getDisplayContent();
displayContent.setFocusedApp(touchedActivity); displayContent.setFocusedApp(touchedActivity);
mWindowManager.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, mWindowManager.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
true /* updateInputWindows */); true /* updateInputWindows */);
} }
} }
}
@Override @Override
public boolean removeTask(int taskId) { public boolean removeTask(int taskId) {

View File

@@ -777,12 +777,21 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
return true; return true;
} }
if (focusedApp.getTask() == activity.getTask() // If the candidate activity is currently being embedded in the focused task, the
&& focusedApp.getTaskFragment() != activity.getTaskFragment()) { // activity cannot be focused unless it is on the same TaskFragment as the focusedApp's.
// Do not use the activity window of another TaskFragment in the same leaf Task TaskFragment parent = activity.getTaskFragment();
if (parent != null && parent.isEmbedded()) {
Task hostTask = focusedApp.getTask();
if (hostTask.isEmbedded()) {
// Use the hosting task if the current task is embedded.
hostTask = hostTask.getParent().asTaskFragment().getTask();
}
if (activity.isDescendantOf(hostTask)
&& activity.getTaskFragment() != focusedApp.getTaskFragment()) {
return false; return false;
} }
} }
}
ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "findFocusedWindow: Found new focus @ %s", w); ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "findFocusedWindow: Found new focus @ %s", w);
mTmpWindow = w; mTmpWindow = w;