Merge "Support to get the exact task which IME is attached to" into tm-dev
This commit is contained in:
@@ -52,7 +52,7 @@ interface ITaskOrganizerController {
|
|||||||
/** Gets all root tasks on a display (ordered from top-to-bottom) */
|
/** Gets all root tasks on a display (ordered from top-to-bottom) */
|
||||||
List<ActivityManager.RunningTaskInfo> getRootTasks(int displayId, in int[] activityTypes);
|
List<ActivityManager.RunningTaskInfo> getRootTasks(int displayId, in int[] activityTypes);
|
||||||
|
|
||||||
/** Get the root task which contains the current ime target */
|
/** Get the {@link WindowContainerToken} of the task which contains the current ime target */
|
||||||
WindowContainerToken getImeTarget(int display);
|
WindowContainerToken getImeTarget(int display);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class TaskOrganizer extends WindowOrganizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the root task which contains the current ime target */
|
/** Get the {@link WindowContainerToken} of the task which contains the current ime target */
|
||||||
@RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS)
|
@RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS)
|
||||||
@Nullable
|
@Nullable
|
||||||
public WindowContainerToken getImeTarget(int display) {
|
public WindowContainerToken getImeTarget(int display) {
|
||||||
|
|||||||
@@ -1117,9 +1117,9 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
|||||||
return SPLIT_POSITION_UNDEFINED;
|
return SPLIT_POSITION_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.equals(mMainStage.mRootTaskInfo.getToken())) {
|
if (mMainStage.containsToken(token)) {
|
||||||
return getMainStagePosition();
|
return getMainStagePosition();
|
||||||
} else if (token.equals(mSideStage.mRootTaskInfo.getToken())) {
|
} else if (mSideStage.containsToken(token)) {
|
||||||
return getSideStagePosition();
|
return getSideStagePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,20 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
|||||||
return mChildrenTaskInfo.contains(taskId);
|
return mChildrenTaskInfo.contains(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean containsToken(WindowContainerToken token) {
|
||||||
|
if (token.equals(mRootTaskInfo.token)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = mChildrenTaskInfo.size() - 1; i >= 0; --i) {
|
||||||
|
if (token.equals(mChildrenTaskInfo.valueAt(i).token)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the top visible child task's id.
|
* Returns the top visible child task's id.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -800,17 +800,24 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
|||||||
final long origId = Binder.clearCallingIdentity();
|
final long origId = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
DisplayContent dc = mService.mWindowManager.mRoot
|
final DisplayContent dc = mService.mWindowManager.mRoot
|
||||||
.getDisplayContent(displayId);
|
.getDisplayContent(displayId);
|
||||||
if (dc == null || dc.getImeTarget(IME_TARGET_LAYERING) == null) {
|
if (dc == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final InsetsControlTarget imeLayeringTarget = dc.getImeTarget(IME_TARGET_LAYERING);
|
||||||
|
if (imeLayeringTarget == null || imeLayeringTarget.getWindow() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid WindowState#getRootTask() so we don't attribute system windows to a task.
|
// Avoid WindowState#getRootTask() so we don't attribute system windows to a task.
|
||||||
final Task task = dc.getImeTarget(IME_TARGET_LAYERING).getWindow().getTask();
|
final Task task = imeLayeringTarget.getWindow().asTask();
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return task.getRootTask().mRemoteToken.toWindowContainerToken();
|
|
||||||
|
return task.mRemoteToken.toWindowContainerToken();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
|
|||||||
Reference in New Issue
Block a user