original_docstring: 
          Async function of detect device first time and get device serial
  
          Args:
              timeout (int, default :data:`.constants.DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT`): Timeout in seconds
  
          Keyword args:
              verbose (bool, default :data:`.constants.DEFAULT_MANAGER_COMMAND_VERBOSE`): Print process to output
              allow_adb_kill (bool, default :data:`.constants.DEFAULT_ADB_SERVER_KILL_ALLOWED`): Allow to kill ADB server
  
          Warning:
              allow_adb_kill == True may affect other script and not recommended to use except Framework was started
              isolated via Docker or Virtual Machine.
  
          Raises:
              TimeoutExpiredError when device not found and timeout expired
              DeviceEnumeratedError if found more one devices or device status is not good
  
          Returns:
              (str, str): Device serial and "adb" of "fastboot" mode
          
docstring: Async function of detect device first time and get device serial
  Args:
  timeout (int, default :data:`.constants.DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT`): Timeout in seconds
  
  
  
  allow_adb_kill == True may affect other script and not recommended to use except Framework was started
  isolated via Docker or Virtual Machine.
  
  TimeoutExpiredError when device not found and timeout expired
  DeviceEnumeratedError if found more one devices or device status is not good
  
  (str, str): Device serial and "adb" of "fastboot" mode
docstring_tokens: Async function of detect device first time and get device serial Args : timeout ( int default : data : ` . constants . DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT ` ) : Timeout in seconds allow_adb_kill == True may affect other script and not recommended to use except Framework was started isolated via Docker or Virtual Machine . TimeoutExpiredError when device not found and timeout expired DeviceEnumeratedError if found more one devices or device status is not good ( str str ) : Device serial and " adb " of " fastboot " mode
code: async def first_detect(self, timeout=DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT, **kwargs) -> (str, str):
          """
          Async function of detect device first time and get device serial
  
          Args:
              timeout (int, default :data:`.constants.DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT`): Timeout in seconds
  
          Keyword args:
              verbose (bool, default :data:`.constants.DEFAULT_MANAGER_COMMAND_VERBOSE`): Print process to output
              allow_adb_kill (bool, default :data:`.constants.DEFAULT_ADB_SERVER_KILL_ALLOWED`): Allow to kill ADB server
  
          Warning:
              allow_adb_kill == True may affect other script and not recommended to use except Framework was started
              isolated via Docker or Virtual Machine.
  
          Raises:
              TimeoutExpiredError when device not found and timeout expired
              DeviceEnumeratedError if found more one devices or device status is not good
  
          Returns:
              (str, str): Device serial and "adb" of "fastboot" mode
          """
          verbose = kwargs.get('verbose', DEFAULT_MANAGER_COMMAND_VERBOSE)
          allow_adb_kill = kwargs.get('allow_adb_kill', DEFAULT_ADB_SERVER_KILL_ALLOWED)
  
          if verbose:
              self.logger.info('Search for device in progress...')
          t = time()
          while (time() - t) <= timeout:
              a_devices, a_status = self.adb.devices(**kwargs)
              f_devices, f_status = self.fb.devices(**kwargs)
              # devices in adb and fastboot in same time
              if len(a_devices) > 0 and len(f_devices) > 0:
                  raise DeviceEnumeratedError('More one device enumerated. Please provide serial number.')
              # one more device found
              elif len(a_devices) > 1 or len(f_devices) > 1:
                  raise DeviceEnumeratedError('More one device enumerated. Please provide serial number.')
              # adb mode
              if len(a_devices) == 1:
                  if a_status[0] == 'offline' and allow_adb_kill is True:
                      # restart adb server once
                      self.adb.restart_server(**kwargs)
                      allow_adb_kill = False
                  elif a_status[0] == 'device':
                      if verbose:
                          self.logger.info('Detected device %s in ADB mode.'
                                           % (NAME.safe_substitute(name=a_devices[0])))
                      return a_devices[0], 'adb'
                  else:
                      raise DeviceEnumeratedError('Device %s detected with status %s'
                                                  % (NAME.safe_substitute(name=a_devices[0]),
                                                     NAME.safe_substitute(name=a_status[0])))
              # fastboot mode
              elif len(f_devices) == 1:
                  if verbose:
                      self.logger.info('Detected device %s in FASTBOOT mode.' % (NAME.safe_substitute(name=f_devices[0])))
                  return f_devices[0], 'fastboot'
              await asyncio.sleep(1)
          raise TimeoutExpiredError('Device not found !')
code_tokens: async def first_detect ( self , timeout = DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT , ** kwargs ) -> ( str , str ) : verbose = kwargs . get ( 'verbose' , DEFAULT_MANAGER_COMMAND_VERBOSE ) allow_adb_kill = kwargs . get ( 'allow_adb_kill' , DEFAULT_ADB_SERVER_KILL_ALLOWED ) if verbose : self . logger . info ( 'Search for device in progress...' ) t = time ( ) while ( time ( ) - t ) <= timeout : a_devices , a_status = self . adb . devices ( ** kwargs ) f_devices , f_status = self . fb . devices ( ** kwargs ) if len ( a_devices ) > 0 and len ( f_devices ) > 0 : raise DeviceEnumeratedError ( 'More one device enumerated. Please provide serial number.' ) elif len ( a_devices ) > 1 or len ( f_devices ) > 1 : raise DeviceEnumeratedError ( 'More one device enumerated. Please provide serial number.' ) if len ( a_devices ) == 1 : if a_status [ 0 ] == 'offline' and allow_adb_kill is True : self . adb . restart_server ( ** kwargs ) allow_adb_kill = False elif a_status [ 0 ] == 'device' : if verbose : self . logger . info ( 'Detected device %s in ADB mode.' % ( NAME . safe_substitute ( name = a_devices [ 0 ] ) ) ) return a_devices [ 0 ] , 'adb' else : raise DeviceEnumeratedError ( 'Device %s detected with status %s' % ( NAME . safe_substitute ( name = a_devices [ 0 ] ) , NAME . safe_substitute ( name = a_status [ 0 ] ) ) ) elif len ( f_devices ) == 1 : if verbose : self . logger . info ( 'Detected device %s in FASTBOOT mode.' % ( NAME . safe_substitute ( name = f_devices [ 0 ] ) ) ) return f_devices [ 0 ] , 'fastboot' await asyncio . sleep ( 1 ) raise TimeoutExpiredError ( 'Device not found !' )
short_docstring: Async function of detect device first time and get device serial
  Args:
  timeout (int, default :data:`.constants.DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT`): Timeout in seconds
short_docstring_tokens: Async function of detect device first time and get device serial Args : timeout ( int default : data : ` . constants . DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT ` ) : Timeout in seconds
comment: """
          Async function of detect device first time and get device serial
  
          Args:
              timeout (int, default :data:`.constants.DEFAULT_FIRST_DEVICE_DETECT_TIMEOUT`): Timeout in seconds
  
          Keyword args:
              verbose (bool, default :data:`.constants.DEFAULT_MANAGER_COMMAND_VERBOSE`): Print process to output
              allow_adb_kill (bool, default :data:`.constants.DEFAULT_ADB_SERVER_KILL_ALLOWED`): Allow to kill ADB server
  
          Warning:
              allow_adb_kill == True may affect other script and not recommended to use except Framework was started
              isolated via Docker or Virtual Machine.
  
          Raises:
              TimeoutExpiredError when device not found and timeout expired
              DeviceEnumeratedError if found more one devices or device status is not good
  
          Returns:
              (str, str): Device serial and "adb" of "fastboot" mode
          """$SEP$# devices in adb and fastboot in same time$SEP$# one more device found$SEP$# adb mode$SEP$# restart adb server once$SEP$# fastboot mode