def start_service(self, app_name): if platform == "android" and app_name in self.plugins_list: # Clean up old logs self.log_name = os.path.join( main_utils.get_mobileinsight_analysis_path(), app_name + "_log.txt") if os.path.exists(self.log_name): os.remove(self.log_name) self.terminal_stop = threading.Event() self.terminal_thread = threading.Thread(target=self.show_log) self.terminal_thread.start() self.error_log = "Running " + app_name + "..." self.service = AndroidService( "MobileInsight is running...", app_name) # stop the running service self.service.stop() self.service.start( app_name + ":" + self.plugins_list[app_name][0]) # app name self.default_app_name = app_name # TODO: support collecting TCPDUMP trace # currentTime = datetime.datetime.now().strftime('%Y%m%d_%H%M%S') # tcpdumpcmd = "su -c tcpdump -i rmnet_data0 -w " \ # + main_utils.get_mobileinsight_log_path() \ # + "/tcpdump_" + str(currentTime) + ".pcap\n" # main_utils.run_shell_cmd(tcpdumpcmd) else: self.error_log = "Error: " + app_name + "cannot be launched!"
def start_service(self, app_name): if platform == "android" and app_name in self.plugins_list: if self.service: # stop the running service self.stop_service() # Show logs on screen # Clean up old logs self.log_name = os.path.join( main_utils.get_mobileinsight_analysis_path(), app_name + "_log.txt") if os.path.exists(self.log_name): os.remove(self.log_name) self.terminal_stop = threading.Event() self.terminal_thread = threading.Thread(target=self.show_log) self.terminal_thread.start() self.error_log = "Running " + app_name + "..." self.service = AndroidService("MobileInsight is running...", app_name) self.service.start(app_name + ":" + self.plugins_list[app_name][0]) # app name self.default_app_name = app_name else: self.error_log = "Error: " + app_name + "cannot be launched!"
def create_folder(): cmd = "" mobileinsight_path = main_utils.get_mobileinsight_path() if not mobileinsight_path: return False try: legacy_mobileinsight_path = main_utils.get_legacy_mobileinsight_path() cmd = cmd + "mv " + legacy_mobileinsight_path + " " + mobileinsight_path + "; " cmd = cmd + "mv " + legacy_mobileinsight_path + "/apps/ " + mobileinsight_path + "/plugins/; " except: pass if not os.path.exists(mobileinsight_path): cmd = cmd + "mkdir " + mobileinsight_path + "; " cmd = cmd + "chmod -R 755 " + mobileinsight_path + "; " log_path = main_utils.get_mobileinsight_log_path() if not os.path.exists(log_path): cmd = cmd + "mkdir " + log_path + "; " cmd = cmd + "chmod -R 755 " + log_path + "; " analysis_path = main_utils.get_mobileinsight_analysis_path() if not os.path.exists(analysis_path): cmd = cmd + "mkdir " + analysis_path + "; " cmd = cmd + "chmod -R 755 " + analysis_path + "; " cfg_path = main_utils.get_mobileinsight_cfg_path() if not os.path.exists(analysis_path): cmd = cmd + "mkdir " + cfg_path + "; " cmd = cmd + "chmod -R 755 " + cfg_path + "; " db_path = main_utils.get_mobileinsight_db_path() if not os.path.exists(db_path): cmd = cmd + "mkdir " + db_path + "; " cmd = cmd + "chmod -R 755 " + db_path + "; " plugin_path = main_utils.get_mobileinsight_plugin_path() if not os.path.exists(plugin_path): cmd = cmd + "mkdir " + plugin_path + "; " cmd = cmd + "chmod -R 755 " + plugin_path + "; " log_decoded_path = main_utils.get_mobileinsight_log_decoded_path() if not os.path.exists(log_decoded_path): cmd = cmd + "mkdir " + log_decoded_path + "; " cmd = cmd + "chmod -R 755 " + log_decoded_path + "; " log_uploaded_path = main_utils.get_mobileinsight_log_uploaded_path() if not os.path.exists(log_uploaded_path): cmd = cmd + "mkdir " + log_uploaded_path + "; " cmd = cmd + "chmod -R 755 " + log_uploaded_path + "; " crash_log_path = main_utils.get_mobileinsight_crash_log_path() if not os.path.exists(crash_log_path): cmd = cmd + "mkdir " + crash_log_path + "; " cmd = cmd + "chmod -R 755 " + crash_log_path + "; " # cmd = cmd + "chmod -R 755 "+mobileinsight_path+"; " main_utils.run_shell_cmd(cmd) return True