def Start(self, startup_args, startup_url=None): self.device.adb.Logcat(clear=True) self.platform_backend.DismissCrashDialogIfNeeded() user_agent_dict = user_agent.GetChromeUserAgentDictFromType( self.browser_options.browser_user_agent_type) command_line_name = self._backend_settings.command_line_name with flag_changer.CustomCommandLineFlags(self.device, command_line_name, startup_args): # Stop existing browser, if any. This is done *after* setting the # command line flags, in case some other Android process manages to # trigger Chrome's startup before we do. self._StopBrowser() self._SetupProfile() self.device.StartActivity(intent.Intent( package=self._backend_settings.package, activity=self._backend_settings.activity, action=None, data=startup_url, category=None, extras=user_agent_dict), blocking=True) try: self.BindDevToolsClient() except: self.Close() raise
def Start(self): self.device.adb.Logcat(clear=True) if self.browser_options.startup_url: url = self.browser_options.startup_url elif self.browser_options.profile_dir: url = None else: # If we have no existing tabs start with a blank page since default # startup with the NTP can lead to race conditions with Telemetry url = 'about:blank' self.platform_backend.DismissCrashDialogIfNeeded() user_agent_dict = user_agent.GetChromeUserAgentDictFromType( self.browser_options.browser_user_agent_type) browser_startup_args = self.GetBrowserStartupArgs() command_line_name = self._backend_settings.command_line_name with flag_changer.CustomCommandLineFlags(self.device, command_line_name, browser_startup_args): # Stop existing browser, if any. This is done *after* setting the # command line flags, in case some other Android process manages to # trigger Chrome's startup before we do. self._StopBrowser() self._SetupProfile() self.device.StartActivity(intent.Intent( package=self._backend_settings.package, activity=self._backend_settings.activity, action=None, data=url, category=None, extras=user_agent_dict), blocking=True) remote_devtools_port = self._backend_settings.GetDevtoolsRemotePort( self.device) # Setting local_port=0 allows the forwarder to pick an available port. self._forwarder = self.platform_backend.forwarder_factory.Create( forwarders.PortPair(0, remote_devtools_port), reverse=True) self._port = self._forwarder.port_pair.local_port try: self._WaitForBrowserToComeUp(remote_devtools_port) except exceptions.BrowserGoneException: logging.critical('Failed to connect to browser.') if not (self.device.HasRoot() or self.device.NeedsSU()): logging.critical( 'Resolve this by either: ' '(1) Flashing to a userdebug build OR ' '(2) Manually enabling web debugging in Chrome at ' 'Settings > Developer tools > Enable USB Web debugging.' ) self.Close() raise except: self.Close() raise
def Start(self, startup_args, startup_url=None): assert not startup_args, ( 'Startup arguments for Android should be set during ' 'possible_browser.SetUpEnvironment') user_agent_dict = user_agent.GetChromeUserAgentDictFromType( self.browser_options.browser_user_agent_type) self.device.StartActivity( intent.Intent(package=self._backend_settings.package, activity=self._backend_settings.activity, action=None, data=startup_url, category=None, extras=user_agent_dict), blocking=True) try: self.BindDevToolsClient() except: self.Close() raise
def Start(self, startup_args): assert not startup_args, ( 'Startup arguments for Android should be set during ' 'possible_browser.SetUpEnvironment') self._dump_finder = minidump_finder.MinidumpFinder( self.browser.platform.GetOSName(), self.browser.platform.GetArchName()) user_agent_dict = user_agent.GetChromeUserAgentDictFromType( self.browser_options.browser_user_agent_type) self.device.StartActivity( intent.Intent(package=self._backend_settings.package, activity=self._backend_settings.activity, action=None, data='about:blank', category=None, extras=user_agent_dict), blocking=True) try: self.BindDevToolsClient() except: self.Close() raise
def Start(self): self.device.adb.Logcat(clear=True) if self.browser_options.startup_url: url = self.browser_options.startup_url elif self.browser_options.profile_dir: url = None else: # If we have no existing tabs start with a blank page since default # startup with the NTP can lead to race conditions with Telemetry url = 'about:blank' self.platform_backend.DismissCrashDialogIfNeeded() user_agent_dict = user_agent.GetChromeUserAgentDictFromType( self.browser_options.browser_user_agent_type) browser_startup_args = self.GetBrowserStartupArgs() command_line_name = self._backend_settings.command_line_name with flag_changer.CustomCommandLineFlags(self.device, command_line_name, browser_startup_args): # Stop existing browser, if any. This is done *after* setting the # command line flags, in case some other Android process manages to # trigger Chrome's startup before we do. self._StopBrowser() self._SetupProfile() self.device.StartActivity(intent.Intent( package=self._backend_settings.package, activity=self._backend_settings.activity, action=None, data=url, category=None, extras=user_agent_dict), blocking=True) try: self.BindDevToolsClient() except: self.Close() raise
def Start(self): self.device.adb.Logcat(clear=True) if self.browser_options.startup_url: url = self.browser_options.startup_url elif self.browser_options.profile_dir: url = None else: # If we have no existing tabs start with a blank page since default # startup with the NTP can lead to race conditions with Telemetry url = 'about:blank' self.platform_backend.DismissCrashDialogIfNeeded() user_agent_dict = user_agent.GetChromeUserAgentDictFromType( self.browser_options.browser_user_agent_type) browser_startup_args = self.GetBrowserStartupArgs() command_line_name = self._backend_settings.command_line_name with flag_changer.CustomCommandLineFlags(self.device, command_line_name, browser_startup_args): # Stop existing browser, if any. This is done *after* setting the # command line flags, in case some other Android process manages to # trigger Chrome's startup before we do. self._StopBrowser() if self.device.HasRoot() or self.device.NeedsSU(): if self.browser_options.profile_dir: self.platform_backend.PushProfile( self._backend_settings.package, self.browser_options.profile_dir) elif not self.browser_options.dont_override_profile: self.platform_backend.RemoveProfile( self._backend_settings.package, self._backend_settings.profile_ignore_list) self.device.StartActivity(intent.Intent( package=self._backend_settings.package, activity=self._backend_settings.activity, action=None, data=url, category=None, extras=user_agent_dict), blocking=True) # TODO(crbug.com/404771): Move port forwarding to network_controller. remote_devtools_port = self._backend_settings.GetDevtoolsRemotePort( self.device) try: # Release reserved port right before forwarding host to device. self._port_keeper.Release() assert self._port == self._port_keeper.port, ( 'Android browser backend must use reserved port by _port_keeper' ) self.platform_backend.ForwardHostToDevice( self._port, remote_devtools_port) except Exception: logging.exception('Failed to forward %s to %s.', str(self._port), str(remote_devtools_port)) logging.warning('Currently forwarding:') try: for line in self.device.adb.ForwardList().splitlines(): logging.warning(' %s', line) except Exception: # pylint: disable=broad-except logging.warning('Exception raised while listing forwarded ' 'connections.') logging.warning('Host tcp ports in use:') try: for line in subprocess.check_output(['netstat', '-t']).splitlines(): logging.warning(' %s', line) except Exception: # pylint: disable=broad-except logging.warning( 'Exception raised while listing tcp ports.') logging.warning('Device unix domain sockets in use:') try: for line in self.device.ReadFile( '/proc/net/unix', as_root=True, force_pull=True).splitlines(): logging.warning(' %s', line) except Exception: # pylint: disable=broad-except logging.warning( 'Exception raised while listing unix domain sockets.') raise try: self._WaitForBrowserToComeUp(remote_devtools_port) except exceptions.BrowserGoneException: logging.critical('Failed to connect to browser.') if not (self.device.HasRoot() or self.device.NeedsSU()): logging.critical( 'Resolve this by either: ' '(1) Flashing to a userdebug build OR ' '(2) Manually enabling web debugging in Chrome at ' 'Settings > Developer tools > Enable USB Web debugging.' ) self.Close() raise except: self.Close() raise
def Start(self): self.device.RunShellCommand('logcat -c') if self.browser_options.startup_url: url = self.browser_options.startup_url elif self.browser_options.profile_dir: url = None else: # If we have no existing tabs start with a blank page since default # startup with the NTP can lead to race conditions with Telemetry url = 'about:blank' self.platform_backend.DismissCrashDialogIfNeeded() user_agent_dict = user_agent.GetChromeUserAgentDictFromType( self.browser_options.browser_user_agent_type) browser_startup_args = self.GetBrowserStartupArgs() with android_command_line_backend.SetUpCommandLineFlags( self.device, self._backend_settings, browser_startup_args): self.device.StartActivity( intent.Intent(package=self._backend_settings.package, activity=self._backend_settings.activity, action=None, data=url, category=None, extras=user_agent_dict), blocking=True) remote_devtools_port = self._backend_settings.GetDevtoolsRemotePort( self.device) try: # Release reserved port right before forwarding host to device. self._port_keeper.Release() assert self._port == self._port_keeper.port, ( 'Android browser backend must use reserved port by _port_keeper') self.platform_backend.ForwardHostToDevice( self._port, remote_devtools_port) except Exception: logging.exception('Failed to forward %s to %s.', str(self._port), str(remote_devtools_port)) logging.warning('Currently forwarding:') try: for line in self.device.adb.ForwardList().splitlines(): logging.warning(' %s', line) except Exception: logging.warning('Exception raised while listing forwarded ' 'connections.') logging.warning('Host tcp ports in use:') try: for line in subprocess.check_output(['netstat', '-t']).splitlines(): logging.warning(' %s', line) except Exception: logging.warning('Exception raised while listing tcp ports.') logging.warning('Device unix domain sockets in use:') try: for line in self.device.ReadFile('/proc/net/unix', as_root=True, force_pull=True).splitlines(): logging.warning(' %s', line) except Exception: logging.warning('Exception raised while listing unix domain sockets.') raise try: self._WaitForBrowserToComeUp() self._InitDevtoolsClientBackend(remote_devtools_port) except exceptions.BrowserGoneException: logging.critical('Failed to connect to browser.') if not (self.device.HasRoot() or self.device.NeedsSU()): logging.critical( 'Resolve this by either: ' '(1) Flashing to a userdebug build OR ' '(2) Manually enabling web debugging in Chrome at ' 'Settings > Developer tools > Enable USB Web debugging.') self.Close() raise except: self.Close() raise