def HeNS_Request_Message(self, boolean, heMS_SetParameterValues): # try: pyautogui.click(1000, 30) self.System_Operation_Data() self.Click_Serial_Number() # Click the Message Log # selenium.click( "link="+config_element.get("system", "system_message_log")) # Refresh the list content for refresh in range(2): selenium.click( "xpath="+config_element.get("system", "system_refresh_button")) # Select the HeMS detail message print 'Type the serial number.' self.Click_CheckBox() selenium.type("id="+config_element.get("detail_message", "search_askey_root"), config_element.get("detail_message", "input_askey_root")) time.sleep(3) selenium.click( "xpath="+config_element.get("detail_message", "search_button")) print "Select the key code" # Verify the SetParameterValues text can be get setParameterValues = selenium.get_text( "xpath="+config_element.get("detail_message", "parametervalues_text")) if setParameterValues == 'SetParameterValues': print 'Get the SetParameterValues text!!' else: print "Do not Get the SetParameterValues text!!" android = Android() android.Copy_Trace_Folder() raise Exception("Do not Get the SetParameterValues text!!") self.Autoit_Detail_Message(40) # Get the message from Get_clipboard message_log_detail_dialog = self.Get_Clipboard() # Verify the boolean value if '<Value xsi:type="boolean">' + boolean + '</Value>' in message_log_detail_dialog: print 'The boolean was matched - SUCCESS' elif '<Value xsi:type="boolean">' + 'true' + '</Value>' in message_log_detail_dialog: print 'The boolean was matched - SUCCESS' elif '<Value xsi:type="boolean">' + 'false' + '</Value>' in message_log_detail_dialog: print 'The boolean was matched - SUCCESS' else: print "The boolean was not matched - FAIL" android = Android() android.Copy_Trace_Folder() raise Exception("The boolean was not matched - FAIL") time.sleep(1) now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) heMS_SetParameterValues = heMS_SetParameterValues + '_' + now + '.txt' fp = open(heMS_SetParameterValues, "w") fp.write(message_log_detail_dialog) autoit.Sleep(1000) autoit.Send("!{F4}") print "Close the Detail page"
def test_Iperf_TCP_Na(self): rs232_putty = RS232_Putty() rs232_putty.RS232_Connect_Putty() os.system("adb shell am force-stop com.magicandroidapps.iperf") android = Android() adbClient = AdbClient() for i in range(1,int(config.get("setting","run_times"))+1): for j in range(1,int(config.get("iperf_setting", "times"))+1): self.Del_File("result.txt") iperf_command = "-s -i 5" # adbClient.Swiandroidh_Iperf() self.Mobile_Device_Connect() self.Killall_Iperf() adbClient.Service_Iperf_Start_N('iperf '+iperf_command) self.Iperf_Log_Clean() adbClient.Iperf_Client() adbClient.Getfile_Command_Iperf() os.system("adb shell input keyevent 4") android.Screen_Shot_Save("iperf_tcp_na") android.Mobile_Device_Disconnect() adbClient.Strip_Split_Iperf() adbClient.Move_File("Down_") adbClient.Split_Move_File("Down_split_")
def FTP_NA_Upload_S(self): android = Android() adbClient = AdbClient() print "NB Server & android Client (ftp upload)" adbClient.swiandroidh_FtpClient() android.mobile_device_connect() adbClient.download_over() android.ftp_creataccount() for i in range(0, int(times)): adbClient.ftplog_renew() android.ftp_connect() android.Verify_ftp_connect() android.folder_select("Upload") android.ftp_localfolder() adbClient.adb_event("123") adbClient.adb_event("123") android.folder_select("Upload") android.ftp_upload(filename) adbClient.Transfer_Status(filestart, fileend) adbClient.getfile_command() adbClient.Check_FileStatus() adbClient.adb_event("4") android.screen_shot_save("FTP_Upload") adbClient.FTP_Urate() adbClient.adb_event("66") adbClient.adb_event("66") adbClient.adb_event("111") adbClient.adb_event("111") adbClient.adb_event("111") android.mobile_device_disconnect()
def FTP_NA_Upload(self): android = Android() adbClient = AdbClient() times = "1" filename = "2.pdf" filestart = "/2.pdf" fileend = "62914560 bytes" print "NB Server & android Client (ftp upload)" adbClient.swiandroidh_FtpClient() adbClient.ftplog_renew() android.mobile_device_connect() adbClient.download_over() android.ftp_creataccount() android.ftp_connect() android.Verify_ftp_connect() android.folder_select("Upload") android.ftp_localfolder() adbClient.adb_event("123") adbClient.adb_event("123") android.folder_select("Upload") android.ftp_upload(filename) adbClient.Transfer_Status(filestart, fileend) adbClient.getfile_command() adbClient.Check_FileStatus() adbClient.adb_event("4") android.screen_shot_save("FTP_Upload") adbClient.FTP_Urate() android.mobile_device_disconnect()
def HeNB_Response_Message(self, status, heNB_SetParameterValuesResponse): try: pyautogui.click(1000, 30) self.System_Operation_Data() self.Click_Serial_Number() # Click the Message Log # selenium.click( "link="+config_element.get("system", "system_message_log")) # Select the HeNB detail message print 'Type the serial number.' self.Click_CheckBox() time.sleep(3) selenium.click( "xpath="+config_element.get("detail_message", "search_button")) print "Select the key code" # Verify the SetParameterValuesResponse text can be get setParameterValuesResponse = selenium.get_text( "xpath="+config_element.get("detail_message", "parametervalues_text")) if setParameterValuesResponse == 'SetParameterValuesResponse': print 'Get the SetParameterValuesResponse text!!' else: print "Do not Get the SetParameterValues text!!" android = Android() android.Copy_Trace_Folder() raise Exception("Do not Get the SetParameterValues text!!") self.Autoit_Detail_Message(40) # Get the message from Get_clipboard message_log_detail_dialog = self.Get_Clipboard() # Verify the status value if '<Status>' + status + '</Status>' in message_log_detail_dialog: print 'The status was matched - SUCCESS' else: print "The status was not matched - FAIL" android = Android() android.Copy_Trace_Folder() raise Exception("The status was not matched - FAIL") time.sleep(1) now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) heNB_SetParameterValuesResponse = heNB_SetParameterValuesResponse + '_' + now + '.txt' fp = open(heNB_SetParameterValuesResponse, "w") fp.write(message_log_detail_dialog) autoit.Sleep(1000) autoit.Send("!{F4}") print "Close the Detail page" except: raise Exception("The HeNB_Response_Message was not success - FAIL")
def Click_Device_Value0(self): time.sleep(80) if d(text=config_setting.get("setting", "PLMN")).exists: d(text=config_setting.get("setting", "PLMN")).click() android = Android() android.Copy_Trace_Folder() raise Exception("The device is clicked. - FAIL") else: print "The device is not clicked. - PASS"
def test_Ftp_Download_With_Handy(self): os.system("adb shell am force-stop com.ftpcafe") os.system("adb shell am force-stop com.anite.handy") android = Android() adbClient = AdbClient() run_times = config.get("setting", "run_times") times = config.get("ftp_setting", "times") filename = config.get("ftp_setting", "filename_handy") filestart = config.get("ftp_setting", "filename_handy") fileend = config.get("ftp_setting", "filename_handy_size") print "NB Server & android Client (ftp loop download)" for i in range(1, int(run_times) + 1): for j in range(1, int(times) + 1): self.Swiandroidh_FtpClient() self.Mobile_Device_Connect() # adbClient.Download_Over() # android.Ftp_Creat_Account() #*******************Download from 10.1.107.213***************** # print 'Donwload Times: ' + str(j) # self.Ftplog_Renew() # self.Ftp_Autoselect_Server('server') # self.Ftp_Connect() # self.Verify_Ftp_Connect() # self.Folder_Select("Downloads") # self.Ftp_Download(filename) #****************** Download from speed.hine.net*************** self.Ftp_Autoselect_Server('hinet') self.Ftp_Connect() self.Verify_Ftp_Connect() print 'Donwload Times: ' + str(j) time.sleep(10) self.Ftp_Download(filename) #*******************Handy function **************************** self.Swiandroidh_Handy() self.Mobile_Device_Connect() time.sleep(28) print "mobile_device_connect is success." time.sleep(1) self.Switch_Voice_Quality(j) self.Handy_Start_Script() time.sleep(1) self.Handy_Run_Script() print "Run script." time.sleep(112) self.Screen_Shot_Save("Volte") time.sleep(25) self.Handy_Keep_Log() time.sleep(5) self.Get_Handy_Folder() android.Mobile_Device_Disconnect() print "mobile_device_disconnect"
def ACS_Initiate_Connection(self): try: self.System_Operation_Data() self.Click_Serial_Number() time.sleep(2) selenium.click( "link="+config_element.get("system", "system_message_queue")) print "Click the message queue" for i in range(2): selenium.click( "xpath="+config_element.get("system", "system_refresh_button")) print "Click the refresh " + str(i+1) + " times" # Verify the SetParameterValues text can be get # time.sleep(1) # Wait the 1 sec for get the acs parametervalues text on 106/06/11 setParameterValues = selenium.get_text( "xpath="+config_element.get("detail_message", "acs_parametervalues_text")) if setParameterValues == 'SetParameterValues': print 'Get the SetParameterValues text!!' else: print "Do not Get the SetParameterValues text!!" android = Android() android.Copy_Trace_Folder() raise Exception("Do not Get the SetParameterValues text!!") self.Autoit_Tab_button(38, 200) autoit.Sleep(2000) autoit.Send("{ENTER}") print 'Click the ACS TCP Initiate Connection was finished' autoit.Sleep(2000) # IE 9 autoit.WinWaitActive( "[title:ACS Notify Page - Windows Internet Explorer]", "") autoit.ControlClick( "ACS Notify Page - Windows Internet Explorer", "", "ToolbarWindow321") self.Autoit_Tab_button(4, 100) autoit.Sleep(2000) autoit.Send("{ENTER}") autoit.Sleep(2000) delete_subfolder = Delete_Subfolder() delete_subfolder.Delete_Path_Subfolder("..\\..\\Result\\femtolog") adbClient = AdbClient() time.sleep(2) adbClient.Swiandroidh_ACS() autoit.WinClose("[class:IEFrame]") # Click the refresh button for i in range(1): selenium.click( "xpath="+config_element.get("system", "system_refresh_button")) print "Click the refresh " + str(i+1) + " times" autoit.Sleep(2000) print "Click the acs initiate connectin button" except: raise Exception("The ace initiate button was not click - FAIL")
def Speed_Test(self, filename): android = Android() adbClient = AdbClient() print "Speed_Test" # adbClient.Swiandroidh_Speedtest() android.Mobile_Device_Connect() time.sleep(2) android.Verify_Speed() time.sleep(40) android.Speed_Download() android.Speed_Upload() android.Screen_Shot_Save(filename) android.Mobile_Device_Disconnect()
def __init__(self, file_path): Svg.__init__(self) Writer.__init__(self) Magic.__init__(self) self.io_dir = os.path.dirname( os.path.dirname(os.path.abspath(file_path))) self.res_dir = os.path.join(self.io_dir, 'res') self.android = Android() self.file_path = file_path self.parse()
def iperf_AN(self): android = Android() adbClient = AdbClient() adbClient.swiandroidh_iperf() iperf_command = "-s -i -5" android.mobile_device_connect() android.service_iperf_start(iperf_command) android.iperf_log_clean() adbClient.client_iperf_start() adbClient.adb_event("4") android.screen_shot_save(iperf_command) android.mobile_device_disconnect() adbClient.move_file("Down_androidP_")
def __init__(self): threading.Thread.__init__(self) #self.pc = PC(tcp_ip="192.168.1.1") self.android = Android() self.arduino = Arduino() #self.pc.connect() self.android.connect() self.arduino.connect() time.sleep(1) self.interface = Interface(arduino=self.arduino, fakeRun=False, android=self.android)
def setUp(self): print 'Start by Automated execution.' global scp, ssh, rs232_putty global android, adbClient, uiautomator_control global reboot_command, customer_nl_local, customer_remote global plmn global boolean scp = SCP() ssh = SSH() rs232_putty = RS232_Putty() uiautomator_control = Uiautomator_Control() android = Android() adbClient = AdbClient() reboot_command = './rsys/scripts/reboot-fap' customer_nl_local = 'customer.nl' customer_remote = 'customer.rcS' plmn = "123-45"
def test_Ftp_Upload_Server(self): os.system("adb shell am force-stop com.ftpcafe") android = Android() adbClient = AdbClient() run_times = config.get("setting","run_times") times = config.get("ftp_setting","times") filename = config.get("ftp_setting", "filename_upload") filestart = config.get("ftp_setting", "filename_upload") fileend = config.get("ftp_setting", "filename_upload_size") print "NB Server & android Client (ftp loop upload)" adbClient.Swiandroidh_FtpClient() for i in range(1,int(run_times)+1): self.Mobile_Device_Connect() # adbClient.Download_Over() # android.Ftp_Creat_Account() for j in range(1,int(times)+1): print 'Upload Times: ' + str(i) self.Ftplog_Renew() self.Ftp_Autoselect_Server('server') self.Ftp_Connect() self.Verify_Ftp_Connect() self.Folder_Select("Uploads") self.Ftp_Localfolder() self.ADB_Event("123") self.ADB_Event("123") self.Folder_Select("Uploads") self.Ftp_Upload(filename) self.Transfer_Status(filestart,fileend) self.Getfile_Command() self.Check_File_Status() self.ADB_Event("4") self.Screen_Shot_Save("FTP_Upload") self.FTP_Urate() self.ADB_Event("66") self.ADB_Event("66") self.ADB_Event("111") self.ADB_Event("111") self.ADB_Event("111") self.mobile_device_disconnect() print "mobile_device_disconnect"
def test_Ftp_Download_Server(self): os.system("adb shell am force-stop com.ftpcafe") android = Android() adbClient = AdbClient() run_times = config.get("setting", "run_times") times = config.get("ftp_setting", "times") filename = config.get("ftp_setting", "filename_download") filestart = config.get("ftp_setting", "filename_download") fileend = config.get("ftp_setting", "filename_download_size") print "NB Server & android Client (ftp loop download)" self.Swiandroidh_FtpClient() for i in range(1, int(run_times) + 1): android.Mobile_Device_Connect() # self.Download_Over() # self.Ftp_Creat_Account() for j in range(1, int(times) + 1): print 'Donwload Times: ' + str(j) self.Ftplog_Renew() self.Ftp_Autoselect_Server('server') self.Ftp_Connect() self.Verify_Ftp_Connect() self.Folder_Select("Downloads") self.Ftp_Download(filename) print "The filename is " + filename self.Del_File("..\..\\Result\\log\\vsftpd.log") self.Transfer_Status(filestart, fileend) self.Getfile_Command() self.Check_File_Status() self.ADB_Event("4") self.Screen_Shot_Save("FTP_Download") self.FTP_Drate() self.ADB_Event("66") self.ADB_Event("66") self.ADB_Event("111") self.ADB_Event("111") self.ADB_Event("111") self.Mobile_Device_Disconnect() print "mobile_device_disconnect"
def start_script_proxy(toast_message=START_MESSAGE, server_wait=1.0, retries=10): adb = lambda cmd, ADB=ADB: sh("%s %s"%(ADB, cmd)) # Start TCP forwarding adb("forward tcp:%i tcp:%i"%(HOST_PORT, REMOTE_PORT)) proxy = Android(addr=(None, HOST_PORT)) start_message = lambda: proxy.makeToast(toast_message) try: # Try if we are already connected SL4A will start the server with # a random port if it's already running regardless of the # USE_SERVICE_PORT parameter start_message() return proxy # We seem to be connected except socket.error, e: # Try to start the server adb("shell am start " "-a com.googlecode.android_scripting.action.LAUNCH_SERVER " "-n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher " "--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT %i"%SL4A_PORT)
def FTP_NA_Download(self): android = Android() adbClient = AdbClient() filename = "1.pdf" filestart = "/1.pdf" fileend = "104857600 bytes" print "NB Server & android Client (ftp download)" adbClient.swiandroidh_FtpClient() adbClient.ftplog_renew() android.mobile_device_connect() adbClient.download_over() android.ftp_creataccount() android.ftp_connect() android.Verify_ftp_connect() android.folder_select("Download") android.ftp_download(filename) adbClient.Transfer_Status(filestart, fileend) adbClient.getfile_command() adbClient.Check_FileStatus() adbClient.adb_event("4") android.screen_shot_save("FTP_Download") adbClient.FTP_Drate() android.mobile_device_disconnect()
def Click_Device_Value1(self, device): for search_times in range( int(config_setting.get("search_times", "times"))): time.sleep(1) self.Switch_Back() time.sleep(1) print 'The Research times : ' + str(search_times + 1) self.Switch_Network_Operators() # Judgment the PLMN number by nexus or note4 plmn = config_setting.get("setting", "PLMN") merge_plmn = plmn.split(" ")[0] + plmn.split(" ")[1] if device == 'nexus': print 'The device is nexus.' time.sleep(180) if d(text=plmn).exists: print 'nexus' d(text=plmn).click() break if device == 'note4': print 'The device is note4.' self.Information_Alert() # time.sleep(95) time.sleep(180) if d(text=merge_plmn).exists: print 'note4' d(text=merge_plmn).click() break if search_times + 1 == int( config_setting.get("search_times", "times")): android = Android() android.Copy_Trace_Folder() raise Exception("The device is not clicked. - FAIL") print "The device is clicked. - PASS"
def flash_images(self, images): fimgs = list() avb = None for image in images: if image == 'fw': self.flash_firmware('{path}/{fw}'.format(path=self._flashfiles, fw=self._fw)) elif image == 'ioc': self.flash_ioc('{path}/{fw}'.format(path=self._flashfiles, fw=self._ioc)) else: # avb make images. d.info('update %s image' % image) if avb == None: avb = AvbImage() avb.avb_make_image(image, self) fimgs.append(image) # flash images. if len(fimgs) != 0: fimgs.append('vbmeta') # setup flash env ad = Android() #ad.adb_wait() # enter bootloader mode. ad.run_cmd_handler(['rebootloader']) # unlock ad.run_cmd_handler(['deviceunlock']) # flash image now for image in fimgs: fimage = r'{}/{}.img'.format(self._flashfiles, image) d.info('fastboot flash {} {}'.format(image, fimage)) ad.flash_image(image, fimage) # lock device. ad.run_cmd_handler(['devicelock']) # reboot ad.run_cmd_handler(['fastreboot'])
def test_Iperf_TCP_An(self): rs232_putty = RS232_Putty() rs232_putty.RS232_Connect_Putty() os.system("adb shell am force-stop com.magicandroidapps.iperf") android = Android() adbClient = AdbClient() for i in range(1, int(config.get("setting", "run_times")) + 1): for j in range(1, int(config.get("iperf_setting", "times")) + 1): adbClient.Del_File("result.txt") iperf_command = "-s -i 5" time.sleep(2) # adbClient.Swiandroidh_Iperf() android.Mobile_Device_Connect() android.Service_Iperf_Start(iperf_command) android.Iperf_Log_Clean() adbClient.Get_Android_IP() adbClient.Client_Iperf_Start() android.Screen_Shot_Save("iperf_tcp_an") android.Mobile_Device_Disconnect() adbClient.Strip_Split_Iperf() adbClient.Move_File("Up_") adbClient.Split_Move_File("Up_split_")
def reset(context): context.my_android = Android() context.my_android.reset()
#-*-coding:utf8;-*- #qpy:3 #qpy:console from android import Android droid = Android() #set droid.toggleBluetoothState(1) #toggle #droid.toggleBluetoothState()
def compile(c): global project_dir global builder global android global config global template_dir global jar_dir global restore_performed global classpath_separator print "[DEBUG] AMP : %s" % c config = c if config['platform'] == 'android': from android import Android from compiler import Compiler # Initialize variables project_dir = config['project_dir'] template_dir = config['template_dir'] jar_dir = project_dir + "/plugins/com.soasta.android.boomerang/lib/" # Initialize the restore_performed value to be False restore_performed = False # Initialize classpath builder = config['android_builder'] android = Android(builder.name, builder.app_id, builder.sdk, 'test', builder.java) full_resource_dir = os.path.join( builder.project_dir, builder.project_dir + "/bin/assets/Resources") compiler = Compiler(config['tiapp'], full_resource_dir, builder.java, project_dir + "/bin/Classes", builder.project_gen_dir, project_dir, include_all_modules=True) classpath = os.pathsep.join([ builder.sdk.get_android_jar(), os.pathsep.join(compiler.jar_libraries) ]) # Classpath separator on Windows is a semi-colon instead of a colon classpath_separator = ":" if (os.name == 'nt'): classpath_separator = ";" classpath = classpath + classpath_separator + jar_dir + "aspectjrt.jar" classpath = classpath + classpath_separator + jar_dir + "aspectjtools.jar" print "[INFO] AMP : Installing Boomerang for Android" print "[DEBUG] AMP : Preparing libraries" print "[DEBUG] AMP : Using classpath %s" % classpath createBackup("titanium") createBackup("modules/titanium-ui") step = 0 try: step = 1 instrument(classpath, "titanium") step = 2 instrument(classpath, "modules/titanium-ui") step = 3 merge() print "[INFO] AMP : Boomerang for Android installed" except: print "[ERROR] AMP : Unexpected error:", sys.exc_info( )[0], sys.exc_info()[1], sys.exc_info()[2], "- step ", str(step) print "[ERROR] AMP : Exception occurred. Restoring Titanium jar files." restore("titanium") restore("modules/titanium-ui") print "[ERROR] AMP : Boomerang was not installed."
from phone import Phone from iphone import IPhone from android import Android moms_number = "888-3434" old_phone = Phone("555-1314") iphone = IPhone("555-0001") android = Android("555-1337") # All phones have the call method defined in Phone old_phone.call(moms_number) iphone.call(moms_number) android.call(moms_number) print("\n") # All phones have the text method defined in Phone old_phone.text(moms_number, "Hey Mom. I want a new phone.") iphone.text(moms_number, "Thanks for the iPhone, Mom!") android.text(moms_number, "Mom, I saved up and bought an Android.") print("\n") # made up strings representing "fingerprints" my_fingerprint = "swirl whorl whorl" other_fingerprint = "spiral whorl swirl" # the iphone has access to it's own unlock and set_fingerprint methods. iphone.unlock() iphone.set_fingerprint(my_fingerprint) iphone.unlock(other_fingerprint) iphone.unlock(my_fingerprint)
def test_Earfcn(self): android = Android() android.Check_Mobile_Note4() rs232 = RS232_Putty() rs232.RS232_Connect_Putty() heMS_SetParameterValues = config_element.get( "location", "heMS_SetParameterValues") print 'Earfcn\'s testcase...' for cycle_times in range( int(config_setting.get("cycle_times", "times"))): print 'The Cycle times : ' + str(cycle_times + 1) earfcn = config_setting.get("setting", "earfcn") frequency = config.get("cellmapper_setting", "frequency") # Click the EarfcnDL and EarfcnFL via RF folder for runtime in range(int(config.get("earfcn_setting", "times"))): os.system("taskkill /F /IM iexplore.exe") print 'The Run Times : ' + str(runtime + 1) print 'Earfcn of ACS : ' + earfcn + ' Frequence of mobile : ' + frequency # Open the airplane mode adbClient = AdbClient() adbClient.Start_Airplane() # Open the acs website homepage webcontrol = Webcontrol() webcontrol.Initial() webcontrol.Login() webcontrol.Clear_All_Data( config_element.get("system", "system_message_queue"), config_element.get("delete_file", "delete_all_message_queue_button"), "Delete Message successfully!") webcontrol.Parameter_List_Earfcn(earfcn) webcontrol.ACS_Initiate_Connection() webcontrol.HeNS_Request_Message_Earfcn( earfcn, heMS_SetParameterValues) webcontrol.Security_Logout() time.sleep(1) webcontrol.Exit() tc = Uiautomator_Control() tc.Switch_Home() # Reboot the cell rs232 = RS232_Putty() rs232.RS232_Connect_Putty() time.sleep(2) ssh = SSH() ssh.SSH_Command('./rsys/scripts/reboot-fap') time.sleep(150) rs232.RS232_Verify_Message_Putty('Time :') # Close the airplane mode adbClient.Stop_Airplane() # Make sure the cell is launched or not by *#0011# tc.Switch_Home() tc.Switch_Setting_Note4() tc.Switch_More_networks() tc.Switch_Mobile_networks() tc.Switch_Network_Operators() tc.Information_Alert() tc.Click_Device_Value1('note4') tc.Information_Alert() time.sleep(10) tc.Switch_Home() tc.CellMapper() tc.ServiceMode(frequency) earfcn = "38750" frequency = "38750" print '\nThe Cycle time is : ' + config_setting.get( "cycle_times", "times") + ' times.\nFinished.'
def compile(c): global project_dir global sdk_dir global deploy_type global builder global android global config global template_dir global jar_dir global restore_performed global classpath_separator global moduleAvailable global touchtest_module_dir_created print "[DEBUG] TouchTest : %s" % c config = c # This Plugin is only for the Android platform. if config['platform'] != 'android': return moduleAvailable = isAndroidModuleEnabled( config['tiapp'].properties['modules'], config['deploy_type']) touchtest_module_dir_created = [] if moduleAvailable: from android import Android from compiler import Compiler # Initialize variables project_dir = config['project_dir'] sdk_dir = config['titanium_dir'] deploy_type = config['deploy_type'] template_dir = config['template_dir'] jar_dir = project_dir + "/plugins/com.soasta.touchtest.android/lib/" # Initialize the restore_performed value to be False restore_performed = False # Initialize classpath builder = config['android_builder'] android = Android(builder.name, builder.app_id, builder.sdk, 'test', builder.java) full_resource_dir = os.path.join( builder.project_dir, builder.project_dir + "/bin/assets/Resources") compiler = Compiler(config['tiapp'], full_resource_dir, builder.java, project_dir + "/bin/Classes", builder.project_gen_dir, project_dir, include_all_modules=True) classpath = os.pathsep.join([ builder.sdk.get_android_jar(), os.pathsep.join(compiler.jar_libraries) ]) # Classpath separator on Windows is a semi-colon instead of a colon classpath_separator = ":" if (os.name == 'nt'): classpath_separator = ";" module_jars = findAndroidModuleJars( config['tiapp'].properties['modules']) classpath = classpath + classpath_separator + jar_dir + "aspectjrt.jar" classpath = classpath + classpath_separator + jar_dir + "aspectjtools.jar" for module_jar in module_jars: print "[INFO] TouchTest : Will also process %s" % module_jar classpath = classpath + classpath_separator + module_jar print "[INFO] TouchTest : Installing TouchTest Driver for Android" print "[DEBUG] TouchTest : Preparing libraries" print "[DEBUG] TouchTest : Using classpath %s" % classpath createBackup("titanium") createBackup("modules/titanium-ui") step = 0 try: step = 1 instrument(classpath, "titanium") step = 2 instrument(classpath, "modules/titanium-ui") step = 3 for module_jar in module_jars: instrumentExternalJars(classpath, module_jar) merge() print "[INFO] TouchTest : TouchTest Driver for Android installed" except: print "[ERROR] TouchTest : Unexpected error:", sys.exc_info( )[0], sys.exc_info()[1], sys.exc_info()[2], "- step ", str(step) print "[ERROR] TouchTest : Exception occured. Restoring Titanium jar files." restore("titanium") restore("modules/titanium-ui") print "[ERROR] TouchTest : TouchTest Driver was not installed."
try: # Try if we are already connected SL4A will start the server with # a random port if it's already running regardless of the # USE_SERVICE_PORT parameter start_message() return proxy # We seem to be connected except socket.error, e: # Try to start the server adb("shell am start " "-a com.googlecode.android_scripting.action.LAUNCH_SERVER " "-n com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher " "--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT %i"%SL4A_PORT) # :TODO: Get rid of the hacky asynchronous SL4A startup for i in range(retries): proxy = Android(addr=(None, HOST_PORT)) try: start_message() break # We seem to be connected except socket.error, e: log.debug("SL4A retry: "+str(e)) time.sleep(server_wait) else: raise IOError("Unable to start SL4A server") return proxy logging.basicConfig(level=logging.DEBUG)
def test_PLMN(self): rs232 = RS232_Putty() rs232.RS232_Connect_Putty() android = Android() android.Check_Mobile_Note4() heMS_SetParameterValues = config_element.get( "location", "heMS_SetParameterValues") heNB_SetParameterValuesResponse = config_element.get( "location", "heNB_SetParameterValuesResponse") print 'PLMN\'s testcase...' for cycle_times in range( int(config_setting.get("cycle_times", "times"))): print 'The Cycle times : ' + str(cycle_times + 1) plmn = config_setting.get("setting", "PLMN") merge_plmn = plmn.split(" ")[0] + plmn.split(" ")[1] cellmapper_plmn = config.get("cellmapper_setting", "PLMN") # Click the PLMNID via PLMNList folder for runtime in range(int(config.get("plmn_setting", "times"))): status = config_setting.get("setting", "status") os.system("taskkill /F /IM iexplore.exe") print 'The Run Times : ' + str(runtime + 1) print 'PLMN of ACS : ' + merge_plmn + ' Frequence of mobile : ' + cellmapper_plmn # Open the airplane mode adbClient = AdbClient() adbClient.Start_Airplane() # Open the acs website homepage webcontrol = Webcontrol() webcontrol.Initial() webcontrol.Login() webcontrol.Clear_All_Data( config_element.get("system", "system_message_queue"), config_element.get("delete_file", "delete_all_message_queue_button"), "Delete Message successfully!") # Set the boolean to false webcontrol.Parameter_List_PLMN( config_element.get("PLMN", "enable_checkbox"), config_element.get("PLMN", "enable_value"), status) webcontrol.ACS_Initiate_Connection() webcontrol.HeNS_Request_Message_PLMN(status, heMS_SetParameterValues) webcontrol.HeNB_Response_Message( status, heNB_SetParameterValuesResponse) # Set the plmnid webcontrol.Parameter_List_PLMN( config_element.get("PLMN", "plmnid_checkbox"), config_element.get("PLMN", "plmnid_value"), merge_plmn) webcontrol.ACS_Initiate_Connection() webcontrol.HeNS_Request_Message_PLMN(merge_plmn, heMS_SetParameterValues) webcontrol.HeNB_Response_Message( status, heNB_SetParameterValuesResponse) # Set the boolean to true webcontrol.Parameter_List_PLMN( config_element.get("PLMN", "enable_checkbox"), config_element.get("PLMN", "enable_value"), str(int(status) + 1)) webcontrol.ACS_Initiate_Connection() webcontrol.HeNS_Request_Message_PLMN(str(int(status) + 1), heMS_SetParameterValues) webcontrol.HeNB_Response_Message( status, heNB_SetParameterValuesResponse) webcontrol.Security_Logout() time.sleep(1) webcontrol.Exit() tc = Uiautomator_Control() tc.Switch_Home() # Reboot the cell rs232 = RS232_Putty() rs232.RS232_Connect_Putty() time.sleep(2) ssh = SSH() ssh.SSH_Command('./rsys/scripts/reboot-fap') time.sleep(150) rs232.RS232_Verify_Message_Putty('Time :') # Close the airplane mode adbClient.Stop_Airplane() # Make sure the cell is launched or not by *#0011# tc.Switch_Home() tc.Switch_Setting_Note4() tc.Switch_More_networks() tc.Switch_Mobile_networks() tc.Switch_Network_Operators() tc.Information_Alert() tc.Click_Device_Value1('note4') tc.Information_Alert() time.sleep(10) tc.Switch_Home() tc.CellMapper() tc.ServiceMode_Verify_PLMN(cellmapper_plmn) merge_plmn = "12301" cellmapper_plmn = "123-01" print '\nThe Cycle time is : ' + config_setting.get( "cycle_times", "times") + ' times.\nFinished.'
from android import Android import subprocess import datetime import time limit = 90 a = Android() print("starting monitor funcs") a.batteryStartMonitoring() time.sleep(1) print("monitoring engaged, waiting for battery level to be full") while not a.batteryGetStatus().result == 5: time.sleep(0.5) print("battery full, unplug now") while a.batteryGetStatus().result == 5: time.sleep(0.1) print(subprocess.check_output(["dumpsys", "batterystats", "--reset"])) print("Time: " + str(datetime.datetime.now())) print("Battery level: " + str(a.batteryGetLevel().result)) counter = 1 while a.batteryGetLevel().result > limit: time.sleep(1) counter = counter + 1 if (counter > 10): counter = 0 with open("/sdcard/voltages.txt", "a") as file:
# # main page! # from android import Android from world import World from command import * world = World() me = Android('2B') command(me, world)