From 2a6e025183aadce2dd415239efcfab35b971c11d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 30 May 2024 02:08:31 -0700 Subject: [PATCH] ui: re-generate JWT on valid system time (#32571) * revert me * Revert "revert me" This reverts commit 17d815ddfc9a18f7fb9f39f89ec8b4481389b339. * duh we have timed! * clean up * use clocks * re-initialize map on SSL handshake failure (time) * this is fine, takes some time to init * fix * log errors like map renderer * more clean up full message is "loading style failed: SSL handshake failed" * MOAR * we still can't swap the token live * mbgl has its own retries that never work, don't reinit multiple times at once * simpler * more * whoops * this works * fix from merge * rm * fix cmt * only an issue calling the function inside itself old-commit-hash: 57d64279bdd0a8935586d7f58b68edaf793a73ed --- selfdrive/ui/qt/maps/map.cc | 8 ++++++++ selfdrive/ui/qt/maps/map.h | 1 + selfdrive/ui/ui.cc | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index bb66f0869d..490eb118ca 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -119,6 +119,14 @@ void MapWindow::updateState(const UIState &s) { const SubMaster &sm = *(s.sm); update(); + // on rising edge of a valid system time, reinitialize the map to set a new token + if (sm.valid("clocks") && !prev_time_valid) { + LOGW("Time is now valid, reinitializing map"); + m_settings.setApiKey(get_mapbox_token()); + initializeGL(); + } + prev_time_valid = sm.valid("clocks"); + if (sm.updated("liveLocationKalman")) { auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman(); auto locationd_pos = locationd_location.getPositionGeodetic(); diff --git a/selfdrive/ui/qt/maps/map.h b/selfdrive/ui/qt/maps/map.h index 8193d55729..31a44f27b1 100644 --- a/selfdrive/ui/qt/maps/map.h +++ b/selfdrive/ui/qt/maps/map.h @@ -51,6 +51,7 @@ private: void setError(const QString &err_str); bool loaded_once = false; + bool prev_time_valid = true; // Panning QPointF m_lastPos; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 0ff4f3111a..c70b7594c9 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -249,7 +249,7 @@ UIState::UIState(QObject *parent) : QObject(parent) { sm = std::make_unique>({ "modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman", "driverStateV2", - "wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan", + "wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan", "clocks", }); Params params;