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

Commit 98a033d8 authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Add topology listener in WM shell"

This reverts commit c89f041d.

Reason for revert: Droidmonitor created revert due to b/385345961. Will be verifying through ABTD before submission.

Change-Id: I40f35ea1e29db3a39bd821dad309fa1de15a32b4
parent c89f041d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
    <uses-permission android:name="android.permission.SUBSCRIBE_TO_KEYGUARD_LOCKED_STATE" />
    <uses-permission android:name="android.permission.UPDATE_DOMAIN_VERIFICATION_USER_SELECTION" />
    <uses-permission android:name="android.permission.MANAGE_KEY_GESTURES" />
    <uses-permission android:name="android.permission.MANAGE_DISPLAYS" />

    <application>
        <activity
+4 −22
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayTopology;
import android.os.RemoteException;
import android.util.ArraySet;
import android.util.Size;
@@ -55,7 +54,6 @@ public class DisplayController {
    private final ShellExecutor mMainExecutor;
    private final Context mContext;
    private final IWindowManager mWmService;
    private final DisplayManager mDisplayManager;
    private final DisplayChangeController mChangeController;
    private final IDisplayWindowListener mDisplayContainerListener;

@@ -63,11 +61,10 @@ public class DisplayController {
    private final ArrayList<OnDisplaysChangedListener> mDisplayChangedListeners = new ArrayList<>();

    public DisplayController(Context context, IWindowManager wmService, ShellInit shellInit,
            ShellExecutor mainExecutor, DisplayManager displayManager) {
            ShellExecutor mainExecutor) {
        mMainExecutor = mainExecutor;
        mContext = context;
        mWmService = wmService;
        mDisplayManager = displayManager;
        // TODO: Inject this instead
        mChangeController = new DisplayChangeController(mWmService, shellInit, mainExecutor);
        mDisplayContainerListener = new DisplayWindowListenerImpl();
@@ -77,7 +74,7 @@ public class DisplayController {
    }

    /**
     * Initializes the window listener and the topology listener.
     * Initializes the window listener.
     */
    public void onInit() {
        try {
@@ -85,9 +82,6 @@ public class DisplayController {
            for (int i = 0; i < displayIds.length; i++) {
                onDisplayAdded(displayIds[i]);
            }

            mDisplayManager.registerTopologyListener(mMainExecutor, this::onDisplayTopologyChanged);
            onDisplayTopologyChanged(mDisplayManager.getDisplayTopology());
        } catch (RemoteException e) {
            throw new RuntimeException("Unable to register display controller");
        }
@@ -97,7 +91,8 @@ public class DisplayController {
     * Gets a display by id from DisplayManager.
     */
    public Display getDisplay(int displayId) {
        return mDisplayManager.getDisplay(displayId);
        final DisplayManager displayManager = mContext.getSystemService(DisplayManager.class);
        return displayManager.getDisplay(displayId);
    }

    /**
@@ -226,14 +221,6 @@ public class DisplayController {
        }
    }

    private void onDisplayTopologyChanged(DisplayTopology topology) {
        // TODO(b/381472611): Call DisplayTopology#getCoordinates and update values in
        //                    DisplayLayout when DM code is ready.
        for (int i = 0; i < mDisplayChangedListeners.size(); ++i) {
            mDisplayChangedListeners.get(i).onTopologyChanged();
        }
    }

    private void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
        synchronized (mDisplays) {
            final DisplayRecord dr = mDisplays.get(displayId);
@@ -421,10 +408,5 @@ public class DisplayController {
         */
        default void onKeepClearAreasChanged(int displayId, Set<Rect> restricted,
                Set<Rect> unrestricted) {}

        /**
         * Called when the display topology has changed.
         */
        default void onTopologyChanged() {}
    }
}
+4 −66
Original line number Diff line number Diff line
@@ -31,9 +31,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Insets;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.DisplayMetrics;
@@ -73,12 +71,9 @@ public class DisplayLayout {
    public static final int NAV_BAR_RIGHT = 1 << 1;
    public static final int NAV_BAR_BOTTOM = 1 << 2;

    private static final String TAG = "DisplayLayout";

    private int mUiMode;
    private int mWidth;
    private int mHeight;
    private RectF mGlobalBoundsDp;
    private DisplayCutout mCutout;
    private int mRotation;
    private int mDensityDpi;
@@ -114,7 +109,6 @@ public class DisplayLayout {
        return mUiMode == other.mUiMode
                && mWidth == other.mWidth
                && mHeight == other.mHeight
                && Objects.equals(mGlobalBoundsDp, other.mGlobalBoundsDp)
                && Objects.equals(mCutout, other.mCutout)
                && mRotation == other.mRotation
                && mDensityDpi == other.mDensityDpi
@@ -133,8 +127,8 @@ public class DisplayLayout {

    @Override
    public int hashCode() {
        return Objects.hash(mUiMode, mWidth, mHeight, mGlobalBoundsDp, mCutout, mRotation,
                mDensityDpi, mNonDecorInsets, mStableInsets, mHasNavigationBar, mHasStatusBar,
        return Objects.hash(mUiMode, mWidth, mHeight, mCutout, mRotation, mDensityDpi,
                mNonDecorInsets, mStableInsets, mHasNavigationBar, mHasStatusBar,
                mNavBarFrameHeight, mTaskbarFrameHeight, mAllowSeamlessRotationDespiteNavBarMoving,
                mNavigationBarCanMove, mReverseDefaultRotation, mInsetsState);
    }
@@ -176,7 +170,6 @@ public class DisplayLayout {
        mUiMode = dl.mUiMode;
        mWidth = dl.mWidth;
        mHeight = dl.mHeight;
        mGlobalBoundsDp = dl.mGlobalBoundsDp;
        mCutout = dl.mCutout;
        mRotation = dl.mRotation;
        mDensityDpi = dl.mDensityDpi;
@@ -200,7 +193,6 @@ public class DisplayLayout {
        mRotation = info.rotation;
        mCutout = info.displayCutout;
        mDensityDpi = info.logicalDensityDpi;
        mGlobalBoundsDp = new RectF(0, 0, pxToDp(mWidth), pxToDp(mHeight));
        mHasNavigationBar = hasNavigationBar;
        mHasStatusBar = hasStatusBar;
        mAllowSeamlessRotationDespiteNavBarMoving = res.getBoolean(
@@ -263,11 +255,6 @@ public class DisplayLayout {
        recalcInsets(res);
    }

    /** Update the global bounds of this layout, in DP. */
    public void setGlobalBoundsDp(RectF bounds) {
        mGlobalBoundsDp = bounds;
    }

    /** Get this layout's non-decor insets. */
    public Rect nonDecorInsets() {
        return mNonDecorInsets;
@@ -278,21 +265,16 @@ public class DisplayLayout {
        return mStableInsets;
    }

    /** Get this layout's width in pixels. */
    /** Get this layout's width. */
    public int width() {
        return mWidth;
    }

    /** Get this layout's height in pixels. */
    /** Get this layout's height. */
    public int height() {
        return mHeight;
    }

    /** Get this layout's global bounds in the multi-display coordinate system in DP. */
    public RectF globalBoundsDp() {
        return mGlobalBoundsDp;
    }

    /** Get this layout's display rotation. */
    public int rotation() {
        return mRotation;
@@ -504,48 +486,4 @@ public class DisplayLayout {
                ? R.dimen.navigation_bar_frame_height_landscape
                : R.dimen.navigation_bar_frame_height);
    }

    /**
     * Converts a pixel value to a density-independent pixel (dp) value.
     *
     * @param px The pixel value to convert.
     * @return The equivalent value in DP units.
     */
    public float pxToDp(Number px) {
        return px.floatValue() * DisplayMetrics.DENSITY_DEFAULT / mDensityDpi;
    }

    /**
     * Converts a density-independent pixel (dp) value to a pixel value.
     *
     * @param dp The DP value to convert.
     * @return The equivalent value in pixel units.
     */
    public float dpToPx(Number dp) {
        return dp.floatValue() * mDensityDpi / DisplayMetrics.DENSITY_DEFAULT;
    }

    /**
     * Converts local pixel coordinates on this layout to global DP coordinates.
     *
     * @param xPx The x-coordinate in pixels, relative to the layout's origin.
     * @param yPx The y-coordinate in pixels, relative to the layout's origin.
     * @return A PointF object representing the coordinates in global DP units.
     */
    public PointF localPxToGlobalDp(Number xPx, Number yPx) {
        return new PointF(mGlobalBoundsDp.left + pxToDp(xPx),
                mGlobalBoundsDp.top + pxToDp(yPx));
    }

    /**
     * Converts global DP coordinates to local pixel coordinates on this layout.
     *
     * @param xDp The x-coordinate in global DP units.
     * @param yDp The y-coordinate in global DP units.
     * @return A PointF object representing the coordinates in local pixel units on this layout.
     */
    public PointF globalDpToLocalPx(Number xDp, Number yDp) {
        return new PointF(dpToPx(xDp.floatValue() - mGlobalBoundsDp.left),
                dpToPx(yDp.floatValue() - mGlobalBoundsDp.top));
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.annotation.NonNull;
import android.app.ActivityTaskManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.SystemProperties;
import android.provider.Settings;
@@ -173,9 +172,8 @@ public abstract class WMShellBaseModule {
    static DisplayController provideDisplayController(Context context,
            IWindowManager wmService,
            ShellInit shellInit,
            @ShellMainThread ShellExecutor mainExecutor,
            DisplayManager displayManager) {
        return new DisplayController(context, wmService, shellInit, mainExecutor, displayManager);
            @ShellMainThread ShellExecutor mainExecutor) {
        return new DisplayController(context, wmService, shellInit, mainExecutor);
    }

    @WMSingleton
+1 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.content.Context;
import android.hardware.display.DisplayManager;
import android.view.IWindowManager;

import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -51,14 +50,12 @@ public class DisplayControllerTests extends ShellTestCase {
    private @Mock IWindowManager mWM;
    private @Mock ShellInit mShellInit;
    private @Mock ShellExecutor mMainExecutor;
    private @Mock DisplayManager mDisplayManager;
    private DisplayController mController;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mController = new DisplayController(
                mContext, mWM, mShellInit, mMainExecutor, mDisplayManager);
        mController = new DisplayController(mContext, mWM, mShellInit, mMainExecutor);
    }

    @Test
Loading