def manager_thread():
    Process(name='shutdownd', target=launcher, args=('selfdrive.shutdownd',)).start()
    system('am startservice com.neokii.optool/.MainService')
    system('am startservice com.neokii.openpilot/.MainService')
    cloudlog.info('manager start')
    cloudlog.info({'environ': os.environ})
    params = Params()
    ignore = []
    if (os.getenv('NOBOARD') is not None):
        ignore.append('pandad')
    if (os.getenv('BLOCK') is not None):
        ignore += os.getenv('BLOCK').split(',')
    ensure_running(managed_processes.values(), started=False, not_run=ignore)
    started_prev = False
    sm = messaging.SubMaster(['deviceState'])
    pm = messaging.PubMaster(['managerState'])
    while True:
        sm.update()
        not_run = ignore[:]
        if (sm['deviceState'].freeSpacePercent < 5):
            not_run.append('loggerd')
        started = sm['deviceState'].started
        driverview = params.get_bool('IsDriverViewEnabled')
        ensure_running(managed_processes.values(), started, driverview, not_run)
        if (started_prev and (not started) and ('updated' in managed_processes)):
            os.sync()
            managed_processes['updated'].signal(signal.SIGHUP)
        started_prev = started
        running_list = [('%s%s\x1b[0m' % (('\x1b[32m' if p.proc.is_alive() else '\x1b[31m'), p.name)) for p in managed_processes.values() if p.proc]
        cloudlog.debug(' '.join(running_list))
        msg = messaging.new_message('managerState')
        msg.managerState.processes = [p.get_process_state_msg() for p in managed_processes.values()]
        pm.send('managerState', msg)
        if params.get_bool('DoUninstall'):
            break
def manager_thread():
    Process(name='shutdownd', target=launcher, args=('selfdrive.shutdownd',)).start()
    system('am startservice com.neokii.optool/.MainService')
    system('am startservice com.neokii.openpilot/.MainService')
    cloudlog.info('manager start')
    cloudlog.info({'environ': os.environ})
    params = Params()
    ignore = []
    if (os.getenv('NOBOARD') is not None):
        ignore.append('pandad')
    if (os.getenv('BLOCK') is not None):
        ignore += os.getenv('BLOCK').split(',')
    ensure_running(managed_processes.values(), started=False, not_run=ignore)
    started_prev = False
    sm = messaging.SubMaster(['deviceState'])
    pm = messaging.PubMaster(['managerState'])
    while True:
        sm.update()
        not_run = ignore[:]
        if (sm['deviceState'].freeSpacePercent < 5):
            not_run.append('loggerd')
        started = sm['deviceState'].started
        driverview = params.get_bool('IsDriverViewEnabled')
        ensure_running(managed_processes.values(), started, driverview, not_run)
        if (started_prev and (not started) and ('updated' in managed_processes)):
            os.sync()
            managed_processes['updated'].signal(signal.SIGHUP)
        started_prev = started
        running_list = [('%s%s\x1b[0m' % (('\x1b[32m' if p.proc.is_alive() else '\x1b[31m'), p.name)) for p in managed_processes.values() if p.proc]
        cloudlog.debug(' '.join(running_list))
        msg = messaging.new_message('managerState')
        msg.managerState.processes = [p.get_process_state_msg() for p in managed_processes.values()]
        pm.send('managerState', msg)
        if params.get_bool('DoUninstall'):
            break