PccSandboxManager
public
final
class
PccSandboxManager
extends Object
| java.lang.Object | |
| ↳ | android.app.privatecompute.PccSandboxManager |
Manager for interacting with the Private Compute Core (PCC) sandbox.
Summary
Public methods | |
|---|---|
<T extends EgressResponse>
void
|
egressData(EgressRequest<T> request, Executor executor, OutcomeReceiver<T, PccEgressException> callback)
Initiates an egress request from a PCC process. |
boolean
|
isPccTrustedSystemComponent(int uid, String packageName)
Returns whether the given package is considered a "Trusted System Component" by the framework. |
boolean
|
isPrivateComputeServicesUid(int uid)
Returns whether the given UID belongs to a Private Compute Services (PCS) package. |
void
|
startNonPccProcessForDataMigration(Executor executor, OutcomeReceiver<MigrationRequestResult, MigrationException> callback)
Requests the framework to start the non-PCC migration service of the calling application. |
void
|
writeToAuditLog(PersistableBundle data)
Writes data to the audit log, if audit mode is enabled. |
Inherited methods | |
|---|---|
Public methods
egressData
public void egressData (EgressRequest<T> request, Executor executor, OutcomeReceiver<T, PccEgressException> callback)
Initiates an egress request from a PCC process.
These requests may be subject to rate limits or user consent defined by the OS. For exact details refer to the exact sub-class of the EgressRequest.
| Parameters | |
|---|---|
request |
EgressRequest: The base EgressRequest containing the payload and use-case.
This value cannot be null. |
executor |
Executor: The Executor on which the callback should be invoked.
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. |
callback |
OutcomeReceiver: The callback to receive the EgressResponse containing the status.
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
If the request is invalid. |
IllegalStateException |
If the request cannot be processed due to the current state of the system (e.g. rate limit exceeded). |
NullPointerException |
If request, executor, or callback is
null. |
SecurityException |
If the calling UID is not running in a valid Private Compute Core sandbox or the underlying feature (such as Proactive Assistance) is disabled. |
isPccTrustedSystemComponent
public boolean isPccTrustedSystemComponent (int uid,
String packageName)Returns whether the given package is considered a "Trusted System Component" by the framework. This also includes Private Compute Services apps, which are an extension to the framework's trust boundary. Trusted System components are allowed two-way communication with the PCC components.
| Parameters | |
|---|---|
uid |
int: The UID of the application. |
packageName |
String: The package name of the application. This can be null when a single
packagename isn't available, e.g. for SYSTEM_UID. If non-null, this API checks whether
uid corresponds to packageName, and returns false if it doesn't. |
| Returns | |
|---|---|
boolean |
true if the app is a trusted system component, false otherwise. |
isPrivateComputeServicesUid
public boolean isPrivateComputeServicesUid (int uid)
Returns whether the given UID belongs to a Private Compute Services (PCS) package. These are
packages that hold the Manifest.permission.PROVIDE_PRIVATE_COMPUTE_SERVICES.
| Parameters | |
|---|---|
uid |
int: The UID to check. |
| Returns | |
|---|---|
boolean |
true if the UID belongs to a PCS package, false otherwise. |
startNonPccProcessForDataMigration
public void startNonPccProcessForDataMigration (Executor executor, OutcomeReceiver<MigrationRequestResult, MigrationException> callback)
Requests the framework to start the non-PCC migration service of the calling application.
This is intended for PCC components to trigger a process outside the PCC sandbox to
perform tasks like data migration. The system will look for a service extending DataMigrationToPccService in the application's manifest that is not marked as a PCC
component. If found, the non-PCC process is started and the service is invoked.
If the non-PCC process is already running, this ensures the migration service is
triggered. System unbinds from the service either when the service indicates it has
accepted/rejected the request, or failing that, after a timeout of DataMigrationToPccService.MIGRATION_TIMEOUT_MS.
| Parameters | |
|---|---|
executor |
Executor: The executor on which the callback will be invoked.
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. |
callback |
OutcomeReceiver: The callback to receive the result of the migration request.
This value cannot be null. |
writeToAuditLog
public void writeToAuditLog (PersistableBundle data)
Writes data to the audit log, if audit mode is enabled. Otherwise, does nothing.
Nested Bundles are supported up to a depth of 100.
| Parameters | |
|---|---|
data |
PersistableBundle: The data to write to the audit log.
This value cannot be null. |