SdkSandboxManager
public
final
class
SdkSandboxManager
extends Object
java.lang.Object | |
↳ | android.app.sdksandbox.SdkSandboxManager |
Provides APIs to load SDKs
into SDK sandbox process, and then interact with them.
SdkSandbox
is a java process running in a separate uid range. Each app has its own
SDK sandbox process.
First app needs to declare SDKs
it depends on in it's AndroidManifest.xml
using <uses-sdk-library>
tag. App can only load SDKs
it depends on into the
SdkSandbox
.
Note: All APIs defined in this class are not stable and subject to change.
Summary
Nested classes | |
---|---|
interface |
SdkSandboxManager.RemoteSdkCallback
A callback for tracking events regarding loading and interacting with SDKs. |
Constants | |
---|---|
int |
LOAD_SDK_ALREADY_LOADED
SDK is already loaded. |
int |
LOAD_SDK_INTERNAL_ERROR
Internal error while loading SDK. |
int |
LOAD_SDK_NOT_FOUND
SDK not found. |
int |
REQUEST_SURFACE_PACKAGE_INTERNAL_ERROR
Internal error while requesting a |
String |
SDK_SANDBOX_SERVICE
Use with |
int |
SDK_SANDBOX_STATE_DISABLED
SDK Sandbox is disabled. |
int |
SDK_SANDBOX_STATE_ENABLED_PROCESS_ISOLATION
SDK Sandbox is enabled. |
Public methods | |
---|---|
static
int
|
getSdkSandboxState()
Returns current state of the |
void
|
loadSdk(String sdkName, Bundle params, Executor callbackExecutor, SdkSandboxManager.RemoteSdkCallback callback)
Load SDK in a SDK sandbox java process. |
void
|
requestSurfacePackage(String sdkName, int displayId, int width, int height, Bundle params)
Send a request for a surface package to the sdk. |
Inherited methods | |
---|---|
Constants
LOAD_SDK_ALREADY_LOADED
public static final int LOAD_SDK_ALREADY_LOADED
SDK is already loaded.
This indicates that client application tried to reload the same SDk by calling
SdkSandboxManager#loadSdk(String, Bundle, Executor, RemoteSdkCallback)
after being successfully loaded.
Constant Value: 101 (0x00000065)
LOAD_SDK_INTERNAL_ERROR
public static final int LOAD_SDK_INTERNAL_ERROR
Internal error while loading SDK.
This indicates a generic internal error happened while applying the call from client application.
Constant Value: 500 (0x000001f4)
LOAD_SDK_NOT_FOUND
public static final int LOAD_SDK_NOT_FOUND
SDK not found.
This indicates that client application tried to load a non-existing SDK by calling
SdkSandboxManager#loadSdk(String, Bundle, Executor, RemoteSdkCallback)
.
Constant Value: 100 (0x00000064)
REQUEST_SURFACE_PACKAGE_INTERNAL_ERROR
public static final int REQUEST_SURFACE_PACKAGE_INTERNAL_ERROR
Internal error while requesting a SurfacePackage
.
This indicates a generic internal error happened while requesting a
SurfacePackage
.
Constant Value: 700 (0x000002bc)
SDK_SANDBOX_SERVICE
public static final String SDK_SANDBOX_SERVICE
Use with Context#getSystemService(String)
to retrieve a SdkSandboxManager
for
interacting with the SDKs belonging to this client application.
Constant Value: "sdk_sandbox"
SDK_SANDBOX_STATE_DISABLED
public static final int SDK_SANDBOX_STATE_DISABLED
SDK Sandbox is disabled.
SdkSandboxManager
APIs are hidden. Attempts at calling them will result in
UnsupportedOperationException
.
Constant Value: 0 (0x00000000)
SDK_SANDBOX_STATE_ENABLED_PROCESS_ISOLATION
public static final int SDK_SANDBOX_STATE_ENABLED_PROCESS_ISOLATION
SDK Sandbox is enabled.
App can use SdkSandboxManager
APIs to load SDKs
it depends on into the
corresponding SdkSandbox
process.
Constant Value: 2 (0x00000002)
Public methods
getSdkSandboxState
public static int getSdkSandboxState ()
Returns current state of the SdkSandbox
.
Returns | |
---|---|
int |
Value is SDK_SANDBOX_STATE_DISABLED , or SDK_SANDBOX_STATE_ENABLED_PROCESS_ISOLATION |
loadSdk
public void loadSdk (String sdkName, Bundle params, Executor callbackExecutor, SdkSandboxManager.RemoteSdkCallback callback)
Load SDK in a SDK sandbox java process.
It loads SDK library with sdkName
to a sandbox process
asynchronously, caller should be notified through
RemoteSdkCallback
callback
.
App should already declare SDKs
it depends on in its AndroidManifest
using <use-sdk-library>
tag. App can only load SDKs
it depends on into
the SdkSandbox
.
When client application loads the first SDK, a new SdkSandbox
process
will be created, otherwise other SDKs will be loaded into the same sandbox which
already created for the client application.
Parameters | |
---|---|
sdkName |
String : name of the SDK to be loaded
This value cannot be null . |
params |
Bundle : the parameters App passes to SDK
This value cannot be null . |
callbackExecutor |
Executor : the Executor on which to invoke the callback
This value cannot be null .
|
callback |
SdkSandboxManager.RemoteSdkCallback : the RemoteSdkCallback which will receive events from
loading and interacting with SDKs
This value cannot be null . |
requestSurfacePackage
public void requestSurfacePackage (String sdkName, int displayId, int width, int height, Bundle params)
Send a request for a surface package to the sdk.
After client application receives a signal about a successful SDK loading
by RemoteSdkCallback#onLoadSdkSuccess(Bundle)
,
it is then able to asynchronously request a SurfacePackage
to render view from SDK.
The requested SurfacePackage
is returned to client application through
RemoteSdkCallback#onSurfacePackageReady(SurfacePackage, int, Bundle)
.
Parameters | |
---|---|
sdkName |
String : name of the SDK loaded into sdk sandbox
This value cannot be null . |
displayId |
int : the id of the logical display to display the surface package |
width |
int : the width of the surface package |
height |
int : the height of the surface package |
params |
Bundle : the parameters which client application passes to SDK
This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-05-18 UTC.