There are two methods for configuring your device for testing the Protected Audience API - by using a CLI tool that Privacy Sandbox provides on GitHub, or by running a series of ADB commands.
CLI method
You can pull the CLI Python scripts from this GitHub repository. Follow the
instructions in the README for installing the dependencies and optionally
setting up your .bashrc
. You can then quickly enable all feature flags for
testing with the following command:
run python3 main.py enable --disable-flag-push
Or you can enable a specific feature with the following command:
run python3 main.py enable --feature-name <feature name> --disable-flag-push
The CLI also offers many other features useful for debugging Protected Audience and Protected App signal use cases, such as inspecting custom audience data, triggering encoding for Protected App Signals, and collecting the on device data to be used in a test request to Bidding and Auction services.
ADB method
Before running your app, you will need to run the following command to open up the UI to enable the Privacy Sandbox:
adb shell am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity
Once the UI pops up, make sure that you toggle all switches to enable the Privacy Sandbox, then run the following ADB commands to finish setting up the device for testing:
adb shell setprop debug.adservices.global_kill_switch false
adb shell setprop debug.adservices.fledge_custom_audience_service_kill_switch false
adb shell setprop debug.adservices.fledge_select_ads_kill_switch false
adb shell setprop debug.adservices.adid_kill_switch false
adb shell setprop debug.adservices.fledge_auction_server_kill_switch false
adb shell setprop debug.adservices.fledge_on_device_auction_kill_switch false
adb shell device_config put adservices adservice_system_service_enabled true
adb shell setprop debug.adservices.disable_fledge_enrollment_check true
adb shell setprop debug.adservices.consent_manager_debug_mode true
adb shell setprop debug.adservices.consent_notification_debug_mode true
adb shell setprop debug.adservices.adservices_shell_command_enabled true
adb shell setprop debug.adservices.fledge_is_ad_selection_cli_enabled true
adb shell setprop debug.adservices.fledge_is_consented_debugging_cli_enabled true
adb shell setprop debug.adservices.fledge_auction_server_consented_debugging_enabled true
adb shell setprop debug.adservices.ad_services_js_isolate_console_messages_in_logs_enabled true
adb shell setprop debug.adservices.fledge_is_custom_audience_cli_enabled true
adb shell setprop debug.adservices.fledge_is_app_signals_cli_enabled true
adb shell device_config put adservices ppapi_app_allow_list \"\*\"
adb shell device_config put adservices pas_app_allow_list \"\*\"
adb shell device_config put adservices fledge_app_install_filtering_enabled true
adb shell device_config put adservices fledge_frequency_cap_filtering_enabled true
adb shell device_config put adservices fledge_fetch_custom_audience_enabled true
adb shell device_config put adservices fledge_schedule_custom_audience_update_enabled true
adb shell device_config put adservices protected_signals_enabled true
adb shell device_config put adservices protected_signals_periodic_encoding_enabled true
adb shell device_config put adservices fledge_ad_selection_ad_selection_prebuilt_uri_enabled true
adb shell device_config put adservices fledge_http_cache_enable_js_caching false
adb shell device_config put adservices fledge_event_level_debug_reporting_enabled true
adb shell device_config put adservices fledge_event_level_debug_report_send_immediately true
adb shell device_config put adservices fledge_ad_selection_contextual_ads_enabled true
adb shell device_config put adservices fledge_auction_server_enabled true
adb shell device_config put adservices fledge_auction_server_enabled_for_report_impression true
adb shell device_config put adservices fledge_auction_server_enabled_for_report_event true
adb shell device_config put adservices fledge_auction_server_enabled_for_update_histogram true
adb shell device_config put adservices fledge_auction_server_enabled_for_select_ads_mediation true
adb shell device_config put adservices fledge_auction_server_ad_render_id_enabled true
adb shell device_config put adservices fledge_auction_server_multi_cloud_enabled true
adb shell device_config put adservices fledge_auction_server_omit_ads_enabled true
adb shell device_config put adservices fledge_auction_server_request_flags_enabled true
adb shell device_config put adservices fledge_get_ad_selection_data_seller_configuration_enabled true
adb shell device_config put adservices fledge_register_ad_beacon_enabled true
adb shell device_config put adservices fledge_cpc_billing_enabled true
adb shell device_config put adservices fledge_data_version_header_enabled true
adb shell device_config put adservices fledge_measurement_report_and_register_event_api_enabled true
adb shell device_config put adservices fledge_kanon_sign_join_enabled true
adb shell device_config put adservices fledge_kanon_sign_join_on_device_auction_enabled true
adb shell device_config put adservices fledge_kanon_sign_join_auction_server_enabled true
adb shell device_config put adservices fledge_kanon_background_process_enabled true
adb shell device_config put adservices fledge_kanon_key_attestation_enabled true
adb shell device_config put adservices fledge_ad_selection_ad_selection_prebuilt_uri_enabled true
adb shell device_config put adservices fledge_event_level_debug_reporting_enabled true
adb shell device_config put adservices fledge_event_level_debug_report_send_immediately true
adb shell device_config put adservices fledge_ad_selection_contextual_ads_enabled true
adb shell device_config set_sync_disabled_for_tests none
adb shell setprop log.tag.adservices VERBOSE
adb shell setprop log.tag.adservices.fledge VERBOSE
adb shell setprop log.tag.adservices.measurement VERBOSE
adb shell setprop log.tag.adservices.topics VERBOSE
adb shell setprop log.tag.adservices.kanon VERBOSE
adb shell setprop log.tag.AdServicesShellCmd VERBOSE
adb shell setprop log.tag.FledgeSample VERBOSE
Once you've run these commands, you should be able to start successfully making calls to the Protected Audience API.