Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df4284f4 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce unnecessary window container traversal

There are usually 30+ ABOVE_TASKS DisplayArea, so check the
type to skip the containers that won't contain activity or task.

Remove the condition of BELOW_TASKS because TaskDisplayArea is
almost at the bottom and usually at least there is an activity
which is above BELOW_TASKS.

Bug: 159103089
Test: CtsWindowManagerDeviceWindow
Change-Id: I71490a738810e256d6059b7453da36b391f8f856
parent edb14a70
Loading
Loading
Loading
Loading
+38 −6
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
    @Override
    ActivityRecord getActivity(Predicate<ActivityRecord> callback, boolean traverseTopToBottom,
            ActivityRecord boundary) {
        if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
        if (mType == Type.ABOVE_TASKS) {
            return null;
        }
        return super.getActivity(callback, traverseTopToBottom, boundary);
@@ -428,23 +428,39 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {

    @Override
    Task getTask(Predicate<Task> callback, boolean traverseTopToBottom) {
        if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
        if (mType == Type.ABOVE_TASKS) {
            return null;
        }
        return super.getTask(callback, traverseTopToBottom);
    }

    @Override
    Task getRootTask(Predicate<Task> callback, boolean traverseTopToBottom) {
        if (mType == Type.ABOVE_TASKS) {
            return null;
        }
        return super.getRootTask(callback, traverseTopToBottom);
    }

    @Override
    boolean forAllActivities(Predicate<ActivityRecord> callback, boolean traverseTopToBottom) {
        if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
        if (mType == Type.ABOVE_TASKS) {
            return false;
        }
        return super.forAllActivities(callback, traverseTopToBottom);
    }

    @Override
    void forAllActivities(Consumer<ActivityRecord> callback, boolean traverseTopToBottom) {
        if (mType == Type.ABOVE_TASKS) {
            return;
        }
        super.forAllActivities(callback, traverseTopToBottom);
    }

    @Override
    boolean forAllRootTasks(Predicate<Task> callback, boolean traverseTopToBottom) {
        if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
        if (mType == Type.ABOVE_TASKS) {
            return false;
        }
        return super.forAllRootTasks(callback, traverseTopToBottom);
@@ -452,7 +468,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {

    @Override
    boolean forAllTasks(Predicate<Task> callback) {
        if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
        if (mType == Type.ABOVE_TASKS) {
            return false;
        }
        return super.forAllTasks(callback);
@@ -460,12 +476,28 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {

    @Override
    boolean forAllLeafTasks(Predicate<Task> callback) {
        if (mType == Type.ABOVE_TASKS || mType == Type.BELOW_TASKS) {
        if (mType == Type.ABOVE_TASKS) {
            return false;
        }
        return super.forAllLeafTasks(callback);
    }

    @Override
    void forAllLeafTasks(Consumer<Task> callback, boolean traverseTopToBottom) {
        if (mType == Type.ABOVE_TASKS) {
            return;
        }
        super.forAllLeafTasks(callback, traverseTopToBottom);
    }

    @Override
    boolean forAllLeafTaskFragments(Predicate<TaskFragment> callback) {
        if (mType == Type.ABOVE_TASKS) {
            return false;
        }
        return super.forAllLeafTaskFragments(callback);
    }

    @Override
    void forAllDisplayAreas(Consumer<DisplayArea> callback) {
        super.forAllDisplayAreas(callback);