Configuración de pruebas para las APIs de Protected Audience

Existen dos métodos para configurar tu dispositivo y probar la API de Protected Audience: con una herramienta de CLI que Privacy Sandbox proporciona en GitHub o con la ejecución de una serie de comandos de ADB.

Método de CLI

Puedes extraer las secuencias de comandos de Python de la CLI de este repositorio de GitHub. Sigue las instrucciones del archivo README para instalar las dependencias y, de manera opcional, configurar tu .bashrc. Luego, puedes habilitar rápidamente todas las marcas de funciones para pruebas con el siguiente comando:

run python3 main.py enable --disable-flag-push

También puedes habilitar una función específica con el siguiente comando:

run python3 main.py enable --feature-name <feature name> --disable-flag-push

La CLI también ofrece muchas otras funciones útiles para depurar casos de uso de Protected Audience y Protected App Signal, como inspeccionar los datos del público personalizado, activar la codificación de los indicadores de apps protegidos y recopilar los datos en el dispositivo que se usarán en una solicitud de prueba a los servicios de ofertas y subastas.

Método ADB

Antes de ejecutar tu app, deberás ejecutar el siguiente comando para abrir la IU y habilitar Privacy Sandbox:

adb shell am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity

Una vez que aparezca la IU, asegúrate de activar todos los interruptores para habilitar Privacy Sandbox y, luego, ejecuta los siguientes comandos de ADB para terminar de configurar el dispositivo para las pruebas:

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

Una vez que ejecutes estos comandos, deberías poder comenzar a realizar, de forma correcta, llamadas a la API de Protected Audience.