def main(): """ Main function only executed if __name__ == __main__ :return: :rtype: """ args = command_line_argument_parse() if args.mapper_device_id: mapper_device_id = args.mapper_device_id else: mapper_device_id = None # get the adb shell dimensions using wmctrl adb.get_dimensions(adb.path, device_id=mapper_device_id) # delay for 5 seconds by default or respect command line arguments delay = args.mapper_delay time.sleep(delay)
def __init__(self, device_id): self.config = dict() self._device_id = device_id self.app = None self.window = None self.dimensions = adb.get_dimensions(adb.path, device_id) if self.check_orientation() == 1: # reverse the detected dimensions. # possibly the device is landscape / not the default # orientation as detected by Android Window Manager self.dimensions = self.dimensions[::-1]
def __init__(self, device_id=None): """ The main class for UXMapper and adb shell spawn to device The guiscrcpy client passes information ot the UXMapper which spawns adb sub processes to handle button and tap events :param device_id: """ logging.debug("Launching UX Mapper") self.has_modules = getWindowsWithTitle and auto logging.debug("Calculating Screen Size") self.android_dimensions = adb.get_dimensions( adb.path, device_id=device_id) self.deviceId = device_id # each device connected is uniquely identified by the tools by # a salted hash. The toolkits are assigned colors based on the first # 6 colors and the stylesheet is derived from self.__sha = hashlib.sha256(str(self.deviceId).encode()).hexdigest()
def start_act(self): self.runningNot.setText("CHECKING DEVICE CONNECTION") timei = time.time() self.progressBar.setValue(5) devices_list = adb.devices(adb.path) if devices_list[0] == "\n": self.runningNot.setText("DEVICE IS NOT CONNECTED") self.progressBar.setValue(0) return 0 try: exc = devices_list[1].find("device") except IndexError: self.runningNot.setText("DEVICE IS NOT CONNECTED") self.progressBar.setValue(0) return 0 if exc > -1: self.runningNot.setText( "DEVICE " + str(devices_list[0]) + " IS CONNECTED") self.progressBar.setValue(10) elif devices_list[1][:-1] == "unauthorized": self.runningNot.setText( "DEVICE IS UNAUTHORIZED. PLEASE CLICK 'OK' ON DEVICE WHEN ASKED FOR" ) self.progressBar.setValue(0) return 0 else: self.runningNot.setText( "DEVICE CONNECTED BUT FAILED TO ESTABLISH CONNECTION" ) self.progressBar.setValue(0) return 0 # check if the defaultDimension is checked or not for giving signal ux = UXMapper() dimValues = adb.get_dimensions(adb.path) self.progressBar.setValue(15) if self.dimensionDefaultCheckbox.isChecked(): self.dimensionSlider.setEnabled(False) self.dimensionText.setText("DEFAULT") config['dimension'] = None else: self.dimensionSlider.setEnabled(True) config['dimension'] = int(self.dimensionSlider.value()) self.dimensionSlider.setValue(config['dimension']) self.dimensionText.setText(str(config['dimension']) + "px") # check if the defaultDimension is checked or not for giving signal self.progressBar.setValue(20) # process dimension if config['dimension'] is None: self.options = " " pass elif config['dimension'] is not None: self.options = " -m " + str(config['dimension']) else: self.options = "" self.progressBar.setValue(25) # CHECK BOX GROUP CONNECT if self.aotop.isChecked(): self.options += " --always-on-top" if self.fullscreen.isChecked(): self.options += " -f" config['fullscreen'] = True else: config['fullscreen'] = False self.progressBar.setValue(30) if self.showTouches.isChecked(): self.options += " --show-touches" config['swtouches'] = True else: config['swtouches'] = False if self.recScui.isChecked(): self.options += " -r " + str(int(time.time())) + ".mp4 " if self.displayForceOn.isChecked(): self.options += " -S" config['dispRO'] = True else: config['dispRO'] = False self.options += " -b " + str(int(self.dial.value())) + "K" config['bitrate'] = int(self.dial.value()) self.progressBar.setValue(40) logging.debug("CONNECTION ESTABLISHED") self.progressBar.setValue(50) logging.debug("Flags passed to scrcpy engine : " + self.options) self.progressBar.setValue(75) config['extra'] = self.flaglineedit.text() self.swipe_instance.init() # show Swipe UI self.panel_instance.init() self.side_instance.init() # run scrcpy usng subprocess args = "{} {}".format(self.options, config['extra']) scrcpy.start(scrcpy.path, args) timef = time.time() eta = timef - timei print("SCRCPY is launched in", eta, "seconds") self.progressBar.setValue(100) # handle config files cfgmgr.update_config(config) cfgmgr.write_file() if self.notifChecker.isChecked(): from guiscrcpy.lib.notify import NotifyAuditor NotifyAuditor() return True
print("Device : OK!") cfgpath = cfgmgr.cfgpath parser = argparse.ArgumentParser() parser.add_argument('-t', '--delay', default=10, help="Set time to delay before screen is captured") parser.add_argument('-r', '--reset', action="store_true", help="Remove prefernces") args = parser.parse_args() dimensions = adb.get_dimensions(adb.path) class MapperUI(QtWidgets.QWidget): def __init__(self): self.last_found_point = None self.image = None QtWidgets.QWidget.__init__(self) self.label = QtWidgets.QLabel(self) self.drawing = False self.widget = QtWidgets.QWidget(self) self.widget.setGeometry(QtCore.QRect(0, 0, 351, 34)) self.widget.setObjectName("widget") self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget) self.horizontalLayout.setSizeConstraint( QtWidgets.QLayout.SetMaximumSize)
def __init__(self): logging.debug("Launching UX Mapper") self.has_modules = getWindowsWithTitle and auto logging.debug("Calculating Screen Size") self.android_dimensions = adb.get_dimensions(adb.path)
parser.add_argument('--mapper-reset', action="store_true", help="Remove mapper configuration file and stat from " "scratch") parser.add_argument('--mapper-device-id', default='', help="Sets the device-id for mapper to configure " "(optional, needed for multiple devices)" ) args = parser.parse_args() if args.mapper_device_id: mapper_device_id = args.mapper_device_id else: mapper_device_id = None dimensions = adb.get_dimensions(adb.path, device_id=mapper_device_id) class MapperUI(QtWidgets.QWidget): def __init__(self): self.last_found_point = None self.image = None QtWidgets.QWidget.__init__(self) self.label = QtWidgets.QLabel(self) self.drawing = False self.widget = QtWidgets.QWidget(self) self.widget.setGeometry(QtCore.QRect(0, 0, 351, 34)) self.widget.setObjectName("widget") self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget) self.horizontalLayout.setSizeConstraint( QtWidgets.QLayout.SetMaximumSize)