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

Commit 722f67c6 authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Introduce WindowContextListenerController"

parents a046679e 4efa68ae
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -780,4 +780,25 @@ interface IWindowManager
     *         verified.
     */
    boolean verifyImpressionToken(in ImpressionToken impressionToken);

    /**
     * Registers a listener for a {@link android.app.WindowContext} to handle configuration changes
     * from the server side.
     *
     * @param clientToken the window context's token
     * @param type Window type of the window context
     * @param displayId The display associated with the window context
     * @param options A bundle used to pass window-related options and choose the right DisplayArea
     *
     * @return {@code true} if the listener was registered successfully.
     */
    boolean registerWindowContextListener(IBinder clientToken, int type, int displayId,
            in Bundle options);

    /**
     * Unregisters a listener which registered with {@link #registerWindowContextListener()}.
     *
     * @param clientToken the window context's token
     */
    void unregisterWindowContextListener(IBinder clientToken);
}
+36 −0
Original line number Diff line number Diff line
@@ -85,6 +85,12 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    "-2014162875": {
      "message": "Could not register window container listener token=%s, container=%s",
      "level": "ERROR",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowContextListenerController.java"
    },
    "-2012562539": {
      "message": "startAnimation(): Notify animation start:",
      "level": "DEBUG",
@@ -811,6 +817,12 @@
      "group": "WM_DEBUG_FOCUS",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-1136467585": {
      "message": "The listener does not exist.",
      "level": "INFO",
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/WindowContextListenerController.java"
    },
    "-1136139407": {
      "message": "no-history finish of %s",
      "level": "DEBUG",
@@ -1819,6 +1831,18 @@
      "group": "WM_DEBUG_TASKS",
      "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
    },
    "90764070": {
      "message": "Could not report token removal to the window token client.",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowContextListenerController.java"
    },
    "91350919": {
      "message": "Attempted to set IME flag to a display that does not exist: %d",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "94402792": {
      "message": "Moving to RESUMED: %s (in existing)",
      "level": "VERBOSE",
@@ -1963,6 +1987,12 @@
      "group": "WM_DEBUG_WINDOW_ORGANIZER",
      "at": "com\/android\/server\/wm\/TaskOrganizerController.java"
    },
    "236210101": {
      "message": "registerWindowContextListener: trying to add listener to a non-existing display:%d",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "241961619": {
      "message": "Adding %s to %s",
      "level": "VERBOSE",
@@ -3403,6 +3433,12 @@
      "group": "WM_DEBUG_TASKS",
      "at": "com\/android\/server\/wm\/RootWindowContainer.java"
    },
    "1948483534": {
      "message": "Could not report config changes to the window token client.",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowContextListenerController.java"
    },
    "1964565370": {
      "message": "Starting remote animation",
      "level": "INFO",
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.content.res.Configuration;
 */
public interface ConfigurationContainerListener {

    /** {@see ConfigurationContainer#onRequestedOverrideConfigurationChanged} */
    /** @see ConfigurationContainer#onRequestedOverrideConfigurationChanged */
    default void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) {}

    /** Called when new merged override configuration is reported. */
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static com.android.server.wm.DisplayAreaPolicyBuilder.Feature;
import static com.android.server.wm.DisplayAreaPolicyBuilder.HierarchyBuilder;

import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;

import java.util.ArrayList;
@@ -71,6 +72,10 @@ public abstract class DisplayAreaPolicy {
     */
    public abstract void addWindow(WindowToken token);

    /** Gets the {@link DisplayArea} which a {@link WindowToken} is about to be attached to. */
    public abstract DisplayArea.Tokens getDisplayAreaForWindowToken(int type, Bundle options,
            boolean ownerCanManageAppTokens, boolean roundedCornerOverlay);

    /**
     * Gets the set of {@link DisplayArea} that are created for the given feature to apply to.
     */
+17 −9
Original line number Diff line number Diff line
@@ -137,12 +137,12 @@ class DisplayAreaPolicyBuilder {
    private ArrayList<HierarchyBuilder> mDisplayAreaGroupHierarchyBuilders = new ArrayList<>();

    /**
     * When a window is created, the policy will use this function to select the
     * {@link RootDisplayArea} to place that window in. The selected root can be either the one of
     * the {@link #mRootHierarchyBuilder} or the one of any of the
     * When a window is created, the policy will use this function, which takes window type and
     * options, to select the {@link RootDisplayArea} to place that window in. The selected root
     * can be either the one of the {@link #mRootHierarchyBuilder} or the one of any of the
     * {@link #mDisplayAreaGroupHierarchyBuilders}.
     **/
    @Nullable private BiFunction<WindowToken, Bundle, RootDisplayArea> mSelectRootForWindowFunc;
    @Nullable private BiFunction<Integer, Bundle, RootDisplayArea> mSelectRootForWindowFunc;

    /** Defines the root hierarchy for the whole logical display. */
    DisplayAreaPolicyBuilder setRootHierarchy(HierarchyBuilder rootHierarchyBuilder) {
@@ -162,7 +162,7 @@ class DisplayAreaPolicyBuilder {

    /** The policy will use this function to find the root to place windows in. */
    DisplayAreaPolicyBuilder setSelectRootForWindowFunc(
            BiFunction<WindowToken, Bundle, RootDisplayArea> selectRootForWindowFunc) {
            BiFunction<Integer, Bundle, RootDisplayArea> selectRootForWindowFunc) {
        mSelectRootForWindowFunc = selectRootForWindowFunc;
        return this;
    }
@@ -655,19 +655,19 @@ class DisplayAreaPolicyBuilder {

    static class Result extends DisplayAreaPolicy {
        final List<RootDisplayArea> mDisplayAreaGroupRoots;
        final BiFunction<WindowToken, Bundle, RootDisplayArea> mSelectRootForWindowFunc;
        final BiFunction<Integer, Bundle, RootDisplayArea> mSelectRootForWindowFunc;
        private final TaskDisplayArea mDefaultTaskDisplayArea;

        Result(WindowManagerService wmService, RootDisplayArea root,
                List<RootDisplayArea> displayAreaGroupRoots,
                @Nullable BiFunction<WindowToken, Bundle, RootDisplayArea>
                @Nullable BiFunction<Integer, Bundle, RootDisplayArea>
                        selectRootForWindowFunc) {
            super(wmService, root);
            mDisplayAreaGroupRoots = Collections.unmodifiableList(displayAreaGroupRoots);
            mSelectRootForWindowFunc = selectRootForWindowFunc == null
                    // Always return the highest level root of the logical display when the func is
                    // not specified.
                    ? (window, options) -> mRoot
                    ? (type, options) -> mRoot
                    : selectRootForWindowFunc;

            // Cache the default TaskDisplayArea for quick access.
@@ -689,7 +689,8 @@ class DisplayAreaPolicyBuilder {

        @VisibleForTesting
        DisplayArea.Tokens findAreaForToken(WindowToken token) {
            return mSelectRootForWindowFunc.apply(token, token.mOptions).findAreaForToken(token);
            return mSelectRootForWindowFunc.apply(token.windowType, token.mOptions)
                    .findAreaForToken(token);
        }

        @VisibleForTesting
@@ -727,6 +728,13 @@ class DisplayAreaPolicyBuilder {
        public TaskDisplayArea getDefaultTaskDisplayArea() {
            return mDefaultTaskDisplayArea;
        }

        @Override
        public DisplayArea.Tokens getDisplayAreaForWindowToken(int type, Bundle options,
                boolean ownerCanManageAppTokens, boolean roundedCornerOverlay) {
            return mSelectRootForWindowFunc.apply(type, options).findAreaForToken(type,
                    ownerCanManageAppTokens, roundedCornerOverlay);
        }
    }

    static class PendingArea {
Loading