SdkSandboxController


open class SdkSandboxController
kotlin.Any
   ↳ 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 android.content.Context#getSystemService and class. The Context can in turn be obtained using android.app.sdksandbox.SandboxedSdkProvider#getContext().

Summary

Constants
static String

Public methods
open MutableList<AppOwnedSdkSandboxInterface!>

Fetches all AppOwnedSdkSandboxInterface that are registered by the app.

open String

Returns the package name of the client app.

open SharedPreferences

Returns SharedPreferences containing data synced from the client app.

open MutableList<SandboxedSdk!>

Fetches information about Sdks that are loaded in the sandbox.

open Unit
loadSdk(sdkName: String, params: Bundle, executor: Executor, receiver: OutcomeReceiver<SandboxedSdk!, LoadSdkException!>)

Loads SDK in an SDK sandbox java process.

open IBinder

Returns an identifier for a SdkSandboxActivityHandler after registering it.

open Unit

Unregister an already registered SdkSandboxActivityHandler.

Constants

SDK_SANDBOX_CONTROLLER_SERVICE

static val SDK_SANDBOX_CONTROLLER_SERVICE: String
Value: "sdk_sandbox_controller_service"

Public methods

getAppOwnedSdkSandboxInterfaces

open fun getAppOwnedSdkSandboxInterfaces(): MutableList<AppOwnedSdkSandboxInterface!>

Fetches all AppOwnedSdkSandboxInterface that are registered by the app.

Return
MutableList<AppOwnedSdkSandboxInterface!> List of AppOwnedSdkSandboxInterface containing all currently registered AppOwnedSdkSandboxInterface. This value cannot be null.
Exceptions
java.lang.UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

getClientPackageName

open fun getClientPackageName(): String

Returns the package name of the client app.

Return
String This value cannot be null.
Exceptions
java.lang.UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context.

getClientSharedPreferences

open fun getClientSharedPreferences(): SharedPreferences

Returns SharedPreferences containing data synced from the client app.

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

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

Return
SharedPreferences SharedPreferences containing data synced from client app. This value cannot be null.
Exceptions
java.lang.UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

getSandboxedSdks

open fun getSandboxedSdks(): MutableList<SandboxedSdk!>

Fetches information about Sdks that are loaded in the sandbox.

Return
MutableList<SandboxedSdk!> List of SandboxedSdk containing all currently loaded sdks This value cannot be null.
Exceptions
java.lang.UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

loadSdk

open fun loadSdk(
    sdkName: String,
    params: Bundle,
    executor: Executor,
    receiver: OutcomeReceiver<SandboxedSdk!, LoadSdkException!>
): Unit

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<SandboxedSdk!, LoadSdkException!>: This either receives a SandboxedSdk on a successful run, or LoadSdkException. This value cannot be null.
Exceptions
java.lang.UnsupportedOperationException if the controller is obtained from an unexpected context. Use SandboxedSdkProvider#getContext() for the right context

registerSdkSandboxActivityHandler

open fun registerSdkSandboxActivityHandler(sdkSandboxActivityHandler: SdkSandboxActivityHandler): IBinder

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.
Return
IBinder IBinder uniquely identify the passed SdkSandboxActivityHandler. This value cannot be null.

unregisterSdkSandboxActivityHandler

open fun unregisterSdkSandboxActivityHandler(sdkSandboxActivityHandler: SdkSandboxActivityHandler): Unit

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.
Return
Unit This value cannot be null.