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

Commit 659a8bc0 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Move IWindowContainer to WindowContainer"

parents 61421099 a80f11c2
Loading
Loading
Loading
Loading
+8 −11
Original line number Original line Diff line number Diff line
@@ -3303,7 +3303,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
        }
    }
    }


    private int sanitizeAndApplyChange(ConfigurationContainer container,
    private int sanitizeAndApplyChange(WindowContainer container,
            WindowContainerTransaction.Change change) {
            WindowContainerTransaction.Change change) {
        if (!(container instanceof Task || container instanceof ActivityStack)) {
        if (!(container instanceof Task || container instanceof ActivityStack)) {
            throw new RuntimeException("Invalid token in task transaction");
            throw new RuntimeException("Invalid token in task transaction");
@@ -3347,13 +3347,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }
        }
    }
    }


    private int applyWindowContainerChange(ConfigurationContainer cc,
    private int applyWindowContainerChange(WindowContainer wc,
            WindowContainerTransaction.Change c) {
            WindowContainerTransaction.Change c) {
        int effects = sanitizeAndApplyChange(cc, c);
        int effects = sanitizeAndApplyChange(wc, c);


        Rect enterPipBounds = c.getEnterPipBounds();
        Rect enterPipBounds = c.getEnterPipBounds();
        if (enterPipBounds != null) {
        if (enterPipBounds != null) {
            Task tr = (Task) cc;
            Task tr = (Task) wc;
            mStackSupervisor.updatePictureInPictureMode(tr,
            mStackSupervisor.updatePictureInPictureMode(tr,
                    enterPipBounds, true);
                    enterPipBounds, true);
        }
        }
@@ -3378,17 +3378,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    while (entries.hasNext()) {
                    while (entries.hasNext()) {
                        final Map.Entry<IBinder, WindowContainerTransaction.Change> entry =
                        final Map.Entry<IBinder, WindowContainerTransaction.Change> entry =
                                entries.next();
                                entries.next();
                        final ConfigurationContainer cc =
                        final WindowContainer wc = WindowContainer.RemoteToken.fromBinder(
                                ConfigurationContainer.RemoteToken.fromBinder(
                                entry.getKey()).getContainer();
                                entry.getKey()).getContainer();
                        int containerEffect = applyWindowContainerChange(cc, entry.getValue());
                        int containerEffect = applyWindowContainerChange(wc, entry.getValue());
                        effects |= containerEffect;
                        effects |= containerEffect;
                        // Lifecycle changes will trigger ensureConfig for everything.
                        // Lifecycle changes will trigger ensureConfig for everything.
                        if ((effects & TRANSACT_EFFECTS_LIFECYCLE) == 0
                        if ((effects & TRANSACT_EFFECTS_LIFECYCLE) == 0
                                && (containerEffect & TRANSACT_EFFECTS_CLIENT_CONFIG) != 0) {
                                && (containerEffect & TRANSACT_EFFECTS_CLIENT_CONFIG) != 0) {
                            if (cc instanceof WindowContainer) {
                            haveConfigChanges.add(wc);
                                haveConfigChanges.add((WindowContainer) cc);
                            }
                        }
                        }
                    }
                    }
                    if ((effects & TRANSACT_EFFECTS_LIFECYCLE) != 0) {
                    if ((effects & TRANSACT_EFFECTS_LIFECYCLE) != 0) {
+0 −61
Original line number Original line Diff line number Diff line
@@ -39,15 +39,11 @@ import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.IBinder;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.IWindowContainer;
import android.view.SurfaceControl;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.ArrayList;


/**
/**
@@ -103,12 +99,6 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
    // Return value from {@link setBounds} indicating the size of the override bounds changed.
    // Return value from {@link setBounds} indicating the size of the override bounds changed.
    static final int BOUNDS_CHANGE_SIZE = 1 << 1;
    static final int BOUNDS_CHANGE_SIZE = 1 << 1;


    /**
     * Used as a unique, cross-process identifier for this Container. It also serves a minimal
     * interface to other processes.
     */
    RemoteToken mRemoteToken = null;

    /**
    /**
     * Returns full configuration applied to this configuration container.
     * Returns full configuration applied to this configuration container.
     * This method should be used for getting settings applied in each particular level of the
     * This method should be used for getting settings applied in each particular level of the
@@ -629,21 +619,6 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
        return mFullConfiguration.windowConfiguration.isAlwaysOnTop();
        return mFullConfiguration.windowConfiguration.isAlwaysOnTop();
    }
    }


    /**
     * Returns {@code true} if this container is focusable. Generally, if a parent is not focusable,
     * this will not be focusable either.
     */
    boolean isFocusable() {
        // TODO(split): Move this to WindowContainer once Split-screen is based on a WindowContainer
        //              like DisplayArea vs. TaskTiles.
        ConfigurationContainer parent = getParent();
        return parent == null || parent.isFocusable();
    }

    boolean setFocusable(boolean focusable) {
        return false;
    }

    boolean hasChild() {
    boolean hasChild() {
        return getChildCount() > 0;
        return getChildCount() > 0;
    }
    }
@@ -654,40 +629,4 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {


    abstract protected ConfigurationContainer getParent();
    abstract protected ConfigurationContainer getParent();


    // TODO: Consider moving to WindowContainer once hierarchies and Task/Stack are merged.
    static class RemoteToken extends IWindowContainer.Stub {
        final WeakReference<ConfigurationContainer> mWeakRef;

        RemoteToken(ConfigurationContainer container) {
            mWeakRef = new WeakReference<>(container);
        }

        ConfigurationContainer getContainer() {
            return mWeakRef.get();
        }

        static RemoteToken fromBinder(IBinder binder) {
            return (RemoteToken) binder;
        }

        @Override
        public SurfaceControl getLeash() {
            throw new RuntimeException("Not implemented");
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder(128);
            sb.append("RemoteToken{");
            sb.append(Integer.toHexString(System.identityHashCode(this)));
            sb.append(' ');
            sb.append(mWeakRef.get());
            sb.append('}');
            return sb.toString();
        }
    }

    RemoteToken getRemoteToken() {
        return mRemoteToken;
    }
}
}
+1 −2
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.server.wm;
package com.android.server.wm;


import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.ActivityTaskManager.RESIZE_MODE_FORCED;
import static android.app.ActivityTaskManager.RESIZE_MODE_FORCED;
import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM;
import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM;
@@ -496,7 +495,7 @@ class Task extends WindowContainer<WindowContainer> {
    }
    }


    class TaskToken extends RemoteToken {
    class TaskToken extends RemoteToken {
        TaskToken(ConfigurationContainer container) {
        TaskToken(WindowContainer container) {
            super(container);
            super(container);
        }
        }


+50 −3
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ import android.util.Pools;
import android.util.Slog;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.DisplayInfo;
import android.view.DisplayInfo;
import android.view.IWindowContainer;
import android.view.MagnificationSpec;
import android.view.MagnificationSpec;
import android.view.RemoteAnimationTarget;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
@@ -75,6 +76,7 @@ import com.android.server.protolog.common.ProtoLog;
import com.android.server.wm.SurfaceAnimator.Animatable;
import com.android.server.wm.SurfaceAnimator.Animatable;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.LinkedList;
@@ -249,6 +251,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<


    private boolean mIsFocusable = true;
    private boolean mIsFocusable = true;


    /**
     * Used as a unique, cross-process identifier for this Container. It also serves a minimal
     * interface to other processes.
     */
    RemoteToken mRemoteToken = null;

    WindowContainer(WindowManagerService wms) {
    WindowContainer(WindowManagerService wms) {
        mWmService = wms;
        mWmService = wms;
        mPendingTransaction = wms.mTransactionFactory.get();
        mPendingTransaction = wms.mTransactionFactory.get();
@@ -860,13 +868,16 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return false;
        return false;
    }
    }


    @Override
    /**
     * Returns {@code true} if this container is focusable. Generally, if a parent is not focusable,
     * this will not be focusable either.
     */
    boolean isFocusable() {
    boolean isFocusable() {
        return super.isFocusable() && mIsFocusable;
        final WindowContainer parent = getParent();
        return (parent == null || parent.isFocusable()) && mIsFocusable;
    }
    }


    /** Set whether this container or its children can be focusable */
    /** Set whether this container or its children can be focusable */
    @Override
    boolean setFocusable(boolean focusable) {
    boolean setFocusable(boolean focusable) {
        if (mIsFocusable == focusable) {
        if (mIsFocusable == focusable) {
            return false;
            return false;
@@ -2259,4 +2270,40 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
    ActivityRecord asActivityRecord() {
    ActivityRecord asActivityRecord() {
        return null;
        return null;
    }
    }

    RemoteToken getRemoteToken() {
        return mRemoteToken;
    }

    static class RemoteToken extends IWindowContainer.Stub {
        final WeakReference<WindowContainer> mWeakRef;

        RemoteToken(WindowContainer container) {
            mWeakRef = new WeakReference<>(container);
        }

        WindowContainer getContainer() {
            return mWeakRef.get();
        }

        static RemoteToken fromBinder(IBinder binder) {
            return (RemoteToken) binder;
        }

        @Override
        public SurfaceControl getLeash() {
            throw new RuntimeException("Not implemented");
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder(128);
            sb.append("RemoteToken{");
            sb.append(Integer.toHexString(System.identityHashCode(this)));
            sb.append(' ');
            sb.append(mWeakRef.get());
            sb.append('}');
            return sb.toString();
        }
    }
}
}