Builder
class Builder
A builder for VirtualDisplayConfig
.
Summary
Public constructors |
Creates a new Builder.
|
Public constructors
Builder
Builder(
name: String,
width: Int,
height: Int,
densityDpi: Int)
Creates a new Builder.
Parameters |
name |
String: The name of the virtual display, must be non-empty. This value cannot be null . |
width |
Int: The width of the virtual display in pixels. Must be greater than 0. Value is 1 or greater |
height |
Int: The height of the virtual display in pixels. Must be greater than 0. Value is 1 or greater |
densityDpi |
Int: The density of the virtual display in dpi. Must be greater than 0. Value is 1 or greater |
Public methods
build
fun build(): VirtualDisplayConfig
Builds the VirtualDisplayConfig
instance.
Exceptions |
java.lang.IllegalArgumentException |
if the dim brightness is set to a value greater than the default brightness. |
setDefaultBrightness
fun setDefaultBrightness(brightness: Float): VirtualDisplayConfig.Builder
Sets the default brightness of the display.
The system will use this brightness value whenever the display should be bright, i.e. it is powered on and not modified due to user activity or app activity.
Value of 0.0
indicates the minimum supported brightness and value of 1.0
indicates the maximum supported brightness.
If unset, defaults to 0.0
Parameters |
brightness |
Float: Value is between 0.0f and 1.0f inclusive |
Exceptions |
java.lang.IllegalArgumentException |
if the brightness is outside the valid range [0.0, 1.0] |
setDimBrightness
fun setDimBrightness(brightness: Float): VirtualDisplayConfig.Builder
Sets the dim brightness of the display.
The system will use this brightness value whenever the display should be dim, i.e. it is powered on and dimmed due to user activity or app activity.
Value of 0.0
indicates the minimum supported brightness and value of 1.0
indicates the maximum supported brightness.
If set, the default brightness must also be set to a value greater or equal to the dim brightness. If unset, defaults to the system default.
Parameters |
brightness |
Float: Value is between 0.0f and 1.0f inclusive |
Exceptions |
java.lang.IllegalArgumentException |
if the brightness is outside the valid range [0.0, 1.0] |
setFlags
fun setFlags(flags: Int): VirtualDisplayConfig.Builder
Sets the virtual display flags, a combination of DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC
, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION
, DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE
, DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
, or DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR
.
Parameters |
flags |
Int: Value is either 0 or a combination of android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC , android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION , android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE , android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY , android.hardware.display.DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR , android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUSTED, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED, android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_FOCUS, and android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_STEAL_TOP_FOCUS_DISABLED |
setRequestedRefreshRate
fun setRequestedRefreshRate(requestedRefreshRate: Float): VirtualDisplayConfig.Builder
Sets the refresh rate of a virtual display in frames per second.
For best results, specify a divisor of the physical refresh rate, e.g., 30 or 60 on a 120hz display. If an arbitrary refresh rate is specified, the rate will be rounded up to a divisor of the physical display. If unset or zero, the virtual display will be refreshed at the physical display refresh rate.
Parameters |
requestedRefreshRate |
Float: Value is 0.0f or greater |