summaryrefslogtreecommitdiff
path: root/adservices/tests/cts/sandbox/measurement
diff options
context:
space:
mode:
Diffstat (limited to 'adservices/tests/cts/sandbox/measurement')
-rw-r--r--adservices/tests/cts/sandbox/measurement/Android.bp2
-rw-r--r--adservices/tests/cts/sandbox/measurement/AndroidTest.xml17
-rw-r--r--adservices/tests/cts/sandbox/measurement/src/com/android/tests/sandbox/measurement/SandboxedMeasurementManagerTest.java40
3 files changed, 48 insertions, 11 deletions
diff --git a/adservices/tests/cts/sandbox/measurement/Android.bp b/adservices/tests/cts/sandbox/measurement/Android.bp
index a6017ce0c5..a99c4688a2 100644
--- a/adservices/tests/cts/sandbox/measurement/Android.bp
+++ b/adservices/tests/cts/sandbox/measurement/Android.bp
@@ -37,7 +37,7 @@ android_test {
":SdkMeasurement",
],
min_sdk_version: "33",
- target_sdk_version: "current",
+ target_sdk_version: "33",
test_suites: [
"cts",
"mts-adservices",
diff --git a/adservices/tests/cts/sandbox/measurement/AndroidTest.xml b/adservices/tests/cts/sandbox/measurement/AndroidTest.xml
index 0d0c483d62..a1fcbd629e 100644
--- a/adservices/tests/cts/sandbox/measurement/AndroidTest.xml
+++ b/adservices/tests/cts/sandbox/measurement/AndroidTest.xml
@@ -31,6 +31,23 @@
<option name="package" value="com.android.tests.sandbox.measurement"/>
</test>
+ <target_preparer class="com.android.tradefed.targetprep.DeviceSetup" >
+ <option name="force-skip-system-props" value="true" />
+ <option name="disable-device-config-sync" value="true" />
+ </target_preparer>
+
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <!-- Disable global_kill_switch to ignore the effect of actual PH values. -->
+ <option name="run-command" value="device_config put adservices global_kill_switch false" />
+ <!-- Override Consent Manager to debug mode to grant user consent -->
+ <option name="run-command" value="setprop debug.adservices.consent_manager_debug_mode true" />
+ <!-- Disable SDK sandbox killswitch to ignore the effect of actual PH values. -->
+ <option name="run-command" value="cmd sdk_sandbox set-state --enabled" />
+
+ <option name="teardown-command" value="setprop debug.adservices.consent_manager_debug_mode false"/>
+ <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/adservices/tests/cts/sandbox/measurement/src/com/android/tests/sandbox/measurement/SandboxedMeasurementManagerTest.java b/adservices/tests/cts/sandbox/measurement/src/com/android/tests/sandbox/measurement/SandboxedMeasurementManagerTest.java
index 6b6f5adfbd..2c0dac3bd8 100644
--- a/adservices/tests/cts/sandbox/measurement/src/com/android/tests/sandbox/measurement/SandboxedMeasurementManagerTest.java
+++ b/adservices/tests/cts/sandbox/measurement/src/com/android/tests/sandbox/measurement/SandboxedMeasurementManagerTest.java
@@ -54,13 +54,12 @@ public class SandboxedMeasurementManagerTest {
// Start a foreground activity
SimpleActivity.startAndWaitForSimpleActivity(sContext, Duration.ofMillis(1000));
- // We need to turn the Consent Manager into debug mode to simulate grant Consent
- overrideConsentManagerDebugMode();
-
enforceMeasurementEnrollmentCheck(true);
// Allow sandbox package name to be able to execute Measurement APIs
allowSandboxPackageNameAccessMeasurementApis();
+
+ overrideMeasurementKillSwitches(true);
}
@After
@@ -69,7 +68,8 @@ public class SandboxedMeasurementManagerTest {
// Reset back the original values.
resetAllowSandboxPackageNameAccessMeasurementApis();
- resetOverrideConsentManagerDebugMode();
+
+ overrideMeasurementKillSwitches(false);
}
@Test
@@ -116,16 +116,36 @@ public class SandboxedMeasurementManagerTest {
"device_config put adservices web_context_client_allow_list " + sdkSbxName);
}
- private void overrideConsentManagerDebugMode() {
- ShellUtils.runShellCommand("setprop debug.adservices.consent_manager_debug_mode true");
- }
-
private void resetAllowSandboxPackageNameAccessMeasurementApis() {
ShellUtils.runShellCommand(
"device_config put adservices web_context_client_allow_list null");
}
- private void resetOverrideConsentManagerDebugMode() {
- ShellUtils.runShellCommand("setprop debug.adservices.consent_manager_debug_mode null");
+ // Override measurement related kill switch to ignore the effect of actual PH values.
+ // If isOverride = true, override measurement related kill switch to OFF to allow adservices
+ // If isOverride = false, override measurement related kill switch to meaningless value so that
+ // PhFlags will use the default value.
+ private void overrideMeasurementKillSwitches(boolean isOverride) {
+ String overrideString = isOverride ? "false" : "null";
+ ShellUtils.runShellCommand("setprop debug.adservices.global_kill_switch " + overrideString);
+ ShellUtils.runShellCommand(
+ "setprop debug.adservices.measurement_kill_switch " + overrideString);
+ ShellUtils.runShellCommand(
+ "setprop debug.adservices.measurement_api_register_source_kill_switch "
+ + overrideString);
+ ShellUtils.runShellCommand(
+ "setprop debug.adservices.measurement_api_register_trigger_kill_switch "
+ + overrideString);
+ ShellUtils.runShellCommand(
+ "setprop debug.adservices.measurement_api_register_web_source_kill_switch "
+ + overrideString);
+ ShellUtils.runShellCommand(
+ "setprop debug.adservices.measurement_api_register_web_trigger_kill_switch "
+ + overrideString);
+ ShellUtils.runShellCommand(
+ "setprop debug.adservices.measurement_api_delete_registrations_kill_switch "
+ + overrideString);
+ ShellUtils.runShellCommand(
+ "setprop debug.adservices.measurement_api_status_kill_switch " + overrideString);
}
}