ui: re-generate JWT on valid system time (#32571)

* revert me

* Revert "revert me"

This reverts commit 17d815ddfc.

* 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: 57d64279bd
pull/32103/head
Shane Smiskol 11 months ago committed by GitHub
parent 3a1c7c61c6
commit 2a6e025183
  1. 8
      selfdrive/ui/qt/maps/map.cc
  2. 1
      selfdrive/ui/qt/maps/map.h
  3. 2
      selfdrive/ui/ui.cc

@ -119,6 +119,14 @@ void MapWindow::updateState(const UIState &s) {
const SubMaster &sm = *(s.sm); const SubMaster &sm = *(s.sm);
update(); 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")) { if (sm.updated("liveLocationKalman")) {
auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman(); auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman();
auto locationd_pos = locationd_location.getPositionGeodetic(); auto locationd_pos = locationd_location.getPositionGeodetic();

@ -51,6 +51,7 @@ private:
void setError(const QString &err_str); void setError(const QString &err_str);
bool loaded_once = false; bool loaded_once = false;
bool prev_time_valid = true;
// Panning // Panning
QPointF m_lastPos; QPointF m_lastPos;

@ -249,7 +249,7 @@ UIState::UIState(QObject *parent) : QObject(parent) {
sm = std::make_unique<SubMaster, const std::initializer_list<const char *>>({ sm = std::make_unique<SubMaster, const std::initializer_list<const char *>>({
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState", "modelV2", "controlsState", "liveCalibration", "radarState", "deviceState",
"pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman", "driverStateV2", "pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman", "driverStateV2",
"wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan", "wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan", "clocks",
}); });
Params params; Params params;

Loading…
Cancel
Save