public class FakeXrExtensions


A fake for the XrExtensions.

This has fake implementations for a subset of the XrExtension capability that is used by the JXRCore runtime for AndroidXR.

Summary

Nested types

Creates fake activity panel.

Fake AudioTrackExtensions.

A fake implementation of Closeable.

Fake implementation of Extensions Config.

A fake implementation of the XR extensions EnvironmentToken.

A fake implementation of the XR extensions EnvironmentVisibilityState.

A fake implementation of the XR extensions GltfModelToken.

Fake input event.

Fake hit info.

Fake MediaPlayerExtensions.

public final class FakeXrExtensions.FakeNode implements Parcelable

A fake implementation of the XR extensions Node.

A fake implementation of the XR extensions Node transaction.

A fake implementation of the XR extensions NodeTransform.

A fake implementation of the XR extensions EnvironmentVisibilityState.

Fake ReformEvent.

Fake ReformOptions.

Fake SoundPoolExtensions.

Fake XrSpatialAudioExtensions.

A fake implementation of the XR extensions SpatialState.

Tracks whether an Activity has requested a mode for when it's focused.

Public constructors

Public methods

void

Synchronously makes a View findable via findViewById().

void
attachSpatialEnvironment(
    @NonNull Activity activity,
    @NonNull Node environmentNode
)

This method is deprecated.

This method is no longer supported.

void
attachSpatialEnvironment(
    @NonNull Activity activity,
    @NonNull Node environmentNode,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Attaches an environment node for a given activity to make it visible.

void
attachSpatialScene(
    @NonNull Activity activity,
    @NonNull Node sceneNode,
    @NonNull Node windowNode
)

This method is deprecated.

This method is no longer supported.

void
attachSpatialScene(
    @NonNull Activity activity,
    @NonNull Node sceneNode,
    @NonNull Node windowNode,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Attaches the given sceneNode as the presentation for the given activity in the space, and asks the system to attach the 2D content of the activity into the given windowNode.

boolean

This method is deprecated.

This method is no longer supported.

void

Synchronously clears the SpatialStateEvent callback that was previously set to the activity via setSpatialStateCallback.

@NonNull ActivityPanel
createActivityPanel(
    @NonNull Activity host,
    @NonNull ActivityPanelLaunchParameters launchParameters
)

Synchronously creates an ActivityPanel to be embedded inside the given host activity.

@NonNull Node

Synchronously creates a node that can host a 2D panel or 3D subspace.

@NonNull NodeTransaction

Synchronously creates a new transaction that can be used to update multiple Node's data and transformation in the 3D space.

@NonNull ReformOptions
createReformOptions(
    @NonNull Consumer<ReformEvent> callback,
    @NonNull Executor executor
)

Synchronously creates a new ReformOptions instance.

@NonNull SplitEngineBridge

Synchronously returns a SplitEngineBridge.

@NonNull Subspace
createSubspace(
    @NonNull SplitEngineBridge splitEngineBridge,
    int subspaceId
)

Synchronously creates a subspace.

void

This method is deprecated.

This method is no longer supported.

void
detachSpatialEnvironment(
    @NonNull Activity activity,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Detaches the environment node and its sub tree for a given activity to make it invisible.

void

This method is deprecated.

This method is no longer supported.

void
detachSpatialScene(
    @NonNull Activity activity,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Detaches the sceneNode that was previously attached for the activity via attachSpatialScene.

@NonNull CompletableFuture<XrExtensions.SceneViewerResult>
displayGltfModel(Activity activity, GltfModelToken gltfModel)

This method is deprecated.

This method is no longer supported.

@NonNull FakeXrExtensions.FakeActivityPanel
int

Get the current version of the XrExtensions API.

void
getBounds(
    @NonNull Activity activity,
    @NonNull Consumer<Bounds> callback,
    @NonNull Executor executor
)

This method is deprecated.

Use getSpatialState synchronous getter.

@NonNull Config

Synchronously returns system config information.

@Nullable FakeXrExtensions.FakeNode
@Nullable FakeXrExtensions.FakeNode
@Nullable FakeXrExtensions.FakeNode
int
int
int

Synchronously returns the OpenXR reference space type.

float
@NonNull FakeXrExtensions.SpaceMode
void
getSpatialCapabilities(
    @NonNull Activity activity,
    @NonNull Consumer<SpatialCapabilities> callback,
    @NonNull Executor executor
)

This method is deprecated.

Use getSpatialState synchronous getter.

@NonNull SpatialState

Synchronously gets the spatial state of the activity.

@Nullable Consumer<SpatialState>
@Nullable Node

Returns the surface tracking node for a view, if there is one.

@NonNull XrSpatialAudioExtensions

Synchronously returns the implementation of the XrSpatialAudioExtensions component.

void
hitTest(
    @NonNull Activity activity,
    @NonNull Vec3 origin,
    @NonNull Vec3 direction,
    @NonNull Consumer<HitTestResult> callback,
    @NonNull Executor executor
)

Hit-tests a ray against the virtual scene.

@NonNull CompletableFuture<EnvironmentToken>
loadEnvironment(
    @Nullable InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes,
    @Nullable String url
)

This method is deprecated.

This method is no longer supported.

@NonNull CompletableFuture<EnvironmentToken>
loadEnvironment(
    InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes,
    String url,
    int textureWidth,
    int textureHeight
)

This method is deprecated.

This method is no longer supported.

@NonNull CompletableFuture<GltfModelToken>
loadGltfModel(
    @Nullable InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes,
    @Nullable String url
)

This method is deprecated.

This method is no longer supported.

@NonNull CompletableFuture<SceneToken>
loadImpressScene(
    InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes
)

This method is deprecated.

This method is no longer supported.

void
registerSpatialStateCallback(
    @NonNull Activity activity,
    @NonNull Consumer<SpatialState> callback,
    @NonNull Executor executor
)

Synchronously registers a callback to receive SpatialState for the activity.

void

Synchronously removes a findable view from the given group.

boolean

This method is deprecated.

This method is no longer supported.

void
requestFullSpaceMode(
    @NonNull Activity activity,
    boolean requestEnter,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Requests to put an activity in a different mode when it has focus.

boolean

This method is deprecated.

This method is no longer supported.

void
@NonNull Bundle

Synchronously sets the full space mode flag to the given Bundle.

@NonNull Bundle

Synchronously sets the inherit full space mode environvment flag to the given Bundle.

@NonNull Bundle
setMainPanelCurvatureRadius(
    @NonNull Bundle bundle,
    float panelCurvatureRadius
)

This method is deprecated.

This method is no longer supported.

void
setMainWindowCurvatureRadius(
    @NonNull Activity activity,
    float curvatureRadius
)

This method is deprecated.

This method is no longer supported.

void
setMainWindowSize(@NonNull Activity activity, int width, int height)

This method is deprecated.

This method is no longer supported.

void
setMainWindowSize(
    @NonNull Activity activity,
    int width,
    int height,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Resizes the main window of the given activity to the requested size.

void
setOpenXrWorldSpaceType(int openXrWorldSpaceType)
void
setPreferredAspectRatio(@NonNull Activity activity, float preferredRatio)

This method is deprecated.

Use the new interface with a callback.

void
setPreferredAspectRatio(
    @NonNull Activity activity,
    float preferredRatio,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Sets a preferred main panel aspect ratio for an activity that is not SPATIAL_UI_CAPABLE.

void
setSpatialStateCallback(
    @NonNull Activity activity,
    @NonNull Consumer<SpatialStateEvent> callback,
    @NonNull Executor executor
)

This method is deprecated.

This method is no longer supported.

@NonNull FakeXrExtensions.FakeNode

This method is deprecated.

This method is no longer supported.

@NonNull FakeXrExtensions.FakeNode

This method is deprecated.

This method is no longer supported.

Public fields

createdEnvironmentTokens

Added in 1.0.0-alpha01
public final @NonNull List<FakeXrExtensions.FakeEnvironmentTokencreatedEnvironmentTokens

createdGltfModelTokens

Added in 1.0.0-alpha01
public final @NonNull List<FakeXrExtensions.FakeGltfModelTokencreatedGltfModelTokens

createdNodes

Added in 1.0.0-alpha01
public final @NonNull List<FakeXrExtensions.FakeNodecreatedNodes

fakeEnvironmentNode

Added in 1.0.0-alpha01
public FakeXrExtensions.FakeNode fakeEnvironmentNode

fakeNodeForMainWindow

Added in 1.0.0-alpha01
public FakeXrExtensions.FakeNode fakeNodeForMainWindow

fakeSpatialState

Added in 1.0.0-alpha01
public final @NonNull FakeXrExtensions.FakeSpatialState fakeSpatialState

fakeTaskNode

Added in 1.0.0-alpha01
public FakeXrExtensions.FakeNode fakeTaskNode

mainWindowHeight

Added in 1.0.0-alpha01
public int mainWindowHeight

mainWindowWidth

Added in 1.0.0-alpha01
public int mainWindowWidth

openXrWorldSpaceType

Added in 1.0.0-alpha01
public int openXrWorldSpaceType

spaceMode

Added in 1.0.0-alpha01
public FakeXrExtensions.SpaceMode spaceMode

spatialStateCallback

Added in 1.0.0-alpha01
public Consumer<SpatialStatespatialStateCallback

Public constructors

FakeXrExtensions

Added in 1.0.0-alpha01
public FakeXrExtensions()

Public methods

addFindableView

Added in 1.0.0-alpha01
public void addFindableView(@NonNull View view, @NonNull ViewGroup group)

Synchronously makes a View findable via findViewById().

This is done without it being a child of the given group.

Parameters
@NonNull View view

the view to add as findable.

@NonNull ViewGroup group

a group that is part of the hierarchy that findViewById() will be called on.

attachSpatialEnvironment

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public void attachSpatialEnvironment(
    @NonNull Activity activity,
    @NonNull Node environmentNode
)

attachSpatialEnvironment

Added in 1.0.0-alpha01
public void attachSpatialEnvironment(
    @NonNull Activity activity,
    @NonNull Node environmentNode,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Attaches an environment node for a given activity to make it visible.

SysUI will attach the environment node to the task node when the activity gains the APP_ENVIRONMENTS_CAPABLE capability.

This method can be called multiple times, SysUI will attach the new environment node and detach the old environment node if it exists.

Note that once an environmentNode is attached and the caller gains APP_ENVIRONMENTS_CAPABLE capability, spatial callback's environment visibility status changes to APP_VISIBLE even if your application hasn't set a skybox or geometry to the environment node yet. For that reason, call this API only when your application wants to show a skybox or geometry. Otherwise, the APP_VISIBLE spatial state may lead to an unexpected behavior. For example, home environment's ambient audio (if any) may stop even if the user can still see the home environment.

Parameters
@NonNull Activity activity

the activity that provides the environment node to attach.

@NonNull Node environmentNode

the environment node provided by the activity to be attached.

@NonNull Consumer<XrExtensionResult> callback

the callback that will be called with the result. XrExtensionResult will indicate either of the following: XrExtensionResult.XR_RESULT_SUCCESS: The request has been accepted, and the client can expect that a spatial state callback with an updated SpatialState will run shortly. XrExtensionResult.XR_RESULT_SUCCESS_NOT_VISIBLE: The request has been accepted, but will not immediately change the spatial state. A spatial state callback with an updated SpatialState won't run until the activity becomes APP_ENVIRONMENTS_CAPABLE. XrExtensionResult.XR_RESULT_IGNORED_ALREADY_APPLIED: The request has been ignored because the activity is already in the requested state. XrExtensionResult.XR_RESULT_ERROR_NOT_ALLOWED: The request has been rejected because the activity does not have the required capability (e.g. called by an embedded guest activity.) XrExtensionResult.XR_RESULT_ERROR_SYSTEM: A unrecoverable service side error has happened.

@NonNull Executor executor

the executor the callback will be called on.

attachSpatialScene

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public void attachSpatialScene(
    @NonNull Activity activity,
    @NonNull Node sceneNode,
    @NonNull Node windowNode
)

attachSpatialScene

Added in 1.0.0-alpha01
public void attachSpatialScene(
    @NonNull Activity activity,
    @NonNull Node sceneNode,
    @NonNull Node windowNode,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Attaches the given sceneNode as the presentation for the given activity in the space, and asks the system to attach the 2D content of the activity into the given windowNode.

The sceneNode will only be visible if the activity is visible as in a lifecycle state between onStart and onStop and is SPATIAL_UI_CAPABLE too.

One activity can only attach one scene node. When a new scene node is attached for the same activity, the previous one will be detached.

Parameters
@NonNull Activity activity

the owner activity of the sceneNode.

@NonNull Node sceneNode

the node to show as the presentation of the activity.

@NonNull Node windowNode

a leash node to allow the app to control the position and size of the activity's main window.

@NonNull Consumer<XrExtensionResult> callback

the callback that will be called with the result. XrExtensionResult will indicate either of the following: XrExtensionResult.XR_RESULT_SUCCESS: The request has been accepted, and the client can expect that a spatial state callback with an updated SpatialState will run shortly. XrExtensionResult.XR_RESULT_SUCCESS_NOT_VISIBLE: The request has been accepted, but will not immediately change the spatial state. A spatial state callback with an updated SpatialState won't run until the activity becomes SPATIAL_UI_CAPABLE. XrExtensionResult.XR_RESULT_IGNORED_ALREADY_APPLIED: The request has been ignored because the activity is already in the requested state. XrExtensionResult.XR_RESULT_ERROR_NOT_ALLOWED: The request has been rejected because the activity does not have the required capability (e.g. called by an embedded guest activity.) XrExtensionResult.XR_RESULT_ERROR_SYSTEM: A unrecoverable service side error has happened.

@NonNull Executor executor

the executor the callback will be called on.

canEmbedActivityPanel

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public boolean canEmbedActivityPanel(@NonNull Activity activity)

clearSpatialStateCallback

Added in 1.0.0-alpha01
public void clearSpatialStateCallback(@NonNull Activity activity)

Synchronously clears the SpatialStateEvent callback that was previously set to the activity via setSpatialStateCallback.

When an Activity is destroyed, it must call this method to clear the callback that was set for itself.

Parameters
@NonNull Activity activity

the activity for the callback to listen to.

createActivityPanel

Added in 1.0.0-alpha01
public @NonNull ActivityPanel createActivityPanel(
    @NonNull Activity host,
    @NonNull ActivityPanelLaunchParameters launchParameters
)

Synchronously creates an ActivityPanel to be embedded inside the given host activity.

Caller must make sure the host can embed ActivityPanel. See (. When embedding is possible, SpatialState's SpatialCapabilities has SPATIAL_ACTIVITY_EMBEDDING_CAPABLE.

For the ActivityPanel to be shown in the scene, caller needs to attach the getNode to the scene node attached through attachSpatialScene.

This API throws IllegalArgumentException if it is called by an embedded (guest) activity.

Parameters
@NonNull Activity host

the host activity to embed the ActivityPanel.

@NonNull ActivityPanelLaunchParameters launchParameters

the parameters to define the initial state of the .

Returns
@NonNull ActivityPanel

the ActivityPanel created.

Throws
java.lang.IllegalStateException

if the host is not allowed to embed .

createNode

Added in 1.0.0-alpha01
public @NonNull Node createNode()

Synchronously creates a node that can host a 2D panel or 3D subspace.

Returns
@NonNull Node

A Node.

createNodeTransaction

Added in 1.0.0-alpha01
public @NonNull NodeTransaction createNodeTransaction()

Synchronously creates a new transaction that can be used to update multiple Node's data and transformation in the 3D space.

Returns
@NonNull NodeTransaction

A NodeTransaction that can be used to queue the updates and submit to backend at once.

createReformOptions

Added in 1.0.0-alpha01
public @NonNull ReformOptions createReformOptions(
    @NonNull Consumer<ReformEvent> callback,
    @NonNull Executor executor
)

Synchronously creates a new ReformOptions instance.

Parameters
@NonNull Consumer<ReformEvent> callback

the callback that will be called with reform events.

@NonNull Executor executor

the executor the callback will be called on.

Returns
@NonNull ReformOptions

the new builder instance.

createSplitEngineBridge

Added in 1.0.0-alpha01
public @NonNull SplitEngineBridge createSplitEngineBridge()

Synchronously returns a SplitEngineBridge.

createSubspace

Added in 1.0.0-alpha01
public @NonNull Subspace createSubspace(
    @NonNull SplitEngineBridge splitEngineBridge,
    int subspaceId
)

Synchronously creates a subspace.

Parameters
@NonNull SplitEngineBridge splitEngineBridge

The splitEngineBridge.

int subspaceId

The unique identifier of the subspace.

Returns
@NonNull Subspace

A Subspace that can be used to render 3D content in.

detachSpatialEnvironment

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public void detachSpatialEnvironment(@NonNull Activity activity)

detachSpatialEnvironment

Added in 1.0.0-alpha01
public void detachSpatialEnvironment(
    @NonNull Activity activity,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Detaches the environment node and its sub tree for a given activity to make it invisible.

This method will detach and cleanup the environment node and its subtree passed from the activity.

Parameters
@NonNull Activity activity

the activity with which SysUI will detach and clean up the environment node tree.

@NonNull Consumer<XrExtensionResult> callback

the callback that will be called with the result. XrExtensionResult will indicate either of the following: XrExtensionResult.XR_RESULT_SUCCESS: The request has been accepted, and the client can expect that a spatial state callback with an updated SpatialState will run shortly. XrExtensionResult.XR_RESULT_SUCCESS_NOT_VISIBLE: The request has been accepted, but will not immediately change the spatial state. A spatial state callback with an updated SpatialState won't run until the activity becomes APP_ENVIRONMENTS_CAPABLE. XrExtensionResult.XR_RESULT_IGNORED_ALREADY_APPLIED: The request has been ignored because the activity is already in the requested state. XrExtensionResult.XR_RESULT_ERROR_SYSTEM: A unrecoverable service side error has happened.

@NonNull Executor executor

the executor the callback will be called on.

detachSpatialScene

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public void detachSpatialScene(@NonNull Activity activity)

detachSpatialScene

Added in 1.0.0-alpha01
public void detachSpatialScene(
    @NonNull Activity activity,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Detaches the sceneNode that was previously attached for the activity via attachSpatialScene.

When an Activity is destroyed, it must call this method to detach the scene node that was attached for itself.

Parameters
@NonNull Activity activity

the owner activity of the sceneNode.

@NonNull Consumer<XrExtensionResult> callback

the callback that will be called with the result. XrExtensionResult will indicate either of the following: XrExtensionResult.XR_RESULT_SUCCESS: The request has been accepted, and the client can expect that a spatial state callback with an updated SpatialState will run shortly. XrExtensionResult.XR_RESULT_SUCCESS_NOT_VISIBLE: The request has been accepted, but will not immediately change the spatial state. A spatial state callback with an updated SpatialState won't run until the activity becomes SPATIAL_UI_CAPABLE. XrExtensionResult.XR_RESULT_IGNORED_ALREADY_APPLIED: The request has been ignored because the activity is already in the requested state. XrExtensionResult.XR_RESULT_ERROR_SYSTEM: A unrecoverable service side error has happened.

@NonNull Executor executor

the executor the callback will be called on.

displayGltfModel

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull CompletableFuture<XrExtensions.SceneViewerResultdisplayGltfModel(Activity activity, GltfModelToken gltfModel)

Suppressed to allow CompletableFuture.

getApiVersion

Added in 1.0.0-alpha01
public int getApiVersion()

Get the current version of the XrExtensions API.

getBounds

Added in 1.0.0-alpha01
public void getBounds(
    @NonNull Activity activity,
    @NonNull Consumer<Bounds> callback,
    @NonNull Executor executor
)

Gets the bounds of the activity.

Parameters
@NonNull Activity activity

the activity to get the bounds.

@NonNull Consumer<Bounds> callback

the callback to run. If the activity is not found in SysUI, the callback runs with a null Bounds.

@NonNull Executor executor

the executor that the callback will be called on.

getConfig

Added in 1.0.0-alpha01
public @NonNull Config getConfig()

Synchronously returns system config information.

Returns
@NonNull Config

A Config object.

getFakeEnvironmentNode

Added in 1.0.0-alpha01
public @Nullable FakeXrExtensions.FakeNode getFakeEnvironmentNode()

getFakeNodeForMainWindow

Added in 1.0.0-alpha01
public @Nullable FakeXrExtensions.FakeNode getFakeNodeForMainWindow()

getFakeTaskNode

Added in 1.0.0-alpha01
public @Nullable FakeXrExtensions.FakeNode getFakeTaskNode()

getMainWindowHeight

Added in 1.0.0-alpha01
public int getMainWindowHeight()

getMainWindowWidth

Added in 1.0.0-alpha01
public int getMainWindowWidth()

getOpenXrWorldSpaceType

Added in 1.0.0-alpha01
public int getOpenXrWorldSpaceType()

Synchronously returns the OpenXR reference space type.

Returns
int

the OpenXR reference space type used as world space for the shared scene.

getPreferredAspectRatio

Added in 1.0.0-alpha01
public float getPreferredAspectRatio()

getSpaceMode

Added in 1.0.0-alpha01
public @NonNull FakeXrExtensions.SpaceMode getSpaceMode()

getSpatialCapabilities

Added in 1.0.0-alpha01
public void getSpatialCapabilities(
    @NonNull Activity activity,
    @NonNull Consumer<SpatialCapabilities> callback,
    @NonNull Executor executor
)

Gets the spatial capabilities of the activity.

Parameters
@NonNull Activity activity

the activity to get the capabilities.

@NonNull Consumer<SpatialCapabilities> callback

the callback to run. If the activity is not found in SysUI, the callback runs with a null SpatialCapabilities.

@NonNull Executor executor

the executor that the callback will be called on.

getSpatialState

Added in 1.0.0-alpha01
public @NonNull SpatialState getSpatialState(@NonNull Activity activity)

Synchronously gets the spatial state of the activity.

Do not call the API from the Binder thread. That may cause a deadlock.

This API throws IllegalArgumentException if it is called by an embedded (guest) activity, and also throws RuntimeException if the calling thread is interrupted.

Parameters
@NonNull Activity activity

the activity to get the capabilities.

Returns
@NonNull SpatialState

the state of the activity.

getSpatialStateCallback

Added in 1.0.0-alpha01
public @Nullable Consumer<SpatialStategetSpatialStateCallback()

getSurfaceTrackingNode

Added in 1.0.0-alpha01
public @Nullable Node getSurfaceTrackingNode(@NonNull View view)

Returns the surface tracking node for a view, if there is one.

The surface tracking node is centered on the Surface that the view is attached to, and is sized to match the surface's size. Note that the view's position in the surface can be retrieved via View.getLocationInSurface().

Parameters
@NonNull View view

the view.

Returns
@Nullable Node

the surface tracking node, or null if no such node exists.

getXrSpatialAudioExtensions

Added in 1.0.0-alpha01
public @NonNull XrSpatialAudioExtensions getXrSpatialAudioExtensions()

Synchronously returns the implementation of the XrSpatialAudioExtensions component.

hitTest

Added in 1.0.0-alpha01
public void hitTest(
    @NonNull Activity activity,
    @NonNull Vec3 origin,
    @NonNull Vec3 direction,
    @NonNull Consumer<HitTestResult> callback,
    @NonNull Executor executor
)

Hit-tests a ray against the virtual scene. If the ray hits an object in the scene, information about the hit will be passed to the callback. If nothing is hit, the hit distance will be infinite. Note that attachSpatialScene() must be called before calling this method. Otherwise, an IllegalArgumentException is thrown.

Parameters
@NonNull Activity activity

the requesting activity.

@NonNull Vec3 origin

the origin of the ray to test, in the activity's task coordinates.

@NonNull Vec3 direction

the direction of the ray to test, in the activity's task coordinates.

@NonNull Consumer<HitTestResult> callback

the callback that will be called with the hit test result.

@NonNull Executor executor

the executor the callback will be called on.

loadEnvironment

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull CompletableFuture<EnvironmentTokenloadEnvironment(
    @Nullable InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes,
    @Nullable String url
)

Suppressed to allow CompletableFuture.

loadEnvironment

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull CompletableFuture<EnvironmentTokenloadEnvironment(
    InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes,
    String url,
    int textureWidth,
    int textureHeight
)

Suppressed to allow CompletableFuture.

loadGltfModel

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull CompletableFuture<GltfModelTokenloadGltfModel(
    @Nullable InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes,
    @Nullable String url
)

Suppressed to allow CompletableFuture.

loadImpressScene

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull CompletableFuture<SceneTokenloadImpressScene(
    InputStream asset,
    int regionSizeBytes,
    int regionOffsetBytes
)

Suppressed to allow CompletableFuture.

registerSpatialStateCallback

Added in 1.0.0-alpha01
public void registerSpatialStateCallback(
    @NonNull Activity activity,
    @NonNull Consumer<SpatialState> callback,
    @NonNull Executor executor
)

Synchronously registers a callback to receive SpatialState for the activity.

One activity can only set one callback. When a new callback is set for the same activity, the previous one will be cleared.

The executor's execute() method will soon be called to run the callback with the current state when it is available, but it never happens directly from within this call.

This API throws IllegalArgumentException if it is called by an embedded (guest) activity.

Parameters
@NonNull Activity activity

the activity for the callback to listen to.

@NonNull Consumer<SpatialState> callback

the callback to set.

@NonNull Executor executor

the executor that the callback will be called on.

removeFindableView

Added in 1.0.0-alpha01
public void removeFindableView(@NonNull View view, @NonNull ViewGroup group)

Synchronously removes a findable view from the given group.

Parameters
@NonNull View view

the view to remove as findable.

@NonNull ViewGroup group

the group to remove the findable view from.

requestFullSpaceMode

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public boolean requestFullSpaceMode(@NonNull Activity activity)

requestFullSpaceMode

Added in 1.0.0-alpha01
public void requestFullSpaceMode(
    @NonNull Activity activity,
    boolean requestEnter,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Requests to put an activity in a different mode when it has focus.

Parameters
@NonNull Activity activity

the activity that requires to enter full space mode.

boolean requestEnter

when true, activity is put in full space mode. Home space mode otherwise.

@NonNull Consumer<XrExtensionResult> callback

the callback that will be called with the result. XrExtensionResult will indicate either of the following: XrExtensionResult.XR_RESULT_SUCCESS: The request has been accepted, and the client can expect that a spatial state callback with an updated SpatialState will run shortly. XrExtensionResult.XR_RESULT_IGNORED_ALREADY_APPLIED: The request has been ignored because the activity is already in the requested mode. XrExtensionResult.XR_RESULT_ERROR_NOT_ALLOWED: The request has been rejected because the activity does not have the required capability (e.g. not the top activity in a top task in the desktop, called by an embedded guest activity.) XrExtensionResult.XR_RESULT_ERROR_SYSTEM: A unrecoverable service side error has happened.

@NonNull Executor executor

the executor the callback will be called on.

requestHomeSpaceMode

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public boolean requestHomeSpaceMode(@NonNull Activity activity)

sendSpatialState

Added in 1.0.0-alpha01
public void sendSpatialState(@NonNull SpatialState spatialState)

setFullSpaceMode

Added in 1.0.0-alpha01
public @NonNull Bundle setFullSpaceMode(@NonNull Bundle bundle)

Synchronously sets the full space mode flag to the given Bundle.

The Bundle then could be used to launch an Activity with requesting to enter full space mode through startActivity. If there's a bundle used for customizing how the Activity should be started by ActivityOptions.toBundle or androidx.core.app.ActivityOptionsCompat.toBundle, it's suggested to use the bundle to call this method.

The flag will be ignored when no Intent.FLAG_ACTIVITY_NEW_TASK is set in the bundle, or it is not started from a focused Activity context.

This flag is also ignored when the android.window.PROPERTY_XR_ACTIVITY_START_MODE property is set to a value other than XR_ACTIVITY_START_MODE_UNDEFINED in the AndroidManifest.xml file for the activity being launched.

Parameters
@NonNull Bundle bundle

the input bundle to set with the full space mode flag.

Returns
@NonNull Bundle

the input bundle with the full space mode flag set.

setFullSpaceModeWithEnvironmentInherited

Added in 1.0.0-alpha01
public @NonNull Bundle setFullSpaceModeWithEnvironmentInherited(@NonNull Bundle bundle)

Synchronously sets the inherit full space mode environvment flag to the given Bundle.

The Bundle then could be used to launch an Activity with requesting to enter full space mode while inherit the existing environment through startActivity. If there's a bundle used for customizing how the Activity should be started by ActivityOptions.toBundle or , it's suggested to use the bundle to call this method.

When launched, the activity will be in full space mode and also inherits the environment from the launching activity. If the inherited environment needs to be animated, the launching activity has to continue updating the environment even after the activity is put into the stopped state.

The flag will be ignored when no Intent.FLAG_ACTIVITY_NEW_TASK is set in the intent, or it is not started from a focused Activity context.

The flag will also be ignored when there is no environment to inherit or the activity has its own environment set already.

This flag is ignored too when the android.window.PROPERTY_XR_ACTIVITY_START_MODE property is set to a value other than XR_ACTIVITY_START_MODE_UNDEFINED in the AndroidManifest.xml file for the activity being launched.

For security reasons, Z testing for the new activity is disabled, and the activity is always drawn on top of the inherited environment. Because Z testing is disabled, the activity should not spatialize itself, and should not curve its panel too much either.

Parameters
@NonNull Bundle bundle

the input bundle to set with the inherit full space mode environment flag.

Returns
@NonNull Bundle

the input bundle with the inherit full space mode flag set.

setMainPanelCurvatureRadius

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull Bundle setMainPanelCurvatureRadius(
    @NonNull Bundle bundle,
    float panelCurvatureRadius
)

setMainWindowCurvatureRadius

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public void setMainWindowCurvatureRadius(
    @NonNull Activity activity,
    float curvatureRadius
)

setMainWindowSize

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public void setMainWindowSize(@NonNull Activity activity, int width, int height)

setMainWindowSize

Added in 1.0.0-alpha01
public void setMainWindowSize(
    @NonNull Activity activity,
    int width,
    int height,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Resizes the main window of the given activity to the requested size.

Parameters
@NonNull Activity activity

the activity whose main window should be resized.

int width

the new main window width in pixels.

int height

the new main window height in pixels.

@NonNull Consumer<XrExtensionResult> callback

the callback that will be called with the result. XrExtensionResult will indicate either of the following: XrExtensionResult.XR_RESULT_SUCCESS: The request has been accepted, and the client can expect that a spatial state callback with an updated SpatialState will run shortly. XrExtensionResult.XR_RESULT_SUCCESS_NOT_VISIBLE: The request has been accepted, but will not immediately change the spatial state. A spatial state callback with an updated SpatialState won't run until the activity becomes SPATIAL_UI_CAPABLE. XrExtensionResult.XR_RESULT_IGNORED_ALREADY_APPLIED: The request has been ignored because the activity is already in the requested state. XrExtensionResult.XR_RESULT_ERROR_NOT_ALLOWED: The request has been rejected because the activity does not have the required capability (e.g. called by an embedded guest activity.) XrExtensionResult.XR_RESULT_ERROR_SYSTEM: A unrecoverable service side error has happened.

@NonNull Executor executor

the executor the callback will be called on.

setOpenXrWorldSpaceType

Added in 1.0.0-alpha01
public void setOpenXrWorldSpaceType(int openXrWorldSpaceType)

setPreferredAspectRatio

Added in 1.0.0-alpha01
public void setPreferredAspectRatio(@NonNull Activity activity, float preferredRatio)

Sets a preferred main panel aspect ratio for home space mode.

The ratio is only applied to the activity. If the activity launches another activity in the same task, the ratio is not applied to the new activity. Also, while the activity is in full space mode, the preference is temporarily removed.

Parameters
@NonNull Activity activity

the activity to set the preference.

float preferredRatio

the aspect ratio determined by taking the panel's width over its height. A value <= 0.0f means there are no preferences.

setPreferredAspectRatio

Added in 1.0.0-alpha01
public void setPreferredAspectRatio(
    @NonNull Activity activity,
    float preferredRatio,
    @NonNull Consumer<XrExtensionResult> callback,
    @NonNull Executor executor
)

Sets a preferred main panel aspect ratio for an activity that is not SPATIAL_UI_CAPABLE.

The ratio is only applied to the activity. If the activity launches another activity in the same task, the ratio is not applied to the new activity. Also, while the activity is SPATIAL_UI_CAPABLE, the preference is temporarily removed. While the activity is SPATIAL_UI_CAPABLE, use ReformOptions API instead.

Parameters
@NonNull Activity activity

the activity to set the preference.

float preferredRatio

the aspect ratio determined by taking the panel's width over its height. A value <= 0.0f means there are no preferences.

@NonNull Consumer<XrExtensionResult> callback

the callback that will be called with the result. XrExtensionResult will indicate either of the following: XrExtensionResult.XR_RESULT_SUCCESS: The request has been accepted, and the client can expect that a spatial state callback with an updated SpatialState will run shortly. XrExtensionResult.XR_RESULT_SUCCESS_NOT_VISIBLE: The request has been accepted, but will not immediately change the spatial state. A spatial state callback with an updated SpatialState won't run until the activity loses the SPATIAL_UI_CAPABLE capability. XrExtensionResult.XR_RESULT_IGNORED_ALREADY_APPLIED: The request has been ignored because the activity is already in the requested state. XrExtensionResult.XR_RESULT_ERROR_NOT_ALLOWED: The request has been rejected because the activity does not have the required capability (e.g. called by an embedded guest activity.) XrExtensionResult.XR_RESULT_ERROR_SYSTEM: A unrecoverable service side error has happened.

@NonNull Executor executor

the executor the callback will be called on.

setSpatialStateCallback

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public void setSpatialStateCallback(
    @NonNull Activity activity,
    @NonNull Consumer<SpatialStateEvent> callback,
    @NonNull Executor executor
)

testGetNodeWithEnvironmentToken

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull FakeXrExtensions.FakeNode testGetNodeWithEnvironmentToken(@NonNull EnvironmentToken token)

Returns a FakeNode with corresponding environmentToken if it was created and found

testGetNodeWithGltfToken

Added in 1.0.0-alpha01
Deprecated in 1.0.0-alpha01
public @NonNull FakeXrExtensions.FakeNode testGetNodeWithGltfToken(@NonNull GltfModelToken token)

Returns a FakeNode with corresponding gltfModelToken if it was created and found