android / privacy-sandbox-samples

Apache License 2.0
130 stars 52 forks source link

Getting Error Could not find job 14 while try to run jobscheduler run -f com.google.android.adservices.api 14 #76

Closed asifrahiman closed 6 months ago

asifrahiman commented 1 year ago

Hi Team, I am trying to set up privacy sandbox in emulater and facing issue

asifabdulrahiman@Affle-Macbook-77 MeasurementSampleApp % adb shell cmd jobscheduler run -f com.google.android.adservices.api 14 Could not find job 14 in package com.google.android.adservices.api / user 0

This also happens for any other job forced run as well

Please find the emulator details: Properties avd.ini.displayname UpsideDownCakePrivacySandbox avd.ini.encoding UTF-8 AvdId UpsideDownCakePrivacySandbox disk.dataPartition.size 6442450944 fastboot.chosenSnapshotFile fastboot.forceChosenSnapshotBoot no fastboot.forceColdBoot no fastboot.forceFastBoot yes hw.accelerometer yes hw.arc false hw.audioInput yes hw.battery yes hw.camera.back virtualscene hw.camera.front emulated hw.cpu.ncore 4 hw.device.hash2 MD5:3db3250dab5d0d93b29353040181c7e9 hw.device.manufacturer Generic hw.device.name medium_phone hw.dPad no hw.gps yes hw.gpu.enabled yes hw.gpu.mode auto hw.initialOrientation Portrait hw.keyboard yes hw.lcd.density 420 hw.lcd.height 2400 hw.lcd.width 1080 hw.mainKeys no hw.ramSize 2048 hw.sdCard yes hw.sensors.orientation yes hw.sensors.proximity yes hw.trackBall no image.androidVersion.api 33 image.androidVersion.codename UpsideDownCakePrivacySandbox image.sysdir.1 system-images/android-UpsideDownCakePrivacySandbox/google_apis_playstore/arm64-v8a/ PlayStore.enabled true runtime.network.latency none runtime.network.speed full showDeviceFrame no skin.dynamic yes skin.path.backup _no_skin tag.display Google Play tag.id google_apis_playstore vm.heapSize 228

I am running below commands to set up the emulator: am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity device_config put adservices ppapi_app_allow_list "" device_config put adservices ppapi_app_signature_allow_list "" device_config put adservices adservice_system_service_enabled true device_config put adservices adservice_enabled true device_config put adservices adservice_enable_status true device_config put adservices global_kill_switch false device_config put adservices disable_sdk_sandbox false device_config put adservices fledge_js_isolate_enforce_max_heap_size false setprop debug.adservices.disable_fledge_enrollment_check true cmd sdk_sandbox set-state --enabled device_config put adservices mdd_measurement_manifest_file_url "https://www.gstatic.com/mdi-serving/rubidium-adservices-adtech-enrollment/1450/48d1f12448dd1c9f8f11d4d8e78f2143f74076cb" cmd jobscheduler run -f com.google.android.adservices.api 14`

cshmerling commented 1 year ago

Just to confirm- after running am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity are you clicking the toggle to enable the Privacy Sandbox? Asking because this error can happen if the Sandbox is not enabled.

asifrahiman commented 1 year ago

Hi Chris,

Yes, we are enabling privacy sandbox toggle button before proceeding to the reminder of the commands.

On Tue, 25 Jul, 2023, 9:29 pm Chris Shmerling, @.***> wrote:

Just to confirm- after running am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity are you clicking the toggle to enable the Privacy Sandbox? Asking because this error can happen if the Sandbox is not enabled.

— Reply to this email directly, view it on GitHub https://github.com/android/privacy-sandbox-samples/issues/76#issuecomment-1650113066, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELBZERJLVQCM4RTWR2XXO3XR7UO5ANCNFSM6AAAAAA2VTOL7Y . You are receiving this because you authored the thread.Message ID: @.***>

cshmerling commented 1 year ago

Thanks for confirming. I know of a few more steps to resolve this issue:

  1. Make sure you are calling one of the PPAPIs before trying to trigger the job (so any call to Topics, Measurement, or Protected Audience APIs). This is expected to fail, but does play a part in warming the job up.
  2. Update your play store with the following steps: 2a. Log into your device or emulator with your Google account. 2b. Go to Google Play Store > profile icon > Settings > About. Under the Play Store version heading, tap Update Play Store.

After these steps, you should be able to invoke the job. If not, let me know and I can see if there is anything else missing from your setup.

asifrahiman commented 1 year ago

Hi, The step number 2 of the above response helped solve the issue, Thanks. However we are facing one more hurdle. Wrt MeasurementSampleApp After setting url we are able to send source and trigger events to server. However we are facing issue with reporting. We have forced the reporting jobs using the commands

emu64a:/ $ cmd jobscheduler run -f com.google.android.adservices.api 5
emu64a:/ $ cmd jobscheduler run -f com.google.android.adservices.api 7
emu64a:/ $ cmd jobscheduler run -f com.google.android.adservices.api 3

We have also set the time to 3 days later and triggered the above jobs But the report saving urls are not triggered from app.

We have verified the url of reporting and its same as the one given during the enrolment process. Could you help us in figuring out why the reporting jobs are not triggered?

We did find the below errors in the logcat :

2023-07-30 16:38:37.592 6593-17241 adservices com.google.android.adservices.api E Failed to get registration response: java.net.ConnectException: Failed to connect to /127.0.0.1:8080 2023-07-27 16:45:15.924 6593-6653 adservices com.google.android.adservices.api E Failed to get registration response: java.net.ConnectException: Failed to connect to /127.0.0.1:8080

asifrahiman commented 1 year ago

Hi @cshmerling, Were you able to check on the above query?

cshmerling commented 1 year ago

Thanks for your patience. I've tried looking in to this issue, but have not come up with an adequate resolution. Flagging @erintwalsh who knows more about Measurement/ARA

erintwalsh commented 1 year ago

hi @asifrahiman, would you mind reproducing the error and then running adb bugreport, and attaching the file? Thank you!

asifrahiman commented 1 year ago

Hi @erintwalsh, Issue here is that we are not receiving the event-report and aggregate-report requests which i believe is sent internally. The only way we could trigger there was force running jobs, event after which we are not receiving the requests. We are not sure how we can reproduce this scenario. There are no direct errors which are visible. Only one which seemed remotely close is as below.

2023-07-30 16:38:37.592 6593-17241 adservices com.google.android.adservices.api E Failed to get registration response: java.net.ConnectException: Failed to connect to /127.0.0.1:8080 2023-07-27 16:45:15.924 6593-6653 adservices com.google.android.adservices.api E Failed to get registration response: java.net.ConnectException: Failed to connect to /127.0.0.1:8080

if we just need to trigger the jobs and then get a adb bugreport i will share it here. bugreport-sdk_gphone64_arm64-URA8.230510.004-2023-08-07-12-25-49.zip

erintwalsh commented 1 year ago

@asifrahiman thanks for your response! It looks like the error is that you're trying to use a localhost for your server. The Attribution API is not allowed to connect to a localhost; I would recommend hosting your endpoint on the cloud or elsewhere and then calling it with registerSource and registerTrigger.

asifrahiman commented 1 year ago

Hi @erintwalsh We have set the url as https://psb.atomex.net and set up a MeasurementAdTechServer to handle the requests. We are recieving source and trigger requests in the server. We are only facing issue with event-report and aggregate-report.

asifrahiman commented 1 year ago

hi @erintwalsh @cshmerling Any update on the above?

erintwalsh commented 1 year ago

hi @asifrahiman,

Try running this command after you call each registerSource and registerTrigger:

For Tiramisu (API level 33) ext 5 and below:

adb shell cmd jobscheduler run -f com.google.android.adservices.api 15

For UpsideDownCake (API level 34) and above:

adb shell cmd jobscheduler run -f com.google.android.adservices.api 20

then follow each other step (run jobscheduler command 5, then set date and time forward, then jobscheduler command 3 and 7) afterwards

asifrahiman commented 1 year ago

Hi @erintwalsh, It seems to have worked in sending the aggregate-report url but issue still remains.

The steps i did was as follows.

  1. Executed register click event with source registration id 1 and executed - adb shell cmd jobscheduler run -f com.google.android.adservices.api 20
  2. Executed register view event with source registration id 1 and executed - adb shell cmd jobscheduler run -f com.google.android.adservices.api 20
  3. Executed register trigger with conversion registration id 1 and executed - adb shell cmd jobscheduler run -f com.google.android.adservices.api 20
  4. run adb shell cmd jobscheduler run -f com.google.android.adservices.api 5
  5. updated date by 3 days
  6. run adb shell cmd jobscheduler run -f com.google.android.adservices.api 3
  7. run adb shell cmd jobscheduler run -f com.google.android.adservices.api 7

These are the total requests received at the server

  1. 2023-08-18 05:56:22.735 DEBUG 2678366 --- [nio-8111-exec-2] o.s.w.f.CommonsRequestLoggingFilter : Before request [POST /attribution_source?ad_id=1, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"0", user-agent:"", attribution-reporting-source-info:"EVENT", accept-encoding:"gzip", Content-Type:"application/x-www-form-urlencoded;charset=UTF-8"]] 2023-08-18 05:56:22.739 DEBUG 2678366 --- [nio-8111-exec-2] o.s.w.f.CommonsRequestLoggingFilter : After request [POST /attribution_source?ad_id=1, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"0", user-agent:"", attribution-reporting-source-info:"EVENT", accept-encoding:"gzip", Content-Type:"application/x-www-form-urlencoded;charset=UTF-8"], payload=ad_id=1]
  2. 2023-08-18 05:56:23.051 DEBUG 2678366 --- [nio-8111-exec-3] o.s.w.f.CommonsRequestLoggingFilter : Before request [POST /attribution_source?ad_id=1, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"0", user-agent:"", attribution-reporting-source-info:"NAVIGATION", accept-encoding:"gzip", Content-Type:"application/x-www-form-urlencoded;charset=UTF-8"]] 2023-08-18 05:56:23.055 DEBUG 2678366 --- [nio-8111-exec-3] o.s.w.f.CommonsRequestLoggingFilter : After request [POST /attribution_source?ad_id=1, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"0", user-agent:"", attribution-reporting-source-info:"NAVIGATION", accept-encoding:"gzip", Content-Type:"application/x-www-form-urlencoded;charset=UTF-8"], payload=ad_id=1]
  3. 2023-08-18 05:56:32.857 DEBUG 2678366 --- [nio-8111-exec-5] o.s.w.f.CommonsRequestLoggingFilter : Before request [POST /attribution_trigger?conv_id=1, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"0", user-agent:"", accept-encoding:"gzip", Content-Type:"application/x-www-form-urlencoded;charset=UTF-8"]] 2023-08-18 05:56:32.861 DEBUG 2678366 --- [nio-8111-exec-5] o.s.w.f.CommonsRequestLoggingFilter : After request [POST /attribution_trigger?conv_id=1, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"0", user-agent:"", accept-encoding:"gzip", Content-Type:"application/x-www-form-urlencoded;charset=UTF-8"], payload=conv_id=1]
  4. 2023-08-18 05:56:36.863 DEBUG 2678366 --- [nio-8111-exec-4] o.s.w.f.CommonsRequestLoggingFilter : Before request [POST /.well-known/attribution-reporting/debug/report-event-attribution, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"297", user-agent:"", origin:"null", accept-encoding:"gzip", Content-Type:"application/json;charset=UTF-8"]] 2023-08-18 05:56:36.866 DEBUG 2678366 --- [nio-8111-exec-4] o.s.w.f.CommonsRequestLoggingFilter : After request [POST /.well-known/attribution-reporting/debug/report-event-attribution, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"297", user-agent:"", origin:"null", accept-encoding:"gzip", Content-Type:"application/json;charset=UTF-8"]]
  5. 2023-08-18 05:56:37.946 DEBUG 2678366 --- [nio-8111-exec-6] o.s.w.f.CommonsRequestLoggingFilter : Before request [POST /.well-known/attribution-reporting/debug/report-event-attribution, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"297", user-agent:"", origin:"null", accept-encoding:"gzip", Content-Type:"application/json;charset=UTF-8"]] 2023-08-18 05:56:37.947 DEBUG 2678366 --- [nio-8111-exec-6] o.s.w.f.CommonsRequestLoggingFilter : After request [POST /.well-known/attribution-reporting/debug/report-event-attribution, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"297", user-agent:"", origin:"null", accept-encoding:"gzip", Content-Type:"application/json;charset=UTF-8"]]
  6. 2023-08-18 05:57:02.230 DEBUG 2678366 --- [nio-8111-exec-7] o.s.w.f.CommonsRequestLoggingFilter : Before request [POST /.well-known/attribution-reporting/report-event-attribution, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"273", user-agent:"", origin:"null", accept-encoding:"gzip", Content-Type:"application/json;charset=UTF-8"]] 2023-08-18 05:57:02.232 DEBUG 2678366 --- [nio-8111-exec-7] o.s.w.f.CommonsRequestLoggingFilter : After request [POST /.well-known/attribution-reporting/report-event-attribution, headers=[host:"psb.atomex.net", x-real-ip:"103.160.233.114", x-forwarded-for:"103.160.233.114", x-forwarded-proto:"https", connection:"close", content-length:"273", user-agent:"", origin:"null", accept-encoding:"gzip", Content-Type:"application/json;charset=UTF-8"]]

However i believe the requests are coming with empty payload. Not sure if thats expected. Also when i am trying to fetch https://psb.atomex.net/event-reports. the response is empty array. Same for https://psb.atomex.net/aggregate-reports as well.

Let us know if theres anything we can do to look further into the issue.

asifrahiman commented 1 year ago

hi @erintwalsh @cshmerling Any update on the above?

cshmerling commented 8 months ago

Hi @asifrahiman , we were not able to track down the issue. However, we have since released many updates to our SDK and emulator/device images. Can you try updating and letting us know if the issue persists?

cshmerling commented 6 months ago

Closing this due to inactivity. Please re-open the issue if you are still encountering the problem.