ProtectedSignalsManager


public abstract class ProtectedSignalsManager


This class provides APIs for app and ad-SDKs to join / leave custom audiences.

Summary

Public methods

static final ProtectedSignalsManager

Creates ProtectedSignalsManager.

abstract void

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

Public methods

obtain

Added in 1.1.0-beta11
@ExperimentalFeatures.Ext12OptIn
public static final ProtectedSignalsManager obtain(@NonNull Context context)

Creates ProtectedSignalsManager.

Returns
ProtectedSignalsManager

ProtectedSignalsManager object. If the device is running an incompatible build, the value returned is null.

updateSignals

Added in 1.1.0-beta11
@ExperimentalFeatures.Ext12OptIn
@RequiresPermission
public abstract void updateSignals(@NonNull UpdateSignalsRequest request)

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.

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 {@link IllegalArgumentException}

This call fails with an {@link SecurityException} if

  1. the {@code 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 {@link IllegalArgumentException} if

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

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

This call fails with an {@link IllegalStateException} if an internal service error is encountered.