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

Commit eedcbf15 authored by Michael Wright's avatar Michael Wright
Browse files

Add new system API for stable display size

Fixes: 34388294
Test: manual
Change-Id: Ie380230bbd82370f507161b4cdb6f0d100b09f11
parent 87ad0f7f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16561,6 +16561,7 @@ package android.hardware.display {
    method public android.view.Display getDisplay(int);
    method public android.view.Display[] getDisplays();
    method public android.view.Display[] getDisplays(java.lang.String);
    method public android.graphics.Point getStableDisplaySize();
    method public void registerDisplayListener(android.hardware.display.DisplayManager.DisplayListener, android.os.Handler);
    method public void unregisterDisplayListener(android.hardware.display.DisplayManager.DisplayListener);
    field public static final java.lang.String DISPLAY_CATEGORY_PRESENTATION = "android.hardware.display.category.PRESENTATION";
+16 −0
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ package android.hardware.display;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.graphics.Point;
import android.media.projection.MediaProjection;
import android.os.Handler;
import android.util.SparseArray;
@@ -585,6 +587,20 @@ public final class DisplayManager {
                name, width, height, densityDpi, surface, flags, callback, handler, uniqueId);
    }

    /**
     * Gets the stable device display size, in pixels.
     *
     * This should really only be used for things like server-side filtering of available
     * applications. Most applications don't need the level of stability guaranteed by this and
     * should instead query either the size of the display they're currently running on or the
     * size of the default display.
     * @hide
     */
    @SystemApi
    public Point getStableDisplaySize() {
        return mGlobal.getStableDisplaySize();
    }

    /**
     * Listens for changes in available display devices.
     */
+12 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.hardware.display;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.hardware.display.DisplayManager.DisplayListener;
import android.media.projection.IMediaProjection;
import android.media.projection.MediaProjection;
@@ -444,6 +445,17 @@ public final class DisplayManagerGlobal {
        }
    }

    /**
     * Gets the stable device display size, in pixels.
     */
    public Point getStableDisplaySize() {
        try {
            return mDm.getStableDisplaySize();
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    private final class DisplayManagerCallback extends IDisplayManagerCallback.Stub {
        @Override
        public void onDisplayEvent(int displayId, int event) {
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.hardware.display;

import android.graphics.Point;
import android.hardware.display.IDisplayManagerCallback;
import android.hardware.display.IVirtualDisplayCallback;
import android.hardware.display.WifiDisplay;
@@ -77,4 +78,7 @@ interface IDisplayManager {

    // No permissions required but must be same Uid as the creator.
    void releaseVirtualDisplay(in IVirtualDisplayCallback token);

    // Get a stable metric for the device's display size. No permissions required.
    Point getStableDisplaySize();
}
+6 −0
Original line number Diff line number Diff line
@@ -3044,4 +3044,10 @@

    <!-- Allow SystemUI to show the shutdown dialog -->
    <bool name="config_showSysuiShutdown">true</bool>

    <!-- The stable device width and height in pixels. If these aren't set to a positive number
         then the device will use the width and height of the default display the first time it's
         booted.  -->
    <integer name="config_stableDeviceDisplayWidth">-1</integer>
    <integer name="config_stableDeviceDisplayHeight">-1</integer>
</resources>
Loading