Files
appointment_tool/commandor.py
T
2022-03-19 10:32:55 +01:00

61 lines
2.3 KiB
Python

import subprocess
import time
from pojo.contact_pojo import ContactPojo
PACKAGE_NAME = "com.opera.mini.android"
ACTIVITY_NAME = "MainActivity"
BROADCAST_ACTION = "com.lpa.appointement.broadcast"
class Commandor:
def __init__(self):
pass
def start_page(self, contact: ContactPojo):
# specifying an explicit component name
self.clear_app_data()
cmd = "/Users/panlei/Library/Android/sdk/platform-tools/adb shell am start -n {}/.{} --es \"first_name\" \"{}\" --es \"last_name\" \"{}\" --es \"phone\" \"{}\" --es \"email\" \"{}\" --es \"passport\" \"{}\"".format(
PACKAGE_NAME, ACTIVITY_NAME, contact.last_name, contact.first_name, "+33{}".format(contact.phone),
"{}_{}@gmail.com".format(contact.first_name, contact.last_name), contact.passport)
print("cmd is " + cmd)
subprocess.call(cmd, shell=True)
pass
def clear_app_data(self):
subprocess.call("/Users/panlei/Library/Android/sdk/platform-tools/adb shell pm clear {}".format(PACKAGE_NAME),
shell=True)
def send_otp(self, otp: str):
subprocess.call(
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a {} --es otp \"{}\"".format(
BROADCAST_ACTION, otp), shell=True)
pass
def reset_air_plan_mode(self):
subprocess.call(
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell settings put global airplane_mode_on 1",
shell=True)
time.sleep(1)
subprocess.call(
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a android.intent.action.AIRPLANE_MODE",
shell=True)
time.sleep(1)
subprocess.call(
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell settings put global airplane_mode_on 0",
shell=True)
time.sleep(1)
subprocess.call(
"/Users/panlei/Library/Android/sdk/platform-tools/adb shell am broadcast -a android.intent.action.AIRPLANE_MODE",
shell=True)
time.sleep(10)
if __name__ == '__main__':
commandor = Commandor()
# contact = ContactPojo("0649614591", "E24183897", "LIU", "Yusi", "AZEER", "lei-pan@outlook.com")
# commandor.start_page(contact)
commandor.reset_air_plan_mode()
# commandor.send_otp("262353")