components/cronet/tools/android_rndis_forwarder.py
def _EnableRndis(self):
    """Enables the RNDIS network interface."""
    script_prefix = '/data/local/tmp/rndis'
    # This could be accomplished via "svc usb setFunction rndis" but only on
    # devices which have the "USB tethering" feature.
    # Also, on some devices, it's necessary to go through "none" function.
    script = """
trap '' HUP
trap '' TERM
trap '' PIPE

function manual_config() {
  echo %(functions)s > %(dev)s/functions
  echo 224 > %(dev)s/bDeviceClass
  echo 1 > %(dev)s/enable
  start adbd
  setprop sys.usb.state %(functions)s
}

# This function kills adb transport, so it has to be run "detached".
function doit() {
  setprop sys.usb.config none
  while [ `getprop sys.usb.state` != "none" ]; do
    sleep 1
  done
  manual_config
  # For some combinations of devices and host kernels, adb won't work unless the
  # interface is up, but if we bring it up immediately, it will break adb.
  #sleep 1
  if ip link show rndis0 ; then
    ifconfig rndis0 %(device_ip_address)s netmask 255.255.255.0 up
  else
    ifconfig usb0 %(device_ip_address)s netmask 255.255.255.0 up
  fi
  echo DONE >> %(prefix)s.log
}

doit &
    """ % {'dev': self._RNDIS_DEVICE,
           'functions': 'rndis,adb',
           'prefix': script_prefix,
           'device_ip_address': self._DEVICE_IP_ADDRESS}
    script_file = '%s.sh' % script_prefix
    log_file = '%s.log' % script_prefix
    self._device.WriteFile(script_file, script)
    # TODO(szym): run via su -c if necessary.
    self._device.RemovePath(log_file, force=True)
    self._device.RunShellCommand(['.', script_file], check_return=True)
    self._device.WaitUntilFullyBooted()
    result = self._device.ReadFile(log_file).splitlines()
    assert any('DONE' in line for line in result), 'RNDIS script did not run!'
Enables the RNDIS network interface.
Enables the RNDIS network interface.
Enables the RNDIS network interface .
def _EnableRndis(self):
    script_prefix = '/data/local/tmp/rndis'
    script = """
trap '' HUP
trap '' TERM
trap '' PIPE
function manual_config() {
  echo %(functions)s > %(dev)s/functions
  echo 224 > %(dev)s/bDeviceClass
  echo 1 > %(dev)s/enable
  start adbd
  setprop sys.usb.state %(functions)s
}
# This function kills adb transport, so it has to be run "detached".
function doit() {
  setprop sys.usb.config none
  while [ `getprop sys.usb.state` != "none" ]; do
    sleep 1
  done
  manual_config
  # For some combinations of devices and host kernels, adb won't work unless the
  # interface is up, but if we bring it up immediately, it will break adb.
  #sleep 1
  if ip link show rndis0 ; then
    ifconfig rndis0 %(device_ip_address)s netmask 255.255.255.0 up
  else
    ifconfig usb0 %(device_ip_address)s netmask 255.255.255.0 up
  fi
  echo DONE >> %(prefix)s.log
}
doit &
    """ % {'dev': self._RNDIS_DEVICE,
           'functions': 'rndis,adb',
           'prefix': script_prefix,
           'device_ip_address': self._DEVICE_IP_ADDRESS}
    script_file = '%s.sh' % script_prefix
    log_file = '%s.log' % script_prefix
    self._device.WriteFile(script_file, script)
    self._device.RemovePath(log_file, force=True)
    self._device.RunShellCommand(['.', script_file], check_return=True)
    self._device.WaitUntilFullyBooted()
    result = self._device.ReadFile(log_file).splitlines()
    assert any('DONE' in line for line in result), 'RNDIS script did not run!'
def _EnableRndis ( self ) : script_prefix = '/data/local/tmp/rndis' script = """
trap '' HUP
trap '' TERM
trap '' PIPE

function manual_config() {
  echo %(functions)s > %(dev)s/functions
  echo 224 > %(dev)s/bDeviceClass
  echo 1 > %(dev)s/enable
  start adbd
  setprop sys.usb.state %(functions)s
}

# This function kills adb transport, so it has to be run "detached".
function doit() {
  setprop sys.usb.config none
  while [ `getprop sys.usb.state` != "none" ]; do
    sleep 1
  done
  manual_config
  # For some combinations of devices and host kernels, adb won't work unless the
  # interface is up, but if we bring it up immediately, it will break adb.
  #sleep 1
  if ip link show rndis0 ; then
    ifconfig rndis0 %(device_ip_address)s netmask 255.255.255.0 up
  else
    ifconfig usb0 %(device_ip_address)s netmask 255.255.255.0 up
  fi
  echo DONE >> %(prefix)s.log
}

doit &
    """ % { 'dev' : self . _RNDIS_DEVICE , 'functions' : 'rndis,adb' , 'prefix' : script_prefix , 'device_ip_address' : self . _DEVICE_IP_ADDRESS } script_file = '%s.sh' % script_prefix log_file = '%s.log' % script_prefix self . _device . WriteFile ( script_file , script ) self . _device . RemovePath ( log_file , force = True ) self . _device . RunShellCommand ( [ '.' , script_file ] , check_return = True ) self . _device . WaitUntilFullyBooted ( ) result = self . _device . ReadFile ( log_file ) . splitlines ( ) assert any ( 'DONE' in line for line in result ) , 'RNDIS script did not run!'
Enables the RNDIS network interface.
Enables the RNDIS network interface .
"""Enables the RNDIS network interface.""" # This could be accomplished via "svc usb setFunction rndis" but only on # devices which have the "USB tethering" feature. # Also, on some devices, it's necessary to go through "none" function. # TODO(szym): run via su -c if necessary.
self