Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

Commit 8490e1f

Browse files
Privacy Sandbox Teamsemyers
authored andcommitted
No public description
PiperOrigin-RevId: 736543788 Change-Id: I8d84f316735fb27766fa176a05c105b70cd15826
1 parent 4f47754 commit 8490e1f

4 files changed

Lines changed: 100 additions & 5 deletions

File tree

adservices_cli/adservices.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class AdServices:
3030
"""Privacy Sandbox for Android CLI (http://g.co/privacysandbox)."""
3131

3232
_ADSERVICES_SYSTEM_PROPERTIES_NAMESPACE = "debug.adservices"
33-
_ADSERVICES_DEVICE_CONFIG_NAMESPACE = "adservices"
3433
_ADSERVICES_PACKAGE = "com.google.android.adservices"
3534
_ADSERVICES_DOCS_URL = (
3635
"https://developer.android.com/design-for-safety/privacy-sandbox"
@@ -263,6 +262,11 @@ def _set_service_enabled(
263262
else:
264263
self._enable_feature(feature_name, flag_value)
265264

265+
if feature_name in flag_constants.FEATURES_WITH_DISABLED_JS_CACHING:
266+
self._put_adservices_device_config(
267+
flag_constants.ENABLE_HTTP_CACHE_JS_CACHING, kill_switch_value
268+
)
269+
266270
if feature_name == flag_constants.ON_DEVICE_AUCTION_V3:
267271
bidding_logic_js_version = "3" if enabled else "2"
268272
self._put_adservices_device_config(
@@ -293,12 +297,12 @@ def _get_ad_services_version(self) -> int:
293297

294298
def _get_adservices_device_config(self, key: str, silent: bool = True) -> str:
295299
return self.adb.get_device_config(
296-
self._ADSERVICES_DEVICE_CONFIG_NAMESPACE, key, silent
300+
constants.ADSERVICES_DEVICE_CONFIG_NAMESPACE, key, silent
297301
)
298302

299303
def _put_adservices_device_config(self, key: str, value: str):
300304
self.adb.put_device_config(
301-
self._ADSERVICES_DEVICE_CONFIG_NAMESPACE, key, value, silent=False
305+
constants.ADSERVICES_DEVICE_CONFIG_NAMESPACE, key, value, silent=False
302306
)
303307

304308
def _get_adservices_sys_prop(self, key: str, silent: bool = True) -> str:

adservices_cli/adservices_test.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from unittest import mock
16+
17+
from absl.testing import absltest
18+
from absl.testing import parameterized
19+
20+
import adb
21+
import adservices
22+
import constants
23+
import flag_constants
24+
25+
26+
class AdServicesTest(parameterized.TestCase):
27+
28+
def setUp(self):
29+
super().setUp()
30+
self.adb = mock.create_autospec(adb.AdbClient)
31+
self.adservices = adservices.AdServices(self.adb)
32+
self.adb.get_sdk_version.return_value = 33
33+
34+
@parameterized.named_parameters(
35+
{
36+
'testcase_name': 'all_enabled',
37+
'feature_name': flag_constants.FEATURE_ALL,
38+
'feature_enabled': True,
39+
'js_cache_enabled': 'false',
40+
},
41+
{
42+
'testcase_name': 'on_device_auction_enabled',
43+
'feature_name': flag_constants.ON_DEVICE_AUCTION,
44+
'feature_enabled': True,
45+
'js_cache_enabled': 'false',
46+
},
47+
{
48+
'testcase_name': 'on_device_auction_v3_enabled',
49+
'feature_name': flag_constants.ON_DEVICE_AUCTION_V3,
50+
'feature_enabled': True,
51+
'js_cache_enabled': 'false',
52+
},
53+
{
54+
'testcase_name': 'all_disabled',
55+
'feature_name': flag_constants.FEATURE_ALL,
56+
'feature_enabled': False,
57+
'js_cache_enabled': 'true',
58+
},
59+
{
60+
'testcase_name': 'on_device_auction_disabled',
61+
'feature_name': flag_constants.ON_DEVICE_AUCTION,
62+
'feature_enabled': False,
63+
'js_cache_enabled': 'true',
64+
},
65+
{
66+
'testcase_name': 'on_device_auction_v3_disabled',
67+
'feature_name': flag_constants.ON_DEVICE_AUCTION_V3,
68+
'feature_enabled': False,
69+
'js_cache_enabled': 'true',
70+
},
71+
)
72+
def test_set_service_enabled_sets_js_cache(
73+
self, feature_name, feature_enabled, js_cache_enabled
74+
):
75+
self.adservices._set_service_enabled(feature_enabled, feature_name)
76+
77+
self.adb.put_device_config.assert_any_call(
78+
constants.ADSERVICES_DEVICE_CONFIG_NAMESPACE,
79+
flag_constants.ENABLE_HTTP_CACHE_JS_CACHING,
80+
js_cache_enabled,
81+
silent=False,
82+
)
83+
84+
85+
if __name__ == '__main__':
86+
absltest.main()

adservices_cli/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
"""Adservices common constants."""
1616

1717
ADSERVICES_API_PACKAGE = "com.google.android.adservices.api"
18+
ADSERVICES_DEVICE_CONFIG_NAMESPACE = "adservices"

adservices_cli/flag_constants.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
KANON,
5050
ON_DEVICE_AUCTION_V3,
5151
]
52+
FEATURES_WITH_DISABLED_JS_CACHING = [
53+
FEATURE_ALL,
54+
ON_DEVICE_AUCTION,
55+
ON_DEVICE_AUCTION_V3,
56+
]
5257
## AdServices feature flags
5358
### AdServices
5459
_ENABLE_ADSERVICES_SYSTEM_SERVICE = "adservice_system_service_enabled"
@@ -76,6 +81,7 @@
7681

7782
### On Device Auction
7883
AD_SELECTION_BIDDING_LOGIC_V3 = "fledge_ad_selection_bidding_logic_js_version"
84+
ENABLE_HTTP_CACHE_JS_CACHING = "fledge_http_cache_enable_js_caching"
7985
_ENABLE_AD_SELECTION_PREBUILT_URI = (
8086
"fledge_ad_selection_ad_selection_prebuilt_uri_enabled"
8187
)
@@ -86,13 +92,11 @@
8692
"fledge_event_level_debug_report_send_immediately"
8793
)
8894
_ENABLE_CONTEXTUAL_ADS_FILTER = "fledge_ad_selection_contextual_ads_enabled"
89-
_ENABLE_HTTP_CACHE_ENABLE_JS_CACHING = "fledge_http_cache_enable_js_caching"
9095
ENABLE_ALL_ON_DEVICE_AD_SELECTION_FLAGS = [
9196
_ENABLE_AD_SELECTION_PREBUILT_URI,
9297
_ENABLE_EVENT_LEVEL_DEBUG_REPORTING,
9398
_ENABLE_EVENT_LEVEL_DEBUG_REPORT_SEND_IMMEDIATELY,
9499
_ENABLE_CONTEXTUAL_ADS_FILTER,
95-
_ENABLE_HTTP_CACHE_ENABLE_JS_CACHING,
96100
]
97101

98102
### Server auctions

0 commit comments

Comments
 (0)