Stay organized with collections Save and categorize content based on your preferences.

SandboxedSdkProvider

public abstract class SandboxedSdkProvider
extends Object

java.lang.Object
   ↳ 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.

Note: All APIs defined in this class are not stable and subject to change.

Summary

Nested classes

interface SandboxedSdkProvider.DataReceivedCallback

Callback for tracking the status of data received from the client application. 

Public constructors

SandboxedSdkProvider()

Public methods

final void attachContext(Context context)

Sets the SDK Context which can then be received using getContext().

void beforeUnloadSdk()

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

Context getContext()

Return the Context previously set through SandboxedSdkProvider#attachContext.

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

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

abstract void onDataReceived(Bundle data, SandboxedSdkProvider.DataReceivedCallback callback)

Called when data sent from the app is received by an SDK.

abstract SandboxedSdk onLoadSdk(Bundle params)

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

Inherited methods

Public constructors

SandboxedSdkProvider

public SandboxedSdkProvider ()

Public methods

attachContext

public final void attachContext (Context context)

Sets the SDK Context which can then be received using getContext(). This is called before onLoadSdk(Bundle) 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

public void beforeUnloadSdk ()

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 SandboxedSdk.getInterface().

getContext

public Context getContext ()

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

Returns
Context

getView

public abstract View getView (Context windowContext, 
                Bundle params, 
                int width, 
                int height)

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.

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.

Returns
View a View which SDK sandbox pass to the client application requesting the view This value cannot be null.

onDataReceived

public abstract void onDataReceived (Bundle data, 
                SandboxedSdkProvider.DataReceivedCallback callback)

Called when data sent from the app is received by an SDK.

Parameters
data Bundle: the data sent by the app. This value cannot be null.

callback SandboxedSdkProvider.DataReceivedCallback: to notify the app if the data has been successfully received. This value cannot be null.

onLoadSdk

public abstract SandboxedSdk onLoadSdk (Bundle params)

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 include the initialization logic 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.

Returns
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.

Throws
LoadSdkException