Example #1
0
  def __init__(self, browser_options, backend_settings, rndis,
               output_profile_path, extensions_to_load):
    super(AndroidBrowserBackend, self).__init__(
        is_content_shell=backend_settings.is_content_shell,
        supports_extensions=False, browser_options=browser_options,
        output_profile_path=output_profile_path,
        extensions_to_load=extensions_to_load)
    if len(extensions_to_load) > 0:
      raise browser_backend.ExtensionsNotSupportedException(
          'Android browser does not support extensions.')

    # Initialize fields so that an explosion during init doesn't break in Close.
    self._adb = backend_settings.adb
    self._backend_settings = backend_settings
    self._saved_cmdline = None
    self._port = adb_commands.AllocateTestServerPort()

    # Kill old browser.
    self._adb.CloseApplication(self._backend_settings.package)

    if self._adb.Adb().CanAccessProtectedFileContents():
      if not self.browser_options.dont_override_profile:
        self._backend_settings.RemoveProfile()
      if self.browser_options.profile_dir:
        self._backend_settings.PushProfile(self.browser_options.profile_dir)

    # Pre-configure RNDIS forwarding.
    self._rndis_forwarder = None
    if rndis or self.browser_options.netsim:
      self._rndis_forwarder = android_rndis.RndisForwarderWithRoot(self._adb)
      self.WEBPAGEREPLAY_HOST = self._rndis_forwarder.host_ip
    # TODO(szym): only override DNS if WPR has privileges to proxy on port 25.
    self._override_dns = self.browser_options.netsim
Example #2
0
    def __init__(self, browser_options, backend_settings, use_rndis_forwarder,
                 output_profile_path, extensions_to_load, target_arch,
                 android_platform_backend):
        super(AndroidBrowserBackend, self).__init__(
            supports_tab_control=backend_settings.supports_tab_control,
            supports_extensions=False,
            browser_options=browser_options,
            output_profile_path=output_profile_path,
            extensions_to_load=extensions_to_load)
        if len(extensions_to_load) > 0:
            raise browser_backend.ExtensionsNotSupportedException(
                'Android browser does not support extensions.')

        # Initialize fields so that an explosion during init doesn't break in Close.
        self._android_platform_backend = android_platform_backend
        self._backend_settings = backend_settings
        self._saved_cmdline = ''
        self._target_arch = target_arch
        self._saved_sslflag = ''

        # TODO(tonyg): This is flaky because it doesn't reserve the port that it
        # allocates. Need to fix this.
        self._port = adb_commands.AllocateTestServerPort()

        # Disables android.net SSL certificate check.  This is necessary for
        # applications using the android.net stack to work with proxy HTTPS server
        # created by telemetry
        if self._backend_settings.relax_ssl_check:
            self._saved_sslflag = self._adb.device().GetProp(
                'socket.relaxsslcheck')
            self._adb.device().SetProp('socket.relaxsslcheck', 'yes')

        # Kill old browser.
        self._KillBrowser()

        if self._adb.device().old_interface.CanAccessProtectedFileContents():
            if self.browser_options.profile_dir:
                self._backend_settings.PushProfile(
                    self.browser_options.profile_dir, self._adb)
            elif not self.browser_options.dont_override_profile:
                self._backend_settings.RemoveProfile(self._adb)

        self._forwarder_factory = android_forwarder.AndroidForwarderFactory(
            self._adb, use_rndis_forwarder)

        if self.browser_options.netsim or use_rndis_forwarder:
            assert use_rndis_forwarder, 'Netsim requires RNDIS forwarding.'
            self.wpr_port_pairs = forwarders.PortPairs(
                http=forwarders.PortPair(0, 80),
                https=forwarders.PortPair(0, 443),
                dns=forwarders.PortPair(0, 53))

        # Set the debug app if needed.
        if self._adb.IsUserBuild():
            logging.debug('User build device, setting debug app')
            self._adb.device().RunShellCommand(
                'am set-debug-app --persistent %s' %
                self._backend_settings.package)
  def __init__(self, android_platform_backend, browser_options,
               backend_settings, use_rndis_forwarder, output_profile_path,
               extensions_to_load, target_arch):
    assert isinstance(android_platform_backend,
                      android_platform_backend_module.AndroidPlatformBackend)
    super(AndroidBrowserBackend, self).__init__(
        android_platform_backend,
        supports_tab_control=backend_settings.supports_tab_control,
        supports_extensions=False, browser_options=browser_options,
        output_profile_path=output_profile_path,
        extensions_to_load=extensions_to_load)
    if len(extensions_to_load) > 0:
      raise browser_backend.ExtensionsNotSupportedException(
          'Android browser does not support extensions.')

    # Initialize fields so that an explosion during init doesn't break in Close.
    self._backend_settings = backend_settings
    self._saved_cmdline = ''
    self._target_arch = target_arch
    self._saved_sslflag = ''

    # TODO(tonyg): This is flaky because it doesn't reserve the port that it
    # allocates. Need to fix this.
    self._port = adb_commands.AllocateTestServerPort()

    # TODO(wuhu): Move to network controller backend.
    self._platform_backend.InstallTestCa()

    # Kill old browser.
    self._KillBrowser()

    if self._adb.device().old_interface.CanAccessProtectedFileContents():
      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._forwarder_factory = android_forwarder.AndroidForwarderFactory(
        self._adb, use_rndis_forwarder)

    if self.browser_options.netsim or use_rndis_forwarder:
      assert use_rndis_forwarder, 'Netsim requires RNDIS forwarding.'
      self.wpr_port_pairs = forwarders.PortPairs(
          http=forwarders.PortPair(0, 80),
          https=forwarders.PortPair(0, 443),
          dns=forwarders.PortPair(0, 53))

    # Set the debug app if needed.
    self._platform_backend.SetDebugApp(self._backend_settings.package)
    def __init__(self, browser_options, backend_settings, use_rndis_forwarder,
                 output_profile_path, extensions_to_load):
        super(AndroidBrowserBackend, self).__init__(
            is_content_shell=backend_settings.is_content_shell,
            supports_extensions=False,
            browser_options=browser_options,
            output_profile_path=output_profile_path,
            extensions_to_load=extensions_to_load)
        if len(extensions_to_load) > 0:
            raise browser_backend.ExtensionsNotSupportedException(
                'Android browser does not support extensions.')

        # Initialize fields so that an explosion during init doesn't break in Close.
        self._adb = backend_settings.adb
        self._backend_settings = backend_settings
        self._saved_cmdline = ''

        # TODO(tonyg): This is flaky because it doesn't reserve the port that it
        # allocates. Need to fix this.
        self._port = adb_commands.AllocateTestServerPort()

        # Kill old browser.
        self._adb.CloseApplication(self._backend_settings.package)

        if self._adb.Adb().CanAccessProtectedFileContents():
            if self.browser_options.profile_dir:
                self._backend_settings.PushProfile(
                    self.browser_options.profile_dir)
            elif not self.browser_options.dont_override_profile:
                self._backend_settings.RemoveProfile()

        self._forwarder_factory = android_forwarder.AndroidForwarderFactory(
            self._adb, use_rndis_forwarder)

        if self.browser_options.netsim:
            assert use_rndis_forwarder, 'Netsim requires RNDIS forwarding.'
            self.wpr_port_pairs = forwarders.PortPairs(
                http=forwarders.PortPair(0, 80),
                https=forwarders.PortPair(0, 443),
                dns=forwarders.PortPair(0, 53))

        # Set the debug app if needed.
        if self._adb.IsUserBuild():
            logging.debug('User build device, setting debug app')
            self._adb.RunShellCommand('am set-debug-app --persistent %s' %
                                      self._backend_settings.package)
Example #5
0
 def __init__(self, app_backend, pid, name):
     self._app_backend = app_backend
     self._pid = pid
     self._name = name
     self._local_port = adb_commands.AllocateTestServerPort()
     self._devtools_client = None