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

Commit 01e840ff authored by Michael Wright's avatar Michael Wright
Browse files

Add resize method for virtual displays

Change-Id: I2632fc56c2d2cba356379e42f5c1a3e283b11d1e
parent e877138d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13247,6 +13247,7 @@ package android.hardware.display {
    method public android.view.Display getDisplay();
    method public android.view.Surface getSurface();
    method public void release();
    method public void resize(int, int, int);
    method public void setSurface(android.view.Surface);
  }
+9 −0
Original line number Diff line number Diff line
@@ -416,6 +416,15 @@ public final class DisplayManagerGlobal {
        }
    }

    public void resizeVirtualDisplay(IVirtualDisplayCallbacks token,
            int width, int height, int densityDpi) {
        try {
            mDm.resizeVirtualDisplay(token, width, height, densityDpi);
        } catch (RemoteException ex) {
            Log.w(TAG, "Failed to resize virtual display.", ex);
        }
    }

    public void releaseVirtualDisplay(IVirtualDisplayCallbacks token) {
        try {
            mDm.releaseVirtualDisplay(token);
+4 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ interface IDisplayManager {
            in IMediaProjection projectionToken, String packageName, String name,
            int width, int height, int densityDpi, in Surface surface, int flags);

    // No permissions required, but must be same Uid as the creator.
    void resizeVirtualDisplay(in IVirtualDisplayCallbacks token,
            int width, int height, int densityDpi);

    // No permissions required but must be same Uid as the creator.
    void setVirtualDisplaySurface(in IVirtualDisplayCallbacks token, in Surface surface);

+12 −0
Original line number Diff line number Diff line
@@ -79,6 +79,18 @@ public final class VirtualDisplay {
        }
    }

    /**
     * Asks the virtual display to resize.
     *<p>
     * This is really just a convenience to allow applications using
     * virtual displays to adapt to changing conditions without having
     * to tear down and recreate the display.
     * </p>
     */
    public void resize(int width, int height, int densityDpi) {
        mGlobal.resizeVirtualDisplay(mToken, width, height, densityDpi);
    }

    /**
     * Releases the virtual display and destroys its underlying surface.
     * <p>
+12 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class SurfaceControl {
            IBinder displayToken, int orientation,
            int l, int t, int r, int b,
            int L, int T, int R, int B);
    private static native void nativeSetDisplaySize(IBinder displayToken, int width, int height);
    private static native SurfaceControl.PhysicalDisplayInfo[] nativeGetDisplayConfigs(
            IBinder displayToken);
    private static native int nativeGetActiveConfig(IBinder displayToken);
@@ -588,6 +589,17 @@ public class SurfaceControl {
        }
    }

    public static void setDisplaySize(IBinder displayToken, int width, int height) {
        if (displayToken == null) {
            throw new IllegalArgumentException("displayToken must not be null");
        }
        if (width <= 0 || height <= 0) {
            throw new IllegalArgumentException("width and height must be positive");
        }

        nativeSetDisplaySize(displayToken, width, height);
    }

    public static IBinder createDisplay(String name, boolean secure) {
        if (name == null) {
            throw new IllegalArgumentException("name must not be null");
Loading