您可以通过以下两种方法将设备配置为测试 Protected Audience API:使用 Privacy Sandbox 在 GitHub 上提供的 CLI 工具,或运行一系列 ADB 命令。
CLI 方法
您可以从此 GitHub 代码库拉取 CLI Python 脚本。按照 README 中的说明安装依赖项,并根据需要设置 .bashrc
。然后,您可以使用以下命令快速启用所有功能标志以进行测试:
run python3 main.py enable --disable-flag-push
或者,您也可以使用以下命令启用特定功能:
run python3 main.py enable --feature-name <feature name> --disable-flag-push
CLI 还提供许多其他功能,这些功能对调试 Protected Audience 和 Protected App Signals 用例非常有用,例如检查自定义受众群体数据、触发 Protected App Signals 的编码,以及收集要在对出价和竞价服务的测试请求中使用的设备端数据。
ADB 方法
在运行应用之前,您需要运行以下命令打开界面以启用 Privacy Sandbox:
adb shell am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity
界面弹出后,请务必切换所有开关以启用 Privacy Sandbox,然后运行以下 adb 命令以完成设备测试的设置:
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
运行这些命令后,您应该就能够开始成功调用 Protected Audience API。