code: def check_stf_agent(adbprefix=None, kill=False):
      '''return True if agent is alive.'''
      if adbprefix is None: 
          adbprefix = ['adb']
      command = adbprefix + ['shell', 'ps']
      out = subprocess.check_output(command).strip()
      out = out.splitlines()
      if len(out) > 1:
          first, out = out[0], out[1:]
          idx = first.split().index('PID')
          pid = None
          for line in out:
              if 'stf.agent' in line:
                  pid = line.split()[idx]
                  print 'stf.agent is running, pid is', pid
                  break
          if pid is not None:
              if kill:
                  print 'killing', pid
                  command = adbprefix + ['shell', 'kill', '-9', pid]
                  subprocess.call(command)
                  return False
              return True
      return Falsf check_stf_agent(adbprefix=None, kill=False):
      '''return True if agent is alive.'''
      if adbprefix is None: 
          adbprefix = ['adb']
      command = adbprefix + ['shell', 'ps']
      out = subprocess.check_output(command).strip()
      out = out.splitlines()
      if len(out) > 1:
          first, out = out[0], out[1:]
          idx = first.split().index('PID')
          pid = None
          for line in out:
              if 'stf.agent' in line:
                  pid = line.split()[idx]
                  print 'stf.agent is running, pid is', pid
                  break
          if pid is not None:
              if kill:
                  print 'killing', pid
                  command = adbprefix + ['shell', 'kill', '-9', pid]
                  subprocess.call(command)
                  return False
              return True
      return False
docs: return True if agent is alive.