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

Commit 919d1d28 authored by Jerry Chang's avatar Jerry Chang
Browse files

Migrate wm package in sysui to WM shell lib (1/n)

Bug: 161655636
Test: atest WindowManagerShellTests
Test: atest SystemUITests
Change-Id: I42f13ee7fbb14ba3b7f33ed5654ec72454dc6dba
parent 82658d6c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.systemui.wm;
package com.android.wm.shell.common;

import android.os.Handler;
import android.os.RemoteException;
+5 −11
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.systemui.wm;
package com.android.wm.shell.common;

import android.annotation.Nullable;
import android.content.Context;
@@ -28,21 +28,16 @@ import android.view.Display;
import android.view.IDisplayWindowListener;
import android.view.IWindowManager;

import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.wm.DisplayChangeController.OnDisplayChangingListener;
import com.android.wm.shell.common.DisplayChangeController.OnDisplayChangingListener;

import java.util.ArrayList;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * This module deals with display rotations coming from WM. When WM starts a rotation: after it has
 * frozen the screen, it will call into this class. This will then call all registered local
 * controllers and give them a chance to queue up task changes to be applied synchronously with that
 * rotation.
 */
@Singleton
public class DisplayController {
    private static final String TAG = "DisplayController";

@@ -55,7 +50,7 @@ public class DisplayController {
    private final ArrayList<OnDisplaysChangedListener> mDisplayChangedListeners = new ArrayList<>();

    /**
     * Get's a display by id from DisplayManager.
     * Gets a display by id from DisplayManager.
     */
    public Display getDisplay(int displayId) {
        final DisplayManager displayManager = mContext.getSystemService(DisplayManager.class);
@@ -169,10 +164,9 @@ public class DisplayController {
                }
            };

    @Inject
    public DisplayController(Context context, @Main Handler mainHandler,
    public DisplayController(Context context, Handler handler,
            IWindowManager wmService) {
        mHandler = mainHandler;
        mHandler = handler;
        mContext = context;
        mWmService = wmService;
        mChangeController = new DisplayChangeController(mHandler, mWmService);
+21 −23
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.systemui.wm;
package com.android.wm.shell.common;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -40,18 +40,12 @@ import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;

import com.android.internal.view.IInputMethodManager;
import com.android.systemui.TransactionPool;
import com.android.systemui.dagger.qualifiers.Main;

import java.util.ArrayList;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * Manages IME control at the display-level. This occurs when IME comes up in multi-window mode.
 */
@Singleton
public class DisplayImeController implements DisplayController.OnDisplaysChangedListener {
    private static final String TAG = "DisplayImeController";

@@ -66,18 +60,17 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
    private static final int DIRECTION_HIDE = 2;
    private static final int FLOATING_IME_BOTTOM_INSET = -80;

    SystemWindows mSystemWindows;
    final Handler mHandler;
    protected final SystemWindows mSystemWindows;
    protected final Handler mHandler;
    final TransactionPool mTransactionPool;

    final SparseArray<PerDisplay> mImePerDisplay = new SparseArray<>();

    final ArrayList<ImePositionProcessor> mPositionProcessors = new ArrayList<>();

    @Inject
    public DisplayImeController(SystemWindows syswin, DisplayController displayController,
            @Main Handler mainHandler, TransactionPool transactionPool) {
        mHandler = mainHandler;
            Handler handler, TransactionPool transactionPool) {
        mHandler = handler;
        mSystemWindows = syswin;
        mTransactionPool = transactionPool;
        displayController.addDisplayWindowListener(this);
@@ -305,8 +298,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                // pretend the ime has some size just below the screen.
                mImeFrame.set(newFrame);
                final int floatingInset = (int) (
                        mSystemWindows.mDisplayController.getDisplayLayout(mDisplayId).density()
                                * FLOATING_IME_BOTTOM_INSET);
                        mSystemWindows.mDisplayController.getDisplayLayout(mDisplayId)
                        .density() * FLOATING_IME_BOTTOM_INSET);
                mImeFrame.bottom -= floatingInset;
            } else if (newFrame.height() != 0) {
                // Don't set a new frame if it's empty and hiding -- this maintains continuity
@@ -364,6 +357,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            mAnimation.setInterpolator(INTERPOLATOR);
            mAnimation.addListener(new AnimatorListenerAdapter() {
                private boolean mCancelled = false;

                @Override
                public void onAnimationStart(Animator animation) {
                    SurfaceControl.Transaction t = mTransactionPool.acquire();
@@ -386,10 +380,12 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                    t.apply();
                    mTransactionPool.release(t);
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    mCancelled = true;
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    if (DEBUG) Slog.d(TAG, "onAnimationEnd " + mCancelled);
@@ -452,7 +448,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
        @IntDef(prefix = {"IME_ANIMATION_"}, value = {
                IME_ANIMATION_NO_ALPHA,
        })
        @interface ImeAnimationFlags {}
        @interface ImeAnimationFlags {
        }

        /**
         * Called when the IME position is starting to animate.
@@ -476,8 +473,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
         *
         * @param imeTop The current y position of the top of the IME surface.
         */
        default void onImePositionChanged(int displayId, int imeTop,
                SurfaceControl.Transaction t) {}
        default void onImePositionChanged(int displayId, int imeTop, SurfaceControl.Transaction t) {
        }

        /**
         * Called when the IME position is done animating.
@@ -485,7 +482,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
         * @param cancel {@code true} if this was cancelled. This implies another start is coming.
         */
        default void onImeEndPositioning(int displayId, boolean cancel,
                SurfaceControl.Transaction t) {}
                SurfaceControl.Transaction t) {
        }
    }

    public IInputMethodManager getImms() {
+5 −5
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.systemui.wm;
package com.android.wm.shell.common;

import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
@@ -52,7 +52,7 @@ import java.lang.annotation.RetentionPolicy;

/**
 * Contains information about the layout-properties of a display. This refers to internal layout
 * like insets/cutout/rotation. In general, this can be thought of as the System-UI analog to
 * like insets/cutout/rotation. In general, this can be thought of as the shell analog to
 * DisplayPolicy.
 */
public class DisplayLayout {
+6 −11
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.systemui.wm;
package com.android.wm.shell.common;

import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;

@@ -52,23 +52,19 @@ import com.android.internal.os.IResultReceiver;

import java.util.HashMap;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * Represents the "windowing" layer of the System-UI. This layer allows system-ui components to
 * place and manipulate windows without talking to WindowManager.
 * Represents the "windowing" layer of the WM Shell. This layer allows shell components to place and
 * manipulate windows without talking to WindowManager.
 */
@Singleton
public class SystemWindows {
    private static final String TAG = "SystemWindows";

    private final SparseArray<PerDisplay> mPerDisplay = new SparseArray<>();
    final HashMap<View, SurfaceControlViewHost> mViewRoots = new HashMap<>();
    Context mContext;
    public Context mContext;
    public IWindowManager mWmService;
    IWindowSession mSession;
    DisplayController mDisplayController;
    IWindowManager mWmService;

    private final DisplayController.OnDisplaysChangedListener mDisplayListener =
            new DisplayController.OnDisplaysChangedListener() {
@@ -88,7 +84,6 @@ public class SystemWindows {
                public void onDisplayRemoved(int displayId) { }
            };

    @Inject
    public SystemWindows(Context context, DisplayController displayController,
            IWindowManager wmService) {
        mContext = context;
@@ -172,7 +167,7 @@ public class SystemWindows {
    /**
     * Get the IWindow token for a specific root.
     *
     * @param windowType A window type from {@link android.view.WindowManager}.
     * @param windowType A window type from {@link WindowManager}.
     */
    IWindow getWindow(int displayId, int windowType) {
        PerDisplay pd = mPerDisplay.get(displayId);
Loading