SdkSandboxController

public class SdkSandboxController
extends Object

java.lang.Object
   ↳ android.app.sdksandbox.sdkprovider.SdkSandboxController


Controller that is used by SDK loaded in the sandbox to access information provided by the sdk sandbox.

It enables the SDK to communicate with other SDKS in the SDK sandbox and know about the state of the sdks that are currently loaded in it.

An instance of SdkSandboxController can be obtained using Context.getSystemService(Class) and class. The Context can in turn be obtained using SandboxedSdkProvider.getContext().

Summary

Constants

String SDK_SANDBOX_CONTROLLER_SERVICE

Public methods

List<AppOwnedSdkSandboxInterface> getAppOwnedSdkSandboxInterfaces()

Fetches all AppOwnedSdkSandboxInterface that are registered by the app.

String getClientPackageName()

Returns the package name of the client app.

SharedPreferences getClientSharedPreferences()

Returns SharedPreferences containing data synced from the client app.

List<SandboxedSdk> getSandboxedSdks()

Fetches information about Sdks that are loaded in the sandbox.

void loadSdk(String sdkName, Bundle params, Executor executor, OutcomeReceiver<SandboxedSdkLoadSdkException> receiver)

Loads SDK in an SDK sandbox java process.

IBinder registerSdkSandboxActivityHandler(SdkSandboxActivityHandler sdkSandboxActivityHandler)

Returns an identifier for a SdkSandboxActivityHandler after registering it.

void unregisterSdkSandboxActivityHandler(SdkSandboxActivityHandler sdkSandboxActivityHandler)

Unregister an already registered SdkSandboxActivityHandler.

Inherited methods

Constants

SDK_SANDBOX_CONTROLLER_SERVICE

public static final String SDK_SANDBOX_CONTROLLER_SERVICE

Constant Value: "sdk_sandbox_controller_service"

Public methods

getAppOwnedSdkSandboxInterfaces

public List<AppOwnedSdkSandboxInterface> getAppOwnedSdkSandboxInterfaces ()

Fetches all AppOwnedSdkSandboxInterface that are registered by the app.

Returns
List<AppOwnedSdkSandboxInterface> List of AppOwnedSdkSandboxInterface containing all currently registered AppOwnedSdkSandboxInterface. This value cannot be null.

Throws
UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

getClientPackageName

public String getClientPackageName ()

Returns the package name of the client app.

Returns
String This value cannot be null.

Throws
UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context.

getClientSharedPreferences

public SharedPreferences getClientSharedPreferences ()

Returns SharedPreferences containing data synced from the client app.

Keys that have been synced by the client app using SdkSandboxManager.addSyncedSharedPreferencesKeys(Set) can be found in this SharedPreferences.

The returned SharedPreferences should only be read. Writing to it is not supported.

Returns
SharedPreferences SharedPreferences containing data synced from client app. This value cannot be null.

Throws
UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

getSandboxedSdks

public List<SandboxedSdk> getSandboxedSdks ()

Fetches information about Sdks that are loaded in the sandbox.

Returns
List<SandboxedSdk> List of SandboxedSdk containing all currently loaded sdks This value cannot be null.

Throws
UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

loadSdk

public void loadSdk (String sdkName, 
                Bundle params, 
                Executor executor, 
                OutcomeReceiver<SandboxedSdkLoadSdkException> receiver)

Loads SDK in an SDK sandbox java process.

Loads SDK library with sdkName to an SDK sandbox process asynchronously. The caller will be notified through the receiver.

The caller may only load SDKs the client app depends on into the SDK sandbox.

Parameters
sdkName String: name of the SDK to be loaded. This value cannot be null.

params Bundle: additional parameters to be passed to the SDK in the form of a Bundle as agreed between the client and the SDK. This value cannot be null.

executor Executor: the Executor on which to invoke the receiver. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

receiver OutcomeReceiver: This either receives a SandboxedSdk on a successful run, or LoadSdkException. This value cannot be null.

Throws
UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

registerSdkSandboxActivityHandler

public IBinder registerSdkSandboxActivityHandler (SdkSandboxActivityHandler sdkSandboxActivityHandler)

Returns an identifier for a SdkSandboxActivityHandler after registering it.

This function registers an implementation of SdkSandboxActivityHandler created by an SDK and returns an IBinder which uniquely identifies the passed SdkSandboxActivityHandler object.

If the same SdkSandboxActivityHandler registered multiple times without unregistering, the same IBinder token will be returned.

Parameters
sdkSandboxActivityHandler SdkSandboxActivityHandler: is the SdkSandboxActivityHandler to register. This value cannot be null.

Returns
IBinder IBinder uniquely identify the passed SdkSandboxActivityHandler. This value cannot be null.

unregisterSdkSandboxActivityHandler

public void unregisterSdkSandboxActivityHandler (SdkSandboxActivityHandler sdkSandboxActivityHandler)

Unregister an already registered SdkSandboxActivityHandler.

If the passed SdkSandboxActivityHandler is registered, it will be unregistered. Otherwise, it will do nothing.

After unregistering, SDK can register the same handler object again or create a new one in case it wants a new Activity.

If the IBinder token of the unregistered handler used to start a Activity, the Activity will fail to start.

Parameters
sdkSandboxActivityHandler SdkSandboxActivityHandler: is the SdkSandboxActivityHandler to unregister. This value cannot be null.

Returns
void This value cannot be null.