From 9cf02ca8db5405d0464d5d9a6a81c9aee479c3e1 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 26 Dec 2024 20:22:44 -0800 Subject: [PATCH] Skip registration on newer devices (#34316) --- common/params.cc | 1 - system/athena/registration.py | 8 +------- system/athena/tests/test_registration.py | 2 -- system/manager/manager.py | 5 +++-- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/common/params.cc b/common/params.cc index 2011b5213195bf..abdfb6e2757724 100644 --- a/common/params.cc +++ b/common/params.cc @@ -133,7 +133,6 @@ std::unordered_map keys = { {"GsmRoaming", PERSISTENT}, {"HardwareSerial", PERSISTENT}, {"HasAcceptedTerms", PERSISTENT}, - {"IMEI", PERSISTENT}, {"InstallDate", PERSISTENT}, {"IsDriverViewEnabled", CLEAR_ON_MANAGER_START}, {"IsEngaged", PERSISTENT}, diff --git a/system/athena/registration.py b/system/athena/registration.py index a1e8605a9d5a0b..964fbff51e6cd8 100755 --- a/system/athena/registration.py +++ b/system/athena/registration.py @@ -33,20 +33,17 @@ def register(show_spinner=False) -> str | None: """ params = Params() - IMEI = params.get("IMEI", encoding='utf8') - HardwareSerial = params.get("HardwareSerial", encoding='utf8') dongle_id: str | None = params.get("DongleId", encoding='utf8') if dongle_id is None and Path(Paths.persist_root()+"/comma/dongle_id").is_file(): # not all devices will have this; added early in comma 3X production (2/28/24) with open(Paths.persist_root()+"/comma/dongle_id") as f: dongle_id = f.read().strip() - needs_registration = None in (IMEI, HardwareSerial, dongle_id) pubkey = Path(Paths.persist_root()+"/comma/id_rsa.pub") if not pubkey.is_file(): dongle_id = UNREGISTERED_DONGLE_ID cloudlog.warning(f"missing public key: {pubkey}") - elif needs_registration: + elif dongle_id is None: if show_spinner: spinner = Spinner() spinner.update("registering device") @@ -71,9 +68,6 @@ def register(show_spinner=False) -> str | None: if time.monotonic() - start_time > 60 and show_spinner: spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})") - params.put("IMEI", imei1) - params.put("HardwareSerial", serial) - backoff = 0 start_time = time.monotonic() while True: diff --git a/system/athena/tests/test_registration.py b/system/athena/tests/test_registration.py index 17ebaa472d4f13..c1dabb78ecb249 100644 --- a/system/athena/tests/test_registration.py +++ b/system/athena/tests/test_registration.py @@ -32,8 +32,6 @@ def _generate_keys(self): def test_valid_cache(self, mocker): # if all params are written, return the cached dongle id. # should work with a dongle ID on either /persist/ or normal params - self.params.put("IMEI", "imei") - self.params.put("HardwareSerial", "serial") self._generate_keys() dongle = "DONGLE_ID_123" diff --git a/system/manager/manager.py b/system/manager/manager.py index 4a5da353e99681..89e5a472f23c86 100755 --- a/system/manager/manager.py +++ b/system/manager/manager.py @@ -58,7 +58,8 @@ def manager_init() -> None: except PermissionError: print(f"WARNING: failed to make {Paths.shm_path()}") - # set version params + # set params + serial = HARDWARE.get_serial() params.put("Version", build_metadata.openpilot.version) params.put("TermsVersion", terms_version) params.put("TrainingVersion", training_version) @@ -68,13 +69,13 @@ def manager_init() -> None: params.put("GitRemote", build_metadata.openpilot.git_origin) params.put_bool("IsTestedBranch", build_metadata.tested_channel) params.put_bool("IsReleaseBranch", build_metadata.release_channel) + params.put("HardwareSerial", serial) # set dongle id reg_res = register(show_spinner=True) if reg_res: dongle_id = reg_res else: - serial = params.get("HardwareSerial") raise Exception(f"Registration failed for device {serial}") os.environ['DONGLE_ID'] = dongle_id # Needed for swaglog os.environ['GIT_ORIGIN'] = build_metadata.openpilot.git_normalized_origin # Needed for swaglog