Skip to content

Commit

Permalink
Skip registration on newer devices (commaai#34316)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored Dec 27, 2024
1 parent 2e0c91c commit 9cf02ca
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ std::unordered_map<std::string, uint32_t> keys = {
{"GsmRoaming", PERSISTENT},
{"HardwareSerial", PERSISTENT},
{"HasAcceptedTerms", PERSISTENT},
{"IMEI", PERSISTENT},
{"InstallDate", PERSISTENT},
{"IsDriverViewEnabled", CLEAR_ON_MANAGER_START},
{"IsEngaged", PERSISTENT},
Expand Down
8 changes: 1 addition & 7 deletions system/athena/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions system/athena/tests/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions system/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 9cf02ca

Please sign in to comment.