From 47a983fb00f90881715c5f1105d1ac1b637ee13b Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 14 Sep 2021 20:24:41 -0700 Subject: [PATCH] updated: add persistent param for build date (#22237) old-commit-hash: ed70c5aaf537d14ca870d30851172c7a5242b7d1 --- selfdrive/common/params.cc | 3 ++- selfdrive/updated.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index b261855b4e..c7ef3c0fcb 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -153,8 +153,9 @@ std::unordered_map keys = { {"GsmRoaming", PERSISTENT}, {"HardwareSerial", PERSISTENT}, {"HasAcceptedTerms", PERSISTENT}, - {"IsDriverViewEnabled", CLEAR_ON_MANAGER_START}, {"IMEI", PERSISTENT}, + {"InstallDate", PERSISTENT}, + {"IsDriverViewEnabled", CLEAR_ON_MANAGER_START}, {"IsLdwEnabled", PERSISTENT}, {"IsMetric", PERSISTENT}, {"IsOffroad", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/updated.py b/selfdrive/updated.py index f3fb5d8d8f..3865d1228b 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -346,6 +346,12 @@ def main(): if EON and os.geteuid() != 0: raise RuntimeError("updated must be launched as root!") + ov_lock_fd = open(LOCK_FILE, 'w') + try: + fcntl.flock(ov_lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + except IOError as e: + raise RuntimeError("couldn't get overlay lock; is another updated running?") from e + # Set low io priority proc = psutil.Process() if psutil.LINUX: @@ -355,11 +361,9 @@ def main(): if Path(os.path.join(STAGING_ROOT, "old_openpilot")).is_dir(): cloudlog.event("update installed") - ov_lock_fd = open(LOCK_FILE, 'w') - try: - fcntl.flock(ov_lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) - except IOError as e: - raise RuntimeError("couldn't get overlay lock; is another updated running?") from e + if not params.get("InstallDate"): + t = datetime.datetime.utcnow().isoformat() + params.put("InstallDate", t.encode('utf8')) # Wait for IsOffroad to be set before our first update attempt wait_helper = WaitTimeHelper(proc)