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

Commit e664a076 authored by Vladimir Komsiyski's avatar Vladimir Komsiyski Committed by Android (Google) Code Review
Browse files

Merge "API for rotating virtual displays." into main

parents 512bbdf2 9da6da84
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20355,6 +20355,7 @@ package android.hardware.display {
    method public android.view.Surface getSurface();
    method public void release();
    method public void resize(int, int, int);
    method @FlaggedApi("android.companion.virtualdevice.flags.virtual_display_rotation_api") public void setRotation(int);
    method public void setSurface(android.view.Surface);
  }
+7 −0
Original line number Diff line number Diff line
@@ -89,3 +89,10 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    namespace: "virtual_devices"
    name: "virtual_display_rotation_api"
    description: "API for on-demand rotation of virtual displays"
    bug: "291748430"
}
+8 −0
Original line number Diff line number Diff line
@@ -817,6 +817,14 @@ public final class DisplayManagerGlobal {
        }
    }

    void setVirtualDisplayRotation(IVirtualDisplayCallback token, @Surface.Rotation int rotation) {
        try {
            mDm.setVirtualDisplayRotation(token, rotation);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Gets the stable device display size, in pixels.
     */
+3 −0
Original line number Diff line number Diff line
@@ -117,6 +117,9 @@ interface IDisplayManager {
    // No permissions required but must be same Uid as the creator.
    void setVirtualDisplayState(in IVirtualDisplayCallback token, boolean isOn);

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

    // Get a stable metric for the device's display size. No permissions required.
    Point getStableDisplaySize();

+23 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.hardware.display;

import android.annotation.FlaggedApi;
import android.view.Display;
import android.view.Surface;

@@ -122,6 +123,28 @@ public final class VirtualDisplay {
        }
    }

    /**
     * Sets the rotation of the virtual display.
     *
     * @param rotation the new rotation of the display. May be one of {@link Surface#ROTATION_0},
     *     {@link Surface#ROTATION_90}, {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
     *     Upon creation, the rotation of the virtual display is always {@link Surface#ROTATION_0}.
     */
    @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_VIRTUAL_DISPLAY_ROTATION_API)
    public void setRotation(@Surface.Rotation int rotation) {
        if (!android.companion.virtualdevice.flags.Flags.virtualDisplayRotationApi()) {
            return;
        }
        if (rotation != Surface.ROTATION_0 && rotation != Surface.ROTATION_90
                && rotation != Surface.ROTATION_180 && rotation != Surface.ROTATION_270) {
            throw new IllegalArgumentException(
                    "Invalid virtual display rotation value: " + rotation);
        }
        if (mToken != null && mDisplay.getRotation() != rotation) {
            mGlobal.setVirtualDisplayRotation(mToken, rotation);
        }
    }

    @Override
    public String toString() {
        return "VirtualDisplay{display=" + mDisplay + ", token=" + mToken
Loading