Menyiapkan pengujian untuk Protected Audience API

Ada dua metode untuk mengonfigurasi perangkat Anda guna menguji Protected Audience API - dengan menggunakan alat CLI yang disediakan Privacy Sandbox di GitHub, atau dengan menjalankan serangkaian perintah ADB.

Metode CLI

Anda dapat mengambil skrip Python CLI dari repositori GitHub ini. Ikuti petunjuk di README untuk menginstal dependensi dan menyiapkan .bashrc secara opsional. Kemudian, Anda dapat dengan cepat mengaktifkan semua flag fitur untuk pengujian dengan perintah berikut:

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

Atau, Anda dapat mengaktifkan fitur tertentu dengan perintah berikut:

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

CLI juga menawarkan banyak fitur lain yang berguna untuk men-debug kasus penggunaan Protected Audience dan Protected App Signals, seperti memeriksa data audiens kustom, memicu encoding untuk Protected App Signals, dan mengumpulkan data di perangkat untuk digunakan dalam permintaan pengujian ke layanan Bidding dan Lelang.

Metode ADB

Sebelum menjalankan aplikasi, Anda harus menjalankan perintah berikut untuk membuka UI guna mengaktifkan Privacy Sandbox:

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

Setelah UI muncul, pastikan Anda mengalihkan semua tombol untuk mengaktifkan Privacy Sandbox, lalu jalankan perintah ADB berikut untuk menyelesaikan penyiapan perangkat untuk pengujian:

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

Setelah menjalankan perintah ini, Anda seharusnya dapat mulai berhasil melakukan panggilan ke Protected Audience API.