ProtectedSignalsManager


public class ProtectedSignalsManager
extends Object

java.lang.Object
   ↳ android.adservices.signals.ProtectedSignalsManager


ProtectedSignalsManager provides APIs for apps and ad-SDKs to manage their protected signals.

Summary

Public methods

static ProtectedSignalsManager get(Context context)

Factory method for creating an instance of ProtectedSignalsManager.

void updateSignals(UpdateSignalsRequest updateSignalsRequest, Executor executor, OutcomeReceiver<ObjectException> receiver)

The updateSignals API will retrieve a JSON from the URI that describes which signals to add or remove.

Inherited methods

Public methods

get

public static ProtectedSignalsManager get (Context context)

Factory method for creating an instance of ProtectedSignalsManager.

Parameters
context Context: The Context to use This value cannot be null.

Returns
ProtectedSignalsManager A ProtectedSignalsManager instance This value cannot be null.

updateSignals

public void updateSignals (UpdateSignalsRequest updateSignalsRequest, 
                Executor executor, 
                OutcomeReceiver<ObjectException> receiver)

The updateSignals API will retrieve a JSON from the URI that describes which signals to add or remove. This API also allows registering the encoder endpoint. The endpoint is used to download an encoding logic, which enables encoding the signals.

The top level keys for the JSON must correspond to one of 5 commands:

"put" - Adds a new signal, overwriting any existing signals with the same key. The value for this is a JSON object where the keys are base 64 strings corresponding to the key to put for and the values are base 64 string corresponding to the value to put.

"append" - Appends a new signal/signals to a time series of signals, removing the oldest signals to make room for the new ones if the size of the series exceeds the given maximum. The value for this is a JSON object where the keys are base 64 strings corresponding to the key to append to and the values are objects with two fields: "values" and "maxSignals" . "values" is a list of base 64 strings corresponding to signal values to append to the time series. "maxSignals" is the maximum number of values that are allowed in this timeseries. If the current number of signals associated with the key exceeds maxSignals the oldest signals will be removed. Note that you can append to a key added by put. Not that appending more than the maximum number of values will cause a failure.

"put_if_not_present" - Adds a new signal only if there are no existing signals with the same key. The value for this is a JSON object where the keys are base 64 strings corresponding to the key to put for and the values are base 64 string corresponding to the value to put.

"remove" - Removes the signal for a key. The value of this is a list of base 64 strings corresponding to the keys of signals that should be deleted.

"update_encoder" - Provides an action to update the endpoint, and a URI which can be used to retrieve an encoding logic. The sub-key for providing an update action is "action" and the values currently supported are:

  1. "REGISTER" : Registers the encoder endpoint if provided for the first time or overwrites the existing one with the newly provided endpoint. Providing the "endpoint" is required for the "REGISTER" action.

The sub-key for providing an encoder endpoint is "endpoint" and the value is the URI string for the endpoint.

On success, the onResult method of the provided OutcomeReceiver will be called with an empty Object. This Object has no significance and is used merely as a placeholder.

Key may only be operated on by one command per JSON. If two command attempt to operate on the same key, this method will through an IllegalArgumentException

This call fails with an SecurityException if

  1. the ownerPackageName is not calling app's package name and/or
  2. the buyer is not authorized to use the API.

This call fails with an IllegalArgumentException if

  1. The JSON retrieved from the server is not valid.
  2. The provided URI is invalid.

This call fails with LimitExceededException if the calling package exceeds the allowed rate limits and is throttled.

This call fails with an IllegalStateException if an internal service error is encountered.
Requires AdServicesPermissions.ACCESS_ADSERVICES_PROTECTED_SIGNALS

Parameters
updateSignalsRequest UpdateSignalsRequest: This value cannot be null.

executor Executor: 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 value cannot be null.