diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index cc7cdd87a..cd00e6b50 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -163,6 +163,8 @@ def upload_handler(end_event: threading.Event) -> None: sm = messaging.SubMaster(['deviceState']) tid = threading.get_ident() + cellular_unmetered = Params().get_bool("CellularUnmetered") + while not end_event.is_set(): cur_upload_items[tid] = None @@ -182,7 +184,7 @@ def upload_handler(end_event: threading.Event) -> None: # Check if uploading over cell is allowed sm.update(0) cell = sm['deviceState'].networkType not in [NetworkType.wifi, NetworkType.ethernet] - if cell and (not cur_upload_items[tid].allow_cellular): + if cell and (not cur_upload_items[tid].allow_cellular) and (not cellular_unmetered): retry_upload(tid, end_event, False) continue diff --git a/selfdrive/athena/tests/helpers.py b/selfdrive/athena/tests/helpers.py index 26655b4a3..bb5fcd106 100644 --- a/selfdrive/athena/tests/helpers.py +++ b/selfdrive/athena/tests/helpers.py @@ -53,7 +53,8 @@ class MockParams(): default_params = { "DongleId": b"0000000000000000", "GithubSshKeys": b"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC307aE+nuHzTAgaJhzSf5v7ZZQW9gaperjhCmyPyl4PzY7T1mDGenTlVTN7yoVFZ9UfO9oMQqo0n1OwDIiqbIFxqnhrHU0cYfj88rI85m5BEKlNu5RdaVTj1tcbaPpQc5kZEolaI1nDDjzV0lwS7jo5VYDHseiJHlik3HH1SgtdtsuamGR2T80q1SyW+5rHoMOJG73IH2553NnWuikKiuikGHUYBd00K1ilVAK2xSiMWJp55tQfZ0ecr9QjEsJ+J/efL4HqGNXhffxvypCXvbUYAFSddOwXUPo5BTKevpxMtH+2YrkpSjocWA04VnTYFiPG6U4ItKmbLOTFZtPzoez private", # noqa: E501 - "AthenadUploadQueue": '[]' + "AthenadUploadQueue": '[]', + "CellularUnmetered": False, } params = default_params.copy() @@ -61,6 +62,9 @@ class MockParams(): def restore_defaults(): MockParams.params = MockParams.default_params.copy() + def get_bool(self, k): + return bool(MockParams.params.get(k)) + def get(self, k, encoding=None): ret = MockParams.params.get(k) if ret is not None and encoding is not None: diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 3f64f790c..5bb49d7ce 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -91,6 +91,7 @@ std::unordered_map keys = { {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"CarParamsCache", CLEAR_ON_MANAGER_START}, {"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, + {"CellularUnmetered", PERSISTENT}, {"CompletedTrainingVersion", PERSISTENT}, {"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"CurrentRoute", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON},