From 50b91849d5121ea4c6d3fc4d3d8a7430c6d2fe68 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 21 Feb 2022 15:25:31 +0100 Subject: [PATCH] add commandor --- commandor.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/commandor.py b/commandor.py index 1df0123..c87e7a4 100644 --- a/commandor.py +++ b/commandor.py @@ -1,7 +1,10 @@ import subprocess +from pojo.contact_pojo import ContactPojo + PACKAGE_NAME = "com.lpa.appointement" ACTIVITY_NAME = "MainActivity" +BROADCAST_ACTION = "com.lpa.appointement.broadcast" class Commandor: @@ -9,22 +12,26 @@ class Commandor: def __init__(self): pass - def reload_page(self): + def start_page(self, contact: ContactPojo): # specifying an explicit component name self.clear_app_data() - subprocess.call("adb shell am start -n {}/.{}".format(PACKAGE_NAME, ACTIVITY_NAME), shell=True) + + subprocess.call( + "adb shell am start -n {}/.{} --es \"first_name\" \"{}\" --es \"last_name\" \"{}\" --es \"phone\" \"{}\" --es \"email\" \"{}\" --es \"passport\" \"{}\"".format( + PACKAGE_NAME, ACTIVITY_NAME, contact.first_name, contact.last_name, contact.phone, contact.mail, contact.passport), shell=True) pass def clear_app_data(self): subprocess.call("adb shell pm clear {}".format(PACKAGE_NAME), shell=True) - def send_telephone_number(self): - pass - - def send_otp(self): + def send_otp(self, otp: str): + subprocess.call( + "adb shell am broadcast -a {} --es otp \"{}\"".format(BROADCAST_ACTION, otp), shell=True) pass if __name__ == '__main__': commandor = Commandor() - commandor.reload_page() + contact = ContactPojo("0608090706", "1234567890", "Willy", "Arnold", "AZEER", "test@test.fr") + commandor.start_page(contact) + # commandor.send_otp("12345")