SandboxedSdkProvider


abstract class SandboxedSdkProvider
kotlin.Any
   ↳ android.app.sdksandbox.SandboxedSdkProvider

Encapsulates API which SDK sandbox can use to interact with SDKs loaded into it.

SDK has to implement this abstract class to generate an entry point for SDK sandbox to be able to call it through.

Summary

Public constructors

Public methods
Unit

Sets the SDK Context which can then be received using android.app.sdksandbox.SandboxedSdkProvider#getContext().

open Unit

Does the work needed for the SDK to free its resources before being unloaded.

Context?

Return the Context previously set through SandboxedSdkProvider.attachContext.

abstract View
getView(windowContext: Context, params: Bundle, width: Int, height: Int)

Requests a view to be remotely rendered to the client app process.

abstract SandboxedSdk
onLoadSdk(params: Bundle)

Does the work needed for the SDK to start handling requests.

Public constructors

SandboxedSdkProvider

SandboxedSdkProvider()

Public methods

attachContext

fun attachContext(context: Context): Unit

Sets the SDK Context which can then be received using android.app.sdksandbox.SandboxedSdkProvider#getContext(). This is called before android.app.sdksandbox.SandboxedSdkProvider#onLoadSdk is invoked. No operations requiring a Context should be performed before then, as SandboxedSdkProvider.getContext will return null until this method has been called.

Throws IllegalStateException if a base context has already been set.

Parameters
context Context: The new base context. This value cannot be null.

beforeUnloadSdk

open fun beforeUnloadSdk(): Unit

Does the work needed for the SDK to free its resources before being unloaded.

This function is called by the SDK sandbox manager before it unloads the SDK. The SDK should fail any invocations on the Binder previously returned to the client through android.app.sdksandbox.SandboxedSdk#getInterface.

The SDK should not do any long-running tasks here, like I/O and network calls.

getContext

fun getContext(): Context?

Return the Context previously set through SandboxedSdkProvider.attachContext. This will return null if no context has been previously set.

getView

abstract fun getView(
    windowContext: Context,
    params: Bundle,
    width: Int,
    height: Int
): View

Deprecated: This method will no longer be supported as it is being used by android.app.sdksandbox.SdkSandboxManager#requestSurfacePackage which is getting deprecated.

Requests a view to be remotely rendered to the client app process.

Returns View will be wrapped into SurfacePackage. the resulting SurfacePackage will be sent back to the client application.

The SDK should not do any long-running tasks here, like I/O and network calls. Doing so can prevent the SDK from receiving requests from the client.

Parameters
windowContext Context: the Context of the display which meant to show the view This value cannot be null.
params Bundle: list of params passed from the client application requesting the view This value cannot be null.
width Int: The view returned will be laid as if in a window of this width, in pixels.
height Int: The view returned will be laid as if in a window of this height, in pixels.
Return
View a View which SDK sandbox pass to the client application requesting the view This value cannot be null.

onLoadSdk

abstract fun onLoadSdk(params: Bundle): SandboxedSdk

Does the work needed for the SDK to start handling requests.

This function is called by the SDK sandbox after it loads the SDK.

SDK should do any work to be ready to handle upcoming requests. It should not do any long-running tasks here, like I/O and network calls. Doing so can prevent the SDK from receiving requests from the client. Additionally, it should not do initialization that depends on other SDKs being loaded into the SDK sandbox.

The SDK should not do any operations requiring a Context object before this method has been called.

Parameters
params Bundle: list of params passed from the client when it loads the SDK. This can be empty. This value cannot be null.
Return
SandboxedSdk Returns a SandboxedSdk, passed back to the client. The IBinder used to create the SandboxedSdk object will be used by the client to call into the SDK. This value cannot be null.