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

Commit f4ebe2e2 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Removed WallpaperController dependency on WindowList.

WallpaperController now accesses the container hierarchy directly
to determine the state of the wallpaper windows and targets.

Bug: 30060889
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test \
      android.server.cts.ActivityManagerTransitionSelectionTests

Change-Id: Ib70beaf340f257ad4e1093cc127f81e7adf41636
parent 49642fff
Loading
Loading
Loading
Loading
+43 −0
Original line number 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 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 android.os.Debug;
import com.android.internal.util.ToBooleanFunction;
import com.android.server.input.InputApplicationHandle;
import com.android.server.wm.WindowManagerService.H;

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

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

    @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
        // 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
        // in-order.
        if (mIsExiting && !waitingForReplacement()) {
            return;
            return false;
        }
        forAllWindowsUnchecked(callback, traverseTopToBottom);
        return forAllWindowsUnchecked(callback, traverseTopToBottom);
    }

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

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

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

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

/**
 * 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() {
        if (mWallpaperController.adjustWallpaperWindows(mWindows)) {
            assignWindowLayers(true /*setLayoutNeeded*/);
        }
        mWallpaperController.adjustWallpaperWindows(this);
    }

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

        @Override
        void forAllWindows(Consumer<WindowState> callback, boolean traverseTopToBottom) {
        boolean forAllWindows(ToBooleanFunction<WindowState> callback,
                boolean traverseTopToBottom) {
            if (traverseTopToBottom) {
                super.forAllWindows(callback, traverseTopToBottom);
                forAllExitingAppTokenWindows(callback, traverseTopToBottom);
                if (super.forAllWindows(callback, traverseTopToBottom)) {
                    return true;
                }
                if (forAllExitingAppTokenWindows(callback, traverseTopToBottom)) {
                    return true;
                }
            } else {
                forAllExitingAppTokenWindows(callback, traverseTopToBottom);
                super.forAllWindows(callback, traverseTopToBottom);
                if (forAllExitingAppTokenWindows(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) {
            // For legacy reasons we process the TaskStack.mExitingAppTokens first here before the
            // app tokens.
@@ -3255,7 +3265,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                for (int i = mChildren.size() - 1; i >= 0; --i) {
                    final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens;
                    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 {
@@ -3264,11 +3277,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                    final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens;
                    final int appTokensCount = appTokens.size();
                    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
        int getOrientation() {
+3 −2
Original line number Diff line number Diff line
@@ -271,8 +271,9 @@ class DragState {
            Slog.d(TAG_WM, "broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")");
        }

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

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

File changed.

Preview size limit exceeded, changes collapsed.

Loading