-
Notifications
You must be signed in to change notification settings - Fork 1
/
xiaomi_adb.py
111 lines (82 loc) · 2.94 KB
/
xiaomi_adb.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from adb_functions import AdbFunctions
import os
def usage():
print("")
print("")
print("Xiaomi ADB for MiRecovery")
print("by TwizzyIndy")
print("10/2018")
print("")
print("usage : python xiaomi_adb.py [arguments] ")
print("")
print(" -fd : format data ")
print(" -fs : format storage")
print(" -fds : format data and storage")
print(" -wds : wipe data and storage")
print(" -r : reboot")
print(" -redl : reboot to edl")
print(" -rrec : reboot to recovery")
print(" -rbl : reboot to bootlaoder")
print(" -info : get device infos")
print(" -shut : shutdown")
print(" -clearefs: wipe efs")
print(" -mtp_on : mtp mode on")
print(" -mtp_off : mtp mode off")
print(" -getdump : get dump")
print(" -mtp_install_apk : install apk from mtp enabled recovery mode")
print("")
return
def sendAdbCommand(cmd):
adb = AdbFunctions()
adb_devices = adb.devices()
if not adb_devices:
print("no devices found")
if cmd == '-r':
print(adb.command('reboot:'))
elif cmd == '-rrec':
print(adb.command('reboot:recovery'))
elif cmd == '-redl':
print(adb.command('reboot:edl'))
elif cmd == '-rbl':
print(adb.command('reboot:bootloader'))
elif cmd == '-shut':
print(adb.command('shutdown:'))
elif cmd == '-info':
print("")
print("Device : " + str(adb.queryCommand('getdevice:')))
print("Version: " + str(adb.queryCommand('getversion:')))
print("Codebase: " + str(adb.queryCommand('getcodebase:')))
print("Region: " + str(adb.queryCommand('getregion:')))
print("Branch: " + str(adb.queryCommand('getbranch:')))
print("Language: "+ str(adb.queryCommand('getlanguage:')))
print("Serial: " + str(adb.queryCommand('getsn:')))
print("RomZone: " + str(adb.queryCommand('getromzone:')))
print("RecoveryVersion: " + str(adb.queryCommand('getrecoveryversion:')))
elif cmd == '-fd':
print( adb.command('format-data:'))
elif cmd == '-fs':
print( adb.command('format-storage:'))
elif cmd == '-fds':
print( adb.command('format-data-storage:'))
elif cmd == '-wds':
print( adb.command('wipe-data-storage:'))
elif cmd == '-clearefs':
print( adb.command('wipe-efs:'))
elif cmd == '-mtp_on': # need to test query or command type
print( adb.command('enablemtp:'))
elif cmd == '-mtp_off':
print( adb.command('disablemtp:'))
elif cmd == '-getdump':
print( adb.command('getminidump'))
else:
usage()
return
def main():
if( len(os.sys.argv) < 2 ):
usage()
return
arg = os.sys.argv[1]
sendAdbCommand(arg)
return
if __name__ == "__main__":
main()