Merge "Optimize traversal methods from DisplayArea"

This commit is contained in:
Riddle Hsu
2022-11-14 14:06:28 +00:00
committed by Android (Google) Code Review
2 changed files with 51 additions and 5 deletions

View File

@@ -6908,11 +6908,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
* {@link android.view.Display#INVALID_DISPLAY} if not attached.
*/
int getDisplayId() {
final Task rootTask = getRootTask();
if (rootTask == null) {
return INVALID_DISPLAY;
}
return rootTask.getDisplayId();
return task != null && task.mDisplayContent != null
? task.mDisplayContent.mDisplayId : INVALID_DISPLAY;
}
final boolean isDestroyable() {

View File

@@ -368,6 +368,55 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
return null;
}
@Override
ActivityRecord getActivity(Predicate<ActivityRecord> callback, boolean traverseTopToBottom,
ActivityRecord boundary) {
if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
return null;
}
return super.getActivity(callback, traverseTopToBottom, boundary);
}
@Override
Task getTask(Predicate<Task> callback, boolean traverseTopToBottom) {
if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
return null;
}
return super.getTask(callback, traverseTopToBottom);
}
@Override
boolean forAllActivities(Predicate<ActivityRecord> callback, boolean traverseTopToBottom) {
if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
return false;
}
return super.forAllActivities(callback, traverseTopToBottom);
}
@Override
boolean forAllRootTasks(Predicate<Task> callback, boolean traverseTopToBottom) {
if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
return false;
}
return super.forAllRootTasks(callback, traverseTopToBottom);
}
@Override
boolean forAllTasks(Predicate<Task> callback) {
if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
return false;
}
return super.forAllTasks(callback);
}
@Override
boolean forAllLeafTasks(Predicate<Task> callback) {
if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
return false;
}
return super.forAllLeafTasks(callback);
}
@Override
void forAllDisplayAreas(Consumer<DisplayArea> callback) {
super.forAllDisplayAreas(callback);