VirtualDisplayConfig.Builder  |  API reference  |  Android Developers


public static final class VirtualDisplayConfig.Builder
extends Object



A builder for VirtualDisplayConfig.

Summary

Public constructors

Builder(String name, int width, int height, int densityDpi)

Creates a new Builder.

Public methods

VirtualDisplayConfig.Builder addDisplayCategory(String displayCategory)

Adds a display category.

VirtualDisplayConfig build()

Builds the VirtualDisplayConfig instance.

VirtualDisplayConfig.Builder setBrightnessListener(Executor executor, VirtualDisplayConfig.BrightnessListener listener)

Sets the listener to get notified about changes in the display brightness.

VirtualDisplayConfig.Builder setDefaultBrightness(float brightness)

Sets the default brightness of the display.

VirtualDisplayConfig.Builder setDimBrightness(float brightness)

Sets the dim brightness of the display.

VirtualDisplayConfig.Builder setDisplayCategories(Set<String> displayCategories)

Sets the display categories.

VirtualDisplayConfig.Builder setFlags(int flags)

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.

VirtualDisplayConfig.Builder setRequestedRefreshRate(float requestedRefreshRate)

Sets the refresh rate of a virtual display in frames per second.

VirtualDisplayConfig.Builder setSurface(Surface surface)

Sets the surface to which the content of the virtual display should be rendered.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

public Builder (String name, 
                int width, 
                int height, 
                int densityDpi)

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

setBrightnessListener

public VirtualDisplayConfig.Builder setBrightnessListener (Executor executor, 
                VirtualDisplayConfig.BrightnessListener listener)

Sets the listener to get notified about changes in the display brightness.

Parameters
executor Executor: The executor where the callback is executed on.
This value cannot be null.
Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.
listener VirtualDisplayConfig.BrightnessListener: The listener to get notified when the display brightness has changed.
This value cannot be null.
Returns
VirtualDisplayConfig.Builder This value cannot be null.

setDefaultBrightness

public VirtualDisplayConfig.Builder setDefaultBrightness (float brightness)

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
Returns
VirtualDisplayConfig.Builder This value cannot be null.
Throws
IllegalArgumentException if the brightness is outside the valid range [0.0, 1.0]

setDimBrightness

public VirtualDisplayConfig.Builder setDimBrightness (float brightness)

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
Returns
VirtualDisplayConfig.Builder This value cannot be null.
Throws
IllegalArgumentException if the brightness is outside the valid range [0.0, 1.0]

setRequestedRefreshRate

public VirtualDisplayConfig.Builder setRequestedRefreshRate (float requestedRefreshRate)

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
Returns
VirtualDisplayConfig.Builder This value cannot be null.