-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.py
More file actions
26 lines (24 loc) · 1.12 KB
/
commands.py
File metadata and controls
26 lines (24 loc) · 1.12 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
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import android_scripts_python.library.main_functions as main_functions
from android_scripts_python.library.device_operations import display_selected_device, is_adb_device, is_fastboot_device, is_recovery_device
def main():
if len(sys.argv) < 2:
commands = input("Enter the command : ").strip()
else:
commands = " ".join(sys.argv[1:])
main_functions.get_device_choice()
display_selected_device(main_functions.deviceSerial)
if is_adb_device(main_functions.deviceSerial):
print(" Device is in 'adb' mode")
output = main_functions.adb_shell(main_functions.deviceSerial, *commands.split())
print(output)
elif is_fastboot_device(main_functions.deviceSerial) or is_recovery_device(main_functions.deviceSerial):
print(" Device is in 'fastboot' mode")
output = main_functions.fastboot_shell(main_functions.deviceSerial, *commands.split())
print(output)
else:
print(" Device is not in 'adb' mode or 'fastboot' mode")
if __name__ == "__main__":
main()