diff options
170 files changed, 2329 insertions, 2597 deletions
diff --git a/adservices/apk/AndroidManifest.xml b/adservices/apk/AndroidManifest.xml index ad3a4cbfd..cb998df71 100644 --- a/adservices/apk/AndroidManifest.xml +++ b/adservices/apk/AndroidManifest.xml @@ -275,6 +275,15 @@ </intent-filter> </service> + <service android:name="com.android.adservices.shell.AdServicesShellCommandService" + android:exported="true" + android:visibleToInstantApps="false" + > + <intent-filter android:priority="1"> + <action android:name="android.adservices.SHELL_COMMAND_SERVICE"/> + </intent-filter> + </service> + <!-- Daily maintenance Job. --> <service android:name="com.android.adservices.service.MaintenanceJobService" android:permission="android.permission.BIND_JOB_SERVICE"> @@ -436,3 +445,4 @@ /> </application> </manifest> + diff --git a/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java b/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java new file mode 100644 index 000000000..8d07378ca --- /dev/null +++ b/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.adservices.shell; + +import android.annotation.Nullable; +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +import com.android.adservices.LogUtil; +import com.android.adservices.service.FlagsFactory; +import com.android.adservices.service.shell.ShellCommandServiceImpl; + +import java.util.Objects; + +/** Implements a service which runs the shell command in the adservices process. */ +public final class AdServicesShellCommandService extends Service { + + /** The binder service. This field must only be accessed on the main thread. */ + private ShellCommandServiceImpl mShellCommandService; + + @Override + public void onCreate() { + if (!FlagsFactory.getFlags().getAdServicesShellCommandEnabled()) { + LogUtil.e("Shell command service is not enabled."); + return; + } + + mShellCommandService = new ShellCommandServiceImpl(); + } + + @Nullable + @Override + public IBinder onBind(Intent intent) { + if (!FlagsFactory.getFlags().getAdServicesShellCommandEnabled()) { + LogUtil.e("Shell command service is not enabled."); + return null; + } + return Objects.requireNonNull(mShellCommandService); + } + + // TODO(b/308009734): Implement dump method. +} diff --git a/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java b/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java index ee9067980..619978aad 100644 --- a/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java +++ b/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java @@ -19,6 +19,7 @@ import static com.android.adservices.ui.UxUtil.isUxStatesReady; import android.os.Build; import android.os.Bundle; +import android.os.Trace; import androidx.annotation.RequiresApi; import androidx.lifecycle.ViewModelProvider; @@ -58,6 +59,7 @@ public class AdServicesSettingsMainActivity extends AdServicesBaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { + Trace.beginSection("AdServicesSettingsMainActivity#OnCreate"); // Only for main view, we want to use the most up to date OTA strings on the device to // create the ResourcesLoader. if (FlagsFactory.getFlags().getUiOtaStringsFeatureEnabled()) { @@ -70,6 +72,7 @@ public class AdServicesSettingsMainActivity extends AdServicesBaseActivity { if (!isUxStatesReady(this)) { initMainFragment(); } + Trace.endSection(); } private void initMainFragment() { diff --git a/adservices/apk/tests/notification/src/com/android/adservices/ui/notifications/ConsentNotificationTriggerTest.java b/adservices/apk/tests/notification/src/com/android/adservices/ui/notifications/ConsentNotificationTriggerTest.java index b50aaba6d..20dccae4a 100644 --- a/adservices/apk/tests/notification/src/com/android/adservices/ui/notifications/ConsentNotificationTriggerTest.java +++ b/adservices/apk/tests/notification/src/com/android/adservices/ui/notifications/ConsentNotificationTriggerTest.java @@ -182,7 +182,11 @@ public final class ConsentNotificationTriggerTest extends AdServicesExtendedMock .isEqualTo(Notification.FLAG_AUTO_CANCEL); sDevice.openNotification(); - sDevice.wait(Until.hasObject(By.pkg("com.android.systemui")), LAUNCH_TIMEOUT); + sDevice.wait( + Until.hasObject( + By.pkg("com.android.systemui") + .res("com.android.systemui:id/notification_stack_scroller")), + LAUNCH_TIMEOUT); UiObject scroller = sDevice.findObject( @@ -292,7 +296,11 @@ public final class ConsentNotificationTriggerTest extends AdServicesExtendedMock assertThat(notification.actions).isNull(); sDevice.openNotification(); - sDevice.wait(Until.hasObject(By.pkg("com.android.systemui")), LAUNCH_TIMEOUT); + sDevice.wait( + Until.hasObject( + By.pkg("com.android.systemui") + .res("com.android.systemui:id/notification_stack_scroller")), + LAUNCH_TIMEOUT); UiObject scroller = sDevice.findObject( @@ -372,7 +380,11 @@ public final class ConsentNotificationTriggerTest extends AdServicesExtendedMock // verify that notification was displayed sDevice.openNotification(); - sDevice.wait(Until.hasObject(By.pkg("com.android.systemui")), LAUNCH_TIMEOUT); + sDevice.wait( + Until.hasObject( + By.pkg("com.android.systemui") + .res("com.android.systemui:id/notification_stack_scroller")), + LAUNCH_TIMEOUT); UiObject scroller = sDevice.findObject( new UiSelector() @@ -511,7 +523,11 @@ public final class ConsentNotificationTriggerTest extends AdServicesExtendedMock .isEqualTo(Notification.FLAG_AUTO_CANCEL); sDevice.openNotification(); - sDevice.wait(Until.hasObject(By.pkg("com.android.systemui")), LAUNCH_TIMEOUT); + sDevice.wait( + Until.hasObject( + By.pkg("com.android.systemui") + .res("com.android.systemui:id/notification_stack_scroller")), + LAUNCH_TIMEOUT); UiObject scroller = sDevice.findObject( @@ -632,7 +648,11 @@ public final class ConsentNotificationTriggerTest extends AdServicesExtendedMock .isEqualTo(Notification.FLAG_AUTO_CANCEL); sDevice.openNotification(); - sDevice.wait(Until.hasObject(By.pkg("com.android.systemui")), LAUNCH_TIMEOUT); + sDevice.wait( + Until.hasObject( + By.pkg("com.android.systemui") + .res("com.android.systemui:id/notification_stack_scroller")), + LAUNCH_TIMEOUT); UiObject scroller = sDevice.findObject( diff --git a/adservices/apk/tests/settingsgauxselector/src/com/android/adservices/ui/settingsga/SettingsRvcUxSelectorUiAutomatorTest.java b/adservices/apk/tests/settingsgauxselector/src/com/android/adservices/ui/settingsga/SettingsRvcUxSelectorUiAutomatorTest.java index 352a1dcee..e8cbe676b 100644 --- a/adservices/apk/tests/settingsgauxselector/src/com/android/adservices/ui/settingsga/SettingsRvcUxSelectorUiAutomatorTest.java +++ b/adservices/apk/tests/settingsgauxselector/src/com/android/adservices/ui/settingsga/SettingsRvcUxSelectorUiAutomatorTest.java @@ -19,7 +19,7 @@ import static com.android.adservices.service.FlagsConstants.KEY_CONSENT_NOTIFICA import static com.android.adservices.service.FlagsConstants.KEY_DEBUG_UX; import static com.android.adservices.service.FlagsConstants.KEY_ENABLE_AD_SERVICES_SYSTEM_API; import static com.android.adservices.service.FlagsConstants.KEY_GA_UX_FEATURE_ENABLED; -import static com.android.adservices.service.FlagsConstants.KEY_RVC_NOTIFICATION_ENABLED; +import static com.android.adservices.service.FlagsConstants.KEY_RVC_POST_OTA_NOTIFICATION_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_RVC_UX_ENABLED; import static com.google.common.truth.Truth.assertThat; @@ -71,7 +71,7 @@ public class SettingsRvcUxSelectorUiAutomatorTest { .setFlag(KEY_ENABLE_AD_SERVICES_SYSTEM_API, true) .setFlag(KEY_CONSENT_NOTIFICATION_ACTIVITY_DEBUG_MODE, true) .setFlag(KEY_RVC_UX_ENABLED, true) - .setFlag(KEY_RVC_NOTIFICATION_ENABLED, true) + .setFlag(KEY_RVC_POST_OTA_NOTIFICATION_ENABLED, true) .setFlag(KEY_GA_UX_FEATURE_ENABLED, true) .setFlag(KEY_DEBUG_UX, "RVC_UX") .setCompatModeFlags(); diff --git a/adservices/clients/java/android/adservices/clients/measurement/MeasurementClient.java b/adservices/clients/java/android/adservices/clients/measurement/MeasurementClient.java index 639ffd38d..a70270de6 100644 --- a/adservices/clients/java/android/adservices/clients/measurement/MeasurementClient.java +++ b/adservices/clients/java/android/adservices/clients/measurement/MeasurementClient.java @@ -16,7 +16,6 @@ package android.adservices.clients.measurement; -import android.adservices.common.AdServicesOutcomeReceiver; import android.adservices.measurement.DeletionRequest; import android.adservices.measurement.MeasurementManager; import android.adservices.measurement.WebSourceRegistrationRequest; @@ -58,20 +57,82 @@ public class MeasurementClient { @NonNull public ListenableFuture<Void> registerSource( @NonNull Uri attributionSource, @Nullable InputEvent inputEvent) { + Objects.requireNonNull(attributionSource); + + return Build.VERSION.SDK_INT > Build.VERSION_CODES.R + ? registerSourceForSPlus(attributionSource, inputEvent) + : registerSourceForR(attributionSource, inputEvent); + } + + /** + * Invokes the {@code registerTrigger} method of {@link MeasurementManager}, and returns a Void + * future. + */ + @NonNull + public ListenableFuture<Void> registerTrigger(@NonNull Uri trigger) { + Objects.requireNonNull(trigger); + + return Build.VERSION.SDK_INT > Build.VERSION_CODES.R + ? registerTriggerForSPlus(trigger) + : registerTriggerForR(trigger); + } + + /** + * Invokes the {@code registerWebSource} method of {@link MeasurementManager}, and returns a + * Void future. + */ + @NonNull + public ListenableFuture<Void> registerWebSource(@NonNull WebSourceRegistrationRequest request) { + Objects.requireNonNull(request); + + return Build.VERSION.SDK_INT > Build.VERSION_CODES.R + ? registerWebSourceForSPlus(request) + : registerWebSourceForR(request); + } + + /** + * Invokes the {@code registerWebTrigger} method of {@link MeasurementManager}, and returns a + * Void future. + */ + @NonNull + public ListenableFuture<Void> registerWebTrigger( + @NonNull WebTriggerRegistrationRequest request) { + Objects.requireNonNull(request); + + return Build.VERSION.SDK_INT > Build.VERSION_CODES.R + ? registerWebTriggerForSPlus(request) + : registerWebTriggerForR(request); + } + + /** + * Invokes the {@code registerWebTrigger} method of {@link MeasurementManager} with a null + * callback, and returns a Void future if successful, or an {@link Exception} if unsuccessful. + */ + @NonNull + public ListenableFuture<Void> deleteRegistrations(@NonNull DeletionRequest request) { + Objects.requireNonNull(request); + + return Build.VERSION.SDK_INT > Build.VERSION_CODES.R + ? deleteRegistrationsForSPlus(request) + : deleteRegistrationsForR(request); + } + + private ListenableFuture<Void> registerSourceForSPlus( + Uri attributionSource, InputEvent inputEvent) { return CallbackToFutureAdapter.getFuture( completer -> { mMeasurementManager.registerSource( attributionSource, inputEvent, mExecutor, - new AdServicesOutcomeReceiver<>() { + new android.os.OutcomeReceiver<>() { @Override - public void onResult(@NonNull Object ignoredResult) { + public void onResult(Object ignoredResult) { completer.set(null); } @Override - public void onError(@NonNull Exception error) { + public void onError(Exception error) { completer.setException(error); } }); @@ -81,18 +142,61 @@ public class MeasurementClient { }); } - /** - * Invokes the {@code registerTrigger} method of {@link MeasurementManager}, and returns a Void - * future. - */ - @NonNull - public ListenableFuture<Void> registerTrigger(@NonNull Uri trigger) { + private ListenableFuture<Void> registerSourceForR( + Uri attributionSource, InputEvent inputEvent) { + return CallbackToFutureAdapter.getFuture( + completer -> { + mMeasurementManager.registerSource( + attributionSource, + inputEvent, + mExecutor, + new android.adservices.common.AdServicesOutcomeReceiver<>() { + @Override + public void onResult(Object ignoredResult) { + completer.set(null); + } + + @Override + public void onError(Exception error) { + completer.setException(error); + } + }); + // This value is used only for debug purposes: it will be used in toString() + // of returned future or error cases. + return "registerSource"; + }); + } + + private ListenableFuture<Void> registerTriggerForSPlus(Uri trigger) { + return CallbackToFutureAdapter.getFuture( + completer -> { + mMeasurementManager.registerTrigger( + trigger, + mExecutor, + new android.os.OutcomeReceiver<>() { + @Override + public void onResult(Object ignoredResult) { + completer.set(null); + } + + @Override + public void onError(Exception error) { + completer.setException(error); + } + }); + // This value is used only for debug purposes: it will be used in toString() + // of returned future or error cases. + return "registerTrigger"; + }); + } + + private ListenableFuture<Void> registerTriggerForR(Uri trigger) { return CallbackToFutureAdapter.getFuture( completer -> { mMeasurementManager.registerTrigger( trigger, mExecutor, - new AdServicesOutcomeReceiver<>() { + new android.adservices.common.AdServicesOutcomeReceiver<>() { @Override public void onResult(@NonNull Object ignoredResult) { completer.set(null); @@ -108,25 +212,21 @@ public class MeasurementClient { return "registerTrigger"; }); } - /** - * Invokes the {@code registerWebSource} method of {@link MeasurementManager}, and returns a - * Void future. - */ - @NonNull - public ListenableFuture<Void> registerWebSource(@NonNull WebSourceRegistrationRequest request) { + + private ListenableFuture<Void> registerWebSourceForSPlus(WebSourceRegistrationRequest request) { return CallbackToFutureAdapter.getFuture( completer -> { mMeasurementManager.registerWebSource( request, mExecutor, - new AdServicesOutcomeReceiver<>() { + new android.os.OutcomeReceiver<>() { @Override - public void onResult(@NonNull Object ignoredResult) { + public void onResult(Object ignoredResult) { completer.set(null); } @Override - public void onError(@NonNull Exception error) { + public void onError(Exception error) { completer.setException(error); } }); @@ -136,26 +236,44 @@ public class MeasurementClient { }); } - /** - * Invokes the {@code registerWebTrigger} method of {@link MeasurementManager}, and returns a - * Void future. - */ - @NonNull - public ListenableFuture<Void> registerWebTrigger( - @NonNull WebTriggerRegistrationRequest request) { + private ListenableFuture<Void> registerWebSourceForR(WebSourceRegistrationRequest request) { + return CallbackToFutureAdapter.getFuture( + completer -> { + mMeasurementManager.registerWebSource( + request, + mExecutor, + new android.adservices.common.AdServicesOutcomeReceiver<>() { + @Override + public void onResult(Object ignoredResult) { + completer.set(null); + } + + @Override + public void onError(Exception error) { + completer.setException(error); + } + }); + // This value is used only for debug purposes: it will be used in toString() + // of returned future or error cases. + return "registerWebSource"; + }); + } + + private ListenableFuture<Void> registerWebTriggerForSPlus( + WebTriggerRegistrationRequest request) { return CallbackToFutureAdapter.getFuture( completer -> { mMeasurementManager.registerWebTrigger( request, mExecutor, - new AdServicesOutcomeReceiver<>() { + new android.os.OutcomeReceiver<>() { @Override - public void onResult(@NonNull Object ignoredResult) { + public void onResult(Object ignoredResult) { completer.set(null); } @Override - public void onError(@NonNull Exception error) { + public void onError(Exception error) { completer.setException(error); } }); @@ -165,25 +283,66 @@ public class MeasurementClient { }); } - /** - * Invokes the {@code registerWebTrigger} method of {@link MeasurementManager} with a null - * callback, and returns a Void future if successful, or an {@link Exception} if unsuccessful. - */ - @NonNull - public ListenableFuture<Void> deleteRegistrations(@NonNull DeletionRequest request) { + private ListenableFuture<Void> registerWebTriggerForR(WebTriggerRegistrationRequest request) { + return CallbackToFutureAdapter.getFuture( + completer -> { + mMeasurementManager.registerWebTrigger( + request, + mExecutor, + new android.adservices.common.AdServicesOutcomeReceiver<>() { + @Override + public void onResult(Object ignoredResult) { + completer.set(null); + } + + @Override + public void onError(Exception error) { + completer.setException(error); + } + }); + // This value is used only for debug purposes: it will be used in toString() + // of returned future or error cases. + return "registerWebTrigger"; + }); + } + + private ListenableFuture<Void> deleteRegistrationsForSPlus(DeletionRequest request) { return CallbackToFutureAdapter.getFuture( completer -> { mMeasurementManager.deleteRegistrations( request, mExecutor, - new AdServicesOutcomeReceiver<>() { + new android.os.OutcomeReceiver<>() { @Override - public void onResult(@NonNull Object ignoredResult) { + public void onResult(Object ignoredResult) { completer.set(null); } @Override - public void onError(@NonNull Exception error) { + public void onError(Exception error) { + completer.setException(error); + } + }); + // This value is used only for debug purposes: it will be used in toString() + // of returned future or error cases. + return "deleteRegistrations"; + }); + } + + private ListenableFuture<Void> deleteRegistrationsForR(DeletionRequest request) { + return CallbackToFutureAdapter.getFuture( + completer -> { + mMeasurementManager.deleteRegistrations( + request, + mExecutor, + new android.adservices.common.AdServicesOutcomeReceiver<>() { + @Override + public void onResult(Object ignoredResult) { + completer.set(null); + } + + @Override + public void onError(Exception error) { completer.setException(error); } }); diff --git a/adservices/framework/java/android/adservices/common/AdServicesPermissions.java b/adservices/framework/java/android/adservices/common/AdServicesPermissions.java index 2a94c711b..140359b1d 100644 --- a/adservices/framework/java/android/adservices/common/AdServicesPermissions.java +++ b/adservices/framework/java/android/adservices/common/AdServicesPermissions.java @@ -36,14 +36,6 @@ public class AdServicesPermissions { public static final String ACCESS_ADSERVICES_CUSTOM_AUDIENCE = "android.permission.ACCESS_ADSERVICES_CUSTOM_AUDIENCE"; - /** - * This permission needs to be declared by the caller of Protected Signals APIs. - * - * @hide - */ - public static final String ACCESS_ADSERVICES_PROTECTED_SIGNALS = - "android.permission.ACCESS_ADSERVICES_PROTECTED_SIGNALS"; - /** This permission needs to be declared by the caller of Advertising ID APIs. */ public static final String ACCESS_ADSERVICES_AD_ID = "android.permission.ACCESS_ADSERVICES_AD_ID"; diff --git a/adservices/framework/java/android/adservices/shell/IShellCommand.aidl b/adservices/framework/java/android/adservices/shell/IShellCommand.aidl new file mode 100644 index 000000000..2b6bd81cf --- /dev/null +++ b/adservices/framework/java/android/adservices/shell/IShellCommand.aidl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.adservices.shell; + +import android.adservices.shell.IShellCommandCallback; +import android.adservices.shell.ShellCommandParam; +import android.os.ParcelFileDescriptor; + +/** + * Shell Service. + * + * {@hide} + */ +oneway interface IShellCommand { + /** + * Runs the shell command and returns the result through callback. + */ + void runShellCommand(in ShellCommandParam request, in IShellCommandCallback callback); +}
\ No newline at end of file diff --git a/adservices/framework/java/android/adservices/shell/IShellCommandCallback.aidl b/adservices/framework/java/android/adservices/shell/IShellCommandCallback.aidl new file mode 100644 index 000000000..7a86fbb0c --- /dev/null +++ b/adservices/framework/java/android/adservices/shell/IShellCommandCallback.aidl @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.adservices.shell; + +import android.adservices.shell.ShellCommandResult; + +/** + * Callback from the runShellCommand request. + * {@hide} + */ +oneway interface IShellCommandCallback { + void onResult(in ShellCommandResult result); +}
\ No newline at end of file diff --git a/adservices/framework/java/android/adservices/shell/ShellCommandParam.aidl b/adservices/framework/java/android/adservices/shell/ShellCommandParam.aidl new file mode 100644 index 000000000..440947220 --- /dev/null +++ b/adservices/framework/java/android/adservices/shell/ShellCommandParam.aidl @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.adservices.shell; + +/** {@hide} */ +parcelable ShellCommandParam;
\ No newline at end of file diff --git a/adservices/framework/java/android/adservices/shell/ShellCommandParam.java b/adservices/framework/java/android/adservices/shell/ShellCommandParam.java new file mode 100644 index 000000000..18b628d8e --- /dev/null +++ b/adservices/framework/java/android/adservices/shell/ShellCommandParam.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.adservices.shell; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Objects; + +/** + * Represents request which contains command and args as an input to runShellCommand API. + * + * @hide + */ +public class ShellCommandParam implements Parcelable { + + /* Array containing command name with all the args */ + private final String[] mCommandArgs; + + public ShellCommandParam(String... commandArgs) { + mCommandArgs = Objects.requireNonNull(commandArgs); + } + + private ShellCommandParam(Parcel in) { + this(in.createStringArray()); + } + + public static final Creator<ShellCommandParam> CREATOR = + new Parcelable.Creator<>() { + @Override + public ShellCommandParam createFromParcel(Parcel in) { + return new ShellCommandParam(in); + } + + @Override + public ShellCommandParam[] newArray(int size) { + return new ShellCommandParam[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeStringArray(mCommandArgs); + } + + /** Get the command name with all the args as a list. */ + public String[] getCommandArgs() { + return mCommandArgs; + } +} diff --git a/adservices/framework/java/android/adservices/shell/ShellCommandResult.aidl b/adservices/framework/java/android/adservices/shell/ShellCommandResult.aidl new file mode 100644 index 000000000..821fcbc38 --- /dev/null +++ b/adservices/framework/java/android/adservices/shell/ShellCommandResult.aidl @@ -0,0 +1,20 @@ + +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.adservices.shell; + +/** {@hide} */ +parcelable ShellCommandResult;
\ No newline at end of file diff --git a/adservices/framework/java/android/adservices/shell/ShellCommandResult.java b/adservices/framework/java/android/adservices/shell/ShellCommandResult.java new file mode 100644 index 000000000..442c67e58 --- /dev/null +++ b/adservices/framework/java/android/adservices/shell/ShellCommandResult.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.adservices.shell; + +import android.annotation.Nullable; +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Objects; + +/** + * Represents the response from the runShellCommand API. + * + * @hide + */ +public class ShellCommandResult implements Parcelable { + + private static final int RESULT_OK = 0; + + private final int mResultCode; + @Nullable private final String mOut; + @Nullable private final String mErr; + + private ShellCommandResult(int resultCode, @Nullable String out, @Nullable String err) { + mResultCode = resultCode; + mOut = out; + mErr = err; + } + + private ShellCommandResult(Parcel in) { + this(in.readInt(), in.readString(), in.readString()); + } + + private ShellCommandResult(Builder builder) { + this(builder.mResultCode, builder.mOut, builder.mErr); + } + + public static final Creator<ShellCommandResult> CREATOR = + new Parcelable.Creator<>() { + @Override + public ShellCommandResult createFromParcel(Parcel in) { + Objects.requireNonNull(in); + return new ShellCommandResult(in); + } + + @Override + public ShellCommandResult[] newArray(int size) { + return new ShellCommandResult[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + Objects.requireNonNull(dest); + dest.writeInt(mResultCode); + dest.writeString(mOut); + dest.writeString(mErr); + } + + /** Returns the command status. */ + public int getResultCode() { + return mResultCode; + } + + /** Returns {@code true} if {@link #getResultCode} is greater than equal to 0. */ + public boolean isSuccess() { + return getResultCode() >= 0; + } + + /** Returns the output of the shell command result. */ + @Nullable + public String getOut() { + return mOut; + } + + /** Returns the error message associated with this response. */ + @Nullable + public String getErr() { + return mErr; + } + + /** + * Builder for {@link ShellCommandResult}. + * + * @hide + */ + public static final class Builder { + private int mResultCode = RESULT_OK; + @Nullable private String mOut; + @Nullable private String mErr; + + public Builder() {} + + /** Sets the Status Code. */ + public Builder setResultCode(int resultCode) { + mResultCode = resultCode; + return this; + } + + /** Sets the shell command output in case of success. */ + public Builder setOut(@Nullable String out) { + mOut = out; + return this; + } + + /** Sets the error message in case of command failure. */ + public Builder setErr(@Nullable String err) { + mErr = err; + return this; + } + + /** Builds a {@link ShellCommandResult} object. */ + public ShellCommandResult build() { + return new ShellCommandResult(this); + } + } +} diff --git a/adservices/framework/java/android/adservices/signals/ProtectedSignalsManager.java b/adservices/framework/java/android/adservices/signals/ProtectedSignalsManager.java index c0b54d956..ffbb084e4 100644 --- a/adservices/framework/java/android/adservices/signals/ProtectedSignalsManager.java +++ b/adservices/framework/java/android/adservices/signals/ProtectedSignalsManager.java @@ -16,7 +16,7 @@ package android.adservices.signals; -import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_PROTECTED_SIGNALS; +import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE; import android.adservices.common.AdServicesStatusUtils; import android.adservices.common.FledgeErrorResponse; @@ -181,7 +181,7 @@ public class ProtectedSignalsManager { * <p>This call fails with an {@link IllegalStateException} if an internal service error is * encountered. */ - @RequiresPermission(ACCESS_ADSERVICES_PROTECTED_SIGNALS) + @RequiresPermission(ACCESS_ADSERVICES_CUSTOM_AUDIENCE) public void updateSignals( @NonNull UpdateSignalsRequest updateSignalsRequest, @NonNull @CallbackExecutor Executor executor, diff --git a/adservices/framework/java/com/android/adservices/AdServicesCommon.java b/adservices/framework/java/com/android/adservices/AdServicesCommon.java index 5fae08509..18b324691 100644 --- a/adservices/framework/java/com/android/adservices/AdServicesCommon.java +++ b/adservices/framework/java/com/android/adservices/AdServicesCommon.java @@ -26,6 +26,7 @@ import java.util.List; // TODO(b/295321663): need to split constants into AdServicesCommonConstants so they can be used by // host-side test artifacts. + /** * Common constants for AdServices * @@ -82,6 +83,10 @@ public class AdServicesCommon { public static final String ACTION_AD_SERVICES_COBALT_UPLOAD_SERVICE = AdServicesCobaltUploadService.SERVICE_INTERFACE; + /** Intent action to discover the Shell Command service in the APK. */ + public static final String ACTION_SHELL_COMMAND_SERVICE = + "android.adservices.SHELL_COMMAND_SERVICE"; + // Used to differentiate between AdServices APK package name and AdExtServices APK package name. // The AdExtServices APK package name suffix is android.ext.services. public static final String ADSERVICES_APK_PACKAGE_NAME_SUFFIX = "android.adservices.api"; diff --git a/adservices/framework/java/com/android/adservices/AndroidServiceBinder.java b/adservices/framework/java/com/android/adservices/AndroidServiceBinder.java index 280be9a2c..b8ce7dd2a 100644 --- a/adservices/framework/java/com/android/adservices/AndroidServiceBinder.java +++ b/adservices/framework/java/com/android/adservices/AndroidServiceBinder.java @@ -27,6 +27,7 @@ import static com.android.adservices.AdServicesCommon.ACTION_APPSETID_PROVIDER_S import static com.android.adservices.AdServicesCommon.ACTION_APPSETID_SERVICE; import static com.android.adservices.AdServicesCommon.ACTION_CUSTOM_AUDIENCE_SERVICE; import static com.android.adservices.AdServicesCommon.ACTION_MEASUREMENT_SERVICE; +import static com.android.adservices.AdServicesCommon.ACTION_SHELL_COMMAND_SERVICE; import static com.android.adservices.AdServicesCommon.ACTION_TOPICS_SERVICE; import static com.android.adservices.AdServicesCommon.SYSTEM_PROPERTY_FOR_DEBUGGING_FEATURE_RAM_LOW; @@ -221,7 +222,8 @@ class AndroidServiceBinder<T> extends ServiceBinder<T> { && !mServiceIntentAction.equals(ACTION_APPSETID_PROVIDER_SERVICE) && !mServiceIntentAction.equals(ACTION_AD_SERVICES_COBALT_UPLOAD_SERVICE) && !mServiceIntentAction.equals(ACTION_AD_SERVICES_COMMON_SERVICE) - && !mServiceIntentAction.equals(ACTION_AD_EXT_DATA_STORAGE_SERVICE)) { + && !mServiceIntentAction.equals(ACTION_AD_EXT_DATA_STORAGE_SERVICE) + && !mServiceIntentAction.equals(ACTION_SHELL_COMMAND_SERVICE)) { LogUtil.e("Bad service intent action: " + mServiceIntentAction); return null; } diff --git a/adservices/service-core/java/com/android/adservices/service/Flags.java b/adservices/service-core/java/com/android/adservices/service/Flags.java index 9b1a8de6f..4fcbb820b 100644 --- a/adservices/service-core/java/com/android/adservices/service/Flags.java +++ b/adservices/service-core/java/com/android/adservices/service/Flags.java @@ -709,7 +709,7 @@ public interface Flags extends CommonFlags { return MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_EVENT; } - float MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_NAVIGATION = 11.46173F; + float MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_NAVIGATION = 11.5F; /** Returns max information gain in Flexible Event API for Navigation sources */ default float getMeasurementFlexApiMaxInformationGainNavigation() { @@ -3522,14 +3522,6 @@ public interface Flags extends CommonFlags { return MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS; } - /** Disable early reporting windows configurability by default. */ - boolean MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS = false; - - /** Returns true if event reporting windows configurability is enabled, false otherwise. */ - default boolean getMeasurementEnableConfigurableEventReportingWindows() { - return MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS; - } - /** * Default early reporting windows for VTC type source. Derived from {@link * com.android.adservices.service.measurement.PrivacyParams#EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS}. @@ -3589,18 +3581,8 @@ public interface Flags extends CommonFlags { return MEASUREMENT_AGGREGATE_REPORT_DELAY_CONFIG; } - /** Disable conversions configurability by default. */ - boolean DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS = false; - - /** - * Returns true, if event reports max conversions configurability is enabled, false otherwise. - */ - default boolean getMeasurementEnableVtcConfigurableMaxEventReports() { - return DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS; - } - - /** Disable conversions configurability by default. */ - int DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT = 2; + /** Default max allowed number of event reports. */ + int DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT = 1; /** Returns the default max allowed number of event reports. */ default int getMeasurementVtcConfigurableMaxEventReportsCount() { @@ -3983,11 +3965,11 @@ public interface Flags extends CommonFlags { } /** Default RVC NOTIFICATION feature flag.. */ - boolean DEFAULT_RVC_NOTIFICATION_ENABLED = false; + boolean DEFAULT_RVC_POST_OTA_NOTIFICATION_ENABLED = false; /** RVC Notification feature flag.. */ - default boolean getEnableRvcNotification() { - return DEFAULT_RVC_NOTIFICATION_ENABLED; + default boolean getEnableRvcPostOtaNotification() { + return DEFAULT_RVC_POST_OTA_NOTIFICATION_ENABLED; } /** Default enableAdServices system API feature flag.. */ @@ -4104,76 +4086,6 @@ public interface Flags extends CommonFlags { return MEASUREMENT_MIN_REPORTING_ORIGIN_UPDATE_WINDOW; } - float MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY = 0.0000208f; - - /** - * {@link Source} Noise probability for 'Event' when both destinations (app and web) are - * available on the source and supports install attribution. - */ - default float getMeasurementInstallAttrDualDestinationEventNoiseProbability() { - return MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; - } - - float MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY = 0.0170218f; - - /** - * {@link Source} Noise probability for 'Navigation' when both destinations (app and web) are - * available on the source. - */ - default float getMeasurementDualDestinationNavigationNoiseProbability() { - return MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; - } - - float MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY = - MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; - - /** - * {@link Source} Noise probability for 'Navigation' when both destinations (app and web) are - * available on the source and supports install attribution. - */ - default float getMeasurementInstallAttrDualDestinationNavigationNoiseProbability() { - return MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; - } - - float MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY = 0.0000042f; - - /** - * {@link Source} Noise probability for 'Event' when both destinations (app and web) are - * available on the source. - */ - default float getMeasurementDualDestinationEventNoiseProbability() { - return MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; - } - - float MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY = 0.0000125f; - - /** {@link Source} Noise probability for 'Event' which supports install attribution. */ - default float getMeasurementInstallAttrEventNoiseProbability() { - return MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY; - } - - float MEASUREMENT_EVENT_NOISE_PROBABILITY = 0.0000025f; - - /** {@link Source} Noise probability for 'Event'. */ - default float getMeasurementEventNoiseProbability() { - return MEASUREMENT_EVENT_NOISE_PROBABILITY; - } - - float MEASUREMENT_NAVIGATION_NOISE_PROBABILITY = 0.0024263f; - - /** {@link Source} Noise probability for 'Navigation'. */ - default float getMeasurementNavigationNoiseProbability() { - return MEASUREMENT_NAVIGATION_NOISE_PROBABILITY; - } - - float MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY = - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY; - - /** {@link Source} Noise probability for 'Navigation' which supports install attribution. */ - default float getMeasurementInstallAttrNavigationNoiseProbability() { - return MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY; - } - boolean MEASUREMENT_ENABLE_PREINSTALL_CHECK = false; /** Returns true when pre-install check is enabled. */ diff --git a/adservices/service-core/java/com/android/adservices/service/FlagsConstants.java b/adservices/service-core/java/com/android/adservices/service/FlagsConstants.java index 0f7570492..2d4e6cb4c 100644 --- a/adservices/service-core/java/com/android/adservices/service/FlagsConstants.java +++ b/adservices/service-core/java/com/android/adservices/service/FlagsConstants.java @@ -286,9 +286,6 @@ public final class FlagsConstants { public static final String KEY_MEASUREMENT_ENABLE_COARSE_EVENT_REPORT_DESTINATIONS = "measurement_enable_coarse_event_report_destinations"; - public static final String KEY_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS = - "measurement_enable_vtc_configurable_max_event_reports_count"; - public static final String KEY_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT = "measurement_vtc_configurable_max_event_reports_count"; @@ -1071,9 +1068,6 @@ public final class FlagsConstants { public static final String KEY_MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS = "measurement_min_event_report_delay_millis"; - public static final String KEY_MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS = - "measurement_enable_configurable_event_reporting_windows"; - public static final String KEY_MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS = "measurement_event_reports_vtc_early_reporting_windows"; @@ -1139,32 +1133,6 @@ public final class FlagsConstants { public static final String KEY_MEASUREMENT_ENABLE_REDIRECT_TO_WELL_KNOWN_PATH = "measurement_enable_redirect_to_well_known_path"; - public static final String - KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY = - "measurement_install_attr_dual_destination_event_noise_probability"; - - public static final String KEY_MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY = - "measurement_dual_destination_navigation_noise_probability"; - - public static final String - KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY = - "measurement_install_attr_dual_destination_navigation_noise_probability"; - - public static final String KEY_MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY = - "measurement_dual_destination_event_noise_probability"; - - public static final String KEY_MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY = - "measurement_install_attr_event_noise_probability"; - - public static final String KEY_MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY = - "measurement_install_attr_navigation_noise_probability"; - - public static final String KEY_MEASUREMENT_EVENT_NOISE_PROBABILITY = - "measurement_event_noise_probability"; - - public static final String KEY_MEASUREMENT_NAVIGATION_NOISE_PROBABILITY = - "measurement_navigation_noise_probability"; - // Database Schema Version Flags public static final String KEY_ENABLE_DATABASE_SCHEMA_VERSION_8 = "enable_database_schema_version_8"; @@ -1178,7 +1146,8 @@ public final class FlagsConstants { public static final String KEY_RVC_UX_ENABLED = "rvc_ux_enabled"; - public static final String KEY_RVC_NOTIFICATION_ENABLED = "rvc_notification_enabled"; + public static final String KEY_RVC_POST_OTA_NOTIFICATION_ENABLED = + "rvc_post_ota_notification_enabled"; public static final String KEY_ENABLE_AD_SERVICES_SYSTEM_API = "enable_ad_services_system_api"; diff --git a/adservices/service-core/java/com/android/adservices/service/PhFlags.java b/adservices/service-core/java/com/android/adservices/service/PhFlags.java index e1a8b2679..e221e027d 100644 --- a/adservices/service-core/java/com/android/adservices/service/PhFlags.java +++ b/adservices/service-core/java/com/android/adservices/service/PhFlags.java @@ -3481,16 +3481,6 @@ public final class PhFlags extends CommonPhFlags implements Flags { } @Override - public boolean getMeasurementEnableConfigurableEventReportingWindows() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getBoolean( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants - .KEY_MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS, - /* defaultValue */ MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS); - } - - @Override public String getMeasurementEventReportsVtcEarlyReportingWindows() { // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. return DeviceConfig.getString( @@ -4298,49 +4288,6 @@ public final class PhFlags extends CommonPhFlags implements Flags { + getMeasurementMinReportingOriginUpdateWindow()); writer.println( "\t" - + FlagsConstants - .KEY_MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY - + " = " - + getMeasurementDualDestinationNavigationNoiseProbability()); - writer.println( - "\t" - + FlagsConstants - .KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY - + " = " - + getMeasurementInstallAttrDualDestinationEventNoiseProbability()); - writer.println( - "\t" - + FlagsConstants - .KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY - + " = " - + getMeasurementInstallAttrDualDestinationNavigationNoiseProbability()); - writer.println( - "\t" - + FlagsConstants.KEY_MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY - + " = " - + getMeasurementDualDestinationEventNoiseProbability()); - writer.println( - "\t" - + FlagsConstants.KEY_MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY - + " = " - + getMeasurementInstallAttrEventNoiseProbability()); - writer.println( - "\t" - + FlagsConstants.KEY_MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY - + " = " - + getMeasurementInstallAttrNavigationNoiseProbability()); - writer.println( - "\t" - + FlagsConstants.KEY_MEASUREMENT_EVENT_NOISE_PROBABILITY - + " = " - + getMeasurementEventNoiseProbability()); - writer.println( - "\t" - + FlagsConstants.KEY_MEASUREMENT_NAVIGATION_NOISE_PROBABILITY - + " = " - + getMeasurementNavigationNoiseProbability()); - writer.println( - "\t" + FlagsConstants.KEY_MEASUREMENT_REGISTRATION_JOB_QUEUE_KILL_SWITCH + " = " + getAsyncRegistrationJobQueueKillSwitch()); @@ -4386,11 +4333,6 @@ public final class PhFlags extends CommonPhFlags implements Flags { + getMeasurementMinEventReportDelayMillis()); writer.println( "\t" - + FlagsConstants.KEY_MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS - + " = " - + getMeasurementEnableConfigurableEventReportingWindows()); - writer.println( - "\t" + FlagsConstants.KEY_MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS + " = " + getMeasurementEventReportsVtcEarlyReportingWindows()); @@ -5705,12 +5647,12 @@ public final class PhFlags extends CommonPhFlags implements Flags { } @Override - public boolean getEnableRvcNotification() { + public boolean getEnableRvcPostOtaNotification() { return getEnableAdServicesSystemApi() && DeviceConfig.getBoolean( FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants.KEY_RVC_NOTIFICATION_ENABLED, - /* defaultValue */ DEFAULT_RVC_NOTIFICATION_ENABLED); + /* flagName */ FlagsConstants.KEY_RVC_POST_OTA_NOTIFICATION_ENABLED, + /* defaultValue */ DEFAULT_RVC_POST_OTA_NOTIFICATION_ENABLED); } @Override @@ -5733,7 +5675,9 @@ public final class PhFlags extends CommonPhFlags implements Flags { getRecordManualInteractionEnabled()); uxMap.put(FlagsConstants.KEY_GA_UX_FEATURE_ENABLED, getGaUxFeatureEnabled()); uxMap.put(FlagsConstants.KEY_RVC_UX_ENABLED, getEnableRvcUx()); - uxMap.put(FlagsConstants.KEY_RVC_NOTIFICATION_ENABLED, getEnableRvcNotification()); + uxMap.put( + FlagsConstants.KEY_RVC_POST_OTA_NOTIFICATION_ENABLED, + getEnableRvcPostOtaNotification()); uxMap.put( FlagsConstants.KEY_UI_OTA_STRINGS_FEATURE_ENABLED, getUiOtaStringsFeatureEnabled()); uxMap.put( @@ -5866,83 +5810,6 @@ public final class PhFlags extends CommonPhFlags implements Flags { } @Override - public float getMeasurementInstallAttrDualDestinationEventNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants - .KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY); - } - - @Override - public float getMeasurementDualDestinationNavigationNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants - .KEY_MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY); - } - - @Override - public float getMeasurementInstallAttrDualDestinationNavigationNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants - .KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY); - } - - @Override - public float getMeasurementDualDestinationEventNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants - .KEY_MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY); - } - - @Override - public float getMeasurementInstallAttrEventNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants.KEY_MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY); - } - - @Override - public float getMeasurementInstallAttrNavigationNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants - .KEY_MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY); - } - - @Override - public float getMeasurementEventNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants.KEY_MEASUREMENT_EVENT_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_EVENT_NOISE_PROBABILITY); - } - - @Override - public float getMeasurementNavigationNoiseProbability() { - // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. - return DeviceConfig.getFloat( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants.KEY_MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, - /* defaultValue */ MEASUREMENT_NAVIGATION_NOISE_PROBABILITY); - } - - @Override public boolean getMeasurementEnablePreinstallCheck() { // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. return DeviceConfig.getBoolean( @@ -5952,16 +5819,6 @@ public final class PhFlags extends CommonPhFlags implements Flags { } @Override - public boolean getMeasurementEnableVtcConfigurableMaxEventReports() { - return DeviceConfig.getBoolean( - FlagsConstants.NAMESPACE_ADSERVICES, - /* flagName */ FlagsConstants - .KEY_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS, - /* defaultValue */ - DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS); - } - - @Override public int getMeasurementVtcConfigurableMaxEventReportsCount() { return DeviceConfig.getInt( FlagsConstants.NAMESPACE_ADSERVICES, diff --git a/adservices/service-core/java/com/android/adservices/service/adselection/AdSelectionServiceImpl.java b/adservices/service-core/java/com/android/adservices/service/adselection/AdSelectionServiceImpl.java index 63016c24d..9bff5dea6 100644 --- a/adservices/service-core/java/com/android/adservices/service/adselection/AdSelectionServiceImpl.java +++ b/adservices/service-core/java/com/android/adservices/service/adselection/AdSelectionServiceImpl.java @@ -332,7 +332,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, inputParams.getCallerPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -370,7 +370,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, inputParams.getCallerPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -473,7 +473,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, inputParams.getCallerPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -762,7 +762,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, inputParams.getCallerPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -805,7 +805,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, requestParams.getCallerPackageName(), apiName); DevContext devContext = mDevContextFilter.createDevContext(); @@ -871,7 +871,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, inputParams.getCallerPackageName(), apiName); int callerUid = getCallingUid(apiName); @@ -928,7 +928,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, request.getCallerPackageName(), apiName); AppInstallAdvertisersSetter setter = @@ -960,7 +960,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, inputParams.getCallerPackageName(), apiName); final int callingUid = getCallingUid(apiName); @@ -1033,7 +1033,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -1100,7 +1100,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -1150,7 +1150,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -1205,7 +1205,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -1256,7 +1256,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -1305,7 +1305,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); int callingUid = getCallingUid(apiName); @@ -1355,7 +1355,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); // TODO(b/265204820): Implement service @@ -1393,7 +1393,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); // TODO(b/265204820): Implement service @@ -1428,7 +1428,7 @@ public class AdSelectionServiceImpl extends AdSelectionService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); // TODO(b/265204820): Implement service diff --git a/adservices/service-core/java/com/android/adservices/service/common/FledgeAuthorizationFilter.java b/adservices/service-core/java/com/android/adservices/service/common/FledgeAuthorizationFilter.java index c99b0b9a3..7809ecd40 100644 --- a/adservices/service-core/java/com/android/adservices/service/common/FledgeAuthorizationFilter.java +++ b/adservices/service-core/java/com/android/adservices/service/common/FledgeAuthorizationFilter.java @@ -123,47 +123,22 @@ public class FledgeAuthorizationFilter { * @param apiNameLoggingId the id of the api being called * @throws SecurityException if the package did not declare custom audience permission */ - public void assertAppDeclaredCustomAudiencePermission( + public void assertAppDeclaredPermission( @NonNull Context context, @NonNull String appPackageName, int apiNameLoggingId) throws SecurityException { Objects.requireNonNull(context); Objects.requireNonNull(appPackageName); if (!PermissionHelper.hasCustomAudiencesPermission(context, appPackageName)) { - logAndThrowPermissionFailure(apiNameLoggingId); - } - } - - /** - * Check if the app had declared the protected signals permission. - * - * @param context api service context - * @param apiNameLoggingId the id of the api being called - * @throws SecurityException if the package did not declare custom audience permission - */ - public void assertAppDeclaredProtectedSignalsPermission( - @NonNull Context context, @NonNull String appPackageName, int apiNameLoggingId) - throws SecurityException { - Objects.requireNonNull(context); - Objects.requireNonNull(appPackageName); - - if (!PermissionHelper.hasProtectedSignalsPermission(context, appPackageName)) { - /* - * Using the same message for both since getAdSelectionData can be called with either - * permission and we don't want the error message to depend on which is checked first. - */ - logAndThrowPermissionFailure(apiNameLoggingId); + sLogger.v("Permission not declared by caller in API %d", apiNameLoggingId); + mAdServicesLogger.logFledgeApiCallStats( + apiNameLoggingId, STATUS_PERMISSION_NOT_REQUESTED, 0); + throw new SecurityException( + AdServicesStatusUtils + .SECURITY_EXCEPTION_PERMISSION_NOT_REQUESTED_ERROR_MESSAGE); } } - private void logAndThrowPermissionFailure(int apiNameLoggingId) { - sLogger.v("Permission not declared by caller in API %d", apiNameLoggingId); - mAdServicesLogger.logFledgeApiCallStats( - apiNameLoggingId, STATUS_PERMISSION_NOT_REQUESTED, 0); - throw new SecurityException( - AdServicesStatusUtils.SECURITY_EXCEPTION_PERMISSION_NOT_REQUESTED_ERROR_MESSAGE); - } - /** * Check if a certain ad tech is enrolled and authorized to perform the operation for the * package. diff --git a/adservices/service-core/java/com/android/adservices/service/common/PackageChangedReceiver.java b/adservices/service-core/java/com/android/adservices/service/common/PackageChangedReceiver.java index e2afca136..35d6ff658 100644 --- a/adservices/service-core/java/com/android/adservices/service/common/PackageChangedReceiver.java +++ b/adservices/service-core/java/com/android/adservices/service/common/PackageChangedReceiver.java @@ -295,6 +295,10 @@ public class PackageChangedReceiver extends BroadcastReceiver { @VisibleForTesting void consentOnPackageFullyRemoved( @NonNull Context context, @NonNull Uri packageUri, int packageUid) { + if (!SdkLevel.isAtLeastS()) { + LogUtil.d("consentOnPackageFullyRemoved is not needed on Android R, returning..."); + return; + } Objects.requireNonNull(context); Objects.requireNonNull(packageUri); diff --git a/adservices/service-core/java/com/android/adservices/service/common/PermissionHelper.java b/adservices/service-core/java/com/android/adservices/service/common/PermissionHelper.java index 67142b6d3..d02225e4e 100644 --- a/adservices/service-core/java/com/android/adservices/service/common/PermissionHelper.java +++ b/adservices/service-core/java/com/android/adservices/service/common/PermissionHelper.java @@ -101,16 +101,6 @@ public final class PermissionHelper { } /** - * @return {@code true} if the caller has the permission to invoke Protected Signals APIs. - */ - public static boolean hasProtectedSignalsPermission( - @NonNull Context context, @NonNull String appPackageName) { - // TODO(b/236268316): Add check for SDK permission. - return hasPermission( - context, appPackageName, AdServicesPermissions.ACCESS_ADSERVICES_PROTECTED_SIGNALS); - } - - /** * @return {@code true} if the caller has the permission to invoke AdService's state * modification API. */ diff --git a/adservices/service-core/java/com/android/adservices/service/consent/ConsentManager.java b/adservices/service-core/java/com/android/adservices/service/consent/ConsentManager.java index 900ffd58f..1b2a3bcb8 100644 --- a/adservices/service-core/java/com/android/adservices/service/consent/ConsentManager.java +++ b/adservices/service-core/java/com/android/adservices/service/consent/ConsentManager.java @@ -39,6 +39,7 @@ import android.app.job.JobScheduler; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; +import android.os.Trace; import androidx.annotation.RequiresApi; @@ -206,6 +207,7 @@ public class ConsentManager { public static ConsentManager getInstance(@NonNull Context context) { Objects.requireNonNull(context); + Trace.beginSection("ConsentManager#Initialization"); if (sConsentManager == null) { synchronized (LOCK) { if (sConsentManager == null) { @@ -253,7 +255,8 @@ public class ConsentManager { context, datastore, appSearchConsentManager, - adServicesExtDataManager); + adServicesExtDataManager, + statsdAdServicesLogger); } } @@ -288,6 +291,7 @@ public class ConsentManager { } } } + Trace.endSection(); return sConsentManager; } @@ -2154,6 +2158,7 @@ public class ConsentManager { for back compat. */ ThrowableSetter ppapiAndAdExtDataServiceSetter, ErrorLogger errorLogger) { + Trace.beginSection("ConsentManager#WriteOperation"); mReadWriteLock.writeLock().lock(); try { switch (mConsentSourceOfTruth) { @@ -2188,8 +2193,8 @@ public class ConsentManager { throw new RuntimeException(getClass().getSimpleName() + " failed. " + e.getMessage()); } finally { mReadWriteLock.writeLock().unlock(); + Trace.endSection(); } - } @FunctionalInterface @@ -2218,6 +2223,7 @@ public class ConsentManager { for back compat. */ ThrowableGetter<T> ppapiAndAdExtDataServiceGetter, ErrorLogger errorLogger) { + Trace.beginSection("ConsentManager#ReadOperation"); mReadWriteLock.readLock().lock(); try { switch (mConsentSourceOfTruth) { @@ -2248,6 +2254,7 @@ public class ConsentManager { LogUtil.e(getClass().getSimpleName() + " failed. " + e.getMessage()); } finally { mReadWriteLock.readLock().unlock(); + Trace.endSection(); } return defaultReturn; @@ -2260,8 +2267,20 @@ public class ConsentManager { : AD_SERVICES_SETTINGS_USAGE_REPORTED__REGION__ROW; } - /* Returns an object of ConsentMigrationStats */ - private static ConsentMigrationStats getConsentManagerStatsForLogging( + /*** + * Returns an object of ConsentMigrationStats for logging + * + * @param appConsents AppConsents consents per API (fledge, msmt, topics, default) + * @param migrationStatus Status of migration ( FAILURE, SUCCESS_WITH_SHARED_PREF_UPDATED, + * SUCCESS_WITH_SHARED_PREF_NOT_UPDATED) + * @param migrationType Type of migration ( PPAPI_TO_SYSTEM_SERVICE, + * APPSEARCH_TO_SYSTEM_SERVICE, + * ADEXT_SERVICE_TO_SYSTEM_SERVICE, + * ADEXT_SERVICE_TO_APPSEARCH) + * @param context Context of the application + * @return consentMigrationStats returns ConsentMigrationStats for logging + */ + public static ConsentMigrationStats getConsentManagerStatsForLogging( AppConsents appConsents, ConsentMigrationStats.MigrationStatus migrationStatus, ConsentMigrationStats.MigrationType migrationType, @@ -2269,7 +2288,6 @@ public class ConsentManager { ConsentMigrationStats consentMigrationStats = ConsentMigrationStats.builder() .setMigrationType(migrationType) - .setMigrationStatus(migrationStatus) // When appConsents is null we log it as a failure .setMigrationStatus( appConsents != null diff --git a/adservices/service-core/java/com/android/adservices/service/consent/ConsentMigrationUtils.java b/adservices/service-core/java/com/android/adservices/service/consent/ConsentMigrationUtils.java index 2ea541bc5..9bd7afd61 100644 --- a/adservices/service-core/java/com/android/adservices/service/consent/ConsentMigrationUtils.java +++ b/adservices/service-core/java/com/android/adservices/service/consent/ConsentMigrationUtils.java @@ -20,6 +20,8 @@ import static android.adservices.extdata.AdServicesExtDataParams.BOOLEAN_TRUE; import static android.adservices.extdata.AdServicesExtDataParams.BOOLEAN_UNKNOWN; import static android.adservices.extdata.AdServicesExtDataParams.STATE_MANUAL_INTERACTIONS_RECORDED; +import static com.android.adservices.service.consent.ConsentManager.getConsentManagerStatsForLogging; + import android.adservices.extdata.AdServicesExtDataParams; import android.annotation.NonNull; import android.annotation.TargetApi; @@ -35,6 +37,8 @@ import com.android.adservices.service.appsearch.AppSearchConsentManager; import com.android.adservices.service.appsearch.AppSearchConsentStorageManager; import com.android.adservices.service.common.compat.FileCompatUtils; import com.android.adservices.service.extdata.AdServicesExtDataStorageServiceManager; +import com.android.adservices.service.stats.ConsentMigrationStats; +import com.android.adservices.service.stats.StatsdAdServicesLogger; import com.android.modules.utils.build.SdkLevel; import java.util.Objects; @@ -51,16 +55,18 @@ public final class ConsentMigrationUtils { * as it's the new consent source of truth. If any new data is written for consent, we need to * make sure it is migrated correctly post-OTA in this method. */ + @TargetApi(Build.VERSION_CODES.S) public static void handleConsentMigrationToAppSearchIfNeeded( @NonNull Context context, @NonNull BooleanFileDatastore datastore, @Nullable AppSearchConsentManager appSearchConsentManager, - @Nullable AdServicesExtDataStorageServiceManager adExtDataManager) { + @Nullable AdServicesExtDataStorageServiceManager adExtDataManager, + @Nullable StatsdAdServicesLogger statsdAdServicesLogger) { Objects.requireNonNull(context); Objects.requireNonNull(datastore); + Objects.requireNonNull(statsdAdServicesLogger); LogUtil.d("Check if consent migration to AppSearch is needed."); - - // TODO (b/306753680): Add consent migration logging. + AppConsents appConsents = null; try { SharedPreferences sharedPreferences = FileCompatUtils.getSharedPreferencesHelper( @@ -79,20 +85,34 @@ public final class ConsentMigrationUtils { return; } - migrateDataToAppSearch(appSearchConsentManager, dataFromR, datastore); + appConsents = migrateDataToAppSearch(appSearchConsentManager, dataFromR, datastore); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(ConsentConstants.SHARED_PREFS_KEY_HAS_MIGRATED_TO_APP_SEARCH, true); if (editor.commit()) { LogUtil.d("Finished migrating consent to AppSearch."); + logMigrationToAppSearch( + statsdAdServicesLogger, + appConsents, + ConsentMigrationStats.MigrationStatus.SUCCESS_WITH_SHARED_PREF_UPDATED, + context); } else { LogUtil.e("Finished migrating consent to AppSearch. Shared prefs not updated."); + logMigrationToAppSearch( + statsdAdServicesLogger, + appConsents, + ConsentMigrationStats.MigrationStatus.SUCCESS_WITH_SHARED_PREF_NOT_UPDATED, + context); } - // No longer need access to Android R data. Safe to clear here. adExtDataManager.clearDataOnOtaAsync(); } catch (Exception e) { LogUtil.e("Consent migration to AppSearch failed: ", e); + logMigrationToAppSearch( + statsdAdServicesLogger, + appConsents, + ConsentMigrationStats.MigrationStatus.FAILURE, + context); } } @@ -244,7 +264,7 @@ public final class ConsentMigrationUtils { } @TargetApi(Build.VERSION_CODES.S) - private static void migrateDataToAppSearch( + private static AppConsents migrateDataToAppSearch( AppSearchConsentManager appSearchConsentManager, AdServicesExtDataParams dataFromR, BooleanFileDatastore datastore) { @@ -278,6 +298,34 @@ public final class ConsentMigrationUtils { if (dataFromR.getIsAdultAccount() != BOOLEAN_UNKNOWN) { appSearchConsentManager.setAdultAccount(dataFromR.getIsAdultAccount() == BOOLEAN_TRUE); } + + // Logging false for fledge and topics consent by default because only measurement is + // supported on R. + AppConsents appConsents = + AppConsents.builder() + .setDefaultConsent( + measurementDefaultConsent != null + ? measurementDefaultConsent + : false) + .setMsmtConsent(isMeasurementConsented) + .setFledgeConsent(false) + .setTopicsConsent(false) + .build(); + return appConsents; + } + + @TargetApi(Build.VERSION_CODES.S) + private static void logMigrationToAppSearch( + StatsdAdServicesLogger statsdAdServicesLogger, + AppConsents appConsents, + ConsentMigrationStats.MigrationStatus migrationStatus, + Context context) { + statsdAdServicesLogger.logConsentMigrationStats( + getConsentManagerStatsForLogging( + appConsents, + migrationStatus, + ConsentMigrationStats.MigrationType.ADEXT_SERVICE_TO_APPSEARCH, + context)); } @TargetApi(Build.VERSION_CODES.S) diff --git a/adservices/service-core/java/com/android/adservices/service/customaudience/CustomAudienceServiceImpl.java b/adservices/service-core/java/com/android/adservices/service/customaudience/CustomAudienceServiceImpl.java index 8373bb5eb..fcab6c9a8 100644 --- a/adservices/service-core/java/com/android/adservices/service/customaudience/CustomAudienceServiceImpl.java +++ b/adservices/service-core/java/com/android/adservices/service/customaudience/CustomAudienceServiceImpl.java @@ -203,8 +203,7 @@ public class CustomAudienceServiceImpl extends ICustomAudienceService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( - mContext, ownerPackageName, apiName); + mFledgeAuthorizationFilter.assertAppDeclaredPermission(mContext, ownerPackageName, apiName); final int callerUid = getCallingUid(apiName); final DevContext devContext = mDevContextFilter.createDevContext(); @@ -301,7 +300,7 @@ public class CustomAudienceServiceImpl extends ICustomAudienceService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, input.getCallerPackageName(), apiName); final int callerUid = getCallingUid(apiName); @@ -386,8 +385,7 @@ public class CustomAudienceServiceImpl extends ICustomAudienceService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( - mContext, ownerPackageName, apiName); + mFledgeAuthorizationFilter.assertAppDeclaredPermission(mContext, ownerPackageName, apiName); final int callerUid = getCallingUid(apiName); final DevContext devContext = mDevContextFilter.createDevContext(); @@ -506,7 +504,7 @@ public class CustomAudienceServiceImpl extends ICustomAudienceService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); CustomAudienceDao customAudienceDao = mCustomAudienceImpl.getCustomAudienceDao(); @@ -567,7 +565,7 @@ public class CustomAudienceServiceImpl extends ICustomAudienceService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); CustomAudienceDao customAudienceDao = mCustomAudienceImpl.getCustomAudienceDao(); @@ -616,7 +614,7 @@ public class CustomAudienceServiceImpl extends ICustomAudienceService.Stub { } // Caller permissions must be checked with a non-null callingAppPackageName - mFledgeAuthorizationFilter.assertAppDeclaredCustomAudiencePermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, devContext.getCallingAppPackageName(), apiName); CustomAudienceDao customAudienceDao = mCustomAudienceImpl.getCustomAudienceDao(); diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/PrivacyParams.java b/adservices/service-core/java/com/android/adservices/service/measurement/PrivacyParams.java index 00a945fa9..b62df0267 100644 --- a/adservices/service-core/java/com/android/adservices/service/measurement/PrivacyParams.java +++ b/adservices/service-core/java/com/android/adservices/service/measurement/PrivacyParams.java @@ -37,11 +37,6 @@ public final class PrivacyParams { public static final int EVENT_SOURCE_MAX_REPORTS = 1; /** - * Max reports for Install Attributed 'Navigation' {@link Source}. - */ - public static final int INSTALL_ATTR_NAVIGATION_SOURCE_MAX_REPORTS = 3; - - /** * Max reports for Install Attributed 'Event' {@link Source}. */ public static final int INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS = 2; diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/Source.java b/adservices/service-core/java/com/android/adservices/service/measurement/Source.java index 2fe5e16b0..35da5c705 100644 --- a/adservices/service-core/java/com/android/adservices/service/measurement/Source.java +++ b/adservices/service-core/java/com/android/adservices/service/measurement/Source.java @@ -121,6 +121,7 @@ public class Source { if (mParsedEventReportWindows != null) { return mParsedEventReportWindows; } + if (mEventReportWindows == null) { return null; } @@ -140,7 +141,8 @@ public class Source { } /** - * Returns parsed or default value of event report windows. + * Returns parsed or default value of event report windows (can be used during {@code Source} + * construction since the method does not require a {@code Source} object). * * @param eventReportWindows string to be parsed * @param sourceType Source's Type @@ -149,13 +151,13 @@ public class Source { * @return parsed or default value */ @Nullable - public static List<Pair<Long, Long>> getOrDefaultEventReportWindows( + public static List<Pair<Long, Long>> getOrDefaultEventReportWindowsForFlex( @Nullable JSONObject eventReportWindows, @NonNull SourceType sourceType, long expiryDelta, @NonNull Flags flags) { if (eventReportWindows == null) { - return getDefaultEventReportWindows(expiryDelta, sourceType, flags); + return getDefaultEventReportWindowsForFlex(expiryDelta, sourceType, flags); } return parseEventReportWindows(eventReportWindows); } @@ -180,17 +182,17 @@ public class Source { @NonNull JSONObject jsonObject) { List<Pair<Long, Long>> result = new ArrayList<>(); try { - long startDuration = 0; + long startTime = 0L; if (!jsonObject.isNull("start_time")) { - startDuration = jsonObject.getLong("start_time"); + startTime = jsonObject.getLong("start_time"); } JSONArray endTimesJSON = jsonObject.getJSONArray("end_times"); for (int i = 0; i < endTimesJSON.length(); i++) { - long endDuration = endTimesJSON.getLong(i); - Pair<Long, Long> window = new Pair<>(startDuration, endDuration); + long endTime = endTimesJSON.getLong(i); + Pair<Long, Long> window = Pair.create(startTime, endTime); result.add(window); - startDuration = endDuration; + startTime = endTime; } } catch (JSONException e) { LoggerFactory.getMeasurementLogger() @@ -200,24 +202,25 @@ public class Source { return result; } - private static List<Pair<Long, Long>> getDefaultEventReportWindows( + private static List<Pair<Long, Long>> getDefaultEventReportWindowsForFlex( long expiryDelta, SourceType sourceType, Flags flags) { List<Pair<Long, Long>> result = new ArrayList<>(); - List<Long> defaultEarlyWindows = - EventReportWindowCalcDelegate.getDefaultEarlyReportingWindows(sourceType, false); - List<Long> earlyWindows = + // Obtain default early report windows without regard to install-related behaviour. + List<Long> defaultEarlyWindowEnds = + EventReportWindowCalcDelegate.getDefaultEarlyReportingWindowEnds(sourceType, false); + List<Long> earlyWindowEnds = new EventReportWindowCalcDelegate(flags) - .getConfiguredOrDefaultEarlyReportingWindows( - sourceType, defaultEarlyWindows, false); + .getConfiguredOrDefaultEarlyReportingWindowEnds( + sourceType, defaultEarlyWindowEnds); long windowStart = 0; - for (long earlyWindow : earlyWindows) { - if (earlyWindow >= expiryDelta) { - continue; + for (long earlyWindowEnd : earlyWindowEnds) { + if (earlyWindowEnd >= expiryDelta) { + break; } - result.add(new Pair<>(windowStart, earlyWindow)); - windowStart = earlyWindow; + result.add(Pair.create(windowStart, earlyWindowEnd)); + windowStart = earlyWindowEnd; } - result.add(new Pair<>(windowStart, expiryDelta)); + result.add(Pair.create(windowStart, expiryDelta)); return result; } @@ -234,8 +237,7 @@ public class Source { } private double getInformationGainThreshold(Flags flags) { - int destinationMultiplier = getDestinationTypeMultiplier(flags); - if (destinationMultiplier == 2) { + if (getDestinationTypeMultiplier(flags) == 2) { return mSourceType == SourceType.EVENT ? flags.getMeasurementFlexApiMaxInformationGainDualDestinationEvent() : flags.getMeasurementFlexApiMaxInformationGainDualDestinationNavigation(); @@ -262,32 +264,31 @@ public class Source { setFlipProbability(mTriggerSpecs.getFlipProbability(this, flags)); return; } - boolean installCase = SourceNoiseHandler.isInstallDetectionEnabled(this); EventReportWindowCalcDelegate eventReportWindowCalcDelegate = new EventReportWindowCalcDelegate(flags); int reportingWindowCountForNoising = - eventReportWindowCalcDelegate.getReportingWindowCountForNoising(this, installCase); - int maxReportCount = - eventReportWindowCalcDelegate.getMaxReportCount(this, installCase); - int destinationMultiplier = getDestinationTypeMultiplier(flags); + eventReportWindowCalcDelegate.getReportingWindowCountForNoising(this); long numberOfStates = Combinatorics.getNumberOfStarsAndBarsSequences( - /*numStars=*/ maxReportCount, + /*numStars=*/ eventReportWindowCalcDelegate.getMaxReportCount(this), /*numBars=*/ getTriggerDataCardinality() * reportingWindowCountForNoising - * destinationMultiplier); + * getDestinationTypeMultiplier(flags)); setNumStates(numberOfStates); setFlipProbability(Combinatorics.getFlipProbability(numberOfStates)); } + /** Should source report coarse destinations */ + public boolean shouldReportCoarseDestinations(Flags flags) { + return flags.getMeasurementEnableCoarseEventReportDestinations() + && hasCoarseEventReportDestinations(); + } + /** * Returns the number of destination types to use in privacy computations. */ public int getDestinationTypeMultiplier(Flags flags) { - boolean shouldReportCoarseDestinations = - flags.getMeasurementEnableCoarseEventReportDestinations() - && hasCoarseEventReportDestinations(); - return !shouldReportCoarseDestinations && hasAppDestinations() + return !shouldReportCoarseDestinations(flags) && hasAppDestinations() && hasWebDestinations() ? SourceNoiseHandler.DUAL_DESTINATION_IMPRESSION_NOISE_MULTIPLIER : SourceNoiseHandler.SINGLE_DESTINATION_IMPRESSION_NOISE_MULTIPLIER; @@ -650,9 +651,9 @@ public class Source { /** * Time when {@link Source} event report window will expire. (Appends the Event Time to window) */ - public Long getProcessedEventReportWindow() { + public long getEffectiveEventReportWindow() { if (mEventReportWindow == null) { - return null; + return getExpiryTime(); } // TODO(b/290098169): Cleanup after a few releases // Handling cases where ReportWindow is already stored as mEventTime + mEventReportWindow @@ -744,6 +745,11 @@ public class Source { return mInstallCooldownWindow; } + /** Check if install detection is enabled for the source. */ + public boolean isInstallDetectionEnabled() { + return getInstallCooldownWindow() > 0 && hasAppDestinations(); + } + /** * Is an App-install attributed to the {@link Source}. */ @@ -971,10 +977,9 @@ public class Source { @Nullable Integer maxEventLevelReports, @NonNull Flags flags) { if (maxEventLevelReports == null) { - maxEventLevelReports = - sourceType == Source.SourceType.NAVIGATION - ? PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS - : flags.getMeasurementVtcConfigurableMaxEventReportsCount(); + return sourceType == Source.SourceType.NAVIGATION + ? PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS + : flags.getMeasurementVtcConfigurableMaxEventReportsCount(); } return maxEventLevelReports; } diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/attribution/AttributionJobHandler.java b/adservices/service-core/java/com/android/adservices/service/measurement/attribution/AttributionJobHandler.java index 58251ca9a..3d2eec8c2 100644 --- a/adservices/service-core/java/com/android/adservices/service/measurement/attribution/AttributionJobHandler.java +++ b/adservices/service-core/java/com/android/adservices/service/measurement/attribution/AttributionJobHandler.java @@ -1329,16 +1329,10 @@ class AttributionJobHandler { private boolean isWithinReportLimit( Source source, int existingReportCount, @EventSurfaceType int destinationType) { - return mEventReportWindowCalcDelegate.getMaxReportCount( - source, hasAppInstallAttributionOccurred(source, destinationType)) + return mEventReportWindowCalcDelegate.getMaxReportCount(source, destinationType) > existingReportCount; } - private static boolean hasAppInstallAttributionOccurred( - Source source, @EventSurfaceType int destinationType) { - return destinationType == EventSurfaceType.APP && source.isInstallAttributed(); - } - private static boolean isWithinInstallCooldownWindow(Source source, Trigger trigger) { return trigger.getTriggerTime() < (source.getEventTime() + source.getInstallCooldownWindow()); diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/noising/ImpressionNoiseUtil.java b/adservices/service-core/java/com/android/adservices/service/measurement/noising/ImpressionNoiseUtil.java index 0a456919f..c83f608b6 100644 --- a/adservices/service-core/java/com/android/adservices/service/measurement/noising/ImpressionNoiseUtil.java +++ b/adservices/service-core/java/com/android/adservices/service/measurement/noising/ImpressionNoiseUtil.java @@ -29,72 +29,6 @@ import java.util.concurrent.ThreadLocalRandom; */ public final class ImpressionNoiseUtil { - /** - * This is used in the scenario where both app and web destinations are available with the - * {@link com.android.adservices.service.measurement.Source} and the source is of {@link - * com.android.adservices.service.measurement.Source.SourceType#EVENT} type and post-install - * detection is enabled (cooldown window being available). It's a special case because in this - * condition an extra early window is added only if install detection is enabled (install - * cool-down window is available) and only app conversions are relevant in that window. - * - * <p>Reading guide - The outermost array signifies different states of reporting - one of them - * will be picked at a time. The middle array holds reports in 1st and 2nd window, so there will - * be either 0 elements (no conversions in either window), 1 element (a conversion report in one - * of the windows) and 2 elements (conversions in both windows). The innermost array represents - * a single report. 3 elements in the innermost array are trigger metadata (0 - trigger1 or 1 - - * trigger2), window index (0 - window1, 1 - window2) and destination type (0 - app or 1 - web). - * - * <p>E.g. The element at index 5 is {{0, 1, 0}, {0, 1, 0}}, it means 2 conversions with trigger - * metadata as 0 in window2 (1) of app destination type(0). - */ - public static final int[][][] DUAL_DESTINATION_POST_INSTALL_FAKE_REPORT_CONFIG = - new int[][][] { - // window1 - no conversion, window 2 - no conversion - {}, - // window1 - no conversion, window 2 - 1 conversion with metadata 0 - {{0, 1, 0}}, - {{0, 1, 1}}, - // window1 - no conversion, window 2 - 1 conversion with metadata 1 - {{1, 1, 0}}, - {{1, 1, 1}}, - // window1 - no conversion, window 2 - 2 conversions with metadata 0 and 0 - {{0, 1, 0}, {0, 1, 0}}, - {{0, 1, 0}, {0, 1, 1}}, - // window1 - no conversion, window 2 - 2 conversions with metadata 0 and 1 - {{0, 1, 0}, {1, 1, 0}}, - {{0, 1, 0}, {1, 1, 1}}, - {{0, 1, 1}, {1, 1, 0}}, - // window1 - no conversion, window 2 - 2 conversions with metadata 1 and 1 - {{1, 1, 0}, {1, 1, 0}}, - {{1, 1, 0}, {1, 1, 1}}, - // window1 - 1 app conversion with metadata 0, window 2 - no conversion - {{0, 0, 0}}, - // window1 - 1 app conversion with metadata 1, window 2 - no conversion - {{1, 0, 0}}, - // window1 - 2 conversions with metadata 0 and 0, window 2 - no conversion - {{0, 0, 0}, {0, 0, 0}}, - // window1 - 2 app conversions with metadata 0 and 1, window 2 - no conversion - {{0, 0, 0}, {1, 0, 0}}, - // window1 - 2 app conversions with metadata 1 and 1, window 2 - no conversion - {{1, 0, 0}, {1, 0, 0}}, - // window1 - 1 app conversion with metadata 0, window 2 - 1 conversion with - // metadata 0 - {{0, 0, 0}, {0, 1, 0}}, - {{0, 0, 0}, {0, 1, 1}}, - // window1 - 1 app conversion with metadata 0, window 2 - 1 conversion with - // metadata 1 - {{0, 0, 0}, {1, 1, 0}}, - {{0, 0, 0}, {1, 1, 1}}, - // window1 - 1 app conversion with metadata 1, window 2 - 1 conversions with - // metadata 0 - {{1, 0, 0}, {0, 1, 0}}, - {{1, 0, 0}, {0, 1, 1}}, - // window1 - 1 app conversion with metadata 1, window 2 - 1 conversions with - // metadata 1 - {{1, 0, 0}, {1, 1, 0}}, - {{1, 0, 0}, {1, 1, 1}} - }; - private ImpressionNoiseUtil() {} /** diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/noising/SourceNoiseHandler.java b/adservices/service-core/java/com/android/adservices/service/measurement/noising/SourceNoiseHandler.java index 2c28fa51e..8897662a9 100644 --- a/adservices/service-core/java/com/android/adservices/service/measurement/noising/SourceNoiseHandler.java +++ b/adservices/service-core/java/com/android/adservices/service/measurement/noising/SourceNoiseHandler.java @@ -30,11 +30,9 @@ import com.google.common.collect.ImmutableList; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.Random; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; @@ -85,33 +83,24 @@ public class SourceNoiseHandler { List<Source.FakeReport> fakeReports; TriggerSpecs triggerSpecs = source.getTriggerSpecs(); if (triggerSpecs == null) { - if (isVtcDualDestinationModeWithPostInstallEnabled(source)) { - // Source is 'EVENT' type, both app and web destination are set and install - // exclusivity - // window is provided. Pick one of the static reporting states randomly. - fakeReports = generateVtcDualDestinationPostInstallFakeReports(source); - } else { - // There will at least be one (app or web) destination available - ImpressionNoiseParams noiseParams = getImpressionNoiseParams(source); - fakeReports = - ImpressionNoiseUtil.selectRandomStateAndGenerateReportConfigs( - noiseParams, rand) - .stream() - .map( - reportConfig -> - new Source.FakeReport( - new UnsignedLong( - Long.valueOf(reportConfig[0])), - mEventReportWindowCalcDelegate - .getReportingTimeForNoising( - source, - reportConfig[1], - isInstallDetectionEnabled( - source)), - resolveFakeReportDestinations( - source, reportConfig[2]))) - .collect(Collectors.toList()); - } + // There will at least be one (app or web) destination available + ImpressionNoiseParams noiseParams = getImpressionNoiseParams(source); + fakeReports = + ImpressionNoiseUtil.selectRandomStateAndGenerateReportConfigs( + noiseParams, rand) + .stream() + .map( + reportConfig -> + new Source.FakeReport( + new UnsignedLong( + Long.valueOf(reportConfig[0])), + mEventReportWindowCalcDelegate + .getReportingTimeForNoising( + source, + reportConfig[1]), + resolveFakeReportDestinations( + source, reportConfig[2]))) + .collect(Collectors.toList()); } else { int destinationTypeMultiplier = source.getDestinationTypeMultiplier(mFlags); List<int[]> fakeReportConfigs = @@ -144,51 +133,11 @@ public class SourceNoiseHandler { /** @return Probability of selecting random state for attribution */ public double getRandomAttributionProbability(@NonNull Source source) { - if (source.getTriggerSpecs() != null - || mFlags.getMeasurementEnableConfigurableEventReportingWindows() - || mFlags.getMeasurementEnableVtcConfigurableMaxEventReports() - || (mFlags.getMeasurementFlexLiteApiEnabled() - && (source.getMaxEventLevelReports() != null - || source.hasManualEventReportWindows()))) { - return convertToDoubleAndLimitDecimal(source.getFlipProbability(mFlags)); - } - // TODO(b/290117352): Remove Hardcoded noise values - - // Both destinations are set and install attribution is supported - if (!shouldReportCoarseDestinations(source) - && source.hasWebDestinations() - && isInstallDetectionEnabled(source)) { - return source.getSourceType() == Source.SourceType.EVENT - ? convertToDoubleAndLimitDecimal( - mFlags.getMeasurementInstallAttrDualDestinationEventNoiseProbability()) - : convertToDoubleAndLimitDecimal( - mFlags.getMeasurementInstallAttrDualDestinationNavigationNoiseProbability()); - } - - // Both destinations are set but install attribution isn't supported - if (!shouldReportCoarseDestinations(source) - && source.hasAppDestinations() - && source.hasWebDestinations()) { - return source.getSourceType() == Source.SourceType.EVENT - ? convertToDoubleAndLimitDecimal( - mFlags.getMeasurementDualDestinationEventNoiseProbability()) - : convertToDoubleAndLimitDecimal( - mFlags.getMeasurementDualDestinationNavigationNoiseProbability()); - } - - // App destination is set and install attribution is supported - if (isInstallDetectionEnabled(source)) { - return source.getSourceType() == Source.SourceType.EVENT - ? convertToDoubleAndLimitDecimal( - mFlags.getMeasurementInstallAttrEventNoiseProbability()) - : convertToDoubleAndLimitDecimal( - mFlags.getMeasurementInstallAttrNavigationNoiseProbability()); - } - - // One of the destinations is available without install attribution support - return source.getSourceType() == Source.SourceType.EVENT - ? convertToDoubleAndLimitDecimal(mFlags.getMeasurementEventNoiseProbability()) - : convertToDoubleAndLimitDecimal(mFlags.getMeasurementNavigationNoiseProbability()); + // Methods on Source and EventReportWindowCalcDelegate that calculate flip probability for + // the source rely on reporting windows and max reports that are obtained with consideration + // to install-state and its interaction with configurable report windows and configurable + // max reports. + return convertToDoubleAndLimitDecimal(source.getFlipProbability(mFlags)); } private double convertToDoubleAndLimitDecimal(double probability) { @@ -197,15 +146,6 @@ public class SourceNoiseHandler { .doubleValue(); } - private boolean isVtcDualDestinationModeWithPostInstallEnabled(Source source) { - return !shouldReportCoarseDestinations(source) - && !source.hasManualEventReportWindows() - && source.getMaxEventLevelReports() == null - && source.getSourceType() == Source.SourceType.EVENT - && source.hasWebDestinations() - && isInstallDetectionEnabled(source); - } - /** * Either both app and web destinations can be available or one of them will be available. When * both destinations are available, we double the number of states at noise generation to be @@ -216,7 +156,7 @@ public class SourceNoiseHandler { * @return app or web destination {@link Uri} */ private List<Uri> resolveFakeReportDestinations(Source source, int destinationIdentifier) { - if (shouldReportCoarseDestinations(source)) { + if (source.shouldReportCoarseDestinations(mFlags)) { ImmutableList.Builder<Uri> destinations = new ImmutableList.Builder<>(); Optional.ofNullable(source.getAppDestinations()).ifPresent(destinations::addAll); Optional.ofNullable(source.getWebDestinations()).ifPresent(destinations::addAll); @@ -234,44 +174,13 @@ public class SourceNoiseHandler { : source.getWebDestinations(); } - /** Check if install detection is enabled for the source. */ - public static boolean isInstallDetectionEnabled(@NonNull Source source) { - return source.getInstallCooldownWindow() > 0 && source.hasAppDestinations(); - } - - private boolean shouldReportCoarseDestinations(Source source) { - return mFlags.getMeasurementEnableCoarseEventReportDestinations() - && source.hasCoarseEventReportDestinations(); - } - - private List<Source.FakeReport> generateVtcDualDestinationPostInstallFakeReports( - Source source) { - int[][][] fakeReportsConfig = - ImpressionNoiseUtil.DUAL_DESTINATION_POST_INSTALL_FAKE_REPORT_CONFIG; - int randomIndex = new Random().nextInt(fakeReportsConfig.length); - int[][] reportsConfig = fakeReportsConfig[randomIndex]; - return Arrays.stream(reportsConfig) - .map( - reportConfig -> - new Source.FakeReport( - new UnsignedLong(Long.valueOf(reportConfig[0])), - mEventReportWindowCalcDelegate.getReportingTimeForNoising( - source, - /* window index */ reportConfig[1], - isInstallDetectionEnabled(source)), - resolveFakeReportDestinations(source, reportConfig[2]))) - .collect(Collectors.toList()); - } - @VisibleForTesting ImpressionNoiseParams getImpressionNoiseParams(Source source) { int destinationTypeMultiplier = source.getDestinationTypeMultiplier(mFlags); return new ImpressionNoiseParams( - mEventReportWindowCalcDelegate.getMaxReportCount( - source, isInstallDetectionEnabled(source)), + mEventReportWindowCalcDelegate.getMaxReportCount(source), source.getTriggerDataCardinality(), - mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - source, isInstallDetectionEnabled(source)), + mEventReportWindowCalcDelegate.getReportingWindowCountForNoising(source), destinationTypeMultiplier); } } diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/registration/AsyncSourceFetcher.java b/adservices/service-core/java/com/android/adservices/service/measurement/registration/AsyncSourceFetcher.java index 2140bcb62..26157a01b 100644 --- a/adservices/service-core/java/com/android/adservices/service/measurement/registration/AsyncSourceFetcher.java +++ b/adservices/service-core/java/com/android/adservices/service/measurement/registration/AsyncSourceFetcher.java @@ -492,8 +492,9 @@ public class AsyncSourceFetcher { Source.SourceType sourceType, int maxEventLevelReports, Source.TriggerDataMatching triggerDataMatching) { - List<Pair<Long, Long>> parsedEventReportWindows = Source.getOrDefaultEventReportWindows( - eventReportWindows, sourceType, expiry, mFlags); + List<Pair<Long, Long>> parsedEventReportWindows = + Source.getOrDefaultEventReportWindowsForFlex( + eventReportWindows, sourceType, expiry, mFlags); long defaultStart = parsedEventReportWindows.get(0).first; List<Long> defaultEnds = parsedEventReportWindows.stream().map((x) -> x.second).collect(Collectors.toList()); diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegate.java b/adservices/service-core/java/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegate.java index 813fbd03c..93f791385 100644 --- a/adservices/service-core/java/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegate.java +++ b/adservices/service-core/java/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegate.java @@ -54,36 +54,42 @@ public class EventReportWindowCalcDelegate { } /** - * Max reports count based on conversion destination type and installation state. + * Max reports count given the Source object. * - * @param isInstallCase is app installed + * @param source the Source object * @return maximum number of reports allowed */ - public int getMaxReportCount(@NonNull Source source, boolean isInstallCase) { + public int getMaxReportCount(Source source) { + return getMaxReportCount(source, source.isInstallDetectionEnabled()); + } + + /** + * Max reports count based on conversion destination type. + * + * @param source the Source object + * @param destinationType destination type + * @return maximum number of reports allowed + */ + public int getMaxReportCount(@NonNull Source source, @EventSurfaceType int destinationType) { + return getMaxReportCount(source, isInstallCase(source, destinationType)); + } + + private int getMaxReportCount(@NonNull Source source, boolean isInstallCase) { // TODO(b/290101531): Cleanup flags if (mFlags.getMeasurementFlexLiteApiEnabled() && source.getMaxEventLevelReports() != null) { return source.getMaxEventLevelReports(); } - if (source.getSourceType() == Source.SourceType.EVENT - && mFlags.getMeasurementEnableVtcConfigurableMaxEventReports()) { - // Max VTC event reports are configurable - int configuredMaxReports = mFlags.getMeasurementVtcConfigurableMaxEventReportsCount(); + + if (source.getSourceType() == Source.SourceType.EVENT) { // Additional report essentially for first open + 1 post install conversion. If there // is already more than 1 report allowed, no need to have that additional report. - if (isInstallCase && configuredMaxReports == PrivacyParams.EVENT_SOURCE_MAX_REPORTS) { + if (isInstallCase && !source.hasWebDestinations() && isDefaultConfiguredVtc()) { return PrivacyParams.INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS; } - return configuredMaxReports; + return mFlags.getMeasurementVtcConfigurableMaxEventReportsCount(); } - if (isInstallCase) { - return source.getSourceType() == Source.SourceType.EVENT - ? PrivacyParams.INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS - : PrivacyParams.INSTALL_ATTR_NAVIGATION_SOURCE_MAX_REPORTS; - } - return source.getSourceType() == Source.SourceType.EVENT - ? PrivacyParams.EVENT_SOURCE_MAX_REPORTS - : PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS; + return PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS; } /** @@ -100,18 +106,14 @@ public class EventReportWindowCalcDelegate { // Cases where source could have both web and app destinations, there if the trigger // destination is an app, and it was installed, then installState should be considered true. - boolean isAppInstalled = isAppInstalled(source, destinationType); - List<Pair<Long, Long>> earlyReportingWindows = - getEarlyReportingWindows(source, isAppInstalled); - for (Pair<Long, Long> window : earlyReportingWindows) { + List<Pair<Long, Long>> reportingWindows = + getEffectiveReportingWindows(source, isInstallCase(source, destinationType)); + for (Pair<Long, Long> window : reportingWindows) { if (isWithinWindow(triggerTime, window)) { return window.second + mFlags.getMeasurementMinEventReportDelayMillis(); } } - Pair<Long, Long> finalWindow = getFinalReportingWindow(source, earlyReportingWindows); - if (isWithinWindow(triggerTime, finalWindow)) { - return finalWindow.second + mFlags.getMeasurementMinEventReportDelayMillis(); - } + return -1; } @@ -137,20 +139,12 @@ public class EventReportWindowCalcDelegate { */ public MomentPlacement fallsWithinWindow( @NonNull Source source, long triggerTime, @EventSurfaceType int destinationType) { - boolean isAppInstalled = isAppInstalled(source, destinationType); - List<Pair<Long, Long>> earlyReportingWindows = - getEarlyReportingWindows(source, isAppInstalled); - if (earlyReportingWindows.size() > 0) { - Long firstWindowStartTime = earlyReportingWindows.get(0).first; - if (triggerTime < firstWindowStartTime) { - return MomentPlacement.BEFORE; - } - } - Pair<Long, Long> finalWindow = getFinalReportingWindow(source, earlyReportingWindows); - if (earlyReportingWindows.size() == 0 && triggerTime < finalWindow.first) { + List<Pair<Long, Long>> reportingWindows = + getEffectiveReportingWindows(source, isInstallCase(source, destinationType)); + if (triggerTime < reportingWindows.get(0).first) { return MomentPlacement.BEFORE; } - if (triggerTime >= finalWindow.second) { + if (triggerTime >= reportingWindows.get(reportingWindows.size() - 1).second) { return MomentPlacement.AFTER; } return MomentPlacement.WITHIN; @@ -163,39 +157,25 @@ public class EventReportWindowCalcDelegate { * @return reporting time in milliseconds */ public long getReportingTimeForNoising( - @NonNull Source source, int windowIndex, boolean isInstallCase) { - List<Pair<Long, Long>> earlyWindows = getEarlyReportingWindows(source, isInstallCase); - Pair<Long, Long> finalWindow = getFinalReportingWindow(source, earlyWindows); - return windowIndex < earlyWindows.size() - ? earlyWindows.get(windowIndex).second + @NonNull Source source, int windowIndex) { + List<Pair<Long, Long>> reportingWindows = getEffectiveReportingWindows( + source, source.isInstallDetectionEnabled()); + Pair<Long, Long> finalWindow = reportingWindows.get(reportingWindows.size() - 1); + // TODO: (b/288646239) remove this check, confirming noising indexing accuracy. + return windowIndex < reportingWindows.size() + ? reportingWindows.get(windowIndex).second + mFlags.getMeasurementMinEventReportDelayMillis() : finalWindow.second + mFlags.getMeasurementMinEventReportDelayMillis(); } - private Pair<Long, Long> getFinalReportingWindow( - Source source, List<Pair<Long, Long>> earlyWindows) { - if (mFlags.getMeasurementFlexLiteApiEnabled() && source.hasManualEventReportWindows()) { - List<Pair<Long, Long>> windowList = source.parsedProcessedEventReportWindows(); - return windowList.get(windowList.size() - 1); - } - long secondToLastWindowEnd = - !earlyWindows.isEmpty() ? earlyWindows.get(earlyWindows.size() - 1).second : 0; - if (source.getProcessedEventReportWindow() != null) { - return new Pair<>(secondToLastWindowEnd, source.getProcessedEventReportWindow()); - } - return new Pair<>(secondToLastWindowEnd, source.getExpiryTime()); - } - /** - * Returns effective, i.e. the ones that occur before {@link - * Source#getProcessedEventReportWindow()}, event reporting windows count for noising cases. + * Returns effective, that is, the ones that occur before {@link + * Source#getEffectiveEventReportWindow()}, event reporting windows count for noising cases. * * @param source source for which the count is requested - * @param isInstallCase true of cool down window was specified */ - public int getReportingWindowCountForNoising(@NonNull Source source, boolean isInstallCase) { - // Early Count + lastWindow - return getEarlyReportingWindows(source, isInstallCase).size() + 1; + public int getReportingWindowCountForNoising(@NonNull Source source) { + return getEffectiveReportingWindows(source, source.isInstallDetectionEnabled()).size(); } /** @@ -250,47 +230,53 @@ public class EventReportWindowCalcDelegate { return -1L; } - private boolean isAppInstalled(Source source, int destinationType) { + private static boolean isInstallCase(Source source, @EventSurfaceType int destinationType) { return destinationType == EventSurfaceType.APP && source.isInstallAttributed(); } /** * If the flag is enabled and the specified report windows are valid, picks from flag controlled - * configurable early reporting windows. Otherwise, falls back to the statical {@link - * com.android.adservices.service.measurement.PrivacyParams} values. It curtails the windows - * that occur after {@link Source#getProcessedEventReportWindow()} because they would - * effectively be unusable. + * configurable early reporting windows. Otherwise, falls back to the values provided in + * {@code getDefaultEarlyReportingWindowEnds}, which can have install-related custom behaviour. + * It curtails the windows that occur after {@link Source#getEffectiveEventReportWindow()} + * because they would effectively be unusable. */ - private List<Pair<Long, Long>> getEarlyReportingWindows(Source source, boolean installState) { + private List<Pair<Long, Long>> getEffectiveReportingWindows(Source source, + boolean installState) { // TODO(b/290221611) Remove early reporting windows from code, only use them for flags. if (mFlags.getMeasurementFlexLiteApiEnabled() && source.hasManualEventReportWindows()) { - List<Pair<Long, Long>> windows = source.parsedProcessedEventReportWindows(); - // Select early windows only i.e. skip the last element - return windows.subList(0, windows.size() - 1); + return source.parsedProcessedEventReportWindows(); } - List<Long> earlyWindows; - List<Long> defaultEarlyWindows = - getDefaultEarlyReportingWindows(source.getSourceType(), installState); - earlyWindows = - getConfiguredOrDefaultEarlyReportingWindows( - source.getSourceType(), defaultEarlyWindows, true); + List<Long> defaultEarlyWindowEnds = + getDefaultEarlyReportingWindowEnds( + source.getSourceType(), + installState && !source.hasWebDestinations()); + List<Long> earlyWindowEnds = + getConfiguredOrDefaultEarlyReportingWindowEnds( + source.getSourceType(), defaultEarlyWindowEnds); // Add source event time to windows - earlyWindows = - earlyWindows.stream() + earlyWindowEnds = + earlyWindowEnds.stream() .map((x) -> source.getEventTime() + x) .collect(Collectors.toList()); List<Pair<Long, Long>> windowList = new ArrayList<>(); - long windowStart = 0; + long windowStart = 0L; Pair<Long, Long> finalWindow = - getFinalReportingWindow(source, createStartEndWindow(earlyWindows)); - for (long windowEnd : earlyWindows) { - if (finalWindow.second <= windowEnd) { - continue; + getFinalReportingWindow(source, earlyWindowEnds); + + for (long windowEnd : earlyWindowEnds) { + // Start time of `finalWindow` is either 0 or one of `earlyWindowEnds` times; stop + // iterating if we see it, and add `finalWindow`. + if (windowStart == finalWindow.first) { + break; } - windowList.add(new Pair<>(windowStart, windowEnd)); + windowList.add(Pair.create(windowStart, windowEnd)); windowStart = windowEnd; } + + windowList.add(finalWindow); + return ImmutableList.copyOf(windowList); } @@ -298,13 +284,13 @@ public class EventReportWindowCalcDelegate { * Returns the default early reporting windows * * @param sourceType Source's Type - * @param installState Install State of the source + * @param installAttributionEnabled whether windows for install attribution should be provided * @return a list of windows */ - public static List<Long> getDefaultEarlyReportingWindows( - Source.SourceType sourceType, boolean installState) { + public static List<Long> getDefaultEarlyReportingWindowEnds( + Source.SourceType sourceType, boolean installAttributionEnabled) { long[] earlyWindows; - if (installState) { + if (installAttributionEnabled) { earlyWindows = sourceType == Source.SourceType.EVENT ? INSTALL_ATTR_EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS @@ -318,53 +304,34 @@ public class EventReportWindowCalcDelegate { return asList(earlyWindows); } - private List<Pair<Long, Long>> createStartEndWindow(List<Long> windowEnds) { - List<Pair<Long, Long>> windows = new ArrayList<>(); - long start = 0; - for (Long end : windowEnds) { - windows.add(new Pair<>(start, end)); - start = end; - } - return windows; - } - /** * Returns default or configured (via flag) early reporting windows for the SourceType * * @param sourceType Source's Type * @param defaultEarlyWindows default value for early windows - * @param checkEnableFlag set true if configurable window flag should be checked * @return list of windows */ - public List<Long> getConfiguredOrDefaultEarlyReportingWindows( - Source.SourceType sourceType, List<Long> defaultEarlyWindows, boolean checkEnableFlag) { - // TODO(b/290101531): Cleanup flags - if (checkEnableFlag && !mFlags.getMeasurementEnableConfigurableEventReportingWindows()) { - return defaultEarlyWindows; + public List<Long> getConfiguredOrDefaultEarlyReportingWindowEnds( + Source.SourceType sourceType, List<Long> defaultEarlyWindowEnds) { + // `defaultEarlyWindowEnds` may contain custom install-related logic, which we only apply if + // the configurable report windows (and max reports) are in their default state. Without + // this check, we may construct default-value report windows without the custom + // install-related logic applied. + if ((sourceType == Source.SourceType.EVENT && isDefaultConfiguredVtc()) + || (sourceType == Source.SourceType.NAVIGATION && isDefaultConfiguredCtc())) { + return defaultEarlyWindowEnds; } String earlyReportingWindowsString = pickEarlyReportingWindowsConfig(mFlags, sourceType); - if (earlyReportingWindowsString == null) { - LoggerFactory.getMeasurementLogger() - .d("Invalid configurable early reporting windows; null"); - return defaultEarlyWindows; - } - if (earlyReportingWindowsString.isEmpty()) { // No early reporting windows specified. It needs to be handled separately because - // splitting an empty string results into an array containing a single element, - // i.e. "". We want to handle it as an array having no element. - - if (Source.SourceType.EVENT.equals(sourceType)) { - // We need to add a reporting window at 2d for post-install case. Non-install case - // has no early reporting window by default. - return defaultEarlyWindows; - } + // splitting an empty string results in an array containing a single empty string. We + // want to handle it as an empty array. return Collections.emptyList(); } - ImmutableList.Builder<Long> earlyWindows = new ImmutableList.Builder<>(); + ImmutableList.Builder<Long> earlyWindowEnds = new ImmutableList.Builder<>(); String[] split = earlyReportingWindowsString.split(EARLY_REPORTING_WINDOWS_CONFIG_DELIMITER); if (split.length > MAX_CONFIGURABLE_EVENT_REPORT_EARLY_REPORTING_WINDOWS) { @@ -372,22 +339,54 @@ public class EventReportWindowCalcDelegate { .d( "Invalid configurable early reporting window; more than allowed size: " + MAX_CONFIGURABLE_EVENT_REPORT_EARLY_REPORTING_WINDOWS); - return defaultEarlyWindows; + return defaultEarlyWindowEnds; } - for (String window : split) { + for (String windowEnd : split) { try { - earlyWindows.add(TimeUnit.SECONDS.toMillis(Long.parseLong(window))); + earlyWindowEnds.add(TimeUnit.SECONDS.toMillis(Long.parseLong(windowEnd))); } catch (NumberFormatException e) { LoggerFactory.getMeasurementLogger() .d(e, "Configurable early reporting window parsing failed."); - return defaultEarlyWindows; + return defaultEarlyWindowEnds; } } - return earlyWindows.build(); + return earlyWindowEnds.build(); + } + + private Pair<Long, Long> getFinalReportingWindow( + Source source, List<Long> earlyWindowEnds) { + // The latest end-time we can associate with a report for this source + long effectiveExpiry = Math.min( + source.getEffectiveEventReportWindow(), source.getExpiryTime()); + // Find the latest end-time that can start a window ending at effectiveExpiry + for (int i = earlyWindowEnds.size() - 1; i >= 0; i--) { + long windowEnd = earlyWindowEnds.get(i); + if (windowEnd < effectiveExpiry) { + return Pair.create(windowEnd, effectiveExpiry); + } + } + return Pair.create(0L, effectiveExpiry); + } + + /** Indicates whether VTC report windows and max reports are default configured, which can + * affect custom install-related attribution. + */ + public boolean isDefaultConfiguredVtc() { + return mFlags.getMeasurementEventReportsVtcEarlyReportingWindows().isEmpty() + && mFlags.getMeasurementVtcConfigurableMaxEventReportsCount() == 1; + } + + /** Indicates whether CTC report windows are default configured, which can affect custom + * install-related attribution. + */ + private boolean isDefaultConfiguredCtc() { + return mFlags.getMeasurementEventReportsCtcEarlyReportingWindows().equals( + Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS); } - private String pickEarlyReportingWindowsConfig(Flags flags, Source.SourceType sourceType) { + private static String pickEarlyReportingWindowsConfig(Flags flags, + Source.SourceType sourceType) { return sourceType == Source.SourceType.EVENT ? flags.getMeasurementEventReportsVtcEarlyReportingWindows() : flags.getMeasurementEventReportsCtcEarlyReportingWindows(); diff --git a/adservices/service-core/java/com/android/adservices/service/shell/AdServicesShellCommandHandler.java b/adservices/service-core/java/com/android/adservices/service/shell/AdServicesShellCommandHandler.java index 08efcc33d..d93eba2db 100644 --- a/adservices/service-core/java/com/android/adservices/service/shell/AdServicesShellCommandHandler.java +++ b/adservices/service-core/java/com/android/adservices/service/shell/AdServicesShellCommandHandler.java @@ -89,13 +89,20 @@ public final class AdServicesShellCommandHandler { private static final int RESULT_GENERIC_ERROR = -1; private final PrintWriter mOut; + private final PrintWriter mErr; private String[] mArgs; private int mArgPos; private String mCurArgData; + /** If PrintWriter {@code err} is not provided, we use {@code out} for the {@code err}. */ public AdServicesShellCommandHandler(PrintWriter out) { + this(out, /* err= */ out); + } + + public AdServicesShellCommandHandler(PrintWriter out, PrintWriter err) { mOut = Objects.requireNonNull(out, "out cannot be null"); + mErr = Objects.requireNonNull(err, "err cannot be null"); } /** Runs the given command ({@code args[0]}) and optional arguments */ @@ -117,13 +124,14 @@ public final class AdServicesShellCommandHandler { } } catch (Throwable e) { // TODO(b/308009734): need to test this - mOut.printf("Exception occurred while executing %s\n", Arrays.toString(mArgs)); + mErr.printf("Exception occurred while executing %s\n", Arrays.toString(mArgs)); e.printStackTrace(mOut); } finally { if (DEBUG) { Log.d(TAG, "Flushing output"); } mOut.flush(); + mErr.flush(); } if (DEBUG) { Log.d(TAG, "Sending command result: " + res); @@ -173,7 +181,7 @@ public final class AdServicesShellCommandHandler { } private int invalidArgsError(String syntax) { - mOut.println(String.format(ERROR_TEMPLATE_INVALID_ARGS, Arrays.toString(mArgs), syntax)); + mErr.println(String.format(ERROR_TEMPLATE_INVALID_ARGS, Arrays.toString(mArgs), syntax)); return RESULT_GENERIC_ERROR; } @@ -193,9 +201,9 @@ public final class AdServicesShellCommandHandler { case CMD_SHORT_HELP: case CMD_HELP: onHelp(); - return RESULT_GENERIC_ERROR; + return RESULT_OK; case "": - mOut.println(ERROR_EMPTY_COMMAND); + mErr.println(ERROR_EMPTY_COMMAND); return RESULT_GENERIC_ERROR; case CMD_ECHO: return runEcho(); @@ -204,7 +212,7 @@ public final class AdServicesShellCommandHandler { case CMD_IS_ALLOWED_TOPICS_ACCESS: return runIsAllowedApiAccess(cmd); default: - mOut.printf("Unknown command: %s\n", cmd); + mErr.printf("Unknown command: %s\n", cmd); return RESULT_GENERIC_ERROR; } } diff --git a/adservices/service-core/java/com/android/adservices/service/shell/ShellCommandServiceImpl.java b/adservices/service-core/java/com/android/adservices/service/shell/ShellCommandServiceImpl.java new file mode 100644 index 000000000..285396c15 --- /dev/null +++ b/adservices/service-core/java/com/android/adservices/service/shell/ShellCommandServiceImpl.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.adservices.service.shell; + +import android.adservices.shell.IShellCommand; +import android.adservices.shell.IShellCommandCallback; +import android.adservices.shell.ShellCommandParam; +import android.adservices.shell.ShellCommandResult; +import android.os.RemoteException; + +import com.android.adservices.LogUtil; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * Implements a service which runs shell command in the AdServices process. + * + * <p>This internally calls {@link AdServicesShellCommandHandler} which has main logic to execute + * the shell command. + * + * @hide + */ +public final class ShellCommandServiceImpl extends IShellCommand.Stub { + @Override + public void runShellCommand(ShellCommandParam param, IShellCommandCallback callback) { + StringWriter outStringWriter = new StringWriter(); + StringWriter ErrStringWriter = new StringWriter(); + + try (PrintWriter outPw = new PrintWriter(outStringWriter); + PrintWriter errPw = new PrintWriter(ErrStringWriter); ) { + AdServicesShellCommandHandler handler = new AdServicesShellCommandHandler(outPw, errPw); + int resultCode = handler.run(param.getCommandArgs()); + ShellCommandResult response = + new ShellCommandResult.Builder() + .setResultCode(resultCode) + .setOut(outStringWriter.toString()) + .setErr(ErrStringWriter.toString()) + .build(); + callback.onResult(response); + } catch (RemoteException e) { + LogUtil.e(e, "Unable to send result to the callback for request: %s", param); + } + } +} diff --git a/adservices/service-core/java/com/android/adservices/service/signals/ProtectedSignalsServiceImpl.java b/adservices/service-core/java/com/android/adservices/service/signals/ProtectedSignalsServiceImpl.java index 79dde44bd..9cac9eef5 100644 --- a/adservices/service-core/java/com/android/adservices/service/signals/ProtectedSignalsServiceImpl.java +++ b/adservices/service-core/java/com/android/adservices/service/signals/ProtectedSignalsServiceImpl.java @@ -189,7 +189,7 @@ public class ProtectedSignalsServiceImpl extends IProtectedSignalsService.Stub { } // Caller permissions must be checked in the binder thread, before anything else - mFledgeAuthorizationFilter.assertAppDeclaredProtectedSignalsPermission( + mFledgeAuthorizationFilter.assertAppDeclaredPermission( mContext, updateSignalsInput.getCallerPackageName(), apiName); final int callerUid = getCallingUid(apiName); diff --git a/adservices/service-core/java/com/android/adservices/service/stats/ConsentMigrationStats.java b/adservices/service-core/java/com/android/adservices/service/stats/ConsentMigrationStats.java index b5437a8da..d877f45dd 100644 --- a/adservices/service-core/java/com/android/adservices/service/stats/ConsentMigrationStats.java +++ b/adservices/service-core/java/com/android/adservices/service/stats/ConsentMigrationStats.java @@ -19,6 +19,8 @@ import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICE import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_STATUS__SUCCESS_WITH_SHARED_PREF_NOT_UPDATED; import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_STATUS__SUCCESS_WITH_SHARED_PREF_UPDATED; import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_STATUS__UNSPECIFIED_MIGRATION_STATUS; +import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__ADEXT_SERVICE_TO_APPSEARCH; +import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__ADEXT_SERVICE_TO_SYSTEM_SERVICE; import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__APPSEARCH_TO_SYSTEM_SERVICE; import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__PPAPI_TO_SYSTEM_SERVICE; import static com.android.adservices.service.stats.AdServicesStatsLog.AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__UNSPECIFIED_MIGRATION_TYPE; @@ -75,7 +77,14 @@ public abstract class ConsentMigrationStats { AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__PPAPI_TO_SYSTEM_SERVICE), // Migrating consent from App Search to system service APPSEARCH_TO_SYSTEM_SERVICE( - AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__APPSEARCH_TO_SYSTEM_SERVICE); + AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__APPSEARCH_TO_SYSTEM_SERVICE), + // Migrating consent from AdServicesExtDataStorageService to System Server + ADEXT_SERVICE_TO_SYSTEM_SERVICE( + AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__ADEXT_SERVICE_TO_SYSTEM_SERVICE), + // Migrating consent from AdServicesExtDataStorageService to App Search + ADEXT_SERVICE_TO_APPSEARCH( + AD_SERVICES_CONSENT_MIGRATED__MIGRATION_TYPE__ADEXT_SERVICE_TO_APPSEARCH); + private final int mMigrationType; MigrationType(int migrationType) { diff --git a/adservices/service-core/java/com/android/adservices/service/ui/enrollment/impl/RvcPostOTAChannel.java b/adservices/service-core/java/com/android/adservices/service/ui/enrollment/impl/RvcPostOTAChannel.java index 6d6bc18d6..6d89bd4d3 100644 --- a/adservices/service-core/java/com/android/adservices/service/ui/enrollment/impl/RvcPostOTAChannel.java +++ b/adservices/service-core/java/com/android/adservices/service/ui/enrollment/impl/RvcPostOTAChannel.java @@ -16,7 +16,7 @@ package com.android.adservices.service.ui.enrollment.impl; -import static com.android.adservices.service.FlagsConstants.KEY_RVC_NOTIFICATION_ENABLED; +import static com.android.adservices.service.FlagsConstants.KEY_RVC_POST_OTA_NOTIFICATION_ENABLED; import android.content.Context; import android.os.Build; @@ -40,8 +40,7 @@ public class RvcPostOTAChannel implements PrivacySandboxEnrollmentChannel { ConsentManager consentManager, UxStatesManager uxStatesManager) { // Rvc user should be matched to RvcPostOTAChannel on S+ - // TODO: rename flag to KEY_RVC_POST_OTA_NOTIFICATION_ENABLED - return uxStatesManager.getFlag(KEY_RVC_NOTIFICATION_ENABLED) + return uxStatesManager.getFlag(KEY_RVC_POST_OTA_NOTIFICATION_ENABLED) && consentManager.isOtaAdultUserFromRvc(); } diff --git a/adservices/service/java/com/android/server/adservices/AdServicesManagerService.java b/adservices/service/java/com/android/server/adservices/AdServicesManagerService.java index 19ee994b0..239fabda1 100644 --- a/adservices/service/java/com/android/server/adservices/AdServicesManagerService.java +++ b/adservices/service/java/com/android/server/adservices/AdServicesManagerService.java @@ -767,7 +767,7 @@ public class AdServicesManagerService extends IAdServicesManager.Stub { } LogUtil.v("Executing shell cmd: %s", Arrays.toString(args)); - return new AdServicesShellCommand() + return new AdServicesShellCommand(mContext) .exec( this, in.getFileDescriptor(), diff --git a/adservices/service/java/com/android/server/adservices/AdServicesShellCommand.java b/adservices/service/java/com/android/server/adservices/AdServicesShellCommand.java index 58f41b772..cbdf07537 100644 --- a/adservices/service/java/com/android/server/adservices/AdServicesShellCommand.java +++ b/adservices/service/java/com/android/server/adservices/AdServicesShellCommand.java @@ -18,9 +18,17 @@ package com.android.server.adservices; import static android.app.adservices.AdServicesManager.AD_SERVICES_SYSTEM_SERVICE; +import android.adservices.shell.IShellCommand; +import android.adservices.shell.IShellCommandCallback; +import android.adservices.shell.ShellCommandParam; +import android.adservices.shell.ShellCommandResult; +import android.content.Context; import android.os.Binder; import android.os.Process; +import android.os.RemoteException; +import com.android.adservices.AdServicesCommon; +import com.android.adservices.ServiceBinder; import com.android.internal.annotations.VisibleForTesting; import com.android.modules.utils.BasicShellCommandHandler; @@ -28,7 +36,11 @@ import com.google.errorprone.annotations.FormatMethod; import com.google.errorprone.annotations.FormatString; import java.io.PrintWriter; +import java.util.Arrays; import java.util.Objects; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; /** * Implementation of {@code cmd adservices_manager}. @@ -44,17 +56,23 @@ class AdServicesShellCommand extends BasicShellCommandHandler { static final String WRONG_UID_TEMPLATE = AD_SERVICES_SYSTEM_SERVICE + " shell cmd is only callable by ADB (called by %d)"; + private static final String CMD_IS_SYSTEM_SERVICE_ENABLED = "is-system-service-enabled"; + private final Injector mInjector; private final Flags mFlags; + private final Context mContext; + + private static final int DEFAULT_TIMEOUT_MILLIS = 5_000; - AdServicesShellCommand() { - this(new Injector(), PhFlags.getInstance()); + AdServicesShellCommand(Context context) { + this(new Injector(), PhFlags.getInstance(), context); } @VisibleForTesting - AdServicesShellCommand(Injector injector, Flags flags) { + AdServicesShellCommand(Injector injector, Flags flags, Context context) { mInjector = Objects.requireNonNull(injector); mFlags = Objects.requireNonNull(flags); + mContext = Objects.requireNonNull(context); } @Override @@ -63,17 +81,74 @@ class AdServicesShellCommand extends BasicShellCommandHandler { if (callingUid != Process.ROOT_UID && callingUid != Process.SHELL_UID) { throw new SecurityException(String.format(WRONG_UID_TEMPLATE, callingUid)); } - if (cmd == null || cmd.isEmpty() || cmd.equals("-h") || cmd.equals("help")) { onHelp(); return 0; } switch (cmd) { - case "is-system-service-enabled": + // Below commands are handled by the System Server + case CMD_IS_SYSTEM_SERVICE_ENABLED: return runIsSystemServiceEnabled(); + + // If there is no explicit case is there, we assume we want to run the shell command + // in the adservices process. default: - // Cannot use handleDefaultCommands() because it doesn't show help - return showError("Unsupported commmand: %s", cmd); + // TODO(b/308009734): Check for --user args in the follow-up cl and change + // context and bind to the service accordingly. + return runAdServicesShellCommand(mContext, getAllArgs()); + } + } + + private int runAdServicesShellCommand(Context context, String[] args) { + IShellCommand service = mInjector.getShellCommandService(context); + if (service == null) { + getOutPrintWriter().println("Failed to connect to shell command service"); + return -1; + } + ShellCommandParam param = new ShellCommandParam(args); + CountDownLatch latch = new CountDownLatch(1); + AtomicInteger resultCode = new AtomicInteger(-1); + try { + service.runShellCommand( + param, + new IShellCommandCallback.Stub() { + @Override + public void onResult(ShellCommandResult response) { + if (response.isSuccess()) { + getOutPrintWriter().println(response.getOut()); + resultCode.set(response.getResultCode()); + } else { + showError("%s", response.getErr()); + } + latch.countDown(); + } + }); + } catch (RemoteException e) { + getErrPrintWriter() + .printf( + "Remote exception occurred while executing %s\n", + Arrays.toString(args)); + + latch.countDown(); + } + + // TODO(b/308009734): make the time out configurable with flags and command line argument. + await(latch, DEFAULT_TIMEOUT_MILLIS, getErrPrintWriter()); + + return resultCode.get(); + } + + private void await(CountDownLatch latch, int timeout, PrintWriter pw) { + try { + if (!latch.await(timeout, TimeUnit.MILLISECONDS)) { + pw.printf( + "Elapsed time: %d Millisecond. Timeout occurred , failed to " + + "complete shell command\n", + timeout); + } + } catch (InterruptedException e) { + pw.println("Thread interrupted, failed to complete shell command"); + Thread.currentThread().interrupt(); } } @@ -144,5 +219,14 @@ class AdServicesShellCommand extends BasicShellCommandHandler { int getCallingUid() { return Binder.getCallingUid(); } + + IShellCommand getShellCommandService(Context context) { + ServiceBinder<IShellCommand> serviceBinder = + ServiceBinder.getServiceBinder( + context, + AdServicesCommon.ACTION_SHELL_COMMAND_SERVICE, + IShellCommand.Stub::asInterface); + return serviceBinder.getService(); + } } } diff --git a/adservices/tests/cts/adid/src/com/android/adservices/tests/adid/AdIdManagerTest.java b/adservices/tests/cts/adid/src/com/android/adservices/tests/adid/AdIdManagerTest.java index 034688c6e..3a5abc4c0 100644 --- a/adservices/tests/cts/adid/src/com/android/adservices/tests/adid/AdIdManagerTest.java +++ b/adservices/tests/cts/adid/src/com/android/adservices/tests/adid/AdIdManagerTest.java @@ -17,8 +17,6 @@ package com.android.adservices.tests.adid; import static com.google.common.truth.Truth.assertWithMessage; -import static org.junit.Assert.fail; - import android.adservices.adid.AdId; import android.adservices.adid.AdIdManager; import android.os.LimitExceededException; @@ -162,19 +160,14 @@ public final class AdIdManagerTest extends CtsAdIdEndToEndTestCase { @Test @RequiresLowRamDevice - public void testAdIdManager_whenDeviceNotSupported_R() { + public void testAdIdManager_whenDeviceNotSupported_R() throws Exception { AdIdManager adIdManager = AdIdManager.get(sContext); assertWithMessage("adIdManager").that(adIdManager).isNotNull(); AdServicesOutcomeReceiverForTests<AdId> receiver = new AdServicesOutcomeReceiverForTests<>(); - // NOTE: cannot use assertThrows() as it would cause a NoSuchClassException on R (as - // JUnit somehow scans the whole class) - try { - adIdManager.getAdId(sCallbackExecutor, receiver); - fail("getAdId() should have thrown IllegalStateException"); - } catch (IllegalStateException e) { - // expected - } + + adIdManager.getAdId(sCallbackExecutor, receiver); + receiver.assertFailure(IllegalStateException.class); } private static String toString(AdId adId) { diff --git a/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java b/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java index 7a6e5bec4..e2492b4ad 100644 --- a/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java +++ b/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java @@ -26,8 +26,14 @@ import static android.adservices.customaudience.CustomAudienceFixture.VALID_NAME import static android.adservices.customaudience.CustomAudienceFixture.VALID_USER_BIDDING_SIGNALS; import static android.adservices.customaudience.CustomAudienceFixture.getValidFetchUriByBuyer; -import static com.android.adservices.service.Flags.FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B; -import static com.android.adservices.service.Flags.FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B; +import static com.android.adservices.service.FlagsConstants.KEY_ENABLE_ENROLLMENT_TEST_SEED; +import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT; +import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B; +import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS; +import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT; +import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT; +import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED; +import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B; import static com.google.common.truth.Truth.assertThat; @@ -54,14 +60,12 @@ import android.util.Pair; import androidx.test.platform.app.InstrumentationRegistry; -import com.android.adservices.common.AdServicesDeviceSupportedRule; import com.android.adservices.common.AdServicesFlagsSetterRule; import com.android.adservices.common.AdservicesTestHelper; -import com.android.adservices.common.SdkLevelSupportRule; -import com.android.adservices.service.PhFlagsFixture; +import com.android.adservices.common.RequiresSdkLevelAtLeastS; +import com.android.adservices.common.annotations.SetIntegerFlag; import com.android.adservices.service.devapi.DevContext; import com.android.adservices.service.devapi.DevContextFilter; -import com.android.modules.utils.build.SdkLevel; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListenableFuture; @@ -70,7 +74,6 @@ import com.google.common.util.concurrent.MoreExecutors; import org.junit.After; import org.junit.Assume; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import java.util.ArrayList; @@ -78,7 +81,9 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { +@RequiresSdkLevelAtLeastS // TODO(b/291488819) - Remove SDK Level check if Fledge is enabled on R. +public final class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { + private AdvertisingCustomAudienceClient mClient; private TestAdvertisingCustomAudienceClient mTestClient; @@ -93,24 +98,15 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { private final ArrayList<Pair<AdTechIdentifier, String>> mCustomAudiencesToCleanUp = new ArrayList<>(); - // TODO(b/291488819) - Remove SDK Level check if Fledge is enabled on R. - @Rule(order = 0) - public final SdkLevelSupportRule sdkLevel = SdkLevelSupportRule.forAtLeastS(); - - // Skip the test if it runs on unsupported platforms. - @Rule(order = 1) - public final AdServicesDeviceSupportedRule adServicesDeviceSupportedRule = - new AdServicesDeviceSupportedRule(); - - @Rule(order = 2) - public final AdServicesFlagsSetterRule flags = - AdServicesFlagsSetterRule.forGlobalKillSwitchDisabledTests() - .setCompatModeFlags() - .setPpapiAppAllowList(sContext.getPackageName()); + // TODO(b/317411225): remove this method and annotate the class with @SetFlagEnabled instead + @Override + protected AdServicesFlagsSetterRule getAdServicesFlagsSetterRule() { + return super.getAdServicesFlagsSetterRule().setFlag(KEY_ENABLE_ENROLLMENT_TEST_SEED, true); + } @Before - public void setup() throws InterruptedException { - if (SdkLevel.isAtLeastT()) { + public void setup() throws Exception { + if (sdkLevel.isAtLeastT()) { assertForegroundActivityStarted(); } @@ -131,16 +127,14 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { InstrumentationRegistry.getInstrumentation() .getUiAutomation() .adoptShellPermissionIdentity(Manifest.permission.WRITE_DEVICE_CONFIG); - PhFlagsFixture.overrideEnableEnrollmentSeed(true); // Kill AdServices process AdservicesTestHelper.killAdservicesProcess(sContext); } @After - public void tearDown() throws ExecutionException, InterruptedException, TimeoutException { + public void tearDown() throws Exception { leaveJoinedCustomAudiences(); - PhFlagsFixture.overrideEnableEnrollmentSeed(false); } @Test @@ -274,27 +268,23 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { } @Test + @SetIntegerFlag(name = KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS, value = 2) public void testJoinCustomAudience_invalidNumberOfAds_fail() { - PhFlagsFixture.overrideFledgeCustomAudienceMaxNumAds(2); - try { - CustomAudience customAudienceWithInvalidNumberOfAds = - CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) - .setAds( - ImmutableList.of( - AdDataFixture.getValidAdDataByBuyer(VALID_BUYER_1, 1), - AdDataFixture.getValidAdDataByBuyer(VALID_BUYER_1, 2), - AdDataFixture.getValidAdDataByBuyer(VALID_BUYER_1, 3))) - .build(); - - Exception exception = - assertThrows( - ExecutionException.class, - () -> joinCustomAudience(customAudienceWithInvalidNumberOfAds)); - assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); - assertThat(exception).hasCauseThat().hasMessageThat().isEqualTo(null); - } finally { - PhFlagsFixture.overrideFledgeCustomAudienceMaxNumAds(100); - } + CustomAudience customAudienceWithInvalidNumberOfAds = + CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) + .setAds( + ImmutableList.of( + AdDataFixture.getValidAdDataByBuyer(VALID_BUYER_1, 1), + AdDataFixture.getValidAdDataByBuyer(VALID_BUYER_1, 2), + AdDataFixture.getValidAdDataByBuyer(VALID_BUYER_1, 3))) + .build(); + + Exception exception = + assertThrows( + ExecutionException.class, + () -> joinCustomAudience(customAudienceWithInvalidNumberOfAds)); + assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); + assertThat(exception).hasCauseThat().hasMessageThat().isNull(); } @Test @@ -327,94 +317,71 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { } @Test + @SetIntegerFlag(name = KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT, value = 2) + @SetIntegerFlag(name = KEY_FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT, value = 1000) + @SetIntegerFlag(name = KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT, value = 1000) public void testJoinCustomAudience_maxTotalCustomAudiences_fail() { - PhFlagsFixture.overrideFledgeCustomAudienceMaxCount(2); - PhFlagsFixture.overrideFledgeCustomAudiencePerAppMaxCount(1000); - PhFlagsFixture.overrideFledgeCustomAudienceMaxOwnerCount(1000); - try { - CustomAudience customAudience1 = - CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) - .setName("CA1") - .build(); - CustomAudience customAudience2 = - CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) - .setName("CA2") - .build(); - CustomAudience customAudience3 = - CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) - .setName("CA3") - .build(); - - Exception exception = - assertThrows( - ExecutionException.class, - () -> { - joinCustomAudience(customAudience1); - joinCustomAudience(customAudience2); - joinCustomAudience(customAudience3); - }); - assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); - assertThat(exception).hasCauseThat().hasMessageThat().isEqualTo(null); - } finally { - PhFlagsFixture.overrideFledgeCustomAudienceMaxCount(4000); - } + CustomAudience customAudience1 = + CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1).setName("CA1").build(); + CustomAudience customAudience2 = + CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1).setName("CA2").build(); + CustomAudience customAudience3 = + CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1).setName("CA3").build(); + + Exception exception = + assertThrows( + ExecutionException.class, + () -> { + joinCustomAudience(customAudience1); + joinCustomAudience(customAudience2); + joinCustomAudience(customAudience3); + }); + assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); + assertThat(exception).hasCauseThat().hasMessageThat().isNull(); } @Test + @SetIntegerFlag(name = KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT, value = 4000) + @SetIntegerFlag(name = KEY_FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT, value = 2) + @SetIntegerFlag(name = KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT, value = 1000) public void testJoinCustomAudience_maxCustomAudiencesPerApp_fail() { - PhFlagsFixture.overrideFledgeCustomAudienceMaxCount(4000); - PhFlagsFixture.overrideFledgeCustomAudiencePerAppMaxCount(2); - PhFlagsFixture.overrideFledgeCustomAudienceMaxOwnerCount(1000); - try { - CustomAudience customAudience1 = - CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) - .setName("CA1") - .build(); - CustomAudience customAudience2 = - CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) - .setName("CA2") - .build(); - CustomAudience customAudience3 = - CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1) - .setName("CA3") - .build(); - - Exception exception = - assertThrows( - ExecutionException.class, - () -> { - joinCustomAudience(customAudience1); - joinCustomAudience(customAudience2); - joinCustomAudience(customAudience3); - }); - assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); - assertThat(exception).hasCauseThat().hasMessageThat().isEqualTo(null); - } finally { - PhFlagsFixture.overrideFledgeCustomAudiencePerAppMaxCount(1000); - } + CustomAudience customAudience1 = + CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1).setName("CA1").build(); + CustomAudience customAudience2 = + CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1).setName("CA2").build(); + CustomAudience customAudience3 = + CustomAudienceFixture.getValidBuilderForBuyer(VALID_BUYER_1).setName("CA3").build(); + + Exception exception = + assertThrows( + ExecutionException.class, + () -> { + joinCustomAudience(customAudience1); + joinCustomAudience(customAudience2); + joinCustomAudience(customAudience3); + }); + assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); + assertThat(exception).hasCauseThat().hasMessageThat().isNull(); } @Test public void testFetchAndJoinCustomAudience_validFetchUri_validRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); } @Test @@ -425,31 +392,26 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_unenrolledFetchUri_invalidRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder(Uri.parse("invalid-uri.com")) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - // A valid buyer will not be extracted from an invalid uri, thus failing due to lack of - // authorization. - assertThat(exception).hasCauseThat().isInstanceOf(SecurityException.class); - assertThat(exception) - .hasCauseThat() - .hasMessageThat() - .isEqualTo(SECURITY_EXCEPTION_CALLER_NOT_ALLOWED_ERROR_MESSAGE); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder(Uri.parse("invalid-uri.com")).build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + // A valid buyer will not be extracted from an invalid uri, thus failing due to lack of + // authorization. + assertThat(exception).hasCauseThat().isInstanceOf(SecurityException.class); + assertThat(exception) + .hasCauseThat() + .hasMessageThat() + .isEqualTo(SECURITY_EXCEPTION_CALLER_NOT_ALLOWED_ERROR_MESSAGE); } @Test @@ -460,27 +422,23 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_validName_validRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setName(VALID_NAME) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setName(VALID_NAME) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); } @Test @@ -491,31 +449,26 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_tooLongName_invalidRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - // Use a clearly small size limit. - PhFlagsFixture.overrideFledgeCustomAudienceMaxNameSizeB(1); - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setName(VALID_NAME) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - // The name exceeds size limit. - assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - PhFlagsFixture.overrideFledgeCustomAudienceMaxNameSizeB( - FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + // Use a clearly small size limit. + flags.setFlag(KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B, 1); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setName(VALID_NAME) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + // The name exceeds size limit. + assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); } @Test @@ -526,26 +479,24 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_validActivationTime_validRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setActivationTime(VALID_ACTIVATION_TIME) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setActivationTime(VALID_ACTIVATION_TIME) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); } @Test @@ -556,27 +507,24 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_activationExceedsDelay_invalidRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setActivationTime(INVALID_DELAYED_ACTIVATION_TIME) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - // The activation time exceeds delay limit. - assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setActivationTime(INVALID_DELAYED_ACTIVATION_TIME) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + // The activation time exceeds delay limit. + assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); } @Test @@ -587,26 +535,23 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_validExpirationTime_validRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setExpirationTime(VALID_EXPIRATION_TIME) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setExpirationTime(VALID_EXPIRATION_TIME) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); } @Test @@ -617,28 +562,24 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_beyondMaxExpiration_invalidRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setExpirationTime(INVALID_BEYOND_MAX_EXPIRATION_TIME) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - // The expiration time exceeds max limit. - assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setExpirationTime(INVALID_BEYOND_MAX_EXPIRATION_TIME) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + // The expiration time exceeds max limit. + assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); } @Test @@ -649,26 +590,23 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_validUserBiddingSignals_validRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setUserBiddingSignals(VALID_USER_BIDDING_SIGNALS) - .build(); - - // Without an actual server to respond to this request, the service will fail while - // executing the HTTP request and throw an IllegalStateException. If a request field was - // invalid, the service will fail before executing the HTTP request and throw an - // IllegalArgumentException. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setUserBiddingSignals(VALID_USER_BIDDING_SIGNALS) + .build(); + + // Without an actual server to respond to this request, the service will fail while + // executing the HTTP request and throw an IllegalStateException. If a request field was + // invalid, the service will fail before executing the HTTP request and throw an + // IllegalArgumentException. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + assertThat(exception.getCause()).isInstanceOf(IllegalStateException.class); } @Test @@ -679,29 +617,24 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTestCase { @Test public void testFetchAndJoinCustomAudience_tooBigUserBiddingSignals_invalidRequest() { - try { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(true); - // Use a clearly small size limit. - PhFlagsFixture.overrideFledgeFetchCustomAudienceMaxUserBiddingSignalsSizeB(1); - FetchAndJoinCustomAudienceRequest request = - new FetchAndJoinCustomAudienceRequest.Builder( - getValidFetchUriByBuyer(VALID_BUYER_1)) - .setUserBiddingSignals(VALID_USER_BIDDING_SIGNALS) - .build(); - - // Without an actual server response, we expect an IllegalStateException if the request - // was well-formed and valid. - Exception exception = - assertThrows( - ExecutionException.class, - () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); - // The user bidding signals exceeds size limit. - assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); - } finally { - PhFlagsFixture.overrideFledgeFetchCustomAudienceEnabled(false); - PhFlagsFixture.overrideFledgeFetchCustomAudienceMaxUserBiddingSignalsSizeB( - FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B); - } + // NOTE: not using flag annotations because it's called by other test + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, true); + // Use a clearly small size limit. + flags.setFlag(KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B, 1); + FetchAndJoinCustomAudienceRequest request = + new FetchAndJoinCustomAudienceRequest.Builder( + getValidFetchUriByBuyer(VALID_BUYER_1)) + .setUserBiddingSignals(VALID_USER_BIDDING_SIGNALS) + .build(); + + // Without an actual server response, we expect an IllegalStateException if the request + // was well-formed and valid. + Exception exception = + assertThrows( + ExecutionException.class, + () -> fetchAndJoinCustomAudience(request, VALID_BUYER_1, VALID_NAME)); + // The user bidding signals exceeds size limit. + assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/adservices/tests/cts/src/android/adservices/cts/ForegroundCtsTestCase.java b/adservices/tests/cts/src/android/adservices/cts/ForegroundCtsTestCase.java index 433ea1fe8..7fd36268c 100644 --- a/adservices/tests/cts/src/android/adservices/cts/ForegroundCtsTestCase.java +++ b/adservices/tests/cts/src/android/adservices/cts/ForegroundCtsTestCase.java @@ -16,11 +16,10 @@ package android.adservices.cts; -import static org.junit.Assert.assertTrue; +import static com.google.common.truth.Truth.assertWithMessage; -import android.content.Context; - -import androidx.test.core.app.ApplicationProvider; +import android.os.Build; +import android.util.Log; import com.android.modules.utils.build.SdkLevel; @@ -30,13 +29,17 @@ import org.junit.BeforeClass; import java.time.Duration; import java.util.concurrent.TimeoutException; -abstract class ForegroundCtsTestCase { - // If the context is initialized in the setup method the importance of our foreground - // service will be IMPORTANCE_FOREGROUND_SERVICE (125) instead of +abstract class ForegroundCtsTestCase extends CtsAdServicesDeviceTestCase { + + private static final String TAG = ForegroundCtsTestCase.class.getSimpleName(); + + // NOTICE: if the context used by tests is initialized in the setup method the importance of our + // foreground service will be IMPORTANCE_FOREGROUND_SERVICE (125) instead of // IMPORTANCE_FOREGROUND (100) on some platforms only. - // See http://ag/c/platform/packages/modules/AdServices/+/19607471/comments/e6767fdc_971415d0 - protected static final Context sContext = ApplicationProvider.getApplicationContext(); - private static boolean sSimpleActivityStarted = false; + // This class is indirectly extending AdServicesCtsTestCase - which sets sContext outside any + // JUnit @Before / @BeforeClass method - so the process has the proper importance. + + private static boolean sSimpleActivityStarted; /** * Starts a foreground activity to make the test process a foreground one to pass PPAPI and SDK @@ -45,15 +48,22 @@ abstract class ForegroundCtsTestCase { protected static void makeTestProcessForeground() throws TimeoutException { // PPAPI foreground checks are not done on S-, so no need for the SimpleActivity if (SdkLevel.isAtLeastT()) { + Log.d(TAG, "Starting activity on T+ (and waiting for 2s)"); SimpleActivity.startAndWait(sContext, Duration.ofSeconds(2)); + Log.d(TAG, "Activity started"); sSimpleActivityStarted = true; + } else { + Log.d(TAG, "Not starting activity on device running " + Build.VERSION.SDK_INT); } } /** Terminates the SimpleActivity */ protected static void shutdownForegroundActivity() { if (SdkLevel.isAtLeastT()) { + Log.d(TAG, "Stopping activity on T+"); SimpleActivity.stop(sContext); + } else { + Log.d(TAG, "Not stopping activity on device running " + Build.VERSION.SDK_INT); } } @@ -67,7 +77,9 @@ abstract class ForegroundCtsTestCase { shutdownForegroundActivity(); } - protected void assertForegroundActivityStarted() { - assertTrue("Foreground activity didn't start successfully", sSimpleActivityStarted); + protected static void assertForegroundActivityStarted() { + assertWithMessage("Foreground activity started successfully") + .that(sSimpleActivityStarted) + .isTrue(); } } diff --git a/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java b/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java index 8cc64d5ae..9063ac135 100644 --- a/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java +++ b/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java @@ -46,19 +46,16 @@ import android.os.Process; import androidx.test.platform.app.InstrumentationRegistry; import com.android.adservices.LoggerFactory; -import com.android.adservices.common.AdServicesDeviceSupportedRule; import com.android.adservices.common.AdServicesFlagsSetterRule; import com.android.adservices.common.AdservicesTestHelper; -import com.android.adservices.common.SdkLevelSupportRule; +import com.android.adservices.common.RequiresSdkLevelAtLeastS; import com.android.adservices.service.devapi.DevContext; import com.android.adservices.service.devapi.DevContextFilter; -import com.android.modules.utils.build.SdkLevel; import com.google.common.util.concurrent.ListenableFuture; import org.junit.Assume; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import java.util.ArrayList; @@ -67,7 +64,9 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -public class TestAdSelectionManagerTest extends ForegroundCtsTestCase { +@RequiresSdkLevelAtLeastS // TODO(b/291488819) - Remove SDK Level check if Fledge is enabled on R. +public final class TestAdSelectionManagerTest extends ForegroundCtsTestCase { + private static final LoggerFactory.Logger sLogger = LoggerFactory.getFledgeLogger(); private static final Executor CALLBACK_EXECUTOR = Executors.newCachedThreadPool(); @@ -100,27 +99,20 @@ public class TestAdSelectionManagerTest extends ForegroundCtsTestCase { private TestAdSelectionClient mTestAdSelectionClient; private boolean mIsDebugMode; - // TODO(b/291488819) - Remove SDK Level check if Fledge is enabled on R. - @Rule(order = 0) - public final SdkLevelSupportRule sdkLevel = SdkLevelSupportRule.forAtLeastS(); - - // Skip the test if it runs on unsupported platforms. - @Rule(order = 1) - public final AdServicesDeviceSupportedRule adServicesDeviceSupportedRule = - new AdServicesDeviceSupportedRule(); - - @Rule(order = 2) - public final AdServicesFlagsSetterRule flags = - AdServicesFlagsSetterRule.forGlobalKillSwitchDisabledTests() - .setCompatModeFlags() - .setPpapiAppAllowList(sContext.getPackageName()) - .setFlag(KEY_ENFORCE_ISOLATE_MAX_HEAP_SIZE, false) - .setFlag(KEY_ISOLATE_MAX_HEAP_SIZE_BYTES, false) - .setFlag(KEY_ENABLE_ENROLLMENT_TEST_SEED, true); + // TODO(b/317411225): remove this method and annotate the class with + // @SetFlagEnabled / @SetFlagDisabled instead + @Override + protected AdServicesFlagsSetterRule getAdServicesFlagsSetterRule() { + return super.getAdServicesFlagsSetterRule() + .setFlag(KEY_ENFORCE_ISOLATE_MAX_HEAP_SIZE, false) + .setFlag(KEY_ISOLATE_MAX_HEAP_SIZE_BYTES, false) + .setFlag(KEY_ENABLE_ENROLLMENT_TEST_SEED, true); + } @Before public void setup() { - if (SdkLevel.isAtLeastT()) { + + if (sdkLevel.isAtLeastT()) { assertForegroundActivityStarted(); } diff --git a/adservices/tests/cts/src/android/adservices/debuggablects/MeasurementCtsDebuggableTest.java b/adservices/tests/cts/src/android/adservices/debuggablects/MeasurementCtsDebuggableTest.java index 5f893c176..0e9e8934f 100644 --- a/adservices/tests/cts/src/android/adservices/debuggablects/MeasurementCtsDebuggableTest.java +++ b/adservices/tests/cts/src/android/adservices/debuggablects/MeasurementCtsDebuggableTest.java @@ -659,10 +659,6 @@ public class MeasurementCtsDebuggableTest { // Assume trigger registration can happen within 8 seconds of source registration. getUiDevice().executeShellCommand( "device_config put adservices " - + "measurement_enable_configurable_event_reporting_windows true"); - - getUiDevice().executeShellCommand( - "device_config put adservices " + "measurement_event_reports_vtc_early_reporting_windows 8,15"); getUiDevice().executeShellCommand( @@ -729,11 +725,6 @@ public class MeasurementCtsDebuggableTest { + "measurement_aggregation_coordinator_path null"); // Reset reporting windows - // Assume trigger registration can happen within 8 seconds of source registration. - getUiDevice().executeShellCommand( - "device_config put adservices " - + "measurement_enable_configurable_event_reporting_windows null"); - getUiDevice().executeShellCommand( "device_config put adservices " + "measurement_event_reports_vtc_early_reporting_windows null"); diff --git a/adservices/tests/cts/ui/libs/src/com/android/adservices/tests/ui/libs/UiUtils.java b/adservices/tests/cts/ui/libs/src/com/android/adservices/tests/ui/libs/UiUtils.java index 91c5cc040..54a7715c8 100644 --- a/adservices/tests/cts/ui/libs/src/com/android/adservices/tests/ui/libs/UiUtils.java +++ b/adservices/tests/cts/ui/libs/src/com/android/adservices/tests/ui/libs/UiUtils.java @@ -171,9 +171,9 @@ public class UiUtils { forceSetFlag("rvc_ux_enabled", true); } - /** Override flag rvc_notification_enabled in tests to true */ + /** Override flag rvc_post_ota_notification_enabled in tests to true */ public static void enableRvcNotification() throws Exception { - forceSetFlag("rvc_notification_enabled", true); + forceSetFlag("rvc_post_ota_notification_enabled", true); } /** Override flag rvc_ux_enabled in tests to false */ diff --git a/adservices/tests/host/room/src/com/android/adservices/room/test/RoomDatabaseVersionBumpGuardrailTest.java b/adservices/tests/host/room/src/com/android/adservices/room/test/RoomDatabaseVersionBumpGuardrailTest.java index 8c3db3124..de345b50f 100644 --- a/adservices/tests/host/room/src/com/android/adservices/room/test/RoomDatabaseVersionBumpGuardrailTest.java +++ b/adservices/tests/host/room/src/com/android/adservices/room/test/RoomDatabaseVersionBumpGuardrailTest.java @@ -21,6 +21,7 @@ import android.cts.install.lib.host.InstallUtilsHost; import com.android.tradefed.config.Option; import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; +import com.android.tradefed.util.FileUtil; import org.junit.Test; import org.junit.runner.RunWith; @@ -70,6 +71,9 @@ public class RoomDatabaseVersionBumpGuardrailTest extends BaseHostJUnit4Test { @Option(name = "new-schema-lib") protected String mNewSchemaLib; + @Option(name = "schema-apk-name") + protected String mSchemaApkName = AD_SERVICES_SERVICE_CORE_UNIT_TESTS_APK_FILE_NAME; + @Test public void roomDatabaseVersionBumpGuardrailTest() throws Exception { @@ -79,15 +83,14 @@ public class RoomDatabaseVersionBumpGuardrailTest extends BaseHostJUnit4Test { Map<String, ZipEntry> baseVersions = extractVersionMap(baseSchemas); Map<String, ZipEntry> newVersions = extractVersionMap(newSchemas); - StringBuilder stringBuilder = new StringBuilder(); + StringBuilder errors = new StringBuilder(); for (Map.Entry<String, ZipEntry> e : baseVersions.entrySet()) { String name = e.getKey(); ZipEntry baseFile = e.getValue(); ZipEntry newFile = newVersions.get(name); if (newFile == null) { - stringBuilder.append( - String.format("Database file '%s' missing in new version!\n", name)); + errors.append(String.format("Database file '%s' missing in new version!\n", name)); continue; } @@ -98,7 +101,7 @@ public class RoomDatabaseVersionBumpGuardrailTest extends BaseHostJUnit4Test { if (!Arrays.equals( baseSchemas.getInputStream(baseFile).readAllBytes(), newSchemas.getInputStream(newFile).readAllBytes())) { - stringBuilder.append( + errors.append( String.format( "Database file '%s' changed between major build. Please bump up" + " DB version.\n", @@ -107,29 +110,33 @@ public class RoomDatabaseVersionBumpGuardrailTest extends BaseHostJUnit4Test { } if (getVersionFromFile(baseFile) > getVersionFromFile(newFile)) { - stringBuilder.append( + errors.append( String.format( "Database %s version was turned down from %d to %d\n", name, baseFileVersion, newFileVersion)); } } - if (stringBuilder.length() != 0) { - throw new IllegalStateException(stringBuilder.toString()); + if (errors.length() != 0) { + throw new IllegalStateException(errors.toString()); } } private ZipFile getTestPackageFromFile(String lib) throws IOException { byte[] bytes; - try (ZipFile zipFile = new ZipFile(mHostUtils.getTestFile(lib))) { - ZipEntry entry = - getZipEntry(zipFile, AD_SERVICES_SERVICE_CORE_UNIT_TESTS_APK_FILE_NAME); - bytes = zipFile.getInputStream(entry).readAllBytes(); + File testPackage = mHostUtils.getTestFile(lib); + if (testPackage.isFile()) { + try (ZipFile zipFile = new ZipFile(testPackage)) { + ZipEntry entry = getZipEntry(zipFile, mSchemaApkName); + bytes = zipFile.getInputStream(entry).readAllBytes(); + } + File tempFile = File.createTempFile("schemaFiles", ".zip"); + tempFile.setWritable(true); + new FileOutputStream(tempFile).write(bytes); + return new ZipFile(tempFile); + } else { + return new ZipFile(FileUtil.findFile(testPackage, mSchemaApkName)); } - File tempFile = File.createTempFile("schemaFiles", ".zip"); - tempFile.setWritable(true); - new FileOutputStream(tempFile).write(bytes); - return new ZipFile(tempFile); } private static ZipEntry getZipEntry(ZipFile zipFile, String fileName) { diff --git a/adservices/tests/jetpack/Android.bp b/adservices/tests/jetpack/Android.bp index 9a6a91221..f506a0013 100644 --- a/adservices/tests/jetpack/Android.bp +++ b/adservices/tests/jetpack/Android.bp @@ -437,7 +437,8 @@ android_test { ], libs: [ "android.test.base", - ], + "framework-sdkextensions", + ], test_suites: [ "general-tests", ], @@ -468,7 +469,8 @@ android_test { ], libs: [ "android.test.base", - ], + "framework-sdkextensions", + ], test_suites: [ "general-tests", ], @@ -499,7 +501,8 @@ android_test { ], libs: [ "android.test.base", - ], + "framework-sdkextensions", + ], test_suites: [ "general-tests", ], @@ -530,7 +533,8 @@ android_test { ], libs: [ "android.test.base", - ], + "framework-sdkextensions", + ], test_suites: [ "general-tests", ], @@ -561,7 +565,8 @@ android_test { ], libs: [ "android.test.base", - ], + "framework-sdkextensions", + ], test_suites: [ "general-tests", ], diff --git a/adservices/tests/jetpack/src/com/android/adservices/TestUtil.java b/adservices/tests/jetpack/src/com/android/adservices/TestUtil.java index fa2f7dbb0..46722078d 100644 --- a/adservices/tests/jetpack/src/com/android/adservices/TestUtil.java +++ b/adservices/tests/jetpack/src/com/android/adservices/TestUtil.java @@ -93,6 +93,7 @@ public class TestUtil { public void overrideAllowlists(boolean override) { String overrideStr = override ? "*" : "null"; runShellCommand("device_config put adservices ppapi_app_allow_list " + overrideStr); + runShellCommand("device_config put adservices msmt_api_app_allow_list " + overrideStr); runShellCommand( "device_config put adservices ppapi_app_signature_allow_list " + overrideStr); runShellCommand( diff --git a/adservices/tests/jetpack/src/com/android/adservices/adid/AdIdManagerJetpackTest.java b/adservices/tests/jetpack/src/com/android/adservices/adid/AdIdManagerJetpackTest.java index f5e9d7459..1fbab9bd8 100644 --- a/adservices/tests/jetpack/src/com/android/adservices/adid/AdIdManagerJetpackTest.java +++ b/adservices/tests/jetpack/src/com/android/adservices/adid/AdIdManagerJetpackTest.java @@ -18,6 +18,8 @@ package com.android.adservices.adid; import static com.google.common.truth.Truth.assertThat; +import android.os.ext.SdkExtensions; + import androidx.privacysandbox.ads.adservices.adid.AdId; import androidx.privacysandbox.ads.adservices.java.adid.AdIdManagerFutures; import androidx.test.core.app.ApplicationProvider; @@ -26,6 +28,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import com.android.adservices.TestUtil; import org.junit.After; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -35,6 +38,8 @@ public class AdIdManagerJetpackTest { @Before public void setup() throws Exception { + Assume.assumeTrue(SdkExtensions.getExtensionVersion(SdkExtensions.AD_SERVICES) >= 4); + mTestUtil.overrideAdIdKillSwitch(true); mTestUtil.overrideKillSwitches(true); mTestUtil.overrideConsentManagerDebugMode(true); diff --git a/adservices/tests/jetpack/src/com/android/adservices/appsetid/AppSetIdManagerJetpackTest.java b/adservices/tests/jetpack/src/com/android/adservices/appsetid/AppSetIdManagerJetpackTest.java index c8169f0c1..ed7c06e91 100644 --- a/adservices/tests/jetpack/src/com/android/adservices/appsetid/AppSetIdManagerJetpackTest.java +++ b/adservices/tests/jetpack/src/com/android/adservices/appsetid/AppSetIdManagerJetpackTest.java @@ -18,6 +18,8 @@ package com.android.adservices.appsetid; import static com.google.common.truth.Truth.assertThat; +import android.os.ext.SdkExtensions; + import androidx.privacysandbox.ads.adservices.appsetid.AppSetId; import androidx.privacysandbox.ads.adservices.java.appsetid.AppSetIdManagerFutures; import androidx.test.core.app.ApplicationProvider; @@ -26,6 +28,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import com.android.adservices.TestUtil; import org.junit.After; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -35,6 +38,8 @@ public class AppSetIdManagerJetpackTest { @Before public void setup() throws Exception { + Assume.assumeTrue(SdkExtensions.getExtensionVersion(SdkExtensions.AD_SERVICES) >= 4); + mTestUtil.overrideAppSetIdKillSwitch(true); mTestUtil.overrideKillSwitches(true); mTestUtil.overrideAllowlists(true); diff --git a/adservices/tests/jetpack/src/com/android/adservices/measurement/MeasurementManagerJetpackTest.java b/adservices/tests/jetpack/src/com/android/adservices/measurement/MeasurementManagerJetpackTest.java index b0a589b0e..0154d334c 100644 --- a/adservices/tests/jetpack/src/com/android/adservices/measurement/MeasurementManagerJetpackTest.java +++ b/adservices/tests/jetpack/src/com/android/adservices/measurement/MeasurementManagerJetpackTest.java @@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; import android.net.Uri; +import android.os.ext.SdkExtensions; import androidx.privacysandbox.ads.adservices.java.measurement.MeasurementManagerFutures; import androidx.privacysandbox.ads.adservices.measurement.DeletionRequest; @@ -33,6 +34,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import com.android.adservices.TestUtil; import org.junit.After; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -56,6 +58,7 @@ public class MeasurementManagerJetpackTest { @Before public void setup() throws Exception { + Assume.assumeTrue(SdkExtensions.getExtensionVersion(SdkExtensions.AD_SERVICES) >= 5); // To grant access to all pp api app mTestUtil.overrideAllowlists(true); // We need to turn the Consent Manager into debug mode diff --git a/adservices/tests/jetpack/src/com/android/adservices/protectedaudience/FledgeCtsDebuggableJetpackTest.java b/adservices/tests/jetpack/src/com/android/adservices/protectedaudience/FledgeCtsDebuggableJetpackTest.java index 20ad27236..30ff2e2de 100644 --- a/adservices/tests/jetpack/src/com/android/adservices/protectedaudience/FledgeCtsDebuggableJetpackTest.java +++ b/adservices/tests/jetpack/src/com/android/adservices/protectedaudience/FledgeCtsDebuggableJetpackTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertThrows; import android.content.Context; import android.net.Uri; +import android.os.ext.SdkExtensions; import android.util.Log; import androidx.privacysandbox.ads.adservices.adselection.AdSelectionConfig; @@ -35,7 +36,6 @@ import androidx.privacysandbox.ads.adservices.customaudience.CustomAudience; import androidx.privacysandbox.ads.adservices.customaudience.JoinCustomAudienceRequest; import androidx.privacysandbox.ads.adservices.customaudience.LeaveCustomAudienceRequest; import androidx.privacysandbox.ads.adservices.customaudience.TrustedBiddingData; -import androidx.privacysandbox.ads.adservices.internal.AdServicesInfo; import androidx.privacysandbox.ads.adservices.java.adselection.AdSelectionManagerFutures; import androidx.privacysandbox.ads.adservices.java.customaudience.CustomAudienceManagerFutures; import androidx.test.core.app.ApplicationProvider; @@ -195,6 +195,8 @@ public class FledgeCtsDebuggableJetpackTest { @Before public void setup() throws Exception { + Assume.assumeTrue(SdkExtensions.getExtensionVersion(SdkExtensions.AD_SERVICES) >= 4); + mAdSelectionClient = new AdSelectionClient(sContext); mCustomAudienceClient = new CustomAudienceClient(sContext); @@ -209,9 +211,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testFledgeAuctionSelectionFlow_overall_Success() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -248,9 +247,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelection_etldViolation_failure() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -297,9 +293,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testReportImpression_etldViolation_failure() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -359,9 +352,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelection_skipAdsMalformedBiddingLogic_success() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -407,9 +397,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelection_malformedScoringLogic_failure() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -454,9 +441,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelection_skipAdsFailedGettingBiddingLogic_success() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -502,9 +486,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelection_errorGettingScoringLogic_failure() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -555,9 +536,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelectionFlow_skipNonActivatedCA_Success() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -604,9 +582,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelectionFlow_skipExpiredCA_Success() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -659,9 +634,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelectionFlow_skipCAsThatTimeoutDuringBidding_Success() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); @@ -706,9 +678,6 @@ public class FledgeCtsDebuggableJetpackTest { @Test public void testAdSelection_overallTimeout_Failure() throws Exception { - // Skip the test if SDK extension 4 is not present. - Assume.assumeTrue(AdServicesInfo.INSTANCE.version() >= 4); - List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2); List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0); diff --git a/adservices/tests/jetpack/src/com/android/adservices/topics/TopicsManagerJetpackTest.java b/adservices/tests/jetpack/src/com/android/adservices/topics/TopicsManagerJetpackTest.java index cfb4ad406..4233a8890 100644 --- a/adservices/tests/jetpack/src/com/android/adservices/topics/TopicsManagerJetpackTest.java +++ b/adservices/tests/jetpack/src/com/android/adservices/topics/TopicsManagerJetpackTest.java @@ -18,6 +18,8 @@ package com.android.adservices.topics; import static com.google.common.truth.Truth.assertThat; +import android.os.ext.SdkExtensions; + import androidx.privacysandbox.ads.adservices.java.topics.TopicsManagerFutures; import androidx.privacysandbox.ads.adservices.topics.GetTopicsRequest; import androidx.privacysandbox.ads.adservices.topics.GetTopicsResponse; @@ -28,6 +30,7 @@ import androidx.test.platform.app.InstrumentationRegistry; import com.android.adservices.TestUtil; import org.junit.After; +import org.junit.Assume; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -50,6 +53,8 @@ public class TopicsManagerJetpackTest { @Before public void setup() throws Exception { + Assume.assumeTrue(SdkExtensions.getExtensionVersion(SdkExtensions.AD_SERVICES) >= 4); + mTestUtil.overrideKillSwitches(true); // We need to skip 3 epochs so that if there is any usage from other test runs, it will // not be used for epoch retrieval. diff --git a/adservices/tests/test-util/host-side/com/android/adservices/common/TestDeviceHelper.java b/adservices/tests/test-util/host-side/com/android/adservices/common/TestDeviceHelper.java index 0ef8ff9c8..18c3d4562 100644 --- a/adservices/tests/test-util/host-side/com/android/adservices/common/TestDeviceHelper.java +++ b/adservices/tests/test-util/host-side/com/android/adservices/common/TestDeviceHelper.java @@ -97,8 +97,17 @@ public final class TestDeviceHelper { .doesNotContain("Error: Activity not started, unable to resolve Intent"); } - public static void enableComponent(String packageName, String className) { - runShellCommand("pm enable %s/%s", packageName, className); + /** Enable the given component and return the result of the shell command */ + public static String enableComponent(String packageName, String className) { + return runShellCommand("pm enable %s/%s", packageName, className); + } + + /** + * Enable the given component for the given userId only and return the result of the shell + * command + */ + public static String enableComponent(String packageName, String className, int userId) { + return runShellCommand("pm enable --user %d %s/%s", userId, packageName, className); } /** diff --git a/adservices/tests/unittest/fixtures/java/com/android/adservices/service/PhFlagsFixture.java b/adservices/tests/unittest/fixtures/java/com/android/adservices/service/PhFlagsFixture.java index fc0f3a348..d9be9de3f 100644 --- a/adservices/tests/unittest/fixtures/java/com/android/adservices/service/PhFlagsFixture.java +++ b/adservices/tests/unittest/fixtures/java/com/android/adservices/service/PhFlagsFixture.java @@ -36,22 +36,12 @@ import static com.android.adservices.service.FlagsConstants.KEY_ENFORCE_FOREGROU import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_AD_SELECTION_FILTERING_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_AD_SELECTION_PREBUILT_URI_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_AUCTION_SERVER_KILL_SWITCH; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_BACKGROUND_FETCH_ELIGIBLE_UPDATE_BASE_INTERVAL_S; import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CPC_BILLING_ENABLED; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT; import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_DATA_VERSION_HEADER_ENABLED; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED; -import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B; import static com.android.adservices.service.FlagsConstants.KEY_FLEDGE_REGISTER_AD_BEACON_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_PROTECTED_SIGNALS_CLEANUP_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_SDK_REQUEST_PERMITS_PER_SECOND; -import static org.junit.Assert.assertEquals; - import android.provider.DeviceConfig; /** @@ -98,21 +88,6 @@ public final class PhFlagsFixture { FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_NETWORK_CONNECT_TIMEOUT_MS + (int) ADDITIONAL_TIMEOUT; - public static void configureFledgeBackgroundFetchEligibleUpdateBaseIntervalS( - final long phOverridingValue) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_BACKGROUND_FETCH_ELIGIBLE_UPDATE_BASE_INTERVAL_S, - Long.toString(phOverridingValue), - /* makeDefault */ false); - - Flags phFlags = FlagsFactory.getFlags(); - assertEquals( - "Failed to configure P/H flag", - phOverridingValue, - phFlags.getFledgeBackgroundFetchEligibleUpdateBaseIntervalS()); - } - /** Enables test to override the flag enabling ad selection filtering */ public static void overrideFledgeAdSelectionFilteringEnabled(boolean value) { DeviceConfig.setProperty( @@ -183,19 +158,6 @@ public final class PhFlagsFixture { } /** - * Allows tests to override seed enrollment data flag thereby seeding data into enrollment table - * - * @param enable disable enrollment seed - */ - public static void overrideEnableEnrollmentSeed(boolean enable) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - FlagsConstants.KEY_ENABLE_ENROLLMENT_TEST_SEED, - Boolean.toString(enable), - false); - } - - /** * Enables test to override the flag enabling the enrollment check for callers of Fledge APIs. * * @param enable whether enable or disable the check @@ -311,69 +273,6 @@ public final class PhFlagsFixture { true); } - /** Switches the fetchAndJoinCustomAudience API on/off. */ - public static void overrideFledgeFetchCustomAudienceEnabled(boolean value) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED, - Boolean.toString(value), - true); - } - - /** Configures the maximum size of a custom audience's name. */ - public static void overrideFledgeCustomAudienceMaxNameSizeB(int value) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B, - Integer.toString(value), - true); - } - - /** Configures the maximum size of a custom audience's user bidding signals. */ - public static void overrideFledgeFetchCustomAudienceMaxUserBiddingSignalsSizeB(int value) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B, - Integer.toString(value), - true); - } - - /** Configures the maximum number of ads allowed per custom audience. */ - public static void overrideFledgeCustomAudienceMaxNumAds(int value) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS, - Integer.toString(value), - true); - } - - /** Configures the maximum total number of custom audiences in the datastore. */ - public static void overrideFledgeCustomAudienceMaxCount(int value) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT, - Integer.toString(value), - true); - } - - /** Configures the maximum number of custom audiences per owner application in the datastore. */ - public static void overrideFledgeCustomAudiencePerAppMaxCount(int value) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT, - Integer.toString(value), - true); - } - - /** Configures the maximum number of owner applications in the datastore. */ - public static void overrideFledgeCustomAudienceMaxOwnerCount(int value) { - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT, - Integer.toString(value), - true); - } - /** Overrides whether the {@code registerAdBeacon} feature is enabled. */ public static void overrideFledgeRegisterAdBeaconEnabled(boolean value) { DeviceConfig.setProperty( diff --git a/adservices/tests/unittest/service-core/AndroidManifest.xml b/adservices/tests/unittest/service-core/AndroidManifest.xml index 44a4d197f..7be4ea18e 100644 --- a/adservices/tests/unittest/service-core/AndroidManifest.xml +++ b/adservices/tests/unittest/service-core/AndroidManifest.xml @@ -24,7 +24,6 @@ <uses-permission android:name="android.permission.ACCESS_ADSERVICES_AD_ID" /> <uses-permission android:name="android.permission.ACCESS_ADSERVICES_TOPICS" /> <uses-permission android:name="android.permission.ACCESS_ADSERVICES_CUSTOM_AUDIENCE" /> - <uses-permission android:name="android.permission.ACCESS_ADSERVICES_PROTECTED_SIGNALS" /> <!-- Needed to resolve Intent to ComponentName for measurement verifiedDestination --> <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/> diff --git a/adservices/tests/unittest/service-core/assets/attribution_service_test.json b/adservices/tests/unittest/service-core/assets/attribution_service_test.json index 223e9cbf9..7612332a2 100644 --- a/adservices/tests/unittest/service-core/assets/attribution_service_test.json +++ b/adservices/tests/unittest/service-core/assets/attribution_service_test.json @@ -102,7 +102,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T1" }], @@ -244,7 +244,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T1" }], @@ -423,7 +423,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T1" }, @@ -438,7 +438,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T2" } @@ -805,7 +805,7 @@ "triggerPriority": 101, "status": 0, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S2", "triggerId": "T1" }], @@ -965,7 +965,7 @@ "triggerPriority": 101, "status": 0, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S2", "triggerId": "T1" }], @@ -1883,7 +1883,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T1" }], @@ -2580,7 +2580,7 @@ "reportTime": 8730000001, "triggerPriority": 102, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T2" }, @@ -2595,7 +2595,7 @@ "reportTime": 8730000001, "triggerPriority": 103, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T3" }, @@ -2610,7 +2610,7 @@ "reportTime": 8730000001, "triggerPriority": 104, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T4" } @@ -2875,7 +2875,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T1" }, @@ -2890,7 +2890,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T2" }, @@ -2905,7 +2905,7 @@ "reportTime": 8730000001, "triggerPriority": 102, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T4" } @@ -3765,7 +3765,7 @@ "reportTime": 8643600030, "triggerPriority": 0, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T2" } @@ -3928,7 +3928,7 @@ "reportTime": 8643600030, "triggerPriority": 0, "sourceType": "navigation", - "randomizedTriggerRate": 0.0024263, + "randomizedTriggerRate": 0.0001372, "sourceId": "S1", "triggerId": "T2" } @@ -5052,7 +5052,7 @@ "reportTime": 8730000001, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0170218, + "randomizedTriggerRate": 0.0008051, "sourceId": "S1", "triggerId": "T1" }], @@ -5401,7 +5401,7 @@ "reportTime": 8730000002, "triggerPriority": 101, "sourceType": "navigation", - "randomizedTriggerRate": 0.0170218, + "randomizedTriggerRate": 0.0008051, "sourceId": "S1", "triggerId": "T1" }], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_debug_source_storage_limit.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_debug_source_storage_limit.json index ff052bee4..b38a24723 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_debug_source_storage_limit.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_debug_source_storage_limit.json @@ -153,7 +153,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key": "347982378", "trigger_debug_key": "147982378" } @@ -181,7 +181,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key": "347982378", "trigger_debug_key": "147982378" } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_large_keys.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_large_keys.json index 167693041..c7bae560b 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_large_keys.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_large_keys.json @@ -103,7 +103,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_many_trigger_data.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_many_trigger_data.json index 7210704bb..5fad10144 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_many_trigger_data.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_many_trigger_data.json @@ -121,7 +121,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_over_contributions_limit.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_over_contributions_limit.json index c5e8b3cad..20f7179f3 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_over_contributions_limit.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_over_contributions_limit.json @@ -160,7 +160,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -172,7 +172,7 @@ "source_event_id": "1", "trigger_data": "3", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_three_of_three_entries.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_three_of_three_entries.json index f228340d0..bc5b4d132 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_three_of_three_entries.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_three_of_three_entries.json @@ -105,7 +105,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions.json index 985a338ed..54739775a 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions.json @@ -103,7 +103,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api.json index 11df48af0..c619387a7 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api.json @@ -107,7 +107,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key" : "347982378", "trigger_debug_key" : "8971346783" } @@ -135,7 +135,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key" : "347982378", "trigger_debug_key" : "8971346783" } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_source.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_source.json index 13cbac1a2..bfd9f49a5 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_source.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_source.json @@ -106,7 +106,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key" : "347982378" } }], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_trigger.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_trigger.json index 2d394041f..77e5f09e9 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_trigger.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_debug_api_trigger.json @@ -106,7 +106,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "trigger_debug_key" : "8971346783" } }], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api.json index a2e78e209..6c4c776b2 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api.json @@ -107,7 +107,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_source.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_source.json index 9f0ad2801..8bd9dd685 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_source.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_source.json @@ -106,7 +106,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_trigger.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_trigger.json index 7cae580ac..83516309f 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_trigger.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_no_adid_debug_api_trigger.json @@ -106,7 +106,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_null_reports.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_null_reports.json index ba0fae5d7..5b551ae95 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_null_reports.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/aggregatable/aggregatable_two_contributions_null_reports.json @@ -107,7 +107,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_3_conversions.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_3_conversions.json index 5e1ff2b5c..b8d9fe1ab 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_3_conversions.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_3_conversions.json @@ -1,7 +1,6 @@ { "description": "Three reporting windows configured for CTC - 2h (w1), 2d (w2) and expiry (w3). Source (app) has T1 (web), T2(web) and T3(web) in W1, where T4 gets ignored due to equal priority", "phflags_override": { - "measurement_enable_configurable_event_reporting_windows": "true", "measurement_event_reports_ctc_early_reporting_windows": "7200,172800", "measurement_flex_api_max_information_gain_dual_destination_event": "9", "measurement_flex_api_max_information_gain_dual_destination_navigation": "14" diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2.json index a6294ab4b..3c6ad0eda 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2.json @@ -1,7 +1,6 @@ { "description": "Three reporting windows configured for CTC - 2h (w1), 2d (w2) and expiry (w3). Source has T1(app) in W1 and T2(app) in W2.", "phflags_override": { - "measurement_enable_configurable_event_reporting_windows": "true", "measurement_event_reports_ctc_early_reporting_windows": "7200,172800" }, "input": { diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2_w3.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2_w3.json index 98fdf514e..670f89e0c 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2_w3.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_ctc_w1_w2_w3.json @@ -1,7 +1,6 @@ { "description": "Three reporting windows configured for CTC - 2h (w1), 2d (w2) and expiry (w3). Source (web) source has T1(app) in W1, T2(web) in W2 and T4(app) in W3 where T3(web) gets replaced by T4 because T4 has higher priority.", "phflags_override": { - "measurement_enable_configurable_event_reporting_windows": "true", "measurement_event_reports_ctc_early_reporting_windows": "7200,172800", "measurement_flex_api_max_information_gain_dual_destination_event": "9", "measurement_flex_api_max_information_gain_dual_destination_navigation": "14" diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_install_attribution.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_install_attribution.json index 0bd0470df..dc8e961a0 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_install_attribution.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_install_attribution.json @@ -1,7 +1,7 @@ { "description": "Three reporting windows configured for VTC - 1h (w1), 1d (w2) and expiry (w3). Source has 2 app triggers due to install attribution in w1 and w2.", "phflags_override": { - "measurement_enable_configurable_event_reporting_windows": "true", + "measurement_vtc_configurable_max_event_reports_count": "2", "measurement_event_reports_vtc_early_reporting_windows": "3600,86400", "measurement_flex_api_max_information_gain_dual_destination_event": "9", "measurement_flex_api_max_information_gain_dual_destination_navigation": "14" diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w1.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w1.json index 3aa8dafc2..4641d4e53 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w1.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w1.json @@ -1,7 +1,6 @@ { "description": "Three reporting windows configured for VTC - 1h (w1), 1d (w2) and expiry (w3). Source has trigger attributed in W1.", "phflags_override": { - "measurement_enable_configurable_event_reporting_windows": "true", "measurement_event_reports_vtc_early_reporting_windows": "3600,86400" }, "input": { diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w2.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w2.json index 9c6ec1539..ff5af97ef 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w2.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w2.json @@ -1,7 +1,6 @@ { "description": "Three reporting windows configured for VTC - 1h (w1), 1d (w2) and expiry (w3). Source has trigger attributed in W2 (also has another trigger which gets ignored due to lower priority).", "phflags_override": { - "measurement_enable_configurable_event_reporting_windows": "true", "measurement_event_reports_vtc_early_reporting_windows": "3600,86400" }, "input": { diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w3.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w3.json index bc775e3a4..224f52c57 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w3.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/configurable_reporting/configurable_reporting_event_vtc_w3.json @@ -1,7 +1,6 @@ { "description": "Three reporting windows configured for VTC - 1h (w1), 1d (w2) and expiry (w3). Source(app) has web trigger attributed in W3.", "phflags_override": { - "measurement_enable_configurable_event_reporting_windows": "true", "measurement_event_reports_vtc_early_reporting_windows": "3600,86400" }, "input": { diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_aggregatable_two_contributions.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_aggregatable_two_contributions.json index ebd6ed643..2338ff7f0 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_aggregatable_two_contributions.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_aggregatable_two_contributions.json @@ -151,7 +151,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key": "347982378" } }], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-app_source_destination_limit.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-app_source_destination_limit.json index a663f249a..280c87b41 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-app_source_destination_limit.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-app_source_destination_limit.json @@ -111,7 +111,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-web_source_destination_limit.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-web_source_destination_limit.json index d3d1ca334..2e8540bea 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-web_source_destination_limit.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_register_web-web_source_destination_limit.json @@ -98,7 +98,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger-reporting-origin-limit-app-app.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger-reporting-origin-limit-app-app.json index 39716916d..f4498b61c 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger-reporting-origin-limit-app-app.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger-reporting-origin-limit-app-app.json @@ -120,7 +120,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], @@ -136,7 +136,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-app.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-app.json index 459632d36..a4efff0cc 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-app.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-app.json @@ -91,7 +91,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [], @@ -106,7 +106,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "debug_aggregatable_results": [], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-web.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-web.json index 4fdfa14c0..77ff7530a 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-web.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_app-web.json @@ -102,7 +102,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "debug_event_level_results": [{ @@ -116,7 +116,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-app.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-app.json index bc0de4ec0..6d43ca834 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-app.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-app.json @@ -101,7 +101,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "debug_event_level_results": [{ @@ -115,7 +115,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-different-registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-different-registrant.json index b11caa533..42e17840d 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-different-registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-different-registrant.json @@ -103,7 +103,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "debug_event_level_results": [{ @@ -117,7 +117,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-same-registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-same-registrant.json index ee2b33f98..3e9241406 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-same-registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_attributions_per_source_destination_limit_web-web-same-registrant.json @@ -99,7 +99,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "debug_event_level_results": [{ @@ -113,7 +113,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346783", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-app.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-app.json index 422d8a143..4d91151df 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-app.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-app.json @@ -79,7 +79,7 @@ { "payload": { "attribution_destination": "android-app://example.2d1.test", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0001372, "scheduled_report_time": "1643325573", "source_event_id": "1", "source_type": "navigation", @@ -95,7 +95,7 @@ { "payload": { "attribution_destination": "android-app://example.2d1.test", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0001372, "scheduled_report_time": "1643325573", "source_event_id": "1", "source_type": "navigation", diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-web.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-web.json index a18be7506..3182ac4ce 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-web.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_app-web.json @@ -98,7 +98,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0008051 } }], "debug_event_level_results": [{ @@ -112,7 +112,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0008051 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-app.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-app.json index a425ba0f3..86e4d16d0 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-app.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-app.json @@ -97,7 +97,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0008051 } }], "debug_event_level_results": [{ @@ -111,7 +111,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0008051 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-different-registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-different-registrant.json index ba15a27bd..29e524120 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-different-registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-different-registrant.json @@ -101,7 +101,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0001372 } }], "debug_event_level_results": [{ @@ -115,7 +115,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0001372 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-same-registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-same-registrant.json index b0c0aa01e..9eb5b1b4b 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-same-registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/debug_report/debug_report_trigger_event_report_window_passed_web-web-same-registrant.json @@ -95,7 +95,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0001372 } }], "debug_event_level_results": [{ @@ -109,7 +109,7 @@ "source_type": "navigation", "source_debug_key": "347982378", "trigger_debug_key": "8971346781", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0001372 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_3_app_sources_3_web_triggers_3_reports.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_3_app_sources_3_web_triggers_3_reports.json index 1405c785d..5eaa9d1ac 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_3_app_sources_3_web_triggers_3_reports.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_3_app_sources_3_web_triggers_3_reports.json @@ -123,7 +123,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { "report_time": "800176400001", @@ -134,7 +134,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { "report_time": "800176400001", @@ -145,7 +145,7 @@ "source_event_id": "3", "trigger_data": "3", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_cannot_redirect.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_cannot_redirect.json index 518fbf142..7fabaaf82 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_cannot_redirect.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/list_sources/list_sources_cannot_redirect.json @@ -228,7 +228,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect.json index 45fdc162c..975bd064b 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect.json @@ -44,9 +44,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "3", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" - + "priority": "100" }, "Location": null, "Attribution-Reporting-Redirect": null @@ -124,7 +122,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -136,7 +134,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect_to_well_known.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect_to_well_known.json index 878f82c0d..ceb8bd2ad 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect_to_well_known.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/basic_use_of_redirect_to_well_known.json @@ -92,7 +92,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -104,7 +104,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects.json index 413283b34..2240b5661 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects.json @@ -50,9 +50,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "3", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" - + "priority": "100" }, "Location": "https://www.unenrolled-non-registering2.test", "Attribution-Reporting-Redirect": [ @@ -66,9 +64,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "4", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" - + "priority": "100" }, "Location": null, "Attribution-Reporting-Redirect": null @@ -80,9 +76,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "6", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" - + "priority": "100" }, "Attribution-Reporting-Redirect": [ "https://www.ad-tech5.test" @@ -96,9 +90,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "5", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" - + "priority": "100" }, "Location": null, "Attribution-Reporting-Redirect": null @@ -231,7 +223,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -243,7 +235,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects_to_well_known.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects_to_well_known.json index 6dd03b4b4..e9a811d4c 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects_to_well_known.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/complex_use_of_redirects_to_well_known.json @@ -54,8 +54,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "3", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" + "priority": "100" }, "Location": "https://www.unenrolled-non-registering2.test", "Attribution-Reporting-Redirect": [ @@ -69,9 +68,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "4", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" - + "priority": "100" }, "Location": null, "Attribution-Reporting-Redirect": null @@ -83,9 +80,7 @@ "Attribution-Reporting-Register-Source": { "source_event_id": "6", "destination": "android-app://example.2d1.test", - "priority": "100", - "expiry": "800172800002" - + "priority": "100" }, "Attribution-Reporting-Redirect": [ "https://www.ad-tech5.test" @@ -235,7 +230,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -247,7 +242,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_1_allowed.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_1_allowed.json index a86d67674..f6921321a 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_1_allowed.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_1_allowed.json @@ -126,7 +126,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_2_allowed.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_2_allowed.json index 587739024..e9228b9c4 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_2_allowed.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_2_allowed.json @@ -126,7 +126,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_disabled.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_disabled.json index a9752fec1..2da69130d 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_disabled.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/coordinator_origin_disabled.json @@ -126,7 +126,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/enrollment_flag_disabled.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/enrollment_flag_disabled.json index 0b966e24d..4a17c0eb6 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/enrollment_flag_disabled.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/enrollment_flag_disabled.json @@ -108,7 +108,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [{ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_debug_source_storage_limit.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_debug_source_storage_limit.json index 71b47b104..1ba32b6d5 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_debug_source_storage_limit.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_debug_source_storage_limit.json @@ -88,7 +88,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key": "347982378", "trigger_debug_key": "147982378" } @@ -102,7 +102,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key": "347982378", "trigger_debug_key": "147982378" } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_report_window.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_report_window.json index 67ef2d38d..615ab4931 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_report_window.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_report_window.json @@ -121,7 +121,7 @@ "payload": { "attribution_destination": "android-app://destination.test", "scheduled_report_time": "1643325573", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0001372, "source_event_id": "123", "source_type": "navigation", "trigger_data": "1" @@ -133,7 +133,7 @@ "payload": { "attribution_destination": "android-app://destination.test", "scheduled_report_time": "1643325573", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0001372, "source_event_id": "123", "source_type": "navigation", "trigger_data": "2" diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_time_based_source_selection.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_time_based_source_selection.json index 6d9b78f24..b84aeab36 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_time_based_source_selection.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/event_time_based_source_selection.json @@ -78,7 +78,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/limit_num_reports_for_click.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/limit_num_reports_for_click.json index 9adf76d18..71dd31cc7 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/limit_num_reports_for_click.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/limit_num_reports_for_click.json @@ -124,7 +124,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -136,7 +136,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -148,7 +148,7 @@ "source_event_id": "1", "trigger_data": "3", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_as_reporting_origin.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_as_reporting_origin.json index f3944e4eb..bef06b6e4 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_as_reporting_origin.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_as_reporting_origin.json @@ -55,7 +55,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_basic_use_of_redirect.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_basic_use_of_redirect.json index 944d30722..b519eb9f5 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_basic_use_of_redirect.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_basic_use_of_redirect.json @@ -93,7 +93,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -105,7 +105,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_ip_as_reporting_origin.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_ip_as_reporting_origin.json index d7fad3f79..1e0697941 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_ip_as_reporting_origin.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/localhost_ip_as_reporting_origin.json @@ -55,7 +55,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/only_one_source_of_multiple_matches_can_be_attributed.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/only_one_source_of_multiple_matches_can_be_attributed.json index 4563f3798..7a5af3e5c 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/only_one_source_of_multiple_matches_can_be_attributed.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/only_one_source_of_multiple_matches_can_be_attributed.json @@ -103,7 +103,7 @@ "source_event_id": "2", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -115,7 +115,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/priority_based_source_selection.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/priority_based_source_selection.json index 41595f546..fdc35df28 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/priority_based_source_selection.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/priority_based_source_selection.json @@ -78,7 +78,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWebSource_3_sources_3_triggers_3_reports.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWebSource_3_sources_3_triggers_3_reports.json index 8827e69b5..2c000a83b 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWebSource_3_sources_3_triggers_3_reports.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWebSource_3_sources_3_triggers_3_reports.json @@ -128,7 +128,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { "report_time": "800176400001", @@ -139,7 +139,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { "report_time": "800176400001", @@ -150,7 +150,7 @@ "source_event_id": "3", "trigger_data": "3", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching.json index eac5f0a52..03fb47d11 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching.json @@ -64,7 +64,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_different_registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_different_registrant.json index ddb67affd..5ef74d0e6 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_different_registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_different_registrant.json @@ -66,7 +66,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_same_registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_same_registrant.json index b712042b8..f0c60f59e 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_same_registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_ar_debug_same_registrant.json @@ -66,7 +66,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key" : "347982378", "trigger_debug_key" : "8971346783" } @@ -80,7 +80,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key" : "347982378", "trigger_debug_key" : "8971346783" } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_no_adid_no_ar_debug.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_no_adid_no_ar_debug.json index 15dbcae8f..e43a0c409 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_no_adid_no_ar_debug.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_api_no_adid_no_ar_debug.json @@ -64,7 +64,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_disabled_different_registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_disabled_different_registrant.json index 061c0c743..8142f2c57 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_disabled_different_registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_disabled_different_registrant.json @@ -69,7 +69,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_enabled_different_registrant.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_enabled_different_registrant.json index ac91e0adf..0917d9434 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_enabled_different_registrant.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-1_web-web_matching_debug_join_enabled_different_registrant.json @@ -69,7 +69,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key" : "347982378", "trigger_debug_key" : "8971346783" } @@ -83,7 +83,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263, + "randomized_trigger_rate": 0.0008051, "source_debug_key" : "347982378", "trigger_debug_key" : "8971346783" } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_app_and_web_matching.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_app_and_web_matching.json index 8be0277e0..dcf130f11 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_app_and_web_matching.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_app_and_web_matching.json @@ -88,7 +88,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }, { "report_time": "800176400001", @@ -99,7 +99,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_web_only_matching.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_web_only_matching.json index faa480667..ccb8f3fce 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_web_only_matching.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_1-2_web_only_matching.json @@ -83,7 +83,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_adid_debug_api.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_adid_debug_api.json index da1aab976..b047a48a8 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_adid_debug_api.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_adid_debug_api.json @@ -83,7 +83,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }] } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_ar_debug_adid_debug_api.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_ar_debug_adid_debug_api.json index b161cb42f..681d1f66d 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_ar_debug_adid_debug_api.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_ar_debug_adid_debug_api.json @@ -83,7 +83,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }] } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_debug_api_ar_debug.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_debug_api_ar_debug.json index 9fb5654c9..57c247e4e 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_debug_api_ar_debug.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_app-web_debug_api_ar_debug.json @@ -82,7 +82,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }] } diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_multiple_destinations.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_multiple_destinations.json index 93f63a51e..ca316b775 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_multiple_destinations.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_multiple_destinations.json @@ -89,7 +89,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -101,7 +101,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_redirects_ignored.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_redirects_ignored.json index 646b2e2b1..280fc4193 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_redirects_ignored.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_redirects_ignored.json @@ -106,7 +106,7 @@ "source_event_id": "1", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_web_app_matching_debug_api_adid_ar_debug.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_web_app_matching_debug_api_adid_ar_debug.json index 11d36313c..5a229be9b 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_web_app_matching_debug_api_adid_ar_debug.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/registerWeb_web_app_matching_debug_api_adid_ar_debug.json @@ -68,7 +68,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_1-1_app-app_matching.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_1-1_app-app_matching.json index 768d5f994..080c62ca1 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_1-1_app-app_matching.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_1-1_app-app_matching.json @@ -55,7 +55,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_empty_object_event_trigger_data.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_empty_object_event_trigger_data.json index d2be23319..9fd1eb923 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_empty_object_event_trigger_data.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_empty_object_event_trigger_data.json @@ -50,7 +50,7 @@ "source_event_id": "0", "trigger_data": "0", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_null_trigger_data_null_source_event_id.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_null_trigger_data_null_source_event_id.json index c36147be6..670c8de80 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_null_trigger_data_null_source_event_id.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-app_null_trigger_data_null_source_event_id.json @@ -55,7 +55,7 @@ "source_event_id": "0", "trigger_data": "0", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_dual_destination_source_storage_limit_debug_report.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_dual_destination_source_storage_limit_debug_report.json index 2041a9d2f..22e7b538a 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_dual_destination_source_storage_limit_debug_report.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_dual_destination_source_storage_limit_debug_report.json @@ -99,7 +99,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0170218 + "randomized_trigger_rate": 0.0054129 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_source_storage_limit_debug_report.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_source_storage_limit_debug_report.json index dad35eb61..9a88bf402 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_source_storage_limit_debug_report.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_app-web_source_storage_limit_debug_report.json @@ -94,7 +94,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_web-web_source_storage_limit_debug_report.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_web-web_source_storage_limit_debug_report.json index be217c98c..aaa2b6d4c 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_web-web_source_storage_limit_debug_report.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/register_web-web_source_storage_limit_debug_report.json @@ -100,7 +100,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "verbose_debug_reports": [ diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_one_trigger.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_one_trigger.json index 443987f27..9dec79b88 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_one_trigger.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_one_trigger.json @@ -99,7 +99,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }], "aggregatable_results": [] diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_three_triggers_one_dedup.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_three_triggers_one_dedup.json index 17a8ecc36..0343b9bf3 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_three_triggers_one_dedup.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/three_sources_three_triggers_one_dedup.json @@ -149,7 +149,7 @@ "source_event_id": "2", "trigger_data": "1", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -161,7 +161,7 @@ "source_event_id": "2", "trigger_data": "0", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/two_simple_matches_testing_multiplicity.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/two_simple_matches_testing_multiplicity.json index fa9c81136..aaabe1703 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/two_simple_matches_testing_multiplicity.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/misc/two_simple_matches_testing_multiplicity.json @@ -103,7 +103,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } }, { @@ -115,7 +115,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_disabled_basic.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_disabled_basic.json index d859f3413..8fcd67d55 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_disabled_basic.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_disabled_basic.json @@ -193,7 +193,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_original_source_wins_install_attribution.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_original_source_wins_install_attribution.json index ee188284d..9956388e9 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_original_source_wins_install_attribution.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_original_source_wins_install_attribution.json @@ -373,7 +373,7 @@ "source_event_id": "1", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_reg_has_original_xna_source_avoids_creating_derived_source.json b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_reg_has_original_xna_source_avoids_creating_derived_source.json index 233e156c5..bd792b74c 100644 --- a/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_reg_has_original_xna_source_avoids_creating_derived_source.json +++ b/adservices/tests/unittest/service-core/assets/msmt_e2e_tests/xna/xna_reg_has_original_xna_source_avoids_creating_derived_source.json @@ -183,7 +183,7 @@ "source_event_id": "2", "trigger_data": "2", "source_type": "navigation", - "randomized_trigger_rate": 0.0024263 + "randomized_trigger_rate": 0.0008051 } } ], diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/data/customaudience/DBCustomAudienceBackgroundFetchDataTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/data/customaudience/DBCustomAudienceBackgroundFetchDataTest.java index e9574eca6..a078f13c0 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/data/customaudience/DBCustomAudienceBackgroundFetchDataTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/data/customaudience/DBCustomAudienceBackgroundFetchDataTest.java @@ -26,26 +26,21 @@ import static org.junit.Assert.assertThrows; import android.adservices.common.CommonFixture; import android.adservices.customaudience.CustomAudienceFixture; +import com.android.adservices.common.AdServicesExtendedMockitoTestCase; import com.android.adservices.customaudience.DBCustomAudienceBackgroundFetchDataFixture; import com.android.adservices.service.Flags; import com.android.adservices.service.FlagsFactory; -import com.android.adservices.service.PhFlagsFixture; import com.android.adservices.service.customaudience.BackgroundFetchRunner; import com.android.adservices.service.customaudience.CustomAudienceUpdatableData; import com.android.adservices.service.customaudience.CustomAudienceUpdatableDataFixture; -import com.android.modules.utils.testing.TestableDeviceConfig; +import com.android.modules.utils.testing.ExtendedMockitoRule.SpyStatic; -import org.json.JSONException; -import org.junit.Rule; import org.junit.Test; import java.time.Instant; -public class DBCustomAudienceBackgroundFetchDataTest { - // This rule is used for configuring P/H flags - @Rule - public final TestableDeviceConfig.TestableDeviceConfigRule mDeviceConfigRule = - new TestableDeviceConfig.TestableDeviceConfigRule(); +public final class DBCustomAudienceBackgroundFetchDataTest + extends AdServicesExtendedMockitoTestCase { @Test public void testBuildFetchDataSuccess() { @@ -179,22 +174,28 @@ public class DBCustomAudienceBackgroundFetchDataTest { @Test public void testComputeNextEligibleUpdateTimeWithPhFlags() { - long configuredBaseIntervalS = 100L; - PhFlagsFixture.configureFledgeBackgroundFetchEligibleUpdateBaseIntervalS( - configuredBaseIntervalS); + Flags flags = FlagsFactory.getFlagsForTest(); + long configuredBaseIntervalS = flags.getFledgeBackgroundFetchEligibleUpdateBaseIntervalS(); Instant expectedEligibleUpdateTime = CommonFixture.FIXED_NOW.plusSeconds(configuredBaseIntervalS); Instant actualEligibleUpdateTime = DBCustomAudienceBackgroundFetchData .computeNextEligibleUpdateTimeAfterSuccessfulUpdate( - CommonFixture.FIXED_NOW); + CommonFixture.FIXED_NOW, flags); assertEquals(expectedEligibleUpdateTime, actualEligibleUpdateTime); } @Test - public void testCopyWithFullSuccessfulUpdatableDataResetsFailureCounts() throws JSONException { + @SpyStatic(FlagsFactory.class) + public void testCopyWithFullSuccessfulUpdatableDataResetsFailureCounts() throws Exception { + // NOTE: copyWithUpdatableData() will eventually call the + // computeNextEligibleUpdateTimeAfterSuccessfulUpdate() method that calls + // FlagsFactory.getInstance(), so we need to mock that method (otherwise it would call + // DeviceConfig and fail due to lack of permissions) + extendedMockito.mockGetFlags(FlagsFactory.getFlagsForTest()); + DBCustomAudienceBackgroundFetchData originalFetchData = DBCustomAudienceBackgroundFetchDataFixture.getValidBuilderByBuyer( CommonFixture.VALID_BUYER_1) @@ -206,8 +207,7 @@ public class DBCustomAudienceBackgroundFetchDataTest { Instant attemptedUpdateTime = CommonFixture.FIXED_NOW.plusSeconds(10); Instant expectedEligibleUpdateTime = DBCustomAudienceBackgroundFetchData - .computeNextEligibleUpdateTimeAfterSuccessfulUpdate( - attemptedUpdateTime, FlagsFactory.getFlagsForTest()); + .computeNextEligibleUpdateTimeAfterSuccessfulUpdate(attemptedUpdateTime); CustomAudienceUpdatableData updatableData = CustomAudienceUpdatableDataFixture.getValidBuilderFullSuccessfulResponse() diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/PhFlagsTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/PhFlagsTest.java index 2f9384830..25aacd519 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/PhFlagsTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/PhFlagsTest.java @@ -68,7 +68,6 @@ import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_ATTRIBUTI import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_ENROLLMENT_ALLOWLIST; import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_HASH_LIMIT; import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_ENABLE_COARSE_EVENT_REPORT_DESTINATIONS; -import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS; import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_MAX_AGGREGATE_DEDUPLICATION_KEYS_PER_REGISTRATION; import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_MAX_AGGREGATE_REPORT_UPLOAD_RETRY_WINDOW_MS; import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_MAX_ATTRIBUTIONS_PER_INVOCATION; @@ -83,7 +82,7 @@ import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_PLATFORM_ import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_LIMIT; import static com.android.adservices.service.Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT; import static com.android.adservices.service.Flags.DEFAULT_NOTIFICATION_DISMISSED_ON_CLICK; -import static com.android.adservices.service.Flags.DEFAULT_RVC_NOTIFICATION_ENABLED; +import static com.android.adservices.service.Flags.DEFAULT_RVC_POST_OTA_NOTIFICATION_ENABLED; import static com.android.adservices.service.Flags.DEFAULT_RVC_POST_OTA_NOTIF_AGE_CHECK; import static com.android.adservices.service.Flags.DEFAULT_U18_UX_ENABLED; import static com.android.adservices.service.Flags.DISABLE_FLEDGE_ENROLLMENT_CHECK; @@ -282,15 +281,12 @@ import static com.android.adservices.service.Flags.MEASUREMENT_DELETE_EXPIRED_JO import static com.android.adservices.service.Flags.MEASUREMENT_DELETE_UNINSTALLED_JOB_PERIOD_MS; import static com.android.adservices.service.Flags.MEASUREMENT_DELETE_UNINSTALLED_JOB_PERSISTED; import static com.android.adservices.service.Flags.MEASUREMENT_DESTINATION_RATE_LIMIT_WINDOW; -import static com.android.adservices.service.Flags.MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_AGGREGATABLE_REPORT_PAYLOAD_PADDING; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_API_STATUS_ALLOW_LIST_CHECK; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_APP_PACKAGE_NAME_LOGGING; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_ARA_DEDUPLICATION_ALIGNMENT_V1; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_ARA_PARSING_ALIGNMENT_V1; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_CONFIGURABLE_AGGREGATE_REPORT_DELAY; -import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_DATASTORE_MANAGER_THROW_DATASTORE_EXCEPTION; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_DEBUG_REPORT; import static com.android.adservices.service.Flags.MEASUREMENT_ENABLE_DELETE_REPORTS_ON_UNRECOVERABLE_EXCEPTION; @@ -323,7 +319,6 @@ import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_FALLBACK_RE import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW; import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_NETWORK_TYPE; import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_MAIN_REPORTING_JOB_PERIOD_MS; -import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_NOISE_PROBABILITY; import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_REPORTING_JOB_PERSISTED; import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW; import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_NETWORK_TYPE; @@ -338,10 +333,6 @@ import static com.android.adservices.service.Flags.MEASUREMENT_FLEX_API_MAX_INFO import static com.android.adservices.service.Flags.MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_NAVIGATION; import static com.android.adservices.service.Flags.MEASUREMENT_FLEX_API_MAX_TRIGGER_DATA_CARDINALITY; import static com.android.adservices.service.Flags.MEASUREMENT_FLEX_LITE_API_ENABLED; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.Flags.MEASUREMENT_IS_CLICK_VERIFICATION_ENABLED; import static com.android.adservices.service.Flags.MEASUREMENT_IS_CLICK_VERIFIED_BY_INPUT_EVENT; import static com.android.adservices.service.Flags.MEASUREMENT_JOB_AGGREGATE_FALLBACK_REPORTING_KILL_SWITCH; @@ -386,7 +377,6 @@ import static com.android.adservices.service.Flags.MEASUREMENT_MIN_INSTALL_ATTRI import static com.android.adservices.service.Flags.MEASUREMENT_MIN_POST_INSTALL_EXCLUSIVITY_WINDOW; import static com.android.adservices.service.Flags.MEASUREMENT_MIN_REPORTING_ORIGIN_UPDATE_WINDOW; import static com.android.adservices.service.Flags.MEASUREMENT_MIN_REPORTING_REGISTER_SOURCE_EXPIRATION_IN_SECONDS; -import static com.android.adservices.service.Flags.MEASUREMENT_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.Flags.MEASUREMENT_NETWORK_CONNECT_TIMEOUT_MS; import static com.android.adservices.service.Flags.MEASUREMENT_NETWORK_READ_TIMEOUT_MS; import static com.android.adservices.service.Flags.MEASUREMENT_RATE_LIMIT_WINDOW_MILLISECONDS; @@ -676,8 +666,6 @@ import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_DELE import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_DELETE_UNINSTALLED_JOB_PERIOD_MS; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_DELETE_UNINSTALLED_JOB_PERSISTED; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_DESTINATION_RATE_LIMIT_WINDOW; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_AGGREGATABLE_REPORT_PAYLOAD_PADDING; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_API_STATUS_ALLOW_LIST_CHECK; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_APP_PACKAGE_NAME_LOGGING; @@ -685,7 +673,6 @@ import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENAB import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_ARA_PARSING_ALIGNMENT_V1; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_COARSE_EVENT_REPORT_DESTINATIONS; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_CONFIGURABLE_AGGREGATE_REPORT_DELAY; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_DATASTORE_MANAGER_THROW_DATASTORE_EXCEPTION; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_DEBUG_REPORT; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_DELETE_REPORTS_ON_UNRECOVERABLE_EXCEPTION; @@ -704,7 +691,6 @@ import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENAB import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_SOURCE_DEBUG_REPORT; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_TRIGGER_DATA_MATCHING; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_TRIGGER_DEBUG_REPORT; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENABLE_XNA; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENFORCE_ENROLLMENT_ORIGIN_MATCH; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_ENFORCE_FOREGROUND_STATUS_DELETE_REGISTRATIONS; @@ -719,7 +705,6 @@ import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVEN import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_NETWORK_TYPE; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVENT_MAIN_REPORTING_JOB_PERIOD_MS; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVENT_NOISE_PROBABILITY; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVENT_REPORTING_JOB_PERSISTED; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_NETWORK_TYPE; @@ -734,10 +719,6 @@ import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_FLEX import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_NAVIGATION; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_FLEX_API_MAX_TRIGGER_DATA_CARDINALITY; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_FLEX_LITE_API_ENABLED; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_IS_CLICK_VERIFICATION_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_IS_CLICK_VERIFIED_BY_INPUT_EVENT; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_JOB_AGGREGATE_FALLBACK_REPORTING_KILL_SWITCH; @@ -792,7 +773,6 @@ import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_MIN_ import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_MIN_POST_INSTALL_EXCLUSIVITY_WINDOW; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_MIN_REPORTING_ORIGIN_UPDATE_WINDOW; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_MIN_REPORTING_REGISTER_SOURCE_EXPIRATION_IN_SECONDS; -import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_NETWORK_CONNECT_TIMEOUT_MS; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_NETWORK_READ_TIMEOUT_MS; import static com.android.adservices.service.FlagsConstants.KEY_MEASUREMENT_RATE_LIMIT_WINDOW_MILLISECONDS; @@ -829,7 +809,7 @@ import static com.android.adservices.service.FlagsConstants.KEY_PROTECTED_SIGNAL import static com.android.adservices.service.FlagsConstants.KEY_PROTECTED_SIGNALS_PERIODIC_ENCODING_JOB_PERIOD_MS; import static com.android.adservices.service.FlagsConstants.KEY_PROTECTED_SIGNALS_SERVICE_KILL_SWITCH; import static com.android.adservices.service.FlagsConstants.KEY_RECORD_MANUAL_INTERACTION_ENABLED; -import static com.android.adservices.service.FlagsConstants.KEY_RVC_NOTIFICATION_ENABLED; +import static com.android.adservices.service.FlagsConstants.KEY_RVC_POST_OTA_NOTIFICATION_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_RVC_POST_OTA_NOTIF_AGE_CHECK; import static com.android.adservices.service.FlagsConstants.KEY_RVC_UX_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_SDK_REQUEST_PERMITS_PER_SECOND; @@ -5302,24 +5282,6 @@ public class PhFlagsTest { } @Test - public void testGetMeasurementEnableConfigurableEventReportingWindows() { - // Without any overriding, the value is the hard coded constant. - assertThat(mPhFlags.getMeasurementEnableConfigurableEventReportingWindows()) - .isEqualTo(MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS); - - boolean phOverridingValue = !MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS; - - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS, - Boolean.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementEnableConfigurableEventReportingWindows()) - .isEqualTo(phOverridingValue); - } - - @Test public void testGetMeasurementEventReportsVtcEarlyReportingWindows() { // Without any overriding, the value is the hard coded constant. assertThat(mPhFlags.getMeasurementEventReportsVtcEarlyReportingWindows()) @@ -7679,7 +7641,8 @@ public class PhFlagsTest { boolean adServicesSystemApi, boolean phOverridingValue, boolean expected) { // Without any overriding, the value is the hard coded constant. - assertThat(mPhFlags.getEnableRvcNotification()).isEqualTo(DEFAULT_RVC_NOTIFICATION_ENABLED); + assertThat(mPhFlags.getEnableRvcPostOtaNotification()) + .isEqualTo(DEFAULT_RVC_POST_OTA_NOTIFICATION_ENABLED); DeviceConfig.setProperty( DeviceConfig.NAMESPACE_ADSERVICES, @@ -7688,11 +7651,11 @@ public class PhFlagsTest { /* makeDefault */ false); DeviceConfig.setProperty( DeviceConfig.NAMESPACE_ADSERVICES, - KEY_RVC_NOTIFICATION_ENABLED, + KEY_RVC_POST_OTA_NOTIFICATION_ENABLED, Boolean.toString(phOverridingValue), /* makeDefault */ false); - assertThat(mPhFlags.getEnableRvcNotification()).isEqualTo(expected); + assertThat(mPhFlags.getEnableRvcPostOtaNotification()).isEqualTo(expected); } @Test @@ -7921,144 +7884,6 @@ public class PhFlagsTest { } @Test - public void testGetMeasurementInstallAttrDualDestinationEventNoiseProbability() { - assertThat(mPhFlags.getMeasurementInstallAttrDualDestinationEventNoiseProbability()) - .isEqualTo(MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = - MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementInstallAttrDualDestinationEventNoiseProbability()) - .isEqualTo(phOverridingValue); - } - - @Test - public void testGetMeasurementDualDestinationNavigationNoiseProbability() { - assertThat(mPhFlags.getMeasurementDualDestinationNavigationNoiseProbability()) - .isEqualTo(MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = - MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementDualDestinationNavigationNoiseProbability()) - .isEqualTo(phOverridingValue); - } - - @Test - public void testGetMeasurementInstallAttrDualDestinationNavigationNoiseProbability() { - assertThat(mPhFlags.getMeasurementInstallAttrDualDestinationNavigationNoiseProbability()) - .isEqualTo(MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = - MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementInstallAttrDualDestinationNavigationNoiseProbability()) - .isEqualTo(phOverridingValue); - } - - @Test - public void testGetMeasurementDualDestinationEventNoiseProbability() { - assertThat(mPhFlags.getMeasurementDualDestinationEventNoiseProbability()) - .isEqualTo(MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementDualDestinationEventNoiseProbability()) - .isEqualTo(phOverridingValue); - } - - @Test - public void testGetMeasurementInstallAttrEventNoiseProbability() { - assertThat(mPhFlags.getMeasurementInstallAttrEventNoiseProbability()) - .isEqualTo(MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementInstallAttrEventNoiseProbability()) - .isEqualTo(phOverridingValue); - } - - @Test - public void testGetMeasurementInstallAttrNavigationNoiseProbability() { - assertThat(mPhFlags.getMeasurementInstallAttrNavigationNoiseProbability()) - .isEqualTo(MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementInstallAttrNavigationNoiseProbability()) - .isEqualTo(phOverridingValue); - } - - @Test - public void testGetMeasurementEventNoiseProbability() { - assertThat(mPhFlags.getMeasurementEventNoiseProbability()) - .isEqualTo(MEASUREMENT_EVENT_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = MEASUREMENT_EVENT_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_EVENT_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementEventNoiseProbability()).isEqualTo(phOverridingValue); - } - - @Test - public void testGetMeasurementNavigationNoiseProbability() { - assertThat(mPhFlags.getMeasurementNavigationNoiseProbability()) - .isEqualTo(MEASUREMENT_NAVIGATION_NOISE_PROBABILITY); - - // Now overriding with the value from PH. - float phOverridingValue = MEASUREMENT_NAVIGATION_NOISE_PROBABILITY + .0001f; - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, - Float.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementNavigationNoiseProbability()) - .isEqualTo(phOverridingValue); - } - - @Test public void testGetMeasurementEnablePreinstallCheck() { // The priority of applying the flag values: PH (DeviceConfig) and then hard-coded value. assertThat(mPhFlags.getMeasurementEnablePreinstallCheck()) @@ -8184,24 +8009,6 @@ public class PhFlagsTest { } @Test - public void testGetMeasurementEnableVtcConfigurableMaxEventReports() { - // Without any overriding, the value is the hard coded constant. - assertThat(mPhFlags.getMeasurementEnableVtcConfigurableMaxEventReports()) - .isEqualTo(DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS); - - boolean phOverridingValue = !DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS; - - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - KEY_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS, - Boolean.toString(phOverridingValue), - /* makeDefault */ false); - - assertThat(mPhFlags.getMeasurementEnableVtcConfigurableMaxEventReports()) - .isEqualTo(phOverridingValue); - } - - @Test public void testGetMeasurementVtcConfigurableMaxEventReportsCount() { // Without any overriding, the value is the hard coded constant. assertThat(mPhFlags.getMeasurementVtcConfigurableMaxEventReportsCount()) diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/AdSelectionE2ETest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/AdSelectionE2ETest.java index cff50ddab..bbef9eb67 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/AdSelectionE2ETest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/AdSelectionE2ETest.java @@ -7001,7 +7001,7 @@ public final class AdSelectionE2ETest extends AdServicesExtendedMockitoTestCase // Bypass the permission check since it's enforced before the package name check doNothing() .when(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( mContext, invalidPackageName, AD_SERVICES_API_CALLED__API_NAME__SELECT_ADS); // Logger calls come after the callback is returned @@ -7069,7 +7069,7 @@ public final class AdSelectionE2ETest extends AdServicesExtendedMockitoTestCase geq(0)); verify(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( mContext, invalidPackageName, AD_SERVICES_API_CALLED__API_NAME__SELECT_ADS); } diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/FrequencyCapFilteringE2ETest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/FrequencyCapFilteringE2ETest.java index 9a1f32df6..76d93ab08 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/FrequencyCapFilteringE2ETest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/adselection/FrequencyCapFilteringE2ETest.java @@ -377,7 +377,7 @@ public final class FrequencyCapFilteringE2ETest extends AdServicesExtendedMockit // Bypass the permission check since it's enforced before the package name check doNothing() .when(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( mContextSpy, CommonFixture.TEST_PACKAGE_NAME_1, AD_SERVICES_API_CALLED__API_NAME__UPDATE_AD_COUNTER_HISTOGRAM); @@ -401,7 +401,7 @@ public final class FrequencyCapFilteringE2ETest extends AdServicesExtendedMockit verifyNoMoreInteractions(mFrequencyCapDaoSpy); verify(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( mContextSpy, CommonFixture.TEST_PACKAGE_NAME_1, AD_SERVICES_API_CALLED__API_NAME__UPDATE_AD_COUNTER_HISTOGRAM); diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/AppManifestConfigMetricsLoggerTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/AppManifestConfigMetricsLoggerTest.java index ab02e196b..800027b5d 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/AppManifestConfigMetricsLoggerTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/AppManifestConfigMetricsLoggerTest.java @@ -49,8 +49,6 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.util.Log; -import androidx.test.filters.FlakyTest; - import com.android.adservices.common.AdServicesExtendedMockitoTestCase; import com.android.adservices.common.Nullable; import com.android.adservices.common.SyncCallback; @@ -158,12 +156,6 @@ public final class AppManifestConfigMetricsLoggerTest extends AdServicesExtended assertEditNotCalled(); } - @FlakyTest( - bugId = 315979774, - detail = - "Should be fine now (issue was probably calling mPrefs instead of pref, and" - + " method is simpler now regardless), but annotation will be removed in a" - + " follow-up CL") @Test public void testLogUsage_secondTimeDifferentResult() throws Exception { int result = RESULT_ALLOWED_APP_ALLOWS_ALL; diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/FledgeAuthorizationFilterTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/FledgeAuthorizationFilterTest.java index c4c187946..5460b2273 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/FledgeAuthorizationFilterTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/FledgeAuthorizationFilterTest.java @@ -17,7 +17,6 @@ package com.android.adservices.service.common; import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE; -import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_PROTECTED_SIGNALS; import static android.adservices.common.AdServicesStatusUtils.STATUS_CALLER_NOT_ALLOWED; import static android.adservices.common.AdServicesStatusUtils.STATUS_PERMISSION_NOT_REQUESTED; import static android.adservices.common.AdServicesStatusUtils.STATUS_UNAUTHORIZED; @@ -165,7 +164,7 @@ public final class FledgeAuthorizationFilterTest extends AdServicesExtendedMocki } @Test - public void testAssertAppHasCaPermission_appHasPermission() + public void testAssertAppHasPermission_appHasPermission() throws PackageManager.NameNotFoundException { PackageInfo packageInfoGrant = new PackageInfo(); packageInfoGrant.requestedPermissions = new String[] {ACCESS_ADSERVICES_CUSTOM_AUDIENCE}; @@ -177,26 +176,7 @@ public final class FledgeAuthorizationFilterTest extends AdServicesExtendedMocki when(PermissionHelper.hasCustomAudiencesPermission(CONTEXT, CONTEXT.getPackageName())) .thenReturn(true); - mChecker.assertAppDeclaredCustomAudiencePermission( - CONTEXT, CustomAudienceFixture.VALID_OWNER, API_NAME_LOGGING_ID); - - verifyZeroInteractions(mPackageManagerMock, mEnrollmentDaoMock, mAdServicesLoggerMock); - } - - @Test - public void testAssertAppHasPasPermission_appHasPermission() - throws PackageManager.NameNotFoundException { - PackageInfo packageInfoGrant = new PackageInfo(); - packageInfoGrant.requestedPermissions = new String[] {ACCESS_ADSERVICES_PROTECTED_SIGNALS}; - doReturn(packageInfoGrant) - .when(mPackageManagerMock) - .getPackageInfo( - eq(CustomAudienceFixture.VALID_OWNER), eq(PackageManager.GET_PERMISSIONS)); - - when(PermissionHelper.hasProtectedSignalsPermission(CONTEXT, CONTEXT.getPackageName())) - .thenReturn(true); - - mChecker.assertAppDeclaredProtectedSignalsPermission( + mChecker.assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, API_NAME_LOGGING_ID); verifyZeroInteractions(mPackageManagerMock, mEnrollmentDaoMock, mAdServicesLoggerMock); @@ -216,7 +196,7 @@ public final class FledgeAuthorizationFilterTest extends AdServicesExtendedMocki assertThrows( SecurityException.class, () -> - mChecker.assertAppDeclaredCustomAudiencePermission( + mChecker.assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, API_NAME_LOGGING_ID)); @@ -232,7 +212,7 @@ public final class FledgeAuthorizationFilterTest extends AdServicesExtendedMocki } @Test - public void testAssertAppHasCaPermission_mismatchedAppPackageName_throwSecurityException() + public void testAssertAppHasPermission_mismatchedAppPackageName_throwSecurityException() throws PackageManager.NameNotFoundException { doReturn(new PackageInfo()) .when(mPackageManagerMock) @@ -245,34 +225,7 @@ public final class FledgeAuthorizationFilterTest extends AdServicesExtendedMocki assertThrows( SecurityException.class, () -> - mChecker.assertAppDeclaredCustomAudiencePermission( - CONTEXT, "mismatchedAppPackageName", API_NAME_LOGGING_ID)); - - assertEquals( - AdServicesStatusUtils.SECURITY_EXCEPTION_PERMISSION_NOT_REQUESTED_ERROR_MESSAGE, - exception.getMessage()); - verify(mAdServicesLoggerMock) - .logFledgeApiCallStats( - eq(API_NAME_LOGGING_ID), eq(STATUS_PERMISSION_NOT_REQUESTED), anyInt()); - verifyNoMoreInteractions(mAdServicesLoggerMock); - verifyZeroInteractions(mPackageManagerMock, mEnrollmentDaoMock); - } - - @Test - public void testAssertAppHasPasPermission_mismatchedAppPackageName_throwSecurityException() - throws PackageManager.NameNotFoundException { - doReturn(new PackageInfo()) - .when(mPackageManagerMock) - .getPackageInfo( - eq(CustomAudienceFixture.VALID_OWNER), eq(PackageManager.GET_PERMISSIONS)); - when(PermissionHelper.hasProtectedSignalsPermission(CONTEXT, CONTEXT.getPackageName())) - .thenReturn(false); - - SecurityException exception = - assertThrows( - SecurityException.class, - () -> - mChecker.assertAppDeclaredProtectedSignalsPermission( + mChecker.assertAppDeclaredPermission( CONTEXT, "mismatchedAppPackageName", API_NAME_LOGGING_ID)); assertEquals( @@ -286,22 +239,11 @@ public final class FledgeAuthorizationFilterTest extends AdServicesExtendedMocki } @Test - public void testAssertAppHasCaPermission_nullContext_throwNpe() { - assertThrows( - NullPointerException.class, - () -> - mChecker.assertAppDeclaredCustomAudiencePermission( - null, CustomAudienceFixture.VALID_OWNER, API_NAME_LOGGING_ID)); - - verifyZeroInteractions(mPackageManagerMock, mEnrollmentDaoMock, mAdServicesLoggerMock); - } - - @Test - public void testAssertAppHasPasPermission_nullContext_throwNpe() { + public void testAssertAppHasPermission_nullContext_throwNpe() { assertThrows( NullPointerException.class, () -> - mChecker.assertAppDeclaredProtectedSignalsPermission( + mChecker.assertAppDeclaredPermission( null, CustomAudienceFixture.VALID_OWNER, API_NAME_LOGGING_ID)); verifyZeroInteractions(mPackageManagerMock, mEnrollmentDaoMock, mAdServicesLoggerMock); diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PackageChangedReceiverTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PackageChangedReceiverTest.java index 03635db38..7c4f4297c 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PackageChangedReceiverTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PackageChangedReceiverTest.java @@ -16,6 +16,8 @@ package com.android.adservices.service.common; +import static android.adservices.common.CommonFixture.doSleep; + import static com.android.dx.mockito.inline.extended.ExtendedMockito.any; import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyInt; import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyLong; @@ -64,6 +66,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito; import com.android.modules.utils.build.SdkLevel; import org.junit.After; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -326,6 +329,7 @@ public class PackageChangedReceiverTest { @Test public void testReceivePackageFullyRemoved_consent_noPackageUid() throws InterruptedException, IOException { + Assume.assumeTrue(SdkLevel.isAtLeastS()); Intent intent = createIntentSentByAdServiceSystemService( PackageChangedReceiver.PACKAGE_FULLY_REMOVED); @@ -342,6 +346,7 @@ public class PackageChangedReceiverTest { @Test public void testReceivePackageFullyRemoved_consent_packageUidIsExplicitlyDefault() throws InterruptedException, IOException { + Assume.assumeTrue(SdkLevel.isAtLeastS()); Intent intent = createIntentSentByAdServiceSystemService( PackageChangedReceiver.PACKAGE_FULLY_REMOVED); @@ -354,6 +359,7 @@ public class PackageChangedReceiverTest { @Test public void testReceivePackageFullyRemoved_consent_noPackageUid_backCompat() throws InterruptedException, IOException { + Assume.assumeTrue(SdkLevel.isAtLeastS()); Intent intent = createIntentSentBySystem(Intent.ACTION_PACKAGE_FULLY_REMOVED); intent.removeExtra(Intent.EXTRA_UID); @@ -364,6 +370,7 @@ public class PackageChangedReceiverTest { @Test public void testReceivePackageFullyRemoved_consent_packageUidIsExplicitlyDefault_backCompat() throws InterruptedException, IOException { + Assume.assumeTrue(SdkLevel.isAtLeastS()); Intent intent = createIntentSentBySystem(Intent.ACTION_PACKAGE_FULLY_REMOVED); intent.putExtra(Intent.EXTRA_UID, DEFAULT_PACKAGE_UID); @@ -711,6 +718,7 @@ public class PackageChangedReceiverTest { } private void runPackageFullyRemovedForConsent(Intent intent) throws Exception { + Assume.assumeTrue(SdkLevel.isAtLeastS()); // Start a mockitoSession to mock static method // Lenient added to allow easy disabling of other APIs' methods MockitoSession session = @@ -1159,4 +1167,35 @@ public class PackageChangedReceiverTest { mMockitoSession.finishMocking(); } } + + @Test + public void testAppConsentDeletion_onR() throws Exception { + MockitoSession mMockitoSession = + ExtendedMockito.mockitoSession() + .mockStatic(SdkLevel.class) + .mockStatic(ConsentManager.class) + .strictness(Strictness.LENIENT) + .initMocks(this) + .startMocking(); + try { + ExtendedMockito.doReturn(false).when(SdkLevel::isAtLeastS); + doReturn(mConsentManager).when(() -> ConsentManager.getInstance(any())); + PackageChangedReceiver spyReceiver = createSpyPackageReceiverForConsent(); + Intent intent = + createIntentSentByAdServiceSystemService( + PackageChangedReceiver.PACKAGE_FULLY_REMOVED); + doReturn(false).when(spyReceiver).isPackageStillInstalled(any(), anyString()); + + // Invoke the onReceive method to test the behavior + spyReceiver.onReceive(sContext, intent); + + verify(spyReceiver).consentOnPackageFullyRemoved(any(), any(), anyInt()); + doSleep(BACKGROUND_THREAD_TIMEOUT_MS); + + // On R App consent clear should not be called as it is not supported + verify(mConsentManager, never()).clearConsentForUninstalledApp(any(), anyInt()); + } finally { + mMockitoSession.finishMocking(); + } + } } diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PermissionHelperTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PermissionHelperTest.java index e723d48ab..652ba36e6 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PermissionHelperTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/common/PermissionHelperTest.java @@ -19,7 +19,6 @@ package com.android.adservices.service.common; import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_AD_ID; import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_ATTRIBUTION; import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_CUSTOM_AUDIENCE; -import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_PROTECTED_SIGNALS; import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_TOPICS; import static com.google.common.truth.Truth.assertThat; @@ -67,8 +66,7 @@ public class PermissionHelperTest { ACCESS_ADSERVICES_TOPICS, ACCESS_ADSERVICES_AD_ID, ACCESS_ADSERVICES_ATTRIBUTION, - ACCESS_ADSERVICES_CUSTOM_AUDIENCE, - ACCESS_ADSERVICES_PROTECTED_SIGNALS + ACCESS_ADSERVICES_CUSTOM_AUDIENCE }; doReturn(packageInfoGrant) .when(mMockPackageManagerGrant) @@ -170,10 +168,6 @@ public class PermissionHelperTest { getMockContext(ACCESS_ADSERVICES_CUSTOM_AUDIENCE, mMockPackageManagerGrant); assertThat(PermissionHelper.hasCustomAudiencesPermission(mockContext3, APP_PACKAGE_NAME)) .isTrue(); - Context mockContext4 = - getMockContext(ACCESS_ADSERVICES_PROTECTED_SIGNALS, mMockPackageManagerGrant); - assertThat(PermissionHelper.hasProtectedSignalsPermission(mockContext4, APP_PACKAGE_NAME)) - .isTrue(); } @Test @@ -191,8 +185,6 @@ public class PermissionHelperTest { .isFalse(); assertThat(PermissionHelper.hasCustomAudiencesPermission(mockContext, APP_PACKAGE_NAME)) .isFalse(); - assertThat(PermissionHelper.hasProtectedSignalsPermission(mockContext, APP_PACKAGE_NAME)) - .isFalse(); assertThat(PermissionHelper.hasAccessAdServicesStatePermission(mockContext)).isFalse(); assertThat(PermissionHelper.hasModifyAdServicesStatePermission(mockContext)).isFalse(); } diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/consent/ConsentMigrationUtilsTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/consent/ConsentMigrationUtilsTest.java index 3525f21ad..fd4e96d75 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/consent/ConsentMigrationUtilsTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/consent/ConsentMigrationUtilsTest.java @@ -24,6 +24,7 @@ import static android.adservices.extdata.AdServicesExtDataParams.STATE_UNKNOWN; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.never; @@ -42,6 +43,8 @@ import com.android.adservices.data.common.BooleanFileDatastore; import com.android.adservices.mockito.AdServicesExtendedMockitoRule; import com.android.adservices.service.appsearch.AppSearchConsentManager; import com.android.adservices.service.extdata.AdServicesExtDataStorageServiceManager; +import com.android.adservices.service.stats.ConsentMigrationStats; +import com.android.adservices.service.stats.StatsdAdServicesLogger; import com.android.modules.utils.build.SdkLevel; import org.junit.Rule; @@ -68,9 +71,14 @@ public class ConsentMigrationUtilsTest { .setManualInteractionWithConsentStatus(STATE_UNKNOWN) .build(); + private static final int REGION_ROW_CODE = 2; + @Rule public final AdServicesExtendedMockitoRule mExtendedMockitoRule = - new AdServicesExtendedMockitoRule.Builder(this).spyStatic(SdkLevel.class).build(); + new AdServicesExtendedMockitoRule.Builder(this) + .spyStatic(SdkLevel.class) + .spyStatic(DeviceRegionProvider.class) + .build(); @Spy private final Context mContextSpy = ApplicationProvider.getApplicationContext(); @Mock private BooleanFileDatastore mDatastoreMock; @@ -79,6 +87,7 @@ public class ConsentMigrationUtilsTest { @Mock private SharedPreferences mSharedPreferencesMock; @Mock private SharedPreferences.Editor mSharedPreferencesEditorMock; @Mock private AdServicesExtDataParams mAdServicesExtDataParamsMock; + @Mock private StatsdAdServicesLogger mStatsdAdServicesLoggerMock; @Test public void testHandleConsentMigrationToAppSearchIfNeeded_onR_skipsMigration() { @@ -89,10 +98,12 @@ public class ConsentMigrationUtilsTest { mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, - mAdServicesExtDataManagerMock); + mAdServicesExtDataManagerMock, + mStatsdAdServicesLoggerMock); verifyZeroInteractions(mAppSearchConsentManagerMock); verifyZeroInteractions(mAdServicesExtDataManagerMock); + verifyZeroInteractions(mStatsdAdServicesLoggerMock); } @Test @@ -103,10 +114,12 @@ public class ConsentMigrationUtilsTest { mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, - mAdServicesExtDataManagerMock); + mAdServicesExtDataManagerMock, + mStatsdAdServicesLoggerMock); verifyZeroInteractions(mAppSearchConsentManagerMock); verifyZeroInteractions(mAdServicesExtDataManagerMock); + verifyZeroInteractions(mStatsdAdServicesLoggerMock); } @Test @@ -115,10 +128,15 @@ public class ConsentMigrationUtilsTest { mockSDevice(); ConsentMigrationUtils.handleConsentMigrationToAppSearchIfNeeded( - mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, null); + mContextSpy, + mDatastoreMock, + mAppSearchConsentManagerMock, + null, + mStatsdAdServicesLoggerMock); verifyZeroInteractions(mAdServicesExtDataManagerMock); verifyZeroInteractions(mAppSearchConsentManagerMock); + verifyZeroInteractions(mStatsdAdServicesLoggerMock); } @Test @@ -136,10 +154,12 @@ public class ConsentMigrationUtilsTest { mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, - mAdServicesExtDataManagerMock); + mAdServicesExtDataManagerMock, + mStatsdAdServicesLoggerMock); verifyZeroInteractions(mAppSearchConsentManagerMock); verifyZeroInteractions(mAdServicesExtDataManagerMock); + verifyZeroInteractions(mStatsdAdServicesLoggerMock); } @Test @@ -157,12 +177,14 @@ public class ConsentMigrationUtilsTest { mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, - mAdServicesExtDataManagerMock); + mAdServicesExtDataManagerMock, + mStatsdAdServicesLoggerMock); verify(mAppSearchConsentManagerMock).wasU18NotificationDisplayed(); verifyNoMoreInteractions(mAppSearchConsentManagerMock); verifyZeroInteractions(mAdServicesExtDataManagerMock); + verifyZeroInteractions(mStatsdAdServicesLoggerMock); } @Test @@ -183,7 +205,8 @@ public class ConsentMigrationUtilsTest { mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, - mAdServicesExtDataManagerMock); + mAdServicesExtDataManagerMock, + mStatsdAdServicesLoggerMock); verify(mAppSearchConsentManagerMock).wasU18NotificationDisplayed(); verify(mAppSearchConsentManagerMock).wasGaUxNotificationDisplayed(); @@ -192,6 +215,7 @@ public class ConsentMigrationUtilsTest { verify(mAdServicesExtDataManagerMock).getAdServicesExtData(); verifyNoMoreInteractions(mAdServicesExtDataManagerMock); + verifyZeroInteractions(mStatsdAdServicesLoggerMock); } @Test @@ -211,11 +235,14 @@ public class ConsentMigrationUtilsTest { when(mSharedPreferencesMock.edit()).thenReturn(mSharedPreferencesEditorMock); when(mSharedPreferencesEditorMock.commit()).thenReturn(true); + doReturn(false).when(() -> DeviceRegionProvider.isEuDevice(any())); + ConsentMigrationUtils.handleConsentMigrationToAppSearchIfNeeded( mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, - mAdServicesExtDataManagerMock); + mAdServicesExtDataManagerMock, + mStatsdAdServicesLoggerMock); verify(mAppSearchConsentManagerMock).wasU18NotificationDisplayed(); verify(mAppSearchConsentManagerMock).wasGaUxNotificationDisplayed(); @@ -241,6 +268,21 @@ public class ConsentMigrationUtilsTest { verify(mAdServicesExtDataManagerMock).getAdServicesExtData(); verify(mAdServicesExtDataManagerMock).clearDataOnOtaAsync(); verifyNoMoreInteractions(mAdServicesExtDataManagerMock); + + ConsentMigrationStats consentMigrationStats = + ConsentMigrationStats.builder() + .setTopicsConsent(false) + .setFledgeConsent(false) + .setMsmtConsent(false) + .setDefaultConsent(true) + .setMigrationStatus( + ConsentMigrationStats.MigrationStatus + .SUCCESS_WITH_SHARED_PREF_UPDATED) + .setMigrationType( + ConsentMigrationStats.MigrationType.ADEXT_SERVICE_TO_APPSEARCH) + .setRegion(REGION_ROW_CODE) + .build(); + verify(mStatsdAdServicesLoggerMock).logConsentMigrationStats(consentMigrationStats); } @Test @@ -260,11 +302,14 @@ public class ConsentMigrationUtilsTest { when(mSharedPreferencesMock.edit()).thenReturn(mSharedPreferencesEditorMock); when(mSharedPreferencesEditorMock.commit()).thenReturn(false); + doReturn(false).when(() -> DeviceRegionProvider.isEuDevice(any())); + ConsentMigrationUtils.handleConsentMigrationToAppSearchIfNeeded( mContextSpy, mDatastoreMock, mAppSearchConsentManagerMock, - mAdServicesExtDataManagerMock); + mAdServicesExtDataManagerMock, + mStatsdAdServicesLoggerMock); verify(mAppSearchConsentManagerMock).wasU18NotificationDisplayed(); verify(mAppSearchConsentManagerMock).wasGaUxNotificationDisplayed(); @@ -291,6 +336,21 @@ public class ConsentMigrationUtilsTest { verify(mAdServicesExtDataManagerMock).getAdServicesExtData(); verify(mAdServicesExtDataManagerMock).clearDataOnOtaAsync(); verifyNoMoreInteractions(mAdServicesExtDataManagerMock); + + ConsentMigrationStats consentMigrationStats = + ConsentMigrationStats.builder() + .setTopicsConsent(false) + .setFledgeConsent(false) + .setMsmtConsent(true) + .setDefaultConsent(false) + .setMigrationStatus( + ConsentMigrationStats.MigrationStatus + .SUCCESS_WITH_SHARED_PREF_NOT_UPDATED) + .setMigrationType( + ConsentMigrationStats.MigrationType.ADEXT_SERVICE_TO_APPSEARCH) + .setRegion(REGION_ROW_CODE) + .build(); + verify(mStatsdAdServicesLoggerMock).logConsentMigrationStats(consentMigrationStats); } private void mockNoNotifOnS() { diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceEndToEndTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceEndToEndTest.java index a6b65749a..6652bb25f 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceEndToEndTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceEndToEndTest.java @@ -359,7 +359,7 @@ public class CustomAudienceServiceEndToEndTest { // Bypass the permission check since it's enforced before the package name check doNothing() .when(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, otherOwnerPackageName, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -381,7 +381,7 @@ public class CustomAudienceServiceEndToEndTest { CommonFixture.VALID_BUYER_1, VALID_NAME)); verify(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, otherOwnerPackageName, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -752,7 +752,7 @@ public class CustomAudienceServiceEndToEndTest { // Bypass the permission check since it's enforced before the package name check doNothing() .when(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, otherOwnerPackageName, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); @@ -766,7 +766,7 @@ public class CustomAudienceServiceEndToEndTest { AdServicesStatusUtils.SECURITY_EXCEPTION_CALLER_NOT_ALLOWED_ON_BEHALF_ERROR_MESSAGE, callback.getException().getMessage()); verify(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, otherOwnerPackageName, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); @@ -971,7 +971,7 @@ public class CustomAudienceServiceEndToEndTest { // Bypass the permission check since it's enforced before the package name check doNothing() .when(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, MY_APP_PACKAGE_NAME, AD_SERVICES_API_CALLED__API_NAME__OVERRIDE_CUSTOM_AUDIENCE_REMOTE_INFO); @@ -995,7 +995,7 @@ public class CustomAudienceServiceEndToEndTest { mCustomAudienceDao.doesCustomAudienceOverrideExist(otherOwner, BUYER_1, NAME_1)); verify(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, MY_APP_PACKAGE_NAME, AD_SERVICES_API_CALLED__API_NAME__OVERRIDE_CUSTOM_AUDIENCE_REMOTE_INFO); @@ -1107,7 +1107,7 @@ public class CustomAudienceServiceEndToEndTest { // Bypass the permission check since it's enforced before the package name check doNothing() .when(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, incorrectPackageName, AD_SERVICES_API_CALLED__API_NAME__REMOVE_CUSTOM_AUDIENCE_REMOTE_INFO_OVERRIDE); @@ -1135,7 +1135,7 @@ public class CustomAudienceServiceEndToEndTest { mCustomAudienceDao.doesCustomAudienceOverrideExist( MY_APP_PACKAGE_NAME, BUYER_1, NAME_1)); verify(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, incorrectPackageName, AD_SERVICES_API_CALLED__API_NAME__REMOVE_CUSTOM_AUDIENCE_REMOTE_INFO_OVERRIDE); @@ -1289,7 +1289,7 @@ public class CustomAudienceServiceEndToEndTest { // Bypass the permission check since it's enforced before the package name check doNothing() .when(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, incorrectPackageName, AD_SERVICES_API_CALLED__API_NAME__RESET_ALL_CUSTOM_AUDIENCE_OVERRIDES); @@ -1334,7 +1334,7 @@ public class CustomAudienceServiceEndToEndTest { mCustomAudienceDao.doesCustomAudienceOverrideExist( MY_APP_PACKAGE_NAME, BUYER_2, NAME_2)); verify(mFledgeAuthorizationFilterSpy) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, incorrectPackageName, AD_SERVICES_API_CALLED__API_NAME__RESET_ALL_CUSTOM_AUDIENCE_OVERRIDES); diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceImplTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceImplTest.java index 1073c08da..709c6bd74 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceImplTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/customaudience/CustomAudienceServiceImplTest.java @@ -212,7 +212,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CustomAudienceFixture.VALID_OWNER, mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -260,7 +260,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CustomAudienceFixture.VALID_OWNER, mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE)); @@ -326,7 +326,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock)); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -349,7 +349,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -416,7 +416,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -464,7 +464,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -513,7 +513,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CustomAudienceFixture.VALID_OWNER, mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -620,7 +620,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mFetchAndJoinCustomAudienceCallbackMock)); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__FETCH_AND_JOIN_CUSTOM_AUDIENCE); @@ -638,7 +638,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE)); @@ -682,7 +682,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE)); @@ -749,7 +749,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock)); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE)); @@ -773,7 +773,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE)); @@ -862,7 +862,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE)); @@ -910,7 +910,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki .assertCallerIsInForeground( MY_UID, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE, null); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE)); @@ -954,7 +954,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -1003,7 +1003,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CustomAudienceFixture.VALID_OWNER, mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -1050,7 +1050,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); @@ -1102,7 +1102,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); @@ -1158,7 +1158,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mCustomAudienceOverrideCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, "", AD_SERVICES_API_CALLED__API_NAME__OVERRIDE_CUSTOM_AUDIENCE_REMOTE_INFO); @@ -1222,7 +1222,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mCustomAudienceOverrideCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__OVERRIDE_CUSTOM_AUDIENCE_REMOTE_INFO); @@ -1268,8 +1268,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CustomAudienceFixture.VALID_NAME, mCustomAudienceOverrideCallbackMock); - verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission(CONTEXT, "", apiName); + verify(mFledgeAuthorizationFilterMock).assertAppDeclaredPermission(CONTEXT, "", apiName); verify(mDevContextFilterMock).createDevContext(); verify(mCustomAudienceImplMock).getCustomAudienceDao(); verify(mAppImportanceFilterMock) @@ -1322,8 +1321,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mCustomAudienceOverrideCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( - CONTEXT, CustomAudienceFixture.VALID_OWNER, apiName); + .assertAppDeclaredPermission(CONTEXT, CustomAudienceFixture.VALID_OWNER, apiName); verify(mDevContextFilterMock).createDevContext(); verify(mCustomAudienceImplMock).getCustomAudienceDao(); verify(mConsentManagerMock).isFledgeConsentRevokedForApp(CustomAudienceFixture.VALID_OWNER); @@ -1352,8 +1350,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mService.resetAllCustomAudienceOverrides(mCustomAudienceOverrideCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( - CONTEXT, CustomAudienceFixture.VALID_OWNER, apiName); + .assertAppDeclaredPermission(CONTEXT, CustomAudienceFixture.VALID_OWNER, apiName); verify(mDevContextFilterMock).createDevContext(); verify(mCustomAudienceImplMock).getCustomAudienceDao(); verify(mAppImportanceFilterMock).assertCallerIsInForeground(Process.myUid(), apiName, null); @@ -1400,7 +1397,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mService.resetAllCustomAudienceOverrides(mCustomAudienceOverrideCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__RESET_ALL_CUSTOM_AUDIENCE_OVERRIDES); @@ -1419,7 +1416,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki public void testAppManifestPermissionNotRequested_joinCustomAudience_fails() { doThrow(SecurityException.class) .when(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -1437,7 +1434,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki public void testAppManifestPermissionNotRequested_fetchCustomAudience_fails() { doThrow(SecurityException.class) .when(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__FETCH_AND_JOIN_CUSTOM_AUDIENCE); @@ -1458,7 +1455,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki public void testAppManifestPermissionNotRequested_leaveCustomAudience_fails() { doThrow(SecurityException.class) .when(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); @@ -1483,7 +1480,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki .build()); doThrow(SecurityException.class) .when(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__OVERRIDE_CUSTOM_AUDIENCE_REMOTE_INFO); @@ -1513,8 +1510,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki int apiName = AD_SERVICES_API_CALLED__API_NAME__REMOVE_CUSTOM_AUDIENCE_REMOTE_INFO_OVERRIDE; doThrow(SecurityException.class) .when(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( - CONTEXT, CustomAudienceFixture.VALID_OWNER, apiName); + .assertAppDeclaredPermission(CONTEXT, CustomAudienceFixture.VALID_OWNER, apiName); assertThrows( SecurityException.class, @@ -1536,7 +1532,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki .build()); doThrow(SecurityException.class) .when(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__RESET_ALL_CUSTOM_AUDIENCE_OVERRIDES); @@ -1565,7 +1561,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -1621,7 +1617,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CustomAudienceFixture.VALID_OWNER, mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -1667,7 +1663,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); @@ -1725,7 +1721,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki mICustomAudienceCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( any(), eq(CustomAudienceFixture.VALID_OWNER), eq(AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE)); @@ -1771,7 +1767,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CommonFixture.VALID_BUYER_1, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -1811,7 +1807,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki CommonFixture.VALID_BUYER_1, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); @@ -1850,7 +1846,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki RATE_LIMIT_REACHED_ERROR_MESSAGE, actualResponseCaptor.getValue().getErrorMessage()); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__JOIN_CUSTOM_AUDIENCE); @@ -1881,7 +1877,7 @@ public final class CustomAudienceServiceImplTest extends AdServicesExtendedMocki RATE_LIMIT_REACHED_ERROR_MESSAGE, actualResponseCaptor.getValue().getErrorMessage()); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredCustomAudiencePermission( + .assertAppDeclaredPermission( CONTEXT, CustomAudienceFixture.VALID_OWNER, AD_SERVICES_API_CALLED__API_NAME__LEAVE_CUSTOM_AUDIENCE); diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/E2EInteropMockTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/E2EInteropMockTest.java index 0e5544e83..74f8761d6 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/E2EInteropMockTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/E2EInteropMockTest.java @@ -21,7 +21,6 @@ import static java.util.Map.entry; import android.adservices.measurement.RegistrationRequest; import android.net.Uri; import android.os.RemoteException; -import android.provider.DeviceConfig; import com.android.adservices.service.measurement.actions.Action; import com.android.adservices.service.measurement.actions.RegisterSource; @@ -35,7 +34,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.junit.Assert; -import org.junit.Before; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -160,17 +158,6 @@ public class E2EInteropMockTest extends E2EMockTest { mFlags); } - @Before - public void setup() { - // Chromium does not have a flag at dynamic noising based on expiry but Android does, so it - // needs to be enabled. - DeviceConfig.setProperty( - DeviceConfig.NAMESPACE_ADSERVICES, - "measurement_enable_configurable_event_reporting_windows", - "true", - false); - } - @Override void processAction(RegisterSource sourceRegistration) throws JSONException, IOException { RegistrationRequest request = sourceRegistration.mRegistrationRequest; diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/EventReportTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/EventReportTest.java index f0be0f676..ca528c9a3 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/EventReportTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/EventReportTest.java @@ -15,11 +15,7 @@ */ package com.android.adservices.service.measurement; -import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.Flags.MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS; -import static com.android.adservices.service.Flags.MEASUREMENT_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.measurement.PrivacyParams.INSTALL_ATTR_NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS; import static com.android.adservices.service.measurement.PrivacyParams.NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS; import static com.android.adservices.service.measurement.SourceFixture.ValidSourceParams; @@ -67,6 +63,11 @@ public final class EventReportTest { public final TestableDeviceConfig.TestableDeviceConfigRule mDeviceConfigRule = new TestableDeviceConfig.TestableDeviceConfigRule(); + private static final double EVENT_NOISE_PROBABILITY = 0.0000025D; + private static final double INSTALL_ATTR_EVENT_NOISE_PROBABILITY = 0.0000125D; + private static final double INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY = 0.0024263D; + private static final double NAVIGATION_NOISE_PROBABILITY = 0.0024263D; + private static final double DOUBLE_MAX_DELTA = 0.0000001D; private static final long TRIGGER_PRIORITY = 345678L; @@ -288,7 +289,7 @@ public final class EventReportTest { assertEquals(source.getEventReportWindow() + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, report.getReportTime()); assertEquals(source.getSourceType(), report.getSourceType()); - assertEquals(MEASUREMENT_EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + assertEquals(EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -297,7 +298,6 @@ public final class EventReportTest { @Test public void populate_eventSourceAppDestWithoutInstallConfigured() throws JSONException { long baseTime = System.currentTimeMillis(); - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); String earlyReportingWindows1h1d = String.join( ",", @@ -306,7 +306,6 @@ public final class EventReportTest { doReturn(earlyReportingWindows1h1d) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(3).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source source = createSourceForTest( @@ -390,7 +389,7 @@ public final class EventReportTest { report.getReportTime()); assertEquals(Source.SourceType.NAVIGATION, report.getSourceType()); assertEquals( - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -430,7 +429,7 @@ public final class EventReportTest { assertEquals(source.getEventReportWindow() + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, report.getReportTime()); assertEquals(Source.SourceType.EVENT, report.getSourceType()); - assertEquals(MEASUREMENT_EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + assertEquals(EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -468,7 +467,7 @@ public final class EventReportTest { report.getReportTime()); assertEquals(Source.SourceType.EVENT, report.getSourceType()); assertEquals( - MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY, + INSTALL_ATTR_EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); @@ -507,7 +506,7 @@ public final class EventReportTest { assertEquals(source.getEventReportWindow() + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, report.getReportTime()); assertEquals(Source.SourceType.EVENT, report.getSourceType()); - assertEquals(MEASUREMENT_EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + assertEquals(EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -548,7 +547,7 @@ public final class EventReportTest { report.getReportTime()); assertEquals(Source.SourceType.NAVIGATION, report.getSourceType()); assertEquals( - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -589,7 +588,7 @@ public final class EventReportTest { report.getReportTime()); assertEquals(source.getSourceType(), report.getSourceType()); assertEquals( - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -633,7 +632,7 @@ public final class EventReportTest { report.getReportTime()); assertEquals(Source.SourceType.NAVIGATION, report.getSourceType()); assertEquals( - MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, + INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); @@ -679,7 +678,7 @@ public final class EventReportTest { report.getReportTime()); assertEquals(source.getSourceType(), report.getSourceType()); assertEquals( - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + NAVIGATION_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -698,6 +697,7 @@ public final class EventReportTest { .setEnrollmentId("enrollment-id") .setAppDestinations(Collections.singletonList(APP_DESTINATION)) .setWebDestinations(Collections.singletonList(WEB_DESTINATION)) + .setExpiryTime(baseTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(baseTime + TimeUnit.DAYS.toMillis(10)) .setCoarseEventReportDestinations(true) .build(); @@ -738,7 +738,7 @@ public final class EventReportTest { assertEquals(source.getEventReportWindow() + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, report.getReportTime()); assertEquals(Source.SourceType.EVENT, report.getSourceType()); - assertEquals(MEASUREMENT_EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); + assertEquals(EVENT_NOISE_PROBABILITY, report.getRandomizedTriggerRate(), DOUBLE_MAX_DELTA); assertEquals(SOURCE_ID, report.getSourceId()); assertEquals(TRIGGER_ID, report.getTriggerId()); assertEquals(REGISTRATION_ORIGIN, report.getRegistrationOrigin()); @@ -855,6 +855,7 @@ public final class EventReportTest { .setEnrollmentId("enrollment-id") .setAppDestinations(getNullableUriList(appDestination)) .setWebDestinations(getNullableUriList(webDestination)) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); } diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/SourceTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/SourceTest.java index 458efd4f0..f75c65e24 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/SourceTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/SourceTest.java @@ -1521,13 +1521,13 @@ public class SourceTest { } @Test - public void getOrDefaultEventReportWindows() throws JSONException { + public void getOrDefaultEventReportWindowsForFlex() throws JSONException { Flags flags = mock(Flags.class); JSONObject windowsObj = new JSONObject("{'start_time': '2000000', 'end_times': " + "[3600000, 86400000, 172000000]}"); // Provided Windows List<Pair<Long, Long>> eventReportWindows = - Source.getOrDefaultEventReportWindows( + Source.getOrDefaultEventReportWindowsForFlex( windowsObj, Source.SourceType.EVENT, 8640000, @@ -1543,7 +1543,7 @@ public class SourceTest { when(flags.getMeasurementEventReportsCtcEarlyReportingWindows()) .thenReturn("172800,604800"); eventReportWindows = - Source.getOrDefaultEventReportWindows( + Source.getOrDefaultEventReportWindowsForFlex( null, Source.SourceType.EVENT, TimeUnit.DAYS.toMillis(15), flags); assertNotNull(eventReportWindows); assertEquals(2, eventReportWindows.size()); @@ -1552,7 +1552,7 @@ public class SourceTest { // Default Windows - Navigation eventReportWindows = - Source.getOrDefaultEventReportWindows( + Source.getOrDefaultEventReportWindowsForFlex( null, Source.SourceType.NAVIGATION, TimeUnit.DAYS.toMillis(15), flags); assertNotNull(eventReportWindows); assertEquals(3, eventReportWindows.size()); @@ -1608,29 +1608,31 @@ public class SourceTest { } @Test - public void getProcessedEventReportWindow() { + public void getEffectiveEventReportWindow() { + long expiryTime = 7654321L; // null eventReportWindow Source sourceNullEventReportWindow = SourceFixture.getMinimalValidSourceBuilder() .setEventTime(10) + .setExpiryTime(expiryTime) .setEventReportWindow(null) .build(); - assertNull(sourceNullEventReportWindow.getProcessedEventReportWindow()); + assertEquals(expiryTime, sourceNullEventReportWindow.getEffectiveEventReportWindow()); // eventReportWindow Value < eventTime Source sourceNewEventReportWindow = SourceFixture.getMinimalValidSourceBuilder() - .setEventTime(10) + .setEventTime(10L) .setEventReportWindow(4L) .build(); - assertEquals(Long.valueOf(14L), sourceNewEventReportWindow.getProcessedEventReportWindow()); + assertEquals(14L, sourceNewEventReportWindow.getEffectiveEventReportWindow()); // eventReportWindow Value > eventTime Source sourceOldEventReportWindow = SourceFixture.getMinimalValidSourceBuilder() - .setEventTime(10) + .setEventTime(10L) .setEventReportWindow(15L) .build(); - assertEquals(Long.valueOf(15L), sourceOldEventReportWindow.getProcessedEventReportWindow()); + assertEquals(15L, sourceOldEventReportWindow.getEffectiveEventReportWindow()); } } diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerIntegrationTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerIntegrationTest.java index 6b8e4567a..39f46f31e 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerIntegrationTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerIntegrationTest.java @@ -77,7 +77,7 @@ public class AttributionJobHandlerIntegrationTest extends AbstractDbIntegrationT (new AttributionJobHandler( datastoreManager, FlagsFactory.getFlags(), - new DebugReportApi(sContext, FlagsFactory.getFlagsForTest()), + new DebugReportApi(sContext, FlagsFactory.getFlags()), new EventReportWindowCalcDelegate(FlagsFactory.getFlags()), new SourceNoiseHandler(FlagsFactory.getFlags()), mLogger, diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerTest.java index 169fc49c9..c1cbe2ba8 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/attribution/AttributionJobHandlerTest.java @@ -218,6 +218,12 @@ public class AttributionJobHandlerTest { when(mFlags.getMeasurementNullAggReportRateInclSourceRegistrationTime()).thenReturn(0f); when(mFlags.getMeasurementMinEventReportDelayMillis()) .thenReturn(Flags.MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS); + when(mFlags.getMeasurementVtcConfigurableMaxEventReportsCount()) + .thenReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT); + when(mFlags.getMeasurementEventReportsVtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS); + when(mFlags.getMeasurementEventReportsCtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS); } @Test @@ -659,7 +665,6 @@ public class AttributionJobHandlerTest { public void performPendingAttributions_vtcWithConfiguredReportsCount_attributeUptoConfigLimit() throws DatastoreException { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(3).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source source = SourceFixture.getMinimalValidSourceBuilder() @@ -1661,6 +1666,7 @@ public class AttributionJobHandlerTest { .setAttributionMode(Source.AttributionMode.TRUTHFULLY) .setInstallAttributed(true) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(10)) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(28)) .setEventTime(eventTime - TimeUnit.DAYS.toMillis(2)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) @@ -1740,6 +1746,7 @@ public class AttributionJobHandlerTest { .setInstallAttributed(true) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(3)) .setEventTime(eventTime - TimeUnit.DAYS.toMillis(2)) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -1750,6 +1757,7 @@ public class AttributionJobHandlerTest { .setPriority(200L) .setAttributionMode(Source.AttributionMode.TRUTHFULLY) .setEventTime(eventTime) + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .build(); when(mMeasurementDao.getPendingTriggerIds()) @@ -3344,6 +3352,7 @@ public class AttributionJobHandlerTest { + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") .setId("sourceId") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -3439,6 +3448,7 @@ public class AttributionJobHandlerTest { + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") .setId("sourceId") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -3536,6 +3546,7 @@ public class AttributionJobHandlerTest { + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") .setId("sourceId") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -3631,6 +3642,7 @@ public class AttributionJobHandlerTest { + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") .setId("sourceId") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -3729,6 +3741,7 @@ public class AttributionJobHandlerTest { + "}\n") .setId("sourceId") .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -3964,6 +3977,7 @@ public class AttributionJobHandlerTest { + " \"key_1\": [\"value_1\", \"value_2\"],\n" + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -4042,6 +4056,7 @@ public class AttributionJobHandlerTest { + " \"key_1\": [\"value_1\", \"value_2\"],\n" + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -4119,6 +4134,7 @@ public class AttributionJobHandlerTest { + " \"key_1\": [\"value_1\", \"value_2\"],\n" + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -4341,6 +4357,7 @@ public class AttributionJobHandlerTest { + " \"key_1\": [\"value_1\", \"value_2\"],\n" + " \"key_2\": [\"value_1\", \"value_2\"]\n" + "}\n") + .setExpiryTime(triggerTime + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(triggerTime + 1L) .setAggregatableReportWindow(triggerTime + 1L) .build(); @@ -6132,6 +6149,7 @@ public class AttributionJobHandlerTest { .setId("sourceId") .setEventTime(TRIGGER_TIME - TimeUnit.SECONDS.toMillis(LOOKBACK_WINDOW - 1)) .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(TRIGGER_TIME + TimeUnit.DAYS.toMillis(28)) .setEventReportWindow(TRIGGER_TIME + 1) .setAggregatableReportWindow(TRIGGER_TIME + 1) .build(); diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerAttributionProbabilityTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerAttributionProbabilityTest.java index ef24154ac..a9fa26909 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerAttributionProbabilityTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerAttributionProbabilityTest.java @@ -16,14 +16,6 @@ package com.android.adservices.service.measurement.noising; -import static com.android.adservices.service.Flags.MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY; -import static com.android.adservices.service.Flags.MEASUREMENT_NAVIGATION_NOISE_PROBABILITY; import static com.android.adservices.service.measurement.SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS; import static com.android.adservices.service.measurement.SourceFixture.ValidSourceParams.WEB_DESTINATIONS; @@ -61,18 +53,22 @@ public class SourceNoiseHandlerAttributionProbabilityTest { private static final String DELIMITER = ","; private static final long CURRENT_TIME = System.currentTimeMillis(); + private static final double INSTALL_ATTR_EVENT_NOISE_PROBABILITY = 0.0000125D; + private static final double INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY = 0.0024263D; + private static final double EVENT_NOISE_PROBABILITY = 0.0000025D; + private static final double NAVIGATION_NOISE_PROBABILITY = 0.0024263D; + private static final double INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY = + 0.0170218D; + private final String mDescription; - private final boolean mIsEnableConfigurableEventReportingWindows; private final Source mSource; private final Long[] mEarlyReportingWindows; private final double mExpectedProbability; - private final boolean mEnableConfiguredMaxEventReports; private final int mConfiguredMaxEventReportsCount; /** - * The data format is measurement_enable_configurable_event_reporting_windows flag, sourceType, - * sourceEventReportWindow (limit), cooldown window, appDestination, webDestination - * configuredEarlyReportingWindows, coarse destination, enable configured conversions, + * The data format is sourceType, sourceEventReportWindow (limit), cooldown window, + * appDestination, webDestination, configuredEarlyReportingWindows, coarse destination, * configured conversions and expectedProbability. Each test description has numbers like 1-1-1, * 2-1-2, 3-3-3 etc. These signify max reports, trigger data bits and reporting windows count * respectively. For e.g., 2-1-2 stands for 2 maximum conversions, 1 trigger data bit (0 or 1) @@ -85,7 +81,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { { "non-configured reporting windows, EVENT, 1-1-1, app, fine " + "destinations", - false, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -93,15 +88,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configured max reports 1, // configured max reports - MEASUREMENT_EVENT_NOISE_PROBABILITY, // probability + EVENT_NOISE_PROBABILITY, // probability }, { "non-configured reporting windows, EVENT, 2-1-2, app, install " + "detection, fine " + "destinations", - false, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -109,14 +102,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configured max reports 1, // configured max reports - MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY, // probability + INSTALL_ATTR_EVENT_NOISE_PROBABILITY, // probability }, { "non-configured reporting windows, EVENT, 1-1-1, web, fine " + "destinations", - false, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -124,14 +115,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configured max reports 1, // configured max reports - MEASUREMENT_EVENT_NOISE_PROBABILITY, // probability + EVENT_NOISE_PROBABILITY, // probability }, { "non-configured reporting windows, EVENT, 1-1-1, app and web, " + "fine destinations", - false, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -139,155 +128,56 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configured max reports 1, // configured max reports - MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY, // probability + 0.0000042, // probability }, { - "non-configured reporting windows, EVENT, 2-1-2, app & web, " + "non-configured reporting windows, EVENT, 2-1-2, app, " + "install " + "detection, fine" + " destinations", - false, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window ATTRIBUTION_DESTINATIONS, // app destination - WEB_DESTINATIONS, // app destination + null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configured max reports 1, // configured max reports - MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY, + 0.0000125, }, { - "non-configured reporting windows, EVENT, 2-1-2, app & web, " + "non-configured reporting windows, EVENT, 2-1-1, app, " + "install " - + "detection, coarse" + + "detection, fine" + " destinations", - false, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type - DAYS.toMillis(10), // source event report window + DAYS.toMillis(1), // source event report window DAYS.toMillis(1), // install cooldown window ATTRIBUTION_DESTINATIONS, // app destination - WEB_DESTINATIONS, // app destination - new Long[] {}, // early reporting windows - true, // coarse destinations - false, // enable configurable max reports - 1, // configured max reports - MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY, - }, - { - "non-configured reporting windows, NAVIGATION, 3-3-3, app, fine " - + "destinations", - false, // measurement_enable_configurable_event_reporting_windows - Source.SourceType.NAVIGATION, // source type - DAYS.toMillis(10), // source event report window - 0, // install cooldown window - ATTRIBUTION_DESTINATIONS, // app destination null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configured max reports - 3, // configured max reports - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, // probability + 1, // configured max reports + 0.000005, }, { - "non-configured reporting windows, NAVIGATION, 3-3-3, app, install " - + "detection, fine " - + "destinations", - false, // measurement_enable_configurable_event_reporting_windows - Source.SourceType.NAVIGATION, // source type + "non-configured reporting windows, EVENT, 2-1-2, app, " + + "install " + + "detection, coarse" + + " destinations", + Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window ATTRIBUTION_DESTINATIONS, // app destination null, // web destination new Long[] {}, // early reporting windows - false, // coarse destinations - false, // enable configured max reports - 3, // configured max reports - MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, // probability - }, - { - "non-configured reporting windows, NAVIGATION, 3-3-3, web, fine " - + "destinations", - false, // measurement_enable_configurable_event_reporting_windows - Source.SourceType.NAVIGATION, // source type - DAYS.toMillis(10), // source event report window - 0, // install cooldown window - null, - WEB_DESTINATIONS, // web destination - new Long[] {}, // early reporting windows - false, // coarse destinations - false, // enable configurable max reports - 3, // configured max reports - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, // probability - }, - { - "non-configured reporting windows, NAVIGATION, 3-3-3, app & web, " - + "fine destinations", - false, // measurement_enable_configurable_event_reporting_windows - Source.SourceType.NAVIGATION, // source type - DAYS.toMillis(10), // source event report window - 0, // install cooldown window - ATTRIBUTION_DESTINATIONS, // app destination - WEB_DESTINATIONS, // web destination - new Long[] {}, // early reporting windows - false, // coarse destinations - false, // enable configurable max reports - 3, // configured max reports - MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, // probability - }, - { - "non-configured reporting windows, NAVIGATION, 3-3-3, app & web, " - + "coarse destinations", - false, // measurement_enable_configurable_event_reporting_windows - Source.SourceType.NAVIGATION, // source type - DAYS.toMillis(10), // source event report window - 0, // install cooldown window - ATTRIBUTION_DESTINATIONS, // app destination - WEB_DESTINATIONS, // web destination - new Long[] {}, // early reporting windows true, // coarse destinations - false, // enable configurable max reports - 3, // configured max reports - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, // probability - }, - { - "non-configured reporting windows, NAVIGATION, 3-3-3, app & web, " - + "install detection," - + " fine destinations", - false, // measurement_enable_configurable_event_reporting_windows - Source.SourceType.NAVIGATION, // source type - DAYS.toMillis(10), // source event report window - DAYS.toMillis(1), // install cooldown window - ATTRIBUTION_DESTINATIONS, // app destination - WEB_DESTINATIONS, // web destination - new Long[] {}, // early reporting windows - false, // coarse destinations - false, // enable configurable max reports - 3, // configured max reports - MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, - }, - { - "non-configured reporting windows, NAVIGATION, 3-3-3, app & web, " - + "install detection," - + " coarse destinations", - false, // measurement_enable_configurable_event_reporting_windows - Source.SourceType.NAVIGATION, // source type - DAYS.toMillis(10), // source event report window - DAYS.toMillis(1), // install cooldown window - ATTRIBUTION_DESTINATIONS, // app destination - WEB_DESTINATIONS, // web destination - new Long[] {}, // early reporting windows - true, // coarse destinations - false, // enable configurable max reports - 3, // configured max reports - MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, + 1, // configured max reports + INSTALL_ATTR_EVENT_NOISE_PROBABILITY, }, { "configured reporting windows, EVENT, 1-1-1, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -295,13 +185,11 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - MEASUREMENT_EVENT_NOISE_PROBABILITY, // probability + EVENT_NOISE_PROBABILITY, // probability }, { "configured reporting windows, EVENT, 1-1-2, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -309,13 +197,11 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1)}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports 0.0000042, }, { "configured reporting windows, EVENT, 1-1-3, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -323,7 +209,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1), DAYS.toSeconds(1)}, false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports 0.0000058, // probability }, @@ -331,7 +216,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { "configured reporting windows, EVENT, 1-1-2(1 effective window), " + "app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -339,15 +223,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {DAYS.toSeconds(15)}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - MEASUREMENT_EVENT_NOISE_PROBABILITY, // probability + EVENT_NOISE_PROBABILITY, // probability }, { "configured reporting windows, EVENT, 1-1-3(2 effective window), " + "app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type HOURS.toMillis(6), // source event report window 0, // install cooldown window @@ -355,15 +237,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1), DAYS.toSeconds(1)}, false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports 0.0000042, }, { - "configured reporting windows, EVENT, 2-1-3(2 effective windows), " + "configured reporting windows, EVENT, 1-1-2 (2 effective window), " + "app, install " + "detection, fine destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type HOURS.toMillis(6), // source event report window DAYS.toMillis(1), // install cooldown window @@ -373,15 +253,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { HOURS.toSeconds(1), DAYS.toSeconds(1) }, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY, // probability + 0.0000042, // probability }, { - "configured reporting windows, EVENT, 2-1-3, app, install " + "configured reporting windows, EVENT, 1-1-3, app, install " + "detection, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(6), // source event report window DAYS.toMillis(1), // install cooldown window @@ -391,15 +269,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { HOURS.toSeconds(1), DAYS.toSeconds(1) }, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - 0.0000233, // probability + 0.0000058, // probability }, { - "configured reporting windows, EVENT, 2-1-3, app & web, install " + "configured reporting windows, EVENT, 1-1-3, app & web, install " + "detection, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(6), // source event report window DAYS.toMillis(1), // install cooldown window @@ -409,15 +285,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { HOURS.toSeconds(1), DAYS.toSeconds(1) }, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - 0.0000757, // probability + 0.0000108, // probability }, { - "configured reporting windows, EVENT, 2-1-3, app & web, install " + "configured reporting windows, EVENT, 1-1-3, app & web, install " + "detection, coarse " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(6), // source event report window DAYS.toMillis(1), // install cooldown window @@ -427,16 +301,14 @@ public class SourceNoiseHandlerAttributionProbabilityTest { HOURS.toSeconds(1), DAYS.toSeconds(1) }, // early reporting windows true, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - 0.0000233, // probability + 0.0000058, // probability }, { "configured reporting windows, EVENT, 1-1-1, web, (install " + "cooldown -" + " unused), fine" + " destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -444,21 +316,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - MEASUREMENT_EVENT_NOISE_PROBABILITY, // probability + EVENT_NOISE_PROBABILITY, // probability }, { - // It is different from "non-configured reporting windows, 2-1-2, - // app - // & web, install - // detection" because we reject 20 states resulting into only 25 - // states in - // that case. Here we assume all 45 states to be valid. - "configured reporting windows, EVENT, 2-1-2, app & web, install " + "configured reporting windows, EVENT, 1-1-2, app & web, install " + "detection, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -466,21 +330,13 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {HOURS.toSeconds(1)}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - 0.0000374, // probability + 0.0000075, // probability }, { - // It is different from "non-configured reporting windows, 2-1-2, - // app - // & web, install - // detection, coarse destinations" because we reject 20 states - // resulting into only 25 states in that case. Here we assume all - // 45 states to be valid. - "configured reporting windows, EVENT, 2-1-2, app & web, install " + "configured reporting windows, EVENT, 1-1-2, app & web, install " + "detection, coarse " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -488,14 +344,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {HOURS.toSeconds(1)}, // early reporting windows true, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - 0.0000125, // probability + 0.0000042, // probability }, { "configured (ignored due to empty), EVENT, 2-1-2, app, install " + "detection, fine destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -503,14 +357,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY, // probability + INSTALL_ATTR_EVENT_NOISE_PROBABILITY, // probability }, { "configured reporting windows, EVENT, 1-1-1, app & web, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -518,14 +370,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // app destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY, // probability + 0.0000042, // probability }, { "configured reporting windows, EVENT, 1-1-1, app & web, coarse " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -533,14 +383,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // app destination new Long[] {}, // early reporting windows true, // coarse destinations - false, // enable configurable max reports 1, // configured max reports - MEASUREMENT_EVENT_NOISE_PROBABILITY, // probability + EVENT_NOISE_PROBABILITY, // probability }, { "configured reporting windows, NAVIGATION, 3-3-1, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -548,14 +396,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0001372, // probability }, { "configured reporting windows, NAVIGATION, 3-3-2, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -563,14 +409,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1)}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0008051, // probability }, { "configured reporting windows, NAVIGATION, 3-3-3, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -578,16 +422,14 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1), DAYS.toSeconds(1)}, false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, // probability + NAVIGATION_NOISE_PROBABILITY, // probability }, { "configured reporting windows, NAVIGATION, 3-3-2 (1 effective " + "window)" + ", app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(2), // source event report window 0, // install cooldown window @@ -595,7 +437,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {DAYS.toMillis(3)}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0001372, // probability }, @@ -603,7 +444,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { "configured reporting windows, NAVIGATION, 3-3-3 (2 effective " + "windows), app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type HOURS.toMillis(6), // source event report window 0, // install cooldown window @@ -611,7 +451,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1), DAYS.toSeconds(1)}, false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0008051, // probability }, @@ -619,7 +458,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { "configured reporting windows, NAVIGATION, 3-3-1, app, install " + "detection, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -627,7 +465,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0001372, // probability }, @@ -635,7 +472,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { "configured reporting windows, NAVIGATION, 3-3-1, web, install " + "detection, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -643,14 +479,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // app destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0001372, // probability }, { "configured reporting windows, NAVIGATION, 3-3-1, app & web, fine" + " destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -658,14 +492,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // app destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0008051, // probability }, { "configured reporting windows, NAVIGATION, 3-3-1, app & web, " + "coarse destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -673,7 +505,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // app destination new Long[] {}, // early reporting windows true, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0001372, // probability }, @@ -682,7 +513,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { + "install " + "detection, " + "fine destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -690,7 +520,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // app destination new Long[] {}, // early reporting windows false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0008051, // probability }, @@ -699,7 +528,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { + "install " + "detection, " + "coarse destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -707,7 +535,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // app destination new Long[] {}, // early reporting windows true, // coarse destinations - false, // enable configurable max reports 3, // configured max reports 0.0001372, // probability }, @@ -716,7 +543,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { + "install " + "detection, fine" + " destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -724,16 +550,14 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {HOURS.toSeconds(2), DAYS.toSeconds(2)}, false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports - MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, + INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, }, { "configured reporting windows, NAVIGATION, 3-3-3, app & web, " + "install " + "detection, " + "coarse destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -741,14 +565,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {HOURS.toSeconds(2), DAYS.toSeconds(2)}, true, // coarse destinations - false, // enable configurable max reports 3, // configured max reports - MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, + INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, }, { "configured reporting windows, NAVIGATION, 3-3-3, app, install " + "detection, fine destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window DAYS.toMillis(1), // install cooldown window @@ -756,14 +578,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(2), DAYS.toSeconds(2)}, false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports - MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, // probability + INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY, // probability }, { "configured reporting windows, NAVIGATION, 3-3-3, app & web, fine" + " destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -771,14 +591,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {HOURS.toSeconds(2), DAYS.toSeconds(2)}, false, // coarse destinations - false, // enable configurable max reports 3, // configured max reports - MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY, // probability + 0.0170218, // probability }, { "configured reporting windows, NAVIGATION, 3-3-3, app & web, " + "coarse destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.NAVIGATION, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -786,14 +604,12 @@ public class SourceNoiseHandlerAttributionProbabilityTest { WEB_DESTINATIONS, // web destination new Long[] {HOURS.toSeconds(2), DAYS.toSeconds(2)}, true, // coarse destinations - false, // enable configurable max reports 3, // configured max reports - MEASUREMENT_NAVIGATION_NOISE_PROBABILITY, // probability + NAVIGATION_NOISE_PROBABILITY, // probability }, { "non-configured reporting windows, EVENT, 3-1-1, app, fine " + "destinations", - false, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -801,13 +617,11 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {}, // early reporting windows false, // coarse destinations - true, // enable configured max reports 3, // configured max reports 0.0000083, // probability }, { "configured reporting windows, EVENT, 3-1-3, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -815,13 +629,11 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1), DAYS.toSeconds(1)}, false, // coarse destinations - true, // enable configurable max reports 3, // configured max reports 0.0000698, // probability }, { "configured reporting windows, EVENT, 2-1-3, app, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -829,7 +641,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1), DAYS.toSeconds(1)}, false, // coarse destinations - true, // enable configurable max reports 2, // configured max reports 0.0000233, // probability }, @@ -837,7 +648,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { "configured reporting windows, EVENT, 3-1-3, app, install " + "detection, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(6), // source event report window // not honored because conversions and windows are overridden @@ -848,7 +658,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { HOURS.toSeconds(1), DAYS.toSeconds(1) }, // early reporting windows false, // coarse destinations - true, // enable configurable max reports 3, // configured max reports 0.0000698, // probability }, @@ -856,7 +665,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { "configured reporting windows, EVENT, 3-1-3, app & web, install " + "detection, fine " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(6), // source event report window DAYS.toMillis(1), // install cooldown window @@ -866,7 +674,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { HOURS.toSeconds(1), DAYS.toSeconds(1) }, // early reporting windows false, // coarse destinations - true, // enable configurable max reports 3, // configured max reports 0.0003782, // probability }, @@ -874,7 +681,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { "configured reporting windows, EVENT, 3-1-3, app & web, install " + "detection, coarse " + "destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(6), // source event report window DAYS.toMillis(1), // install cooldown window @@ -884,13 +690,11 @@ public class SourceNoiseHandlerAttributionProbabilityTest { HOURS.toSeconds(1), DAYS.toSeconds(1) }, // early reporting windows true, // coarse destinations - true, // enable configurable max reports 3, // configured max reports 0.0000698, // probability }, { "configured reporting windows, EVENT, 1-1-3, app, fine" + " destinations", - true, // measurement_enable_configurable_event_reporting_windows Source.SourceType.EVENT, // source type DAYS.toMillis(10), // source event report window 0, // install cooldown window @@ -898,7 +702,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { null, // web destination new Long[] {HOURS.toSeconds(1), DAYS.toSeconds(1)}, false, // coarse destinations - true, // enable configurable max reports 1, // configured max reports 0.0000058, // probability }, @@ -907,7 +710,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { public SourceNoiseHandlerAttributionProbabilityTest( String description, - boolean isEnableConfigurableEventReportingWindows, Source.SourceType sourceType, long sourceEventReportWindow, long coolDownWindow, @@ -915,11 +717,9 @@ public class SourceNoiseHandlerAttributionProbabilityTest { List<Uri> webDestinations, Long[] earlyReportingWindows, boolean coarseDestination, - boolean isEnableConfigurableMaxEventReports, int configuredMaxEventReportsCount, double expectedProbability) { mDescription = description; - mIsEnableConfigurableEventReportingWindows = isEnableConfigurableEventReportingWindows; mSource = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(sourceType) @@ -936,7 +736,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { BigDecimal.valueOf(expectedProbability) .setScale(7, RoundingMode.HALF_UP) .doubleValue(); - mEnableConfiguredMaxEventReports = isEnableConfigurableMaxEventReports; mConfiguredMaxEventReportsCount = configuredMaxEventReportsCount; } @@ -944,9 +743,6 @@ public class SourceNoiseHandlerAttributionProbabilityTest { public void getRandomAttributionProbability_withParameterizedData() { // Setup Flags flags = mock(Flags.class); - doReturn(mIsEnableConfigurableEventReportingWindows) - .when(flags) - .getMeasurementEnableConfigurableEventReportingWindows(); doReturn(convertEarlyReportingWindowFlagString(mEarlyReportingWindows)) .when(flags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -954,36 +750,9 @@ public class SourceNoiseHandlerAttributionProbabilityTest { .when(flags) .getMeasurementEventReportsCtcEarlyReportingWindows(); doReturn(true).when(flags).getMeasurementEnableCoarseEventReportDestinations(); - doReturn(mEnableConfiguredMaxEventReports) - .when(flags) - .getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(mConfiguredMaxEventReportsCount) .when(flags) .getMeasurementVtcConfigurableMaxEventReportsCount(); - doReturn(MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY) - .when(flags) - .getMeasurementInstallAttrDualDestinationEventNoiseProbability(); - doReturn(MEASUREMENT_INSTALL_ATTR_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY) - .when(flags) - .getMeasurementInstallAttrDualDestinationNavigationNoiseProbability(); - doReturn(MEASUREMENT_DUAL_DESTINATION_NAVIGATION_NOISE_PROBABILITY) - .when(flags) - .getMeasurementDualDestinationNavigationNoiseProbability(); - doReturn(MEASUREMENT_DUAL_DESTINATION_EVENT_NOISE_PROBABILITY) - .when(flags) - .getMeasurementDualDestinationEventNoiseProbability(); - doReturn(MEASUREMENT_INSTALL_ATTR_EVENT_NOISE_PROBABILITY) - .when(flags) - .getMeasurementInstallAttrEventNoiseProbability(); - doReturn(MEASUREMENT_INSTALL_ATTR_NAVIGATION_NOISE_PROBABILITY) - .when(flags) - .getMeasurementInstallAttrNavigationNoiseProbability(); - doReturn(MEASUREMENT_EVENT_NOISE_PROBABILITY) - .when(flags) - .getMeasurementEventNoiseProbability(); - doReturn(MEASUREMENT_NAVIGATION_NOISE_PROBABILITY) - .when(flags) - .getMeasurementNavigationNoiseProbability(); // Execution double actualProbability = diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerTest.java index 06a3dc6ae..c9d0cf23a 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/noising/SourceNoiseHandlerTest.java @@ -50,49 +50,17 @@ public class SourceNoiseHandlerTest { @Before public void setup() { mFlags = mock(Flags.class); - doReturn(false).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); + doReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT) + .when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); + doReturn(Flags.MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS) + .when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); + doReturn(Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS) + .when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); mSourceNoiseHandler = spy(new SourceNoiseHandler(mFlags, new EventReportWindowCalcDelegate(mFlags))); } @Test - public void fakeReports_eventSourceDualDestPostInstallMode_generatesFromStaticReportStates() { - long expiry = System.currentTimeMillis(); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setWebDestinations(SourceFixture.ValidSourceParams.WEB_DESTINATIONS) - .setEventReportWindow(expiry) - .setInstallCooldownWindow( - SourceFixture.ValidSourceParams.INSTALL_COOLDOWN_WINDOW) - .build(); - // Force increase the probability of random attribution. - doReturn(0.50D).when(mSourceNoiseHandler).getRandomAttributionProbability(source); - int falseCount = 0; - int neverCount = 0; - int truthCount = 0; - for (int i = 0; i < 500; i++) { - List<Source.FakeReport> fakeReports = - mSourceNoiseHandler.assignAttributionModeAndGenerateFakeReports(source); - if (source.getAttributionMode() == Source.AttributionMode.FALSELY) { - falseCount++; - assertNotEquals(0, fakeReports.size()); - assertTrue( - isValidEventSourceDualDestPostInstallModeFakeReportState( - source, fakeReports)); - } else if (source.getAttributionMode() == Source.AttributionMode.NEVER) { - neverCount++; - assertEquals(0, fakeReports.size()); - } else { - truthCount++; - } - } - assertNotEquals(0, falseCount); - assertNotEquals(0, neverCount); - assertNotEquals(0, truthCount); - } - - @Test public void fakeReports_flexEventReport_generatesFromStaticReportStates() { Source source = SourceFixture.getValidSourceWithFlexEventReportWithFewerState(); // Force increase the probability of random attribution. @@ -167,6 +135,7 @@ public class SourceNoiseHandlerTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(30)) .build(); assertEquals( @@ -181,6 +150,7 @@ public class SourceNoiseHandlerTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(7)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( @@ -195,6 +165,7 @@ public class SourceNoiseHandlerTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(2)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( @@ -302,6 +273,7 @@ public class SourceNoiseHandlerTest { .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(2)) .setInstallAttributionWindow(TimeUnit.DAYS.toMillis(10)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(30)) .build(); assertEquals( @@ -318,6 +290,7 @@ public class SourceNoiseHandlerTest { .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(2)) .setInstallAttributionWindow(TimeUnit.DAYS.toMillis(10)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(7)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( @@ -334,6 +307,7 @@ public class SourceNoiseHandlerTest { .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(2)) .setInstallAttributionWindow(TimeUnit.DAYS.toMillis(10)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(2)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( @@ -350,6 +324,7 @@ public class SourceNoiseHandlerTest { .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(2)) .setInstallAttributionWindow(TimeUnit.DAYS.toMillis(10)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(30)) .build(); assertEquals( @@ -366,6 +341,7 @@ public class SourceNoiseHandlerTest { .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(2)) .setInstallAttributionWindow(TimeUnit.DAYS.toMillis(10)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(7)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( @@ -382,6 +358,7 @@ public class SourceNoiseHandlerTest { .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(2)) .setInstallAttributionWindow(TimeUnit.DAYS.toMillis(10)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(2)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( @@ -393,11 +370,11 @@ public class SourceNoiseHandlerTest { mSourceNoiseHandler.getImpressionNoiseParams(navigationSource2dExpiry)); Source eventSourceWith2Destinations30dExpiry = SourceFixture.getMinimalValidSourceBuilder() - .setWebDestinations(SourceFixture.ValidSourceParams.WEB_DESTINATIONS) .setSourceType(Source.SourceType.EVENT) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(2)) .setInstallAttributionWindow(TimeUnit.DAYS.toMillis(10)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(30)) .build(); assertEquals( @@ -405,7 +382,7 @@ public class SourceNoiseHandlerTest { /* reportCount= */ 2, /* triggerDataCardinality= */ 2, /* reportingWindowCount= */ 2, - /* destinationMultiplier */ 2), + /* destinationMultiplier */ 1), mSourceNoiseHandler.getImpressionNoiseParams( eventSourceWith2Destinations30dExpiry)); } @@ -491,14 +468,6 @@ public class SourceNoiseHandlerTest { PrivacyParams.EVENT_TRIGGER_DATA_CARDINALITY); } - private boolean isValidEventSourceDualDestPostInstallModeFakeReportState( - Source source, List<Source.FakeReport> fakeReportsState) { - // Generated fake reports state matches one of the states - return Arrays.stream(ImpressionNoiseUtil.DUAL_DESTINATION_POST_INSTALL_FAKE_REPORT_CONFIG) - .map(reportsState -> convertToReportsState(reportsState, source)) - .anyMatch(fakeReportsState::equals); - } - private List<Source.FakeReport> convertToReportsState(int[][] reportsState, Source source) { return Arrays.stream(reportsState) .map( @@ -507,7 +476,7 @@ public class SourceNoiseHandlerTest { new UnsignedLong(Long.valueOf(reportState[0])), new EventReportWindowCalcDelegate(mFlags) .getReportingTimeForNoising( - source, reportState[1], true), + source, reportState[1]), reportState[2] == 0 ? source.getAppDestinations() : source.getWebDestinations())) diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncRegistrationQueueRunnerTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncRegistrationQueueRunnerTest.java index ad96cff74..2cfc9e6c4 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncRegistrationQueueRunnerTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncRegistrationQueueRunnerTest.java @@ -269,6 +269,12 @@ public final class AsyncRegistrationQueueRunnerTest extends AdServicesExtendedMo when(mFlags.getMeasurementFlexApiMaxInformationGainDualDestinationNavigation()) .thenReturn(Flags .MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_DUAL_DESTINATION_NAVIGATION); + when(mFlags.getMeasurementVtcConfigurableMaxEventReportsCount()) + .thenReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT); + when(mFlags.getMeasurementEventReportsVtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS); + when(mFlags.getMeasurementEventReportsCtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS); when(mMeasurementDao.insertSource(any())).thenReturn(DEFAULT_SOURCE_ID); mContext = spy(sDefaultContext); when(mContext.getPackageManager()).thenReturn(mPackageManager); @@ -3641,7 +3647,7 @@ public final class AsyncRegistrationQueueRunnerTest extends AdServicesExtendedMo new Source.FakeReport( new UnsignedLong(0L), new EventReportWindowCalcDelegate(mFlags) - .getReportingTimeForNoising(source, 0, false), + .getReportingTimeForNoising(source, 0), destinations)) .collect(Collectors.toList()); } diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncSourceFetcherTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncSourceFetcherTest.java index 971502132..aa07077e8 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncSourceFetcherTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/registration/AsyncSourceFetcherTest.java @@ -235,6 +235,12 @@ public final class AsyncSourceFetcherTest extends AdServicesExtendedMockitoTestC .thenReturn(Flags.MEASUREMENT_MAX_INSTALL_ATTRIBUTION_WINDOW); when(mFlags.getMeasurementMinInstallAttributionWindow()) .thenReturn(Flags.MEASUREMENT_MIN_INSTALL_ATTRIBUTION_WINDOW); + when(mFlags.getMeasurementVtcConfigurableMaxEventReportsCount()) + .thenReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT); + when(mFlags.getMeasurementEventReportsVtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS); + when(mFlags.getMeasurementEventReportsCtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS); } @Test diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/DebugReportApiTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/DebugReportApiTest.java index 56d80d46f..5656ba007 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/DebugReportApiTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/DebugReportApiTest.java @@ -92,6 +92,12 @@ public final class DebugReportApiTest { when(mFlags.getMeasurementEnableDebugReport()).thenReturn(true); when(mFlags.getMeasurementEnableSourceDebugReport()).thenReturn(true); when(mFlags.getMeasurementEnableTriggerDebugReport()).thenReturn(true); + when(mFlags.getMeasurementVtcConfigurableMaxEventReportsCount()) + .thenReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT); + when(mFlags.getMeasurementEventReportsVtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS); + when(mFlags.getMeasurementEventReportsCtcEarlyReportingWindows()) + .thenReturn(Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS); } @Test diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java index 4635b600c..756c5434c 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/measurement/reporting/EventReportWindowCalcDelegateTest.java @@ -74,9 +74,14 @@ public class EventReportWindowCalcDelegateTest { @Before public void setup() { - doReturn(false).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS) .when(mFlags).getMeasurementMinEventReportDelayMillis(); + doReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT) + .when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); + doReturn(Flags.MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS) + .when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); + doReturn(Flags.MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS) + .when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); mEventReportWindowCalcDelegate = new EventReportWindowCalcDelegate(mFlags); } @@ -88,6 +93,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -107,6 +113,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -124,6 +131,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -144,6 +152,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -162,6 +171,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -180,6 +190,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -198,6 +209,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -215,6 +227,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -234,6 +247,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -253,6 +267,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -270,6 +285,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -281,6 +297,9 @@ public class EventReportWindowCalcDelegateTest { @Test public void testMaxReportCount() { + doReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT) + .when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); + Source eventSourceInstallNotAttributed = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) @@ -288,12 +307,7 @@ public class EventReportWindowCalcDelegateTest { .build(); assertEquals( PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallNotAttributed, false)); - assertEquals( - PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallNotAttributed, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(eventSourceInstallNotAttributed)); Source navigationSourceInstallNotAttributed = SourceFixture.getMinimalValidSourceBuilder() @@ -303,46 +317,33 @@ public class EventReportWindowCalcDelegateTest { assertEquals( PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallNotAttributed, false)); - assertEquals( - PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallNotAttributed, false)); + navigationSourceInstallNotAttributed)); Source eventSourceInstallAttributed = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setInstallAttributed(true) + .setInstallCooldownWindow(1L) .build(); assertEquals( PrivacyParams.INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallAttributed, true)); - // Install attribution state does not matter for web destination - assertEquals( - PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - eventSourceInstallAttributed, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(eventSourceInstallAttributed)); Source navigationSourceInstallAttributed = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setInstallAttributed(true) + .setInstallCooldownWindow(1L) .build(); assertEquals( PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallAttributed, true)); - assertEquals( - PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount( - navigationSourceInstallAttributed, true)); + navigationSourceInstallAttributed)); } @Test public void getMaxReportCount_configuredConversionsNonInstall_returnsConfiguredCount() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(3).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source nonInstallEventSource = SourceFixture.getMinimalValidSourceBuilder() @@ -352,13 +353,12 @@ public class EventReportWindowCalcDelegateTest { // Execution & assertion Assert.assertEquals( - 3, mEventReportWindowCalcDelegate.getMaxReportCount(nonInstallEventSource, false)); + 3, mEventReportWindowCalcDelegate.getMaxReportCount(nonInstallEventSource)); } @Test public void getMaxReportCount_configuredConversionsInstallCase_returnsConfiguredCount() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(2).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source installEventSource = SourceFixture.getMinimalValidSourceBuilder() @@ -368,29 +368,28 @@ public class EventReportWindowCalcDelegateTest { // Execution & assertion Assert.assertEquals( - 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource, true)); + 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource)); } @Test public void getMaxReportCount_configuredConversionsToOneInstallCase_incrementConfiguredCount() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(1).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source installEventSource = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setInstallAttributed(true) + .setInstallCooldownWindow(1L) .build(); // Execution & assertion Assert.assertEquals( - 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource, true)); + 2, mEventReportWindowCalcDelegate.getMaxReportCount(installEventSource)); } @Test public void getMaxReportCount_configuredConversionsToOneInstallCase_noEffectOnCtc() { // Setup - doReturn(true).when(mFlags).getMeasurementEnableVtcConfigurableMaxEventReports(); doReturn(2).when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); Source navigationSource = SourceFixture.getMinimalValidSourceBuilder() @@ -400,7 +399,7 @@ public class EventReportWindowCalcDelegateTest { // Execution & assertion Assert.assertEquals( - 3, mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource, false)); + 3, mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource)); } @Test @@ -412,48 +411,51 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); // Expected: 1 window at expiry Source eventSource7d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource7d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource7d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource7d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource7d, /* windowIndex= */ 1)); // Expected: 1 window at expiry Source eventSource2d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource2d, /* windowIndex= */ 1)); } @Test @@ -468,21 +470,21 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + minDelayMillis, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + minDelayMillis, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); } @Test public void getReportingTimeForNoising_eventSrcWithConfiguredReportingWindows() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -496,27 +498,27 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 2)); } @Test public void getReportingTimeForNoising_eventSrcInstallAttWithConfiguredReportingWindows() { // Addition another window for install attribution is ignored when configurable windows // are applied. - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -531,28 +533,28 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(expiry) .setEventReportWindow(expiry) .setInstallCooldownWindow(expiry) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(1) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 2)); } @Test public void getReportingTimeForNoising_navigationSrcWithConfiguredReportingWindows() { // Addition another window for install attribution is ignored when configurable windows // are applied. - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -566,27 +568,27 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ false)); + eventSource10d, /* windowIndex= */ 2)); } @Test public void getReportingTimeForNoising_navigationSrcInstallAttWithConfiguredReportingWindows() { // Addition another window for install attribution is ignored when configurable windows // are applied. - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -601,21 +603,22 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(expiry) .setEventReportWindow(expiry) .setInstallCooldownWindow(expiry) .build(); assertEquals( eventTime + TimeUnit.HOURS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 2)); } @Test @@ -628,36 +631,38 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.EVENT) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(10)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource10d, /* windowIndex= */ 2, /* isInstallCase */ true)); + eventSource10d, /* windowIndex= */ 2)); // Expected: 1 window at 2d(expiry) Source eventSource2d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 0, /* isInstallCase */ true)); + eventSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - eventSource2d, /* windowIndex= */ 1, /* isInstallCase */ true)); + eventSource2d, /* windowIndex= */ 1)); } @Test @@ -669,56 +674,59 @@ public class EventReportWindowCalcDelegateTest { SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(20)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(20) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 2)); // Expected: 2 windows at 2d & expiry(7d) Source navigationSource7d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 2)); // Expected: 1 window at 2d(expiry) Source navigationSource2d = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource2d, /* windowIndex= */ 1)); } @Test @@ -731,20 +739,21 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.NAVIGATION) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(20)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(20) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource20d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource20d, /* windowIndex= */ 2)); // Expected: 2 windows at 2d & expiry(7d) Source navigationSource7d = @@ -752,20 +761,21 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.NAVIGATION) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(7)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 1, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 1)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource7d, /* windowIndex= */ 2, /* isInstallCase */ false)); + navigationSource7d, /* windowIndex= */ 2)); // Expected: 1 window at 2d(expiry) Source navigationSource2d = @@ -773,169 +783,21 @@ public class EventReportWindowCalcDelegateTest { .setSourceType(Source.SourceType.NAVIGATION) .setInstallCooldownWindow(TimeUnit.DAYS.toMillis(1)) .setEventTime(eventTime) + .setExpiryTime(eventTime + TimeUnit.DAYS.toMillis(30)) .setEventReportWindow(eventTime + TimeUnit.DAYS.toMillis(2)) .build(); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 0, /* isInstallCase */ false)); + navigationSource2d, /* windowIndex= */ 0)); assertEquals( eventTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - navigationSource2d, /* windowIndex= */ 1, /* isInstallCase */ false)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcAppDest_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttAppDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - sourceEventTime - + PrivacyParams.INSTALL_ATTR_EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS[0] - + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttAppDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttWebDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.WEB)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSrcInstallAttWebDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .setInstallAttributed(true) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.WEB)); - } - - @Test - public void getReportingTime_nullWindowConfigEventSourceWebDestination_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long expiryTime = triggerTime + TimeUnit.DAYS.toMillis(30); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.EVENT) - .setEventReportWindow(expiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - expiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.WEB)); - } - - @Test - public void getReportingTime_nullWindowConfigNavigationSourceTriggerInFirstWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(25); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(1); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceEventTime - + PrivacyParams.NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS[0] - + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); + navigationSource2d, /* windowIndex= */ 1)); } @Test public void getReportingTime_emptyWindowConfigNavigationSourceTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -944,6 +806,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -955,7 +818,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_emptyWindowConfigEventSrcTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -966,6 +828,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -977,7 +840,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_emptyWindowConfigEventSrcInstallAttTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -988,6 +850,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1002,7 +865,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_emptyWindowConfigNavigationSrcInstallAttTriggerNextHour() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); doReturn("").when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); long triggerTime = System.currentTimeMillis(); @@ -1013,6 +875,7 @@ public class EventReportWindowCalcDelegateTest { .setAppDestinations( SourceFixture.ValidSourceParams.ATTRIBUTION_DESTINATIONS) .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1024,70 +887,7 @@ public class EventReportWindowCalcDelegateTest { } @Test - public void getReportingTime_nullWindowConfigNavigationSourceTriggerInSecondWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(25); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceEventTime - + PrivacyParams.NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS[1] - + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigNavigationSecondExpiry() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(2); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(3); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceExpiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test - public void getReportingTime_nullWindowConfigNavigationLast_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsVtcEarlyReportingWindows(); - doReturn(null).when(mFlags).getMeasurementEventReportsCtcEarlyReportingWindows(); - long triggerTime = System.currentTimeMillis(); - long sourceExpiryTime = triggerTime + TimeUnit.DAYS.toMillis(1); - long sourceEventTime = triggerTime - TimeUnit.DAYS.toMillis(20); - Source source = - SourceFixture.getMinimalValidSourceBuilder() - .setSourceType(Source.SourceType.NAVIGATION) - .setEventReportWindow(sourceExpiryTime) - .setEventTime(sourceEventTime) - .build(); - assertEquals( - sourceExpiryTime + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, - mEventReportWindowCalcDelegate.getReportingTime( - source, triggerTime, EventSurfaceType.APP)); - } - - @Test public void getReportingTime_MalformedWindowConfigEventSourceAppDestination_returnsDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1100,6 +900,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1111,7 +912,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttAppDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1124,6 +924,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1138,7 +939,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttAppDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1151,6 +951,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1163,7 +964,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttWebDestTrigger1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1176,6 +976,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1188,7 +989,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSrcInstallAttWebDestTrigger2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1201,6 +1001,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1213,7 +1014,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigEventSourceWebDestination() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1226,6 +1026,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1237,7 +1038,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationSourceTriggerInFirstWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1250,6 +1050,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1263,7 +1064,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationSourceTriggerInSecondWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1276,6 +1076,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1289,7 +1090,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationSecondExpiry_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1302,6 +1102,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1313,7 +1114,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_MalformedWindowConfigNavigationLast_fallbackToDefault() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1326,6 +1126,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(sourceExpiryTime) .setEventReportWindow(sourceExpiryTime) .setEventTime(sourceEventTime) .build(); @@ -1337,7 +1138,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigEventSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1350,6 +1150,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1361,7 +1162,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigEventSourceTriggerIn2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1374,6 +1174,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1386,7 +1187,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigEventSourceTriggerInLastWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1399,6 +1199,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1411,7 +1212,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigNavigationSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1424,6 +1224,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1435,7 +1236,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigNavigationSourceTriggerIn2ndWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1448,6 +1248,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1460,7 +1261,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_validWindowConfigNavigationSourceTriggerInLastWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(MALFORMED_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1473,6 +1273,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .setInstallAttributed(true) @@ -1485,7 +1286,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_invalidWindowConfigEventSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(INVALID_1H_1D_2D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1498,6 +1298,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.EVENT) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1509,7 +1310,6 @@ public class EventReportWindowCalcDelegateTest { @Test public void getReportingTime_invalidWindowConfigNavigationSourceTriggerIn1stWindow() { - doReturn(true).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); doReturn(VALID_1H_1D_WINDOW_CONFIG) .when(mFlags) .getMeasurementEventReportsVtcEarlyReportingWindows(); @@ -1522,6 +1322,7 @@ public class EventReportWindowCalcDelegateTest { Source source = SourceFixture.getMinimalValidSourceBuilder() .setSourceType(Source.SourceType.NAVIGATION) + .setExpiryTime(expiryTime) .setEventReportWindow(expiryTime) .setEventTime(sourceEventTime) .build(); @@ -1716,49 +1517,49 @@ public class EventReportWindowCalcDelegateTest { assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - oneWindowNoStart, 0, false)); + oneWindowNoStart, 0)); // InstallCase doesn't affect the report time assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - oneWindowNoStart, 0, true)); + oneWindowNoStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - oneWindowWithStart, 0, false)); + oneWindowWithStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - twoWindowsNoStart, 0, false)); + twoWindowsNoStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(5) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - twoWindowsNoStart, 1, false)); + twoWindowsNoStart, 1)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(2) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 0, false)); + fiveWindowsWithStart, 0)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(5) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 1, false)); + fiveWindowsWithStart, 1)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(7) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 2, false)); + fiveWindowsWithStart, 2)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(10) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 3, false)); + fiveWindowsWithStart, 3)); assertEquals( sourceTime + TimeUnit.DAYS.toMillis(20) + MEASUREMENT_MIN_EVENT_REPORT_DELAY_MILLIS, mEventReportWindowCalcDelegate.getReportingTimeForNoising( - fiveWindowsWithStart, 4, false)); + fiveWindowsWithStart, 4)); } @Test @@ -1866,7 +1667,8 @@ public class EventReportWindowCalcDelegateTest { @Test public void getMaxReportCount_flexLiteApi() { doReturn(true).when(mFlags).getMeasurementFlexLiteApiEnabled(); - doReturn(false).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); + doReturn(Flags.DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT) + .when(mFlags).getMeasurementVtcConfigurableMaxEventReportsCount(); long sourceTime = System.currentTimeMillis(); Source source10Reports = SourceFixture.getMinimalValidSourceBuilder() @@ -1874,10 +1676,20 @@ public class EventReportWindowCalcDelegateTest { .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) .setEventTime(sourceTime) .build(); - assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports, true)); - assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports, false)); + assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports)); + assertEquals(10, mEventReportWindowCalcDelegate.getMaxReportCount(source10Reports)); - Source sourceDefaultEvent = + Source eventSourceInstallAttributed = + SourceFixture.getMinimalValidSourceBuilder() + .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) + .setEventTime(sourceTime) + .setSourceType(Source.SourceType.EVENT) + .setInstallAttributed(true) + .setInstallCooldownWindow(1L) + .build(); + + Source eventSource = SourceFixture.getMinimalValidSourceBuilder() .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) @@ -1887,12 +1699,23 @@ public class EventReportWindowCalcDelegateTest { assertEquals( PrivacyParams.INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultEvent, true)); + mEventReportWindowCalcDelegate.getMaxReportCount( + eventSourceInstallAttributed)); assertEquals( PrivacyParams.EVENT_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultEvent, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(eventSource)); + + Source navigationSourceInstallAttributed = + SourceFixture.getMinimalValidSourceBuilder() + .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) + .setEventTime(sourceTime) + .setSourceType(Source.SourceType.NAVIGATION) + .setInstallAttributed(true) + .setInstallCooldownWindow(1L) + .build(); - Source sourceDefaultNavigation = + Source navigationSource = SourceFixture.getMinimalValidSourceBuilder() .setEventReportWindows(EVENT_REPORT_WINDOWS_5_WINDOWS_WITH_START) .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) @@ -1901,18 +1724,27 @@ public class EventReportWindowCalcDelegateTest { .build(); assertEquals( - PrivacyParams.INSTALL_ATTR_NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultNavigation, true)); + PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, + mEventReportWindowCalcDelegate.getMaxReportCount( + navigationSourceInstallAttributed)); assertEquals( PrivacyParams.NAVIGATION_SOURCE_MAX_REPORTS, - mEventReportWindowCalcDelegate.getMaxReportCount(sourceDefaultNavigation, false)); + mEventReportWindowCalcDelegate.getMaxReportCount(navigationSource)); } @Test public void getReportingWindowCountForNoising_flexLiteApi() { doReturn(true).when(mFlags).getMeasurementFlexLiteApiEnabled(); - doReturn(false).when(mFlags).getMeasurementEnableConfigurableEventReportingWindows(); long sourceTime = System.currentTimeMillis(); + Source defaultSourceEventInstallAttributed = + SourceFixture.getMinimalValidSourceBuilder() + .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) + .setEventTime(sourceTime) + .setSourceType(Source.SourceType.EVENT) + .setInstallAttributed(true) + .setInstallCooldownWindow(1L) + .build(); + Source defaultSourceEvent = SourceFixture.getMinimalValidSourceBuilder() .setExpiryTime(sourceTime + TimeUnit.DAYS.toMillis(30)) @@ -1955,57 +1787,57 @@ public class EventReportWindowCalcDelegateTest { assertEquals( 2, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceEvent, true)); + defaultSourceEventInstallAttributed)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceEvent, false)); + defaultSourceEvent)); assertEquals( 3, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceNavigation, true)); + defaultSourceNavigation)); assertEquals( 3, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - defaultSourceNavigation, false)); + defaultSourceNavigation)); // InstallCase doesn't affect the report count assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowNoStart, true)); + oneWindowNoStart)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowNoStart, false)); + oneWindowNoStart)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowWithStart, true)); + oneWindowWithStart)); assertEquals( 1, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - oneWindowWithStart, false)); + oneWindowWithStart)); assertEquals( 2, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - twoWindowsNoStart, true)); + twoWindowsNoStart)); assertEquals( 2, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - twoWindowsNoStart, false)); + twoWindowsNoStart)); assertEquals( 5, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - fiveWindowsWithStart, true)); + fiveWindowsWithStart)); assertEquals( 5, mEventReportWindowCalcDelegate.getReportingWindowCountForNoising( - fiveWindowsWithStart, false)); + fiveWindowsWithStart)); } @Test diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/shell/AdServicesShellCommandHandlerTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/shell/AdServicesShellCommandHandlerTest.java index 7341b1d33..0d2c08844 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/shell/AdServicesShellCommandHandlerTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/shell/AdServicesShellCommandHandlerTest.java @@ -70,14 +70,14 @@ public final class AdServicesShellCommandHandlerTest extends AdServicesExtendedM @Test public void testRunHelp() throws Exception { - String result = mCmd.runInvalid(CMD_HELP); + String result = mCmd.runValid(CMD_HELP); assertHelpContents(result); } @Test public void testRunHelpShort() throws Exception { - String result = mCmd.runInvalid(CMD_SHORT_HELP); + String result = mCmd.runValid(CMD_SHORT_HELP); assertHelpContents(result); } @@ -283,7 +283,10 @@ public final class AdServicesShellCommandHandlerTest extends AdServicesExtendedM private final StringWriter mOutStringWriter = new StringWriter(); private final PrintWriter mOut = new PrintWriter(mOutStringWriter); - public final AdServicesShellCommandHandler cmd = new AdServicesShellCommandHandler(mOut); + private final StringWriter mErrStringWriter = new StringWriter(); + private final PrintWriter mErr = new PrintWriter(mErrStringWriter); + public final AdServicesShellCommandHandler cmd = + new AdServicesShellCommandHandler(mOut, mErr); private boolean mOutCalled; @@ -302,7 +305,7 @@ public final class AdServicesShellCommandHandlerTest extends AdServicesExtendedM .that(result) .isAtLeast(0); - return getOut(); + return getResult(mOut, mOutStringWriter); } /** @@ -316,7 +319,7 @@ public final class AdServicesShellCommandHandlerTest extends AdServicesExtendedM .that(result) .isLessThan(0); - return getOut(); + return getResult(mErr, mErrStringWriter); } /** @@ -334,13 +337,13 @@ public final class AdServicesShellCommandHandlerTest extends AdServicesExtendedM * <p>Can only be called once per test, as there is no way to reset it, which could cause * confusion for the test developer. */ - String getOut() throws IOException { + String getResult(PrintWriter pw, StringWriter sw) throws IOException { if (mOutCalled) { throw new IllegalStateException("getOut() already called"); } - mOut.flush(); - String out = mOutStringWriter.toString(); - mOut.close(); + pw.flush(); + String out = sw.toString(); + pw.close(); mOutCalled = true; return out; } diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/shell/ShellCommandServiceImplTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/shell/ShellCommandServiceImplTest.java new file mode 100644 index 000000000..a07a5f650 --- /dev/null +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/shell/ShellCommandServiceImplTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.adservices.service.shell; + +import android.adservices.shell.IShellCommandCallback; +import android.adservices.shell.ShellCommandParam; +import android.adservices.shell.ShellCommandResult; +import android.os.IBinder; + +import com.android.adservices.common.AdServicesUnitTestCase; +import com.android.adservices.common.NoFailureSyncCallback; + +import org.junit.Test; + +public final class ShellCommandServiceImplTest extends AdServicesUnitTestCase { + + @Test + public void testRunShellCommand() throws Exception { + ShellCommandServiceImpl service = new ShellCommandServiceImpl(); + SyncIShellCommandCallback callback = new SyncIShellCommandCallback(); + + service.runShellCommand(new ShellCommandParam("echo", "xxx"), callback); + + ShellCommandResult response = callback.assertResultReceived(); + expect.withMessage("result").that(response.getResultCode()).isEqualTo(0); + expect.withMessage("out").that(response.getOut()).contains("xxx"); + expect.withMessage("err").that(response.getErr()).isEmpty(); + } + + @Test + public void testRunShellCommand_invalidCommand() throws Exception { + ShellCommandServiceImpl service = new ShellCommandServiceImpl(); + SyncIShellCommandCallback callback = new SyncIShellCommandCallback(); + + service.runShellCommand(new ShellCommandParam("invalid-cmd"), callback); + + ShellCommandResult response = callback.assertResultReceived(); + expect.withMessage("result").that(response.getResultCode()).isEqualTo(-1); + expect.withMessage("out").that(response.getOut()).isEmpty(); + expect.withMessage("err").that(response.getErr()).contains("Unknown command"); + } + + private static final class SyncIShellCommandCallback + extends NoFailureSyncCallback<ShellCommandResult> implements IShellCommandCallback { + + @Override + public void onResult(ShellCommandResult response) { + injectResult(response); + } + + @Override + public IBinder asBinder() { + return null; + } + } +} diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/signals/ProtectedSignalsServiceImplTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/signals/ProtectedSignalsServiceImplTest.java index 07ca5a5b4..079d58612 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/signals/ProtectedSignalsServiceImplTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/signals/ProtectedSignalsServiceImplTest.java @@ -170,8 +170,7 @@ public class ProtectedSignalsServiceImplTest { mProtectedSignalsService.updateSignals(mInput, mUpdateSignalsCallbackMock); verify(mFledgeAuthorizationFilterMock) - .assertAppDeclaredProtectedSignalsPermission( - eq(CONTEXT), eq(PACKAGE), eq(API_NAME)); + .assertAppDeclaredPermission(eq(CONTEXT), eq(PACKAGE), eq(API_NAME)); verify(mCallingAppUidSupplierMock).getCallingAppUid(); verify(mDevContextFilterMock).createDevContext(); verify(mFlagsMock).getDisableFledgeEnrollmentCheck(); diff --git a/adservices/tests/unittest/system-service/src/com/android/server/adservices/AdServicesShellCommandTest.java b/adservices/tests/unittest/system-service/src/com/android/server/adservices/AdServicesShellCommandTest.java index 779358be3..ca52afb01 100644 --- a/adservices/tests/unittest/system-service/src/com/android/server/adservices/AdServicesShellCommandTest.java +++ b/adservices/tests/unittest/system-service/src/com/android/server/adservices/AdServicesShellCommandTest.java @@ -18,10 +18,19 @@ package com.android.server.adservices; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; +import android.adservices.shell.IShellCommand; +import android.adservices.shell.IShellCommandCallback; +import android.adservices.shell.ShellCommandResult; +import android.content.Context; import android.os.Process; +import android.os.RemoteException; +import com.android.adservices.common.AdServicesMockitoTestCase; import com.android.server.adservices.AdServicesShellCommand.Injector; import com.google.common.truth.Expect; @@ -31,18 +40,15 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; import java.io.FileDescriptor; import java.io.PrintWriter; import java.io.StringWriter; -public final class AdServicesShellCommandTest { +public final class AdServicesShellCommandTest extends AdServicesMockitoTestCase { private static final String[] ALL_COMMANDS = new String[] {"help", "is-system-service-enabled"}; - @Rule public final MockitoRule rule = MockitoJUnit.rule(); @Rule public final Expect expect = Expect.create(); private final StringWriter mOutStringWriter = new StringWriter(); @@ -52,20 +58,30 @@ public final class AdServicesShellCommandTest { private final PrintWriter mErr = new PrintWriter(mErrStringWriter); @Mock private Flags mFlags; + @Mock private Context mContext; + + @Mock private IShellCommand mIShellCommand; private AdServicesShellCommand mShellCmd; + private Injector mInjector; + @Before public void setFixtures() { + mInjector = + new Injector() { + @Override + int getCallingUid() { + return Process.SHELL_UID; + } + + @Override + IShellCommand getShellCommandService(Context context) { + return mIShellCommand; + } + }; mShellCmd = - new AdServicesShellCommand( - new Injector() { - @Override - int getCallingUid() { - return Process.SHELL_UID; - } - }, - mFlags) { + new AdServicesShellCommand(mInjector, mFlags, mContext) { @Override public PrintWriter getOutPrintWriter() { return mOut; @@ -108,7 +124,8 @@ public final class AdServicesShellCommandTest { return 42; } }, - mFlags) + mFlags, + mContext) .onCommand("D'OH")); assertThat(e) .hasMessageThat() @@ -152,14 +169,60 @@ public final class AdServicesShellCommandTest { } @Test - public void testExec_invalidCommand() { - int result = runCmd("D'OH!"); - expect.withMessage("result").that(result).isEqualTo(-1); + public void testExec_invalidCommand() throws Exception { + String cmd = "D'OH!"; + ShellCommandResult responseInvalidShellCommand = + new ShellCommandResult.Builder() + .setErr(String.format("Unsupported command: %s", cmd)) + .setResultCode(-1) + .build(); + mockRunShellCommand(responseInvalidShellCommand); + int result = runCmd(cmd); + + expect.withMessage("result").that(result).isEqualTo(-1); expect.withMessage("out").that(getOut()).isEmpty(); String err = getErr(); expectHelpOutputHasAllCommands(err); - expectHelpOutputHasMessages(err, "D'OH!"); + expectHelpOutputHasMessages(err, cmd); + } + + @Test + public void testExec_validAdServicesShellCommand() throws Exception { + String cmd = "echo"; + ShellCommandResult response = + new ShellCommandResult.Builder().setOut(cmd).setResultCode(0).build(); + mockRunShellCommand(response); + + int result = runCmd(cmd); + + expect.withMessage("result").that(result).isEqualTo(0); + expect.withMessage("out").that(getOut()).contains(cmd); + expect.withMessage("err").that(getErr()).isEmpty(); + } + + @Test + public void testExec_adServicesCommand_throwsRemoteException() throws Exception { + String cmd = "echo"; + + doThrow(new RemoteException()).when(mIShellCommand).runShellCommand(any(), any()); + + int result = runCmd(cmd); + + expect.withMessage("result").that(result).isEqualTo(-1); + expect.withMessage("out").that(getOut()).isEmpty(); + expect.withMessage("err").that(getErr()).contains("Remote exception occurred"); + } + + @Test + public void testExec_adServicesCommand_timeoutHappens() throws Exception { + String cmd = "xxx"; + + int result = runCmd(cmd); + + expect.withMessage("result").that(result).isEqualTo(-1); + expect.withMessage("out").that(getOut()).isEmpty(); + expect.withMessage("err").that(getErr()).contains("Timeout occurred"); } @Test @@ -307,4 +370,14 @@ public final class AdServicesShellCommandTest { private void mockAdServicesSystemServiceEnabled(boolean value) { when(mFlags.getAdServicesSystemServiceEnabled()).thenReturn(value); } + + private void mockRunShellCommand(ShellCommandResult response) throws Exception { + doAnswer( + invocation -> { + ((IShellCommandCallback) invocation.getArgument(1)).onResult(response); + return null; + }) + .when(mIShellCommand) + .runShellCommand(any(), any()); + } } diff --git a/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/UxEngineTest.java b/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/UxEngineTest.java index f52fe2d82..0cdbf6701 100644 --- a/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/UxEngineTest.java +++ b/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/UxEngineTest.java @@ -19,7 +19,7 @@ package com.android.adservices.service.ui; import static com.android.adservices.service.FlagsConstants.KEY_ADSERVICES_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_GA_UX_FEATURE_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_IS_U18_UX_DETENTION_CHANNEL_ENABLED; -import static com.android.adservices.service.FlagsConstants.KEY_RVC_NOTIFICATION_ENABLED; +import static com.android.adservices.service.FlagsConstants.KEY_RVC_POST_OTA_NOTIFICATION_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_RVC_UX_ENABLED; import static com.android.adservices.service.FlagsConstants.KEY_U18_UX_ENABLED; import static com.android.adservices.service.ui.ux.collection.PrivacySandboxUxCollection.BETA_UX; @@ -748,7 +748,7 @@ public class UxEngineTest { verify(mUxStatesManager).getFlag(KEY_RVC_UX_ENABLED); // RVC UX logic where flag is checked once in RvcPostOTAChannel. - verify(mUxStatesManager).getFlag(KEY_RVC_NOTIFICATION_ENABLED); + verify(mUxStatesManager).getFlag(KEY_RVC_POST_OTA_NOTIFICATION_ENABLED); // The UX can not be updated due to the fact that graduation channel is currently disabled. verify(mConsentManager, never()).setUx(any()); diff --git a/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/enrollment/RvcPostOTAChannelTest.java b/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/enrollment/RvcPostOTAChannelTest.java index d8a222b08..1d0b4f932 100644 --- a/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/enrollment/RvcPostOTAChannelTest.java +++ b/adservices/tests/unittest/ui/src/com/android/adservices/service/ui/enrollment/RvcPostOTAChannelTest.java @@ -16,7 +16,7 @@ package com.android.adservices.service.ui.enrollment; -import static com.android.adservices.service.FlagsConstants.KEY_RVC_NOTIFICATION_ENABLED; +import static com.android.adservices.service.FlagsConstants.KEY_RVC_POST_OTA_NOTIFICATION_ENABLED; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; @@ -87,7 +87,7 @@ public class RvcPostOTAChannelTest { @Test public void isEligibleTest_isRvcAdultUser() { - doReturn(true).when(mUxStatesManager).getFlag(KEY_RVC_NOTIFICATION_ENABLED); + doReturn(true).when(mUxStatesManager).getFlag(KEY_RVC_POST_OTA_NOTIFICATION_ENABLED); doReturn(true).when(mConsentManager).isOtaAdultUserFromRvc(); assertThat( @@ -100,7 +100,7 @@ public class RvcPostOTAChannelTest { @Test public void isEligibleTest_notRvcAdultUser() { - doReturn(true).when(mUxStatesManager).getFlag(KEY_RVC_NOTIFICATION_ENABLED); + doReturn(true).when(mUxStatesManager).getFlag(KEY_RVC_POST_OTA_NOTIFICATION_ENABLED); doReturn(false).when(mConsentManager).isOtaAdultUserFromRvc(); assertThat( diff --git a/apex/Android.bp b/apex/Android.bp index 8305223e3..3036699db 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -115,6 +115,7 @@ bootclasspath_fragment { "android.adservices.exceptions", "android.adservices.extdata", "android.adservices.measurement", + "android.adservices.shell", "android.adservices.signals", "android.adservices.topics", "android.app.adservices", diff --git a/sdksandbox/tests/cts/endtoendtests/AndroidTest.xml b/sdksandbox/tests/cts/endtoendtests/AndroidTest.xml index 04237b6c1..8d58b9c56 100644 --- a/sdksandbox/tests/cts/endtoendtests/AndroidTest.xml +++ b/sdksandbox/tests/cts/endtoendtests/AndroidTest.xml @@ -20,6 +20,24 @@ <option name="config-descriptor:metadata" key="parameter" value="not_instant_app"/> <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi"/> <option name="config-descriptor:metadata" key="parameter" value="secondary_user"/> + <option name="test-user-token" value="%TEST_USER%"/> + + <!-- IMPORTANT: This needs to come before SuiteApkInstaller + + SuiteApkInstaller is not able to uninstall the Sdk-Provider.apk because the test + app that requires it is still installed at that point. This means the apk would + stay on the test device after the test ends. + + This preparer, during tear down, runs after SuiteApkInstaller and will finally + uninstall the provider, leaving the device in a clean state. + + See b/314294893 for more details. + --> + <target_preparer + class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> + <option name="teardown-command" + value="pm --user %TEST_USER% uninstall com.android.ctssdkprovider"/> + </target_preparer> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true"/> @@ -41,7 +59,6 @@ <option name="teardown-command" value="cmd sdk_sandbox set-state --reset" /> </target_preparer> - <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController" > <option name="mainline-module-package-name" value="com.google.android.adservices" /> diff --git a/sdksandbox/tests/cts/endtoendtests/DisabledAndroidTest.xml b/sdksandbox/tests/cts/endtoendtests/DisabledAndroidTest.xml index 98f3e93e3..9c266f849 100644 --- a/sdksandbox/tests/cts/endtoendtests/DisabledAndroidTest.xml +++ b/sdksandbox/tests/cts/endtoendtests/DisabledAndroidTest.xml @@ -20,6 +20,26 @@ <option name="config-descriptor:metadata" key="parameter" value="not_instant_app"/> <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi"/> <option name="config-descriptor:metadata" key="parameter" value="secondary_user"/> + + <option name="test-user-token" value="%TEST_USER%"/> + + <!-- IMPORTANT: This needs to come before SuiteApkInstaller + + SuiteApkInstaller is not able to uninstall the Sdk-Provider.apk because the test + app that requires it is still installed at that point. This means the apk would + stay on the test device after the test ends. + + This preparer, during tear down, runs after SuiteApkInstaller and will finally + uninstall the provider, leaving the device in a clean state. + + See b/314294893 for more details. + --> + <target_preparer + class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> + <option name="teardown-command" + value="pm --user %TEST_USER% uninstall com.android.ctssdkprovider"/> + </target_preparer> + <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true"/> <option name="test-file-name" value="SdkSandboxManagerCtsProvider.apk"/> @@ -37,7 +57,6 @@ <option name="teardown-command" value="cmd sdk_sandbox set-state --reset" /> </target_preparer> - <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController" > <option name="mainline-module-package-name" value="com.google.android.adservices" /> diff --git a/sdksandbox/tests/unittest/src/com/android/server/sdksandbox/SdkSandboxManagerServiceUnitTest.java b/sdksandbox/tests/unittest/src/com/android/server/sdksandbox/SdkSandboxManagerServiceUnitTest.java index 4a9d794dd..e9f80f3dd 100644 --- a/sdksandbox/tests/unittest/src/com/android/server/sdksandbox/SdkSandboxManagerServiceUnitTest.java +++ b/sdksandbox/tests/unittest/src/com/android/server/sdksandbox/SdkSandboxManagerServiceUnitTest.java @@ -2357,7 +2357,6 @@ public class SdkSandboxManagerServiceUnitTest { disableForegroundCheck(); sSdkSandboxSettingsListener.setKillSwitchState(true); - setDeviceConfigProperty(PROPERTY_DISABLE_SANDBOX, "true"); FakeLoadSdkCallbackBinder callback = new FakeLoadSdkCallbackBinder(); mService.loadSdk( TEST_PACKAGE, |