android / privacy-sandbox-samples

Apache License 2.0
130 stars 52 forks source link

Custom audience fetching is disabled by default in Developer Preview 9 #80

Closed maciejkowalczyk closed 11 months ago

maciejkowalczyk commented 1 year ago

It seems that fetchAndJoinCustomAudience() just fail with java.lang.IllegalStateException in DP9 I can't find any documentation for enabling it.

cshmerling commented 1 year ago

Looks like we omitted a new flag to override.

adb shell device_config put adservices fledge_fetch_custom_audience_enabled true

Will update the documentation with the same, but this should allow you to call the API

maciejkowalczyk commented 12 months ago

Thanks. This is the workaround we are using to make fetchAndJoinCustomAudience() work. Let's keep this issue open until public docs are updated.

cshmerling commented 11 months ago

Thanks for reporting the issue. I've updated the READMEs for the sample applications to include this command.

guybashan commented 10 months ago

``> Looks like we omitted a new flag to override.

adb shell device_config put adservices fledge_fetch_custom_audience_enabled true

Will update the documentation with the same, but this should allow you to call the API

Hi @cshmerling I think that the documentation is not yet updated with this line and it causes this exception:

                                                                                                    java.lang.IllegalStateException
                                                                                                        at android.adservices.common.AdServicesStatusUtils.asException(AdServicesStatusUtils.java:203)
                                                                                                        at android.adservices.common.AdServicesStatusUtils.asException(AdServicesStatusUtils.java:210)
                                                                                                        at android.adservices.customaudience.CustomAudienceManager$2.lambda$onFailure$1(CustomAudienceManager.java:255)
                                                                                                        at android.adservices.customaudience.CustomAudienceManager$2$$ExternalSyntheticLambda1.run(Unknown Source:4)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                        at java.lang.Thread.run(Thread.java:1012)

Once I ran the command you suggested:

adb shell device_config put adservices fledge_fetch_custom_audience_enabled true

I stopped getting this error, but for some reason I am also not getting any feedback from my: OutcomeReceiver The code doesn't write anything to LogCat:

customAudienceManager.fetchAndJoinCustomAudience(
                            request,
                            executor,
                            new OutcomeReceiver<Object, Exception>() {
                                @Override
                                public void onResult(Object ignoredResult) {
                                    Log.i(TAG, "Fetch and join executed successfully");
                                    completer.set(null);
                                }

                                @Override
                                public void onError(Exception error) {
                                    Log.e(TAG, "Failed while doing fetch and join", error);
                                    completer.setException(error);
                                }
                            });