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

Returns the FakeActivityPanel for the given Activity.

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

Tests can use this method to trigger the spatial state callback.

@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-alpha03
public final @NonNull List<FakeXrExtensions.FakeEnvironmentTokencreatedEnvironmentTokens

createdGltfModelTokens

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

createdNodes

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

fakeSpatialState

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

Public constructors

FakeXrExtensions

Added in 1.0.0-alpha03
public FakeXrExtensions()

Public methods

addFindableView

Added in 1.0.0-alpha03
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-alpha03
Deprecated in 1.0.0-alpha03
public void attachSpatialEnvironment(
    @NonNull Activity activity,
    @NonNull Node environmentNode
)

attachSpatialEnvironment

Added in 1.0.0-alpha03
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-alpha03
Deprecated in 1.0.0-alpha03
public void attachSpatialScene(
    @NonNull Activity activity,
    @NonNull Node sceneNode,
    @NonNull Node windowNode
)

attachSpatialScene

Added in 1.0.0-alpha03
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-alpha03
Deprecated in 1.0.0-alpha03
public boolean canEmbedActivityPanel(@NonNull Activity activity)

clearSpatialStateCallback

Added in 1.0.0-alpha03
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-alpha03
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-alpha03
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-alpha03
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-alpha03
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-alpha03
public @NonNull SplitEngineBridge createSplitEngineBridge()

Synchronously returns a SplitEngineBridge.

createSubspace

Added in 1.0.0-alpha03
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-alpha03
Deprecated in 1.0.0-alpha03
public void detachSpatialEnvironment(@NonNull Activity activity)

detachSpatialEnvironment

Added in 1.0.0-alpha03
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-alpha03
Deprecated in 1.0.0-alpha03
public void detachSpatialScene(@NonNull Activity activity)

detachSpatialScene

Added in 1.0.0-alpha03
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-alpha03
Deprecated in 1.0.0-alpha03
public @NonNull CompletableFuture<XrExtensions.SceneViewerResultdisplayGltfModel(Activity activity, GltfModelToken gltfModel)

Suppressed to allow CompletableFuture.

getActivityPanelForHost

Added in 1.0.0-alpha03
public @NonNull FakeXrExtensions.FakeActivityPanel getActivityPanelForHost(@NonNull Activity host)

Returns the FakeActivityPanel for the given Activity.

getApiVersion

Added in 1.0.0-alpha03
public int getApiVersion()

Get the current version of the XrExtensions API.

getBounds

Added in 1.0.0-alpha03
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-alpha03
public @NonNull Config getConfig()

Synchronously returns system config information.

Returns
@NonNull