Only show update alert if updater failed once since reboot (#1078)
* Only show update alert if updater failed * no negetive days in warning message * Also increase failed count when no internet * Only set count to zero on actual update * First run always fails because IsOffroad is not set yetpull/1079/head
parent
5bd9d49b29
commit
a5bd1d2a88
|
@ -93,6 +93,7 @@ keys = {
|
|||
"TermsVersion": [TxType.PERSISTENT],
|
||||
"TrainingVersion": [TxType.PERSISTENT],
|
||||
"UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START],
|
||||
"UpdateFailedCount": [TxType.CLEAR_ON_MANAGER_START],
|
||||
"Version": [TxType.PERSISTENT],
|
||||
"Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
|
||||
"Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START],
|
||||
|
|
|
@ -272,13 +272,16 @@ def thermald_thread():
|
|||
last_update = now
|
||||
dt = now - last_update
|
||||
|
||||
if dt.days > DAYS_NO_CONNECTIVITY_MAX:
|
||||
update_failed_count = params.get("UpdateFailedCount")
|
||||
update_failed_count = 0 if update_failed_count is None else int(update_failed_count)
|
||||
|
||||
if dt.days > DAYS_NO_CONNECTIVITY_MAX and update_failed_count > 1:
|
||||
if current_connectivity_alert != "expired":
|
||||
current_connectivity_alert = "expired"
|
||||
params.delete("Offroad_ConnectivityNeededPrompt")
|
||||
params.put("Offroad_ConnectivityNeeded", json.dumps(OFFROAD_ALERTS["Offroad_ConnectivityNeeded"]))
|
||||
elif dt.days > DAYS_NO_CONNECTIVITY_PROMPT:
|
||||
remaining_time = str(DAYS_NO_CONNECTIVITY_MAX - dt.days)
|
||||
remaining_time = str(max(DAYS_NO_CONNECTIVITY_MAX - dt.days, 0))
|
||||
if current_connectivity_alert != "prompt" + remaining_time:
|
||||
current_connectivity_alert = "prompt" + remaining_time
|
||||
alert_connectivity_prompt = copy.copy(OFFROAD_ALERTS["Offroad_ConnectivityNeededPrompt"])
|
||||
|
|
|
@ -293,6 +293,7 @@ def attempt_update():
|
|||
|
||||
|
||||
def main(gctx=None):
|
||||
update_failed_count = 0
|
||||
overlay_init_done = False
|
||||
wait_helper = WaitTimeHelper()
|
||||
params = Params()
|
||||
|
@ -312,6 +313,7 @@ def main(gctx=None):
|
|||
raise RuntimeError("couldn't get overlay lock; is another updated running?")
|
||||
|
||||
while True:
|
||||
update_failed_count += 1
|
||||
time_wrong = datetime.datetime.now().year < 2019
|
||||
ping_failed = subprocess.call(["ping", "-W", "4", "-c", "1", "8.8.8.8"])
|
||||
|
||||
|
@ -335,6 +337,7 @@ def main(gctx=None):
|
|||
|
||||
if params.get("IsOffroad") == b"1":
|
||||
attempt_update()
|
||||
update_failed_count = 0
|
||||
else:
|
||||
cloudlog.info("not running updater, openpilot running")
|
||||
|
||||
|
@ -348,8 +351,8 @@ def main(gctx=None):
|
|||
overlay_init_done = False
|
||||
except Exception:
|
||||
cloudlog.exception("uncaught updated exception, shouldn't happen")
|
||||
overlay_init_done = False
|
||||
|
||||
params.put("UpdateFailedCount", str(update_failed_count))
|
||||
wait_between_updates(wait_helper.ready_event)
|
||||
if wait_helper.shutdown:
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue