def _get_device(self, capabilities): capabilities = [ DeviceCapability({'name': capability}) for capability in capabilities ] glb_cfg = mock.MagicMock() logger = mock.MagicMock() device = DeviceBase(glb_cfg, logger) device._device_capabilities = capabilities return device
def __init__(self, config, logger): """ Constructor :type phone_name: string :param phone_name: Name of the current phone(e.g. PHONE1) """ DeviceBase.__init__(self, config, logger) self._error = Error() self._device_ip = self.config.get("ipAddress", "localhost") self._my_name = path.basename(__file__).split(".")[0] self._device_logger = None self._init_logger() # mandatory parameter self._prss_pw_btn_time_switch_off = self.get_config("pressPowerBtnTimeSwitchOff", 10, int) self._prss_pwr_btn_time_switch_on = self.get_config("pressPowerBtnTimeSwitchOn", 3, int) self._call_setup_timeout = self.get_config("callSetupTimeout", 15, int) self._uecmd_default_timeout = self.get_config("defaultTimeout", 50, int) self._boot_timeout = self.get_config("bootTimeout", 300, int) self._soft_shutdown_duration = self.get_config("softShutdownDuration", 120, int) self._hard_shutdown_duration = self.get_config("hardShutdownDuration", 120, int) self._settledown_duration = self.get_config("settleDownDuration", 0, int) self._usb_sleep_duration = self.get_config("usbSleep", 10, int) # EM parameter self._default_wall_charger = self.get_config("defaultWallCharger", "") # CWS parameter self._wifi_adapter_name = self.get_config("WiFiAdapterName", "Wi-Fi", str) # windows logger parameter self.__logger_filters = self.get_config("kernelLogFilter", "Verbose", str) # user files directory self._userdata_path = self.get_config("userdataPath", "C:\\Users\\Public\\Documents") self._binaries_path = self.get_config("binPath", "C:\\Users\\Public\\Documents") self._cellular_network_interface = self.get_config("cellularNetworkInterface", "Mobile broadband") # misc var self._connection_lock = threading.Lock() self._is_acs_connected = False self._eqts_controller = DeviceController.DeviceController(config.device_name, self.config, self.get_em_parameters(), self.get_logger()) # instantiate the Windows web service used to execute device commands service_port = self.get_config("servicePort", "8080", str) http_proxy = self.get_config("httpProxy", "", str) proxies = {"http": http_proxy} self.__windows_service = WindowsService( self._device_ip, service_port, proxies, logger, self._uecmd_default_timeout) logger_port = self.get_config("loggerPort", "8082", str) # instantiate the Logger web service used to inject/retrieve logs self.__logger_service = LoggerService( self._device_ip, logger_port, proxies, logger, 10)
def __init__(self, config, logger): """ Constructor Restart device to enter SOS, get SOS DHCP IP address, then set as static IP, and store it to a temporary file for test program to read. At last to auto start up Android OS """ DeviceBase.__init__(self, config, logger) self._sos_login_name = self.get_config("loginName") self._sos_login_password = self.get_config("loginPassword") self._sos_control_debug_path = self.get_config("controlDebugPath", "/dev/ttyUSB2") self._sos_console_debug_path = self.get_config("consoleDebugPath", "/dev/ttyUSB3") self._sos_acrn_network_interface = self.get_config("acrnNetworkInterface", "acrn-br0") self._control_serial = self.open_debug_port(self._sos_control_debug_path) self._console_serial = DebugCard(self._sos_console_debug_path) self._console_serial.open() retry_times = 3 while retry_times > 0: try: # restart acrn device to make sure it only start up SOS self.restart_acrn_device() # get SOS console self._console_serial.switch_sos_console(self._sos_login_name, self._sos_login_password) # set static IP to SOS self._console_serial.set_static_sos_ip(self._sos_acrn_network_interface) break except: retry_times -= 1 continue # start up Android OS if retry_times > 0: try: self.get_logger().info("launching Android OS ...") self._console_serial.launch_uos() except: pass time.sleep(40) # to wait Android OS complete to start up self._console_serial.close() self.close_debug_port(self._control_serial) self.get_logger().info("Closed all connected serial ports") BroxtonDevice.__init__(self, config, logger)
def __init__(self, config, logger): """ Constructor :type phone_name: string :param phone_name: Name of the current phone(e.g. PHONE1) """ # Create empty UECmd section config["UECmd"] = "" DeviceBase.__init__(self, config, logger) # Is phone connected for UECmd? self._is_phone_connected = False # Is phone booted (ready to be connected)? self._is_phone_booted = False # set device number to not available self._serial_number = AcsConstants.NOT_AVAILABLE
def __init__(self, config, device_config): self.phone_ = """ Constructor :type phone_name: str :param phone_name: Name of the current phone(e.g. PHONE1) """ DeviceBase.__init__(self, config, device_config) self.pid = -1 self.__logger = LOGGER_FWK self.android_build_top = os.environ.get('ANDROID_BUILD_TOP') # Just to avoid error message self._embedded_log = None self.startvm_path = None self._android_version = (self.get_config("AndroidVersion") or self.get_config("OSVersion", "Unknown")).title() self._supported_android_versions = self.retrieve_os_version() self._connection_lock = threading.Lock() self._phone_handle = None self._serial_number = self.get_config("serialNumber", "") self._is_device_connected = True self._uecmd_default_timeout = self.get_config("defaultTimeout", 50, int) self._phone_handle = None self._adb_server_port = self.get_config("adbServerPort", 5037, int) self._device_logger = None self._use_adb_socket = self.get_config("useAdbSocket", "False", "str_to_bool") self._eqts_controller = DeviceController.DeviceController(config.device_name, self._device_config, self.get_em_parameters(), self.get_logger()) if self._serial_number in (None, "None", ""): # Retrieve current value of serial number self._serial_number = self.retrieve_serial_number() try: self.startvm_path = os.path.join(self.android_build_top, "device/intel/minimal/startvm.sh") self.__logger.info("startvm path: " + self.startvm_path) except Exception as e: self.__logger.info( "ANDROID_BUILD_TOP environment variable is not set. " + "Use build/envsetup.sh from the minimal root directoy")
def __init__(self, device_name, device_config): """ Constructor @type device_name: string @param device_name: Name of the current device(e.g. PHONE1) """ DeviceBase.__init__(self, device_name, device_config) self._os_version = self.get_config("OSVersion", "Unknown").title() self._my_name = path.basename(__file__).split(".")[0] # mandatory parameter self._prss_pw_btn_time_switch_off = self.get_config( "pressPowerBtnTimeSwitchOff", 10, int) self._prss_pwr_btn_time_switch_on = self.get_config( "pressPowerBtnTimeSwitchOn", 3, int) # timeouts self._uecmd_default_timeout = int( self.get_config("defaultTimeout", 50, int)) self._boot_timeout = self.get_config("bootTimeout", 300, int) self._settledown_duration = self.get_config("settleDownDuration", 0, int) self._usb_sleep_duration = self.get_config("usbSleep", 10, int) self._hard_shutdown_duration = self.get_config("hardShutdownDuration", 20, int) self._soft_shutdown_duration = self.get_config("softShutdownDuration", 30, int) self._soft_shutdown_settle_down_duration = self.get_config( "softShutdownSettleDownDuration", 20.0, float) # serial_number is the identifier used to communicate with the board (serialno if USB, IP if ethernet) self._serial_number = self.get_config("serialNumber", "") # Flashing configuration elements self._acs_flash_file_path = Paths.FLASH_FILES self._flash_time_out = self.get_config("flashTimeout", 600, int) # _serial_number is the identifier used to communicate with the board (serialno if USB, IP if ethernet) # _device_id is the unique identifier of the device self._device_id = None # PUPDR parameter self._soft_shutdown_cmd = "system_shutdown 0" # misc var self._connection_lock = threading.Lock() self._is_device_connected = False self._eqts_controller = DeviceController.DeviceController( device_name, self._device_config, None, self.get_logger()) # Embedded log feature self._embedded_log = EmbeddedLog.EmbeddedLog(self) self._py_cmds_api = None self._serial_port = self.get_config("serialPort", "/dev/ttyUSB0", str) # Default not use UART connection (no serial) self._retrieve_serial_trace = self.get_config("retrieveSerialTrace", "False", "str_to_bool")
def __init__(self, config, logger): """ Constructor :type config: dict :param config: Device configuration to use :type logger: logger :param logger: Logger to use """ DeviceBase.__init__(self, config, logger) self._os_version = self.get_config("OSVersion", "Unknown").title() self._ip_address = self.get_config("ipAddress", "192.168.2.15") self._my_name = path.basename(__file__).split(".")[0] # mandatory parameter self._prss_pw_btn_time_switch_off = self.get_config( "pressPowerBtnTimeSwitchOff", 10, int) self._prss_pwr_btn_time_switch_on = self.get_config( "pressPowerBtnTimeSwitchOn", 3, int) # timeouts self._call_setup_timeout = self.get_config("callSetupTimeout", 15, int) self._uecmd_default_timeout = int( self.get_config("defaultTimeout", 50, int)) self._boot_timeout = self.get_config("bootTimeout", 300, int) self._settledown_duration = self.get_config("settleDownDuration", 0, int) self._usb_sleep_duration = self.get_config("usbSleep", 10, int) self._hard_shutdown_duration = self.get_config("hardShutdownDuration", 20, int) self._soft_shutdown_duration = self.get_config("softShutdownDuration", 30, int) self._soft_shutdown_settle_down_duration = self.get_config( "softShutdownSettleDownDuration", 20.0, float) # serial_number is the identifier used to communicate with the board (serialno if USB, IP if ethernet) self._serial_number = self.get_config("serialNumber", "") # Flashing configuration elements self._acs_flash_file_path = Paths.FLASH_FILES self._flash_time_out = self.get_config("flashTimeout", 600, int) # EM parameter # self._default_wall_charger = self.get_config("defaultWallCharger", "") self._binaries_path = self.get_config("binPath", "/usr/bin/") self._userdata_path = self.get_config("userdataPath", "/home/root/") self._ext_sdcard_path = self.get_config("sdcard_ext", "/sdcard/") self._ext_usbdrive_path = self.get_config("usbdrive_ext", "/usbdrive/") # PUPDR parameter self._soft_shutdown_cmd = "/sbin/poweroff" # misc var self._connection_lock = threading.Lock() self._is_device_connected = False # device info # Equipment controller self._eqts_controller = DeviceController.DeviceController( self._device_config.device_name, self._device_config, None, self.get_logger()) # Embedded log feature self._embedded_log = EmbeddedLog.EmbeddedLog(self) # Start PTI and/or serial logs if required # Before establishing first connection to the device, enable PTI and/or Serial logging # to capture a maximum of traces. AP and BP logs will be handled further down the line if self._embedded_log: self._embedded_log.stop("SERIAL") time.sleep(1) self._embedded_log.start("SERIAL") self._base = None