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

Commit 81e56d53 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Rework how we decide whether to use system or status bar.

The PhoneWindowManager is now responsible for determing this,
since it needs to do this before we can generate the configuration
since we need to take into account the system bar size we will use.

Also the Display should now report the screen height without
including the system bar.

Change-Id: I82dfcc5e327e4d13d82c373c6c870f557a99b757
parent 42f8094c
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -425,9 +425,6 @@ class ContextImpl extends Context {

        registerService(WINDOW_SERVICE, new ServiceFetcher() {
                public Object getService(ContextImpl ctx) {
                    RuntimeException e = new RuntimeException("foo");
                    e.fillInStackTrace();
                    Log.i(TAG, "Getting window manager", e);
                    CompatibilityInfo ci = ctx.mResources.getCompatibilityInfo();
                    return WindowManagerImpl.getDefault(ci);
                }});
+4 −4
Original line number Diff line number Diff line
@@ -392,8 +392,8 @@ public class CompatibilityInfo implements Parcelable {
            // compatible with large screens, so diddle it.
            CompatibilityInfo.updateCompatibleScreenFrame(inoutDm, null, inoutDm);
        } else {
            inoutDm.widthPixels = inoutDm.realWidthPixels;
            inoutDm.heightPixels = inoutDm.realHeightPixels;
            inoutDm.widthPixels = inoutDm.unscaledWidthPixels;
            inoutDm.heightPixels = inoutDm.unscaledHeightPixels;
        }

        if (isScalingRequired()) {
@@ -429,8 +429,8 @@ public class CompatibilityInfo implements Parcelable {
     */
    public static float updateCompatibleScreenFrame(DisplayMetrics dm,
            Rect outRect, DisplayMetrics outDm) {
        final int width = dm.realWidthPixels;
        final int height = dm.realHeightPixels;
        final int width = dm.unscaledWidthPixels;
        final int height = dm.unscaledHeightPixels;
        int shortSize, longSize;
        if (width < height) {
            shortSize = width;
+16 −8
Original line number Diff line number Diff line
@@ -105,10 +105,18 @@ public class DisplayMetrics {
     */
    public float ydpi;

    /** @hide */
    public int realWidthPixels;
    /** @hide */
    public int realHeightPixels;
    /**
     * The reported display width prior to any compatibility mode scaling
     * being applied.
     * @hide
     */
    public int unscaledWidthPixels;
    /**
     * The reported display height prior to any compatibility mode scaling
     * being applied.
     * @hide
     */
    public int unscaledHeightPixels;

    public DisplayMetrics() {
    }
@@ -121,8 +129,8 @@ public class DisplayMetrics {
        scaledDensity = o.scaledDensity;
        xdpi = o.xdpi;
        ydpi = o.ydpi;
        realWidthPixels = o.realWidthPixels;
        realHeightPixels = o.realHeightPixels;
        unscaledWidthPixels = o.unscaledWidthPixels;
        unscaledHeightPixels = o.unscaledHeightPixels;
    }
    
    public void setToDefaults() {
@@ -133,8 +141,8 @@ public class DisplayMetrics {
        scaledDensity = density;
        xdpi = DENSITY_DEVICE;
        ydpi = DENSITY_DEVICE;
        realWidthPixels = 0;
        realHeightPixels = 0;
        unscaledWidthPixels = 0;
        unscaledHeightPixels = 0;
    }

    @Override
+28 −16
Original line number Diff line number Diff line
@@ -80,25 +80,37 @@ public class Display {
     * adjusted for you based on the current rotation of the display.
     */
    public void getSize(Point outSize) {
        getSizeInternal(outSize, true);
    }

    /**
     * Returns the raw size of the display, in pixels.  Note that this
     * should <em>not</em> generally be used for computing layouts, since
     * a device will typically have screen decoration (such as a status bar)
     * along the edges of the display that reduce the amount of application
     * space available from the raw size returned here.  This value is
     * adjusted for you based on the current rotation of the display.
     */
    private void getSizeInternal(Point outSize, boolean doCompat) {
        try {
            IWindowManager wm = getWindowManager();
            if (wm != null) {
                wm.getDisplaySize(outSize);
            } else {
                // This is just for boot-strapping, initializing the
                // system process before the window manager is up.
                outSize.y = getRealHeight();
            }
            if (mCompatibilityInfo != null) {
                if (doCompat && mCompatibilityInfo != null) {
                    synchronized (mTmpMetrics) {
                    mTmpMetrics.realWidthPixels = outSize.x;
                    mTmpMetrics.realHeightPixels = outSize.y;
                        mTmpMetrics.unscaledWidthPixels = outSize.x;
                        mTmpMetrics.unscaledHeightPixels = outSize.y;
                        mTmpMetrics.density = mDensity;
                        mCompatibilityInfo.applyToDisplayMetrics(mTmpMetrics);
                        outSize.x = mTmpMetrics.widthPixels;
                        outSize.y = mTmpMetrics.heightPixels;
                    }
                }
            } else {
                // This is just for boot-strapping, initializing the
                // system process before the window manager is up.
                outSize.y = getRealHeight();
            }
        } catch (RemoteException e) {
            Slog.w("Display", "Unable to get display size", e);
        }
@@ -109,7 +121,7 @@ public class Display {
     */
    public void getRectSize(Rect outSize) {
        synchronized (mTmpPoint) {
            getSize(mTmpPoint);
            getSizeInternal(mTmpPoint, true);
            outSize.set(0, 0, mTmpPoint.x, mTmpPoint.y);
        }
    }
@@ -137,7 +149,7 @@ public class Display {
        synchronized (mTmpPoint) {
            long now = SystemClock.uptimeMillis();
            if (now > (mLastGetTime+20)) {
                getSize(mTmpPoint);
                getSizeInternal(mTmpPoint, true);
                mLastGetTime = now;
            }
            return mTmpPoint.x;
@@ -152,7 +164,7 @@ public class Display {
        synchronized (mTmpPoint) {
            long now = SystemClock.uptimeMillis();
            if (now > (mLastGetTime+20)) {
                getSize(mTmpPoint);
                getSizeInternal(mTmpPoint, true);
                mLastGetTime = now;
            }
            return mTmpPoint.y;
@@ -218,7 +230,7 @@ public class Display {
     */
    public void getMetrics(DisplayMetrics outMetrics) {
        synchronized (mTmpPoint) {
            getSize(mTmpPoint);
            getSizeInternal(mTmpPoint, false);
            outMetrics.widthPixels = mTmpPoint.x;
            outMetrics.heightPixels = mTmpPoint.y;
        }
@@ -248,8 +260,8 @@ public class Display {
        outMetrics.xdpi         = mDpiX;
        outMetrics.ydpi         = mDpiY;

        outMetrics.realWidthPixels  = outMetrics.widthPixels;
        outMetrics.realHeightPixels = outMetrics.heightPixels;
        outMetrics.unscaledWidthPixels  = outMetrics.widthPixels;
        outMetrics.unscaledHeightPixels = outMetrics.heightPixels;
    }

    static IWindowManager getWindowManager() {
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,9 @@ interface IWindowManager
    void setForcedDisplaySize(int longDimen, int shortDimen);
    void clearForcedDisplaySize();

    // Is device configured with a hideable status bar or a tablet system bar?
    boolean canStatusBarHide();

    // These can only be called when injecting events to your own window,
    // or by holding the INJECT_EVENTS permission.  These methods may block
    // until pending input events are finished being dispatched even when 'sync' is false.
Loading