Fix ATMS#focusTopTask set to PiP task even the activity is not focusable

When swiping up to the overview from the split-screen task with showing
IME and PiP, normally the WM shell enables the
recents input consumer to call ATM#focusTopTask, and it should choose
home (or recents) task as the focus app, but the issue case will find
PiP as the top task, even the PiP activity was not focusable,
this affects InputMonitor ends up missing to apply
dismissing IME logic because the current focus app is not the
home (or recents) task.

As a result, uses isTopActivityFocusable in focusTopTask to align with the PiP activity focusable check to ensure PiP task won't be selected by focusTopTask.

Fix: 285218009
Test: atest ActivityTaskManagerServiceTests#testFocusTopTask
Test: manual as issue steps:
   1) start 2 apps to enter split-screen mode (e.g Settings & Message)
   2) start Youtube app to enter PiP mode
   3) tap Settings's editor to show IME
   4) swiping up to the overview
   5) expect IME should be dismissed after entering to the overview.
Change-Id: Ib48a24a0024fa0e28079c90dd5388ae8a6b39581
This commit is contained in:
Ming-Shin Lu
2023-06-01 12:22:48 +00:00
parent 7502484675
commit 2564e1a9c7
2 changed files with 16 additions and 1 deletions

View File

@@ -2012,7 +2012,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
synchronized (mGlobalLock) {
final DisplayContent dc = mRootWindowContainer.getDisplayContent(displayId);
if (dc == null) return;
final Task task = dc.getTask((t) -> t.isLeafTask() && t.isFocusable(),
final Task task = dc.getTask((t) -> t.isLeafTask() && t.isTopActivityFocusable(),
true /* traverseTopToBottom */);
if (task == null) return;
setFocusedTask(task.mTaskId, null /* touchedActivity */);

View File

@@ -16,6 +16,7 @@
package com.android.server.wm;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
@@ -1059,4 +1060,18 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {
assertEquals(0, mAtm.getActivityInterceptorCallbacks().size());
mAtm.mInternal.unregisterActivityStartInterceptor(SYSTEM_FIRST_ORDERED_ID);
}
@Test
public void testFocusTopTask() {
final ActivityRecord homeActivity = new ActivityBuilder(mAtm)
.setTask(mRootWindowContainer.getDefaultTaskDisplayArea().getOrCreateRootHomeTask())
.build();
final Task pinnedTask = new TaskBuilder(mSupervisor).setCreateActivity(true)
.setWindowingMode(WINDOWING_MODE_PINNED)
.build();
mAtm.focusTopTask(mDisplayContent.mDisplayId);
assertTrue(homeActivity.getTask().isFocused());
assertFalse(pinnedTask.isFocused());
}
}