Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ runs:
uses: ./.github/workflows/auto-cache
with:
path: /tmp/scons_cache
key: scons-${{ runner.arch }}-${{ env.CACHE_COMMIT_DATE }}-${{ github.sha }}
key: scons-${{ runner.os }}-${{ runner.arch }}-${{ env.CACHE_COMMIT_DATE }}-${{ github.sha }}
restore-keys: |
scons-${{ runner.arch }}-${{ env.CACHE_COMMIT_DATE }}
scons-${{ runner.arch }}
scons-${{ runner.os }}-${{ runner.arch }}-${{ env.CACHE_COMMIT_DATE }}
scons-${{ runner.os }}-${{ runner.arch }}
# venv cache
- id: venv-cache
uses: ./.github/workflows/auto-cache
with:
path: ${{ github.workspace }}/.venv
key: venv-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('uv.lock') }}
restore-keys: |
venv-${{ runner.os }}-${{ runner.arch }}
- shell: bash
name: Run setup
run: ./tools/op.sh setup
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,9 @@ jobs:
- uses: actions/checkout@v6
with:
submodules: true
- run: echo "CACHE_COMMIT_DATE=$(git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d-%H:%M')" >> $GITHUB_ENV
- name: Install dependencies
run: ./tools/mac_setup.sh
env:
HOMEBREW_DISPLAY_INSTALL_TIMES: 1
- run: git lfs pull
- name: Getting scons cache
uses: ./.github/workflows/auto-cache
with:
path: /tmp/scons_cache
key: scons-${{ runner.arch }}-macos-${{ env.CACHE_COMMIT_DATE }}-${{ github.sha }}
restore-keys: |
scons-${{ runner.arch }}-macos-${{ env.CACHE_COMMIT_DATE }}
scons-${{ runner.arch }}-macos
- uses: ./.github/workflows/setup-with-retry
- name: Building openpilot
run: . .venv/bin/activate && scons
run: scons

static_analysis:
name: static analysis
Expand Down
26 changes: 22 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import os
import pytest

from openpilot.common.prefix import OpenpilotPrefix
from openpilot.system.manager import manager
from openpilot.system.hardware import TICI, HARDWARE
# Heavy imports (OpenpilotPrefix, manager, HARDWARE, TICI) are deferred to
# first use so that `pytest --collect-only` does not pay for them upfront.
# OpenpilotPrefix, manager, and HARDWARE are only needed at test-execution
# time (inside fixtures). TICI is needed during collection_modifyitems but
# is cached after the first import so the hardware module is loaded at most
# once.

# TODO: pytest-cpp doesn't support FAIL, and we need to create test translations in sessionstart
# pending https://github.com/pytest-dev/pytest-cpp/pull/147
Expand Down Expand Up @@ -47,6 +50,9 @@ def clean_env():

@pytest.fixture(scope="function", autouse=True)
def openpilot_function_fixture(request):
from openpilot.common.prefix import OpenpilotPrefix
from openpilot.system.manager import manager

with clean_env():
# setup a clean environment for each test
with OpenpilotPrefix(shared_download_cache=request.node.get_closest_marker("shared_download_cache") is not None) as prefix:
Expand Down Expand Up @@ -78,17 +84,29 @@ def tici_setup_fixture(request, openpilot_function_fixture):
"""Ensure a consistent state for tests on-device. Needs the openpilot function fixture to run first."""
if 'skip_tici_setup' in request.keywords:
return
from openpilot.system.hardware import HARDWARE
HARDWARE.initialize_hardware()
HARDWARE.set_power_save(False)
os.system("pkill -9 -f athena")


_tici_cached = None


def _is_tici():
global _tici_cached
if _tici_cached is None:
from openpilot.system.hardware import TICI
_tici_cached = TICI
return _tici_cached


@pytest.hookimpl(tryfirst=True)
def pytest_collection_modifyitems(config, items):
skipper = pytest.mark.skip(reason="Skipping tici test on PC")
for item in items:
if "tici" in item.keywords:
if not TICI:
if not _is_tici():
item.add_marker(skipper)
else:
item.fixturenames.append('tici_setup_fixture')
Expand Down
15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,20 @@ allow-direct-references = true

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--ignore=openpilot/ --ignore=opendbc/ --ignore=panda/ --ignore=rednose_repo/ --ignore=tinygrad_repo/ --ignore=teleoprtc_repo/ --ignore=msgq/ -Werror --strict-config --strict-markers --durations=20 --maxprocesses=8 -n auto --dist=loadgroup"
addopts = "-Werror --strict-config --strict-markers --durations=20 --maxprocesses=8 -n auto --dist=loadgroup"
norecursedirs = [
"openpilot",
"opendbc",
"opendbc_repo",
"panda",
"rednose_repo",
"tinygrad_repo",
"teleoprtc_repo",
"msgq",
"third_party",
".git",
"build",
]
cpp_files = "test_*"
cpp_harness = "selfdrive/test/cpp_harness.py"
python_files = "test_*.py"
Expand Down
6 changes: 6 additions & 0 deletions selfdrive/ui/mici/layouts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ def _setup_callbacks(self):
self._onroad_layout.set_click_callback(lambda: self._scroll_to(self._home_layout))
device.add_interactive_timeout_callback(self._on_interactive_timeout)

def show_event(self):
self._scroller.show_event()

def hide_event(self):
self._scroller.hide_event()

def _scroll_to(self, layout: Widget):
layout_x = int(layout.rect.x)
self._scroller.scroll_to(layout_x, smooth=True)
Expand Down
26 changes: 24 additions & 2 deletions selfdrive/ui/mici/layouts/settings/network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,27 @@
from openpilot.selfdrive.ui.lib.prime_state import PrimeType
from openpilot.system.ui.lib.application import gui_app
from openpilot.system.ui.widgets.nav_widget import NavWidget
from openpilot.system.ui.lib.wifi_manager import WifiManager, Network, MeteredType, ConnectStatus, normalize_ssid
from openpilot.system.ui.lib.wifi_manager import WifiManager, Network, MeteredType, ConnectStatus, SecurityType, normalize_ssid


class WifiNetworkButton(BigButton):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._lock_txt = gui_app.texture("icons_mici/settings/network/new/lock.png", 28, 36)
self._draw_lock = False

def set_draw_lock(self, draw: bool):
self._draw_lock = draw

def _draw_content(self, btn_y: float):
super()._draw_content(btn_y)
# Render lock icon at lower right of wifi icon if secured
if self._draw_lock:
icon_x = self._rect.x + self._rect.width - 30 - self._txt_icon.width
icon_y = btn_y + 30
lock_x = icon_x + self._txt_icon.width - self._lock_txt.width + 7
lock_y = icon_y + self._txt_icon.height - self._lock_txt.height + 8
rl.draw_texture_ex(self._lock_txt, (lock_x, lock_y), 0.0, 1.0, rl.WHITE)


class NetworkLayoutMici(NavWidget):
Expand Down Expand Up @@ -68,7 +88,7 @@ def network_metered_callback(value: str):
self._wifi_medium_txt = gui_app.texture("icons_mici/settings/network/wifi_strength_medium.png", 64, 47)
self._wifi_full_txt = gui_app.texture("icons_mici/settings/network/wifi_strength_full.png", 64, 47)

self._wifi_button = BigButton("wi-fi", "not connected", self._wifi_slash_txt, scroll=True)
self._wifi_button = WifiNetworkButton("wi-fi", "not connected", self._wifi_slash_txt, scroll=True)
self._wifi_button.set_click_callback(lambda: gui_app.push_widget(self._wifi_ui))

# ******** Advanced settings ********
Expand Down Expand Up @@ -131,8 +151,10 @@ def _update_state(self):
if display_network is not None:
strength = WifiIcon.get_strength_icon_idx(display_network.strength)
self._wifi_button.set_icon(self._wifi_full_txt if strength == 2 else self._wifi_medium_txt if strength == 1 else self._wifi_low_txt)
self._wifi_button.set_draw_lock(display_network.security_type not in (SecurityType.OPEN, SecurityType.UNSUPPORTED))
else:
self._wifi_button.set_icon(self._wifi_slash_txt)
self._wifi_button.set_draw_lock(False)

def show_event(self):
super().show_event()
Expand Down
3 changes: 3 additions & 0 deletions selfdrive/ui/mici/layouts/settings/network/wifi_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def network(self) -> Network:

@property
def _show_forget_btn(self):
if self._network.is_tethering:
return False

return (self._is_saved and not self._wrong_password) or self._is_connecting

def _handle_mouse_release(self, mouse_pos: MousePos):
Expand Down
8 changes: 5 additions & 3 deletions system/ui/lib/wifi_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,19 @@ class Network:
ssid: str
strength: int
security_type: SecurityType
is_tethering: bool

@classmethod
def from_dbus(cls, ssid: str, aps: list["AccessPoint"]) -> "Network":
def from_dbus(cls, ssid: str, aps: list["AccessPoint"], is_tethering: bool) -> "Network":
# we only want to show the strongest AP for each Network/SSID
strongest_ap = max(aps, key=lambda ap: ap.strength)
security_type = get_security_type(strongest_ap.flags, strongest_ap.wpa_flags, strongest_ap.rsn_flags)

return cls(
ssid=ssid,
strength=strongest_ap.strength,
strength=100 if is_tethering else strongest_ap.strength,
security_type=security_type,
is_tethering=is_tethering,
)


Expand Down Expand Up @@ -820,7 +822,7 @@ def worker():
# catch all for parsing errors
cloudlog.exception(f"Failed to parse AP properties for {ap_path}")

networks = [Network.from_dbus(ssid, ap_list) for ssid, ap_list in aps.items()]
networks = [Network.from_dbus(ssid, ap_list, ssid == self._tethering_ssid) for ssid, ap_list in aps.items()]
networks.sort(key=lambda n: (n.ssid != self._wifi_state.ssid, not self.is_connection_saved(n.ssid), -n.strength, n.ssid.lower()))
self._networks = networks

Expand Down
7 changes: 6 additions & 1 deletion system/ui/widgets/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,12 @@ def _render(self, _):
# draw black fade on left and right
fade_width = 20
rl.draw_rectangle_gradient_h(int(self._rect.x + self._rect.width - fade_width), int(self._rect.y), fade_width, int(self._rect.height), rl.BLANK, rl.BLACK)
if self._scroll_state != ScrollState.STARTING:

# stop drawing left fade once text scrolls past
text_width = visible_sizes[0].x if visible_sizes else 0
first_copy_in_view = self._scroll_offset + text_width > 0
draw_left_fade = self._scroll_state != ScrollState.STARTING and first_copy_in_view
if draw_left_fade:
rl.draw_rectangle_gradient_h(int(self._rect.x), int(self._rect.y), fade_width, int(self._rect.height), rl.BLACK, rl.BLANK)

rl.end_scissor_mode()
Expand Down
Loading