Optimize traversal methods from DisplayArea
There are dozen of display areas won't contain activity or task. So if a traversal method for task/activity is called on a display or root, it can be skipped directly. This can save 200+ times to go through the areas during an activity launch. Also simplify AR#getDisplayId a bit: no need to use root task. If the activity is detached, its task will be null. And if the task is detached, its display will be null. Bug: 159103089 Test: CtsWindowManagerDeviceTestCases Change-Id: Iacd20f14bf8681d9ef156721d056bbe5e5a0c3c8
This commit is contained in:
@@ -6912,11 +6912,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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user