Inspect custom audiences on the command line

Protected Audience provides a series of APIs for joining and leaving custom audiences as part of the android.adservices.customaudience package. For debugging purposes there are CLI commands available for listing and viewing custom audiences. This guide outlines the steps ad tech developers need to follow to inspect the state of their joined custom audiences.

Setup

For security and privacy reasons, custom audiences are not visible by default and can only be directly inspected for debugging purposes. They are only visible using these commands if the following requirements are true:

  • System-wide developer options are enabled
  • android:debuggable="true" is declared in the AndroidManifest.xml file of the app where the CustomAudience was joined from (using joinCustomAudience or fetchAndJoinCustomAudience)
  • Consent for app-suggested ads is toggled on

Enable adservices shell commands

  1. Restart your device to terminate the adservices process.
  2. Confirm adservices is not running. Empty output is expected for the following command.
adb shell ps -A | grep adservices

Then, to enable adservices shell commands, run the following commands:

adb shell setprop debug.adservices.adservices_shell_command_enabled true
adb shell setprop debug.adservices.fledge_is_custom_audience_cli_enabled true

List custom audiences

To view a specific custom audience, run the following command specifying the owner as the package that created the audience and the buyer as the identifier for the ad network that manages the audience:

adb shell cmd adservices_manager custom-audience list --owner <owner> --buyer <buyer>

The output will be a JSON object containing an array custom_audiences. The structure of the elements within this array match the output of the view custom audience command described next.

View a specific custom audience

To view a specific custom audience, run the following command specifying the owner as the package that created the audience, the buyer as the identifier for the ad network that manages the audience, and the name as the name of the audience:

adb shell cmd adservices_manager custom-audience view --owner <owner> --buyer <buyer> --name <name>

Refresh a specific custom audience

To view trigger daily update manually for a specific custom audience run the following command specifying the owner as the package that created the audience, the buyer as the identifier for the ad network that manages the audience, and the name as the name of the audience:

adb shell cmd adservices_manager custom-audience refresh --owner <owner> --buyer <buyer> --name <name>
> Successfully updated custom audience.