diff --git a/src/clusterfuzz/_internal/platforms/android/wifi.py b/src/clusterfuzz/_internal/platforms/android/wifi.py index 2082bdbc7c..1c0e4f585d 100644 --- a/src/clusterfuzz/_internal/platforms/android/wifi.py +++ b/src/clusterfuzz/_internal/platforms/android/wifi.py @@ -49,6 +49,10 @@ def disable_airplane_mode(): def configure(force_enable=False): """Configure airplane mode and wifi on device.""" + # Short-circuit: UWORKERs do not have Datastore access for Wi-Fi credentials. + if environment.is_uworker(): + return + # Airplane mode should be disabled in all cases. This can get inadvertently # turned on via gestures. disable_airplane_mode() diff --git a/src/clusterfuzz/_internal/tests/core/platforms/android/wifi_test.py b/src/clusterfuzz/_internal/tests/core/platforms/android/wifi_test.py new file mode 100644 index 0000000000..e1a0259772 --- /dev/null +++ b/src/clusterfuzz/_internal/tests/core/platforms/android/wifi_test.py @@ -0,0 +1,40 @@ +# Copyright 2026 Google LLC +# +# 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. +"""Tests for wifi functions.""" + +import unittest + +from clusterfuzz._internal.platforms.android import wifi +from clusterfuzz._internal.tests.test_libs import helpers + + +class ConfigureTest(unittest.TestCase): + """Tests for wifi.configure.""" + + def setUp(self): + helpers.patch(self, [ + 'clusterfuzz._internal.system.environment.is_uworker', + 'clusterfuzz._internal.platforms.android.wifi.disable_airplane_mode', + 'clusterfuzz._internal.config.db_config.get', + ]) + + def test_uworker_bypass(self): + """Test that uworker environment skips wifi setup.""" + self.mock.is_uworker.return_value = True + + wifi.configure() + + # Ensure none of the subsequent functions that crash/hit Datastore are called. + self.mock.disable_airplane_mode.assert_not_called() + self.mock.get.assert_not_called()