1# Copyright (C) 2025 The Android Open Source Project 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 15import logging 16from mobly import base_test 17from mobly import test_runner 18from mobly.controllers import android_device 19from utilities.main_utils import common_main 20 21class AndroidFastbootWipeTest(base_test.BaseTestClass): 22 23 def setup_class(self): 24 self.android_devices = self.register_controller(android_device) 25 26 def test_fastboot_wipe(self): 27 # Check that there is at least one device available. 28 if not self.android_devices: 29 raise AssertionError('No Android devices are registered. Please make ' 30 'sure at least one device is connected and ' 31 'configured properly.') 32 ad = self.android_devices[0] # Get the first device object. 33 34 # Reboot the device into fastboot mode using adb. 35 logging.info('Rebooting device into fastboot mode.') 36 ad.adb.reboot('bootloader') 37 38 # Wait for the device to enter fastboot mode. 39 ad.fastboot.wait_for_device() 40 41 # Wipe device using fastboot. 42 logging.info('Wiping device...') 43 ad.fastboot.wipe() 44 45 # Reboot the device after the wipe. 46 logging.info('Rebooting device...') 47 ad.fastboot.reboot() 48 49 # Wait for the device to complete its booting process. 50 ad.wait_for_boot_completion() 51 52 # Check the status of the device. 53 fingerprint = ad.adb.shell('getprop ro.build.fingerprint') 54 logging.info('Build fingerprint: %s', fingerprint) 55 if not fingerprint: 56 raise AssertionError('After wiping and rebooting, the build fingerprint could not be found.') 57 58 logging.info('Fastboot wipe test completed successfully.') 59 60 61if __name__ == '__main__': 62 common_main() 63