def run(self) -> None: self.log.info("{} start with hook device: id={}, name={}, type={}".format( self.__class__.__name__, self.device.id, self.device.name, self.device.type)) try: self.prepare() self.hook_apps() except Exception as e: self.log.error('device {}: {}'.format(self.device.id, e)) try: self.shutdown() except Exception as e: self.log.error('unexpected error occurred when shutdown device {}: {}'.format(self.device.id, e)) self.log.debug('device {} exit'.format(self.device.id)) thread_manager.del_thread(self)
def shutdown(self): for frida_thread in self.frida_threads: if frida_thread.is_alive(): frida_thread.cancel() thread_manager.del_thread(self)