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

Commit 7c73dd6a authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Removed WallpaperController dependency on WindowList."

parents 368d703d f4ebe2e2
Loading
Loading
Loading
Loading
+43 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.internal.util;

import java.util.function.Function;

/**
 * Represents a function that produces an boolean-valued result.  This is the
 * {@code boolean}-producing primitive specialization for {@link Function}.
 *
 * <p>This is a <a href="package-summary.html">functional interface</a>
 * whose functional method is {@link #apply(Object)}.
 *
 * @param <T> the type of the input to the function
 *
 * @see Function
 * @since 1.8
 */
@FunctionalInterface
public interface ToBooleanFunction<T> {

    /**
     * Applies this function to the given argument.
     *
     * @param value the function argument
     * @return the function result
     */
    boolean apply(T value);
}
+8 −6
Original line number Original line Diff line number Diff line
@@ -47,6 +47,7 @@ import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE
import static com.android.server.wm.WindowManagerService.logWithStack;
import static com.android.server.wm.WindowManagerService.logWithStack;


import android.os.Debug;
import android.os.Debug;
import com.android.internal.util.ToBooleanFunction;
import com.android.server.input.InputApplicationHandle;
import com.android.server.input.InputApplicationHandle;
import com.android.server.wm.WindowManagerService.H;
import com.android.server.wm.WindowManagerService.H;


@@ -66,7 +67,7 @@ import android.view.animation.Animation;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.function.Consumer;
import java.util.function.Function;


class AppTokenList extends ArrayList<AppWindowToken> {
class AppTokenList extends ArrayList<AppWindowToken> {
}
}
@@ -1270,19 +1271,20 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    }
    }


    @Override
    @Override
    void forAllWindows(Consumer<WindowState> callback, boolean traverseTopToBottom) {
    boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) {
        // For legacy reasons we process the TaskStack.mExitingAppTokens first in DisplayContent
        // For legacy reasons we process the TaskStack.mExitingAppTokens first in DisplayContent
        // before the non-exiting app tokens. So, we skip the exiting app tokens here.
        // before the non-exiting app tokens. So, we skip the exiting app tokens here.
        // TODO: Investigate if we need to continue to do this or if we can just process them
        // TODO: Investigate if we need to continue to do this or if we can just process them
        // in-order.
        // in-order.
        if (mIsExiting && !waitingForReplacement()) {
        if (mIsExiting && !waitingForReplacement()) {
            return;
            return false;
        }
        }
        forAllWindowsUnchecked(callback, traverseTopToBottom);
        return forAllWindowsUnchecked(callback, traverseTopToBottom);
    }
    }


    void forAllWindowsUnchecked(Consumer<WindowState> callback, boolean traverseTopToBottom) {
    boolean forAllWindowsUnchecked(ToBooleanFunction<WindowState> callback,
        super.forAllWindows(callback, traverseTopToBottom);
            boolean traverseTopToBottom) {
        return super.forAllWindows(callback, traverseTopToBottom);
    }
    }


    @Override
    @Override
+28 −11
Original line number Original line Diff line number Diff line
@@ -127,6 +127,7 @@ import android.view.SurfaceControl;
import android.view.WindowManagerPolicy;
import android.view.WindowManagerPolicy;


import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.view.IInputMethodClient;
import com.android.internal.view.IInputMethodClient;
import com.android.server.input.InputWindowHandle;
import com.android.server.input.InputWindowHandle;


@@ -141,6 +142,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.LinkedList;
import java.util.List;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Consumer;
import java.util.function.Function;


/**
/**
 * Utility class for keeping track of the WindowStates and other pertinent contents of a
 * Utility class for keeping track of the WindowStates and other pertinent contents of a
@@ -1407,9 +1409,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    }
    }


    void adjustWallpaperWindows() {
    void adjustWallpaperWindows() {
        if (mWallpaperController.adjustWallpaperWindows(mWindows)) {
        mWallpaperController.adjustWallpaperWindows(this);
            assignWindowLayers(true /*setLayoutNeeded*/);
        }
    }
    }


    /**
    /**
@@ -3235,17 +3235,27 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
        }


        @Override
        @Override
        void forAllWindows(Consumer<WindowState> callback, boolean traverseTopToBottom) {
        boolean forAllWindows(ToBooleanFunction<WindowState> callback,
                boolean traverseTopToBottom) {
            if (traverseTopToBottom) {
            if (traverseTopToBottom) {
                super.forAllWindows(callback, traverseTopToBottom);
                if (super.forAllWindows(callback, traverseTopToBottom)) {
                forAllExitingAppTokenWindows(callback, traverseTopToBottom);
                    return true;
                }
                if (forAllExitingAppTokenWindows(callback, traverseTopToBottom)) {
                    return true;
                }
            } else {
            } else {
                forAllExitingAppTokenWindows(callback, traverseTopToBottom);
                if (forAllExitingAppTokenWindows(callback, traverseTopToBottom)) {
                super.forAllWindows(callback, traverseTopToBottom);
                    return true;
                }
                if (super.forAllWindows(callback, traverseTopToBottom)) {
                    return true;
                }
            }
            }
            return false;
        }
        }


        private void forAllExitingAppTokenWindows(Consumer<WindowState> callback,
        private boolean forAllExitingAppTokenWindows(ToBooleanFunction<WindowState> callback,
                boolean traverseTopToBottom) {
                boolean traverseTopToBottom) {
            // For legacy reasons we process the TaskStack.mExitingAppTokens first here before the
            // For legacy reasons we process the TaskStack.mExitingAppTokens first here before the
            // app tokens.
            // app tokens.
@@ -3255,7 +3265,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                for (int i = mChildren.size() - 1; i >= 0; --i) {
                for (int i = mChildren.size() - 1; i >= 0; --i) {
                    final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens;
                    final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens;
                    for (int j = appTokens.size() - 1; j >= 0; --j) {
                    for (int j = appTokens.size() - 1; j >= 0; --j) {
                        appTokens.get(j).forAllWindowsUnchecked(callback, traverseTopToBottom);
                        if (appTokens.get(j).forAllWindowsUnchecked(callback,
                                traverseTopToBottom)) {
                            return true;
                        }
                    }
                    }
                }
                }
            } else {
            } else {
@@ -3264,11 +3277,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                    final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens;
                    final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens;
                    final int appTokensCount = appTokens.size();
                    final int appTokensCount = appTokens.size();
                    for (int j = 0; j < appTokensCount; j++) {
                    for (int j = 0; j < appTokensCount; j++) {
                        appTokens.get(j).forAllWindowsUnchecked(callback, traverseTopToBottom);
                        if (appTokens.get(j).forAllWindowsUnchecked(callback,
                                traverseTopToBottom)) {
                            return true;
                        }
                        }
                    }
                    }
                }
                }
            }
            }
            return false;
        }


        @Override
        @Override
        int getOrientation() {
        int getOrientation() {
+3 −2
Original line number Original line Diff line number Diff line
@@ -271,8 +271,9 @@ class DragState {
            Slog.d(TAG_WM, "broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")");
            Slog.d(TAG_WM, "broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")");
        }
        }


        mDisplayContent.forAllWindows((w) -> sendDragStartedLw(w, touchX, touchY, mDataDescription),
        mDisplayContent.forAllWindows(w -> {
                false /* traverseTopToBottom */ );
            sendDragStartedLw(w, touchX, touchY, mDataDescription);
        }, false /* traverseTopToBottom */ );
    }
    }


    /* helper - send a ACTION_DRAG_STARTED event, if the
    /* helper - send a ACTION_DRAG_STARTED event, if the
+120 −240

File changed.

Preview size limit exceeded, changes collapsed.

Loading