-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwipe_device.py
More file actions
38 lines (33 loc) · 1.46 KB
/
wipe_device.py
File metadata and controls
38 lines (33 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
import time
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from android_scripts_python.library import main_functions
from android_scripts_python.library.device_operations import display_selected_device, is_adb_device, is_fastboot_device
def main():
if len(sys.argv) < 2:
main_functions.get_device_choice()
else:
main_functions.build_device_sn_array()
main_functions.deviceSerial = sys.argv[1]
display_selected_device(main_functions.deviceSerial)
if is_adb_device(main_functions.deviceSerial):
print(" Wait for device to reboot in bootloader...", end="")
proc = main_functions.adb_shell(main_functions.deviceSerial, "reboot", "bootloader")
print(" Done")
time.sleep(7)
main_functions.build_device_sn_array()
if is_fastboot_device(main_functions.deviceSerial):
print("\n Wait for the device to complete wipe data and reboot...")
main_functions.fastboot_shell(main_functions.deviceSerial, "-w")
time.sleep(2)
main_functions.fastboot_shell(main_functions.deviceSerial, "reboot-bootloader")
time.sleep(2)
main_functions.fastboot_shell(main_functions.deviceSerial, "reboot")
print(" ")
elif is_adb_device(main_functions.deviceSerial):
print("\n Device is not in Fastboot mode\n")
else:
print("\n Unable to determine the device state \n")
if __name__ == "__main__":
main()