public final class XrDevice


Provides hardware capabilities of the device.

Summary

Nested types

public final class XrDevice.DisplayBlendMode

This class is deprecated. Use androidx.xr.runtime.DisplayBlendMode instead.

Public methods

static final @NonNull XrDevice

This method is deprecated. Use getCurrentDevice(Context) instead.

static final @NonNull XrDevice

Get the current XrDevice for the provided Context.

final @NonNull Lifecycle

Returns this XrDevice's Lifecycle.

final @NonNull DisplayBlendMode

Returns the preferred display blend mode for this session.

final boolean

Returns the XrDevice's support for the given DepthEstimationMode.

final boolean

Returns the XrDevice's support for the given EyeTrackingMode.

final boolean

Returns the XrDevice's support for the given GeospatialMode.

final boolean

Returns the XrDevice's support for the given HandTrackingMode.

final boolean

Returns whether the XrDevice supports the supplied RenderingMode.

Extension functions

final @NonNull NativeInstanceData

Returns a NativeInstanceData class containing pointers to native resources if available.

Public methods

getCurrentDevice

Added in 1.0.0-alpha14
Deprecated in 1.0.0-alpha14
public static final @NonNull XrDevice getCurrentDevice(@NonNull Session session)

Get the current XrDevice for the provided Session.

Parameters
@NonNull Session session

the Session connected to the device.

getCurrentDevice

Added in 1.0.0-alpha14
@ExperimentalXrDeviceLifecycleApi
public static final @NonNull XrDevice getCurrentDevice(
    @NonNull Context context,
    @NonNull CoroutineContext coroutineContext
)

Get the current XrDevice for the provided Context.

Parameters
@NonNull Context context

the Context associated with the device

@NonNull CoroutineContext coroutineContext

the CoroutineContext to use for the XrDevice operations

Throws
IllegalArgumentException

if the provided Context is not supported

getLifecycle

Added in 1.0.0-alpha14
@ExperimentalXrDeviceLifecycleApi
public final @NonNull Lifecycle getLifecycle()

Returns this XrDevice's Lifecycle.

The value will be the Projected device's lifecycle if its Context was used when calling getCurrentDevice. Otherwise, the Session's lifecycle will be returned.

Throws
IllegalStateException

if there is no lifecycle associated with this XrDevice.

getPreferredDisplayBlendMode

Added in 1.0.0-alpha14
public final @NonNull DisplayBlendMode getPreferredDisplayBlendMode()

Returns the preferred display blend mode for this session.

Returns
@NonNull DisplayBlendMode

The DisplayBlendMode that is preferred by the Session for rendering. DisplayBlendMode.NO_DISPLAY will be returned if there are no supported blend modes available.

isDepthEstimationModeSupported

Added in 1.0.0-alpha14
public final boolean isDepthEstimationModeSupported(@NonNull DepthEstimationMode mode)

Returns the XrDevice's support for the given DepthEstimationMode.

Returns
boolean

whether the device supports the supplied DepthEstimationMode.

isEyeTrackingModeSupported

Added in 1.0.0-alpha14
public final boolean isEyeTrackingModeSupported(@NonNull EyeTrackingMode mode)

Returns the XrDevice's support for the given EyeTrackingMode.

Returns
boolean

whether the device supports the supplied EyeTrackingMode.

isGeospatialModeSupported

Added in 1.0.0-alpha14
public final boolean isGeospatialModeSupported(@NonNull GeospatialMode mode)

Returns the XrDevice's support for the given GeospatialMode.

Returns
boolean

whether the device supports the supplied GeospatialMode.

isHandTrackingModeSupported

Added in 1.0.0-alpha14
public final boolean isHandTrackingModeSupported(@NonNull HandTrackingMode mode)

Returns the XrDevice's support for the given HandTrackingMode.

Returns
boolean

whether the device supports the supplied HandTrackingMode.

isRenderingModeSupported

Added in 1.0.0-alpha14
public final boolean isRenderingModeSupported(@NonNull RenderingMode mode)

Returns whether the XrDevice supports the supplied RenderingMode.

Returns
boolean

whether the device supports the supplied RenderingMode. For devices that support RenderingMode.MONO, RenderViewpoint.mono(session) is expected to be non-null. For devices that support RenderingMode.STEREO, RenderViewpoint.left(session), RenderViewpoint.right(session), and RenderViewpoint.mono(session) are all expected to be non-null.

Extension functions

NativeDataExt.getNativeInstanceData

@UnstableNativeResourceApi
public final @NonNull NativeInstanceData NativeDataExt.getNativeInstanceData(
    @NonNull XrDevice receiver,
    @NonNull Context context
)

Returns a NativeInstanceData class containing pointers to native resources if available. This is a dangerous API and can put the XR runtime in a bad state if used incorrectly.

The pointers are owned by the underlying runtime and should only be used to access APIs available in the native C spec for the relevant runtime. Applications should not trigger any lifecycle events on their own.