mirror of
https://jihulab.com/mr-one/openpilot.git
synced 2026-10-26 20:43:49 +08:00
ui: expose limited branch switcher in updates menu
This commit is contained in:
@@ -8,7 +8,6 @@ import subprocess
|
||||
|
||||
from openpilot.selfdrive.ui.layouts.settings.software import SoftwareLayout
|
||||
from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
from openpilot.common.hardware import HARDWARE
|
||||
from openpilot.system.ui.lib.application import gui_app
|
||||
from openpilot.system.ui.lib.multilang import tr, tr_noop
|
||||
from openpilot.system.ui.widgets import DialogResult
|
||||
@@ -28,6 +27,9 @@ DESCRIPTIONS = {
|
||||
}
|
||||
|
||||
|
||||
ALLOWED_BRANCHES = ("3xl", "c3xl-dev", "test")
|
||||
|
||||
|
||||
class SoftwareLayoutSP(SoftwareLayout):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@@ -37,6 +39,7 @@ class SoftwareLayoutSP(SoftwareLayout):
|
||||
initial_state=ui_state.params.get_bool("DisableUpdates"),
|
||||
callback=self._on_disable_updates_toggled,
|
||||
)
|
||||
self._scroller.add_widget(self._branch_btn)
|
||||
self._scroller.add_widget(self.disable_updates_toggle)
|
||||
|
||||
def _handle_reboot(self, result):
|
||||
@@ -51,26 +54,13 @@ class SoftwareLayoutSP(SoftwareLayout):
|
||||
gui_app.push_widget(dialog)
|
||||
|
||||
def _on_select_branch(self):
|
||||
current_git_branch = ui_state.params.get("GitBranch") or ""
|
||||
branches_str = ui_state.params.get("UpdaterAvailableBranches") or ""
|
||||
branches = [b for b in branches_str.split(",") if b]
|
||||
branches = list(ALLOWED_BRANCHES)
|
||||
current_target = ui_state.params.get("UpdaterTargetBranch") or ""
|
||||
top_level_branches = [current_git_branch, "release-mici", "release-tizi", "staging", "dev", "master"]
|
||||
if current_target not in branches:
|
||||
current_target = ""
|
||||
|
||||
if HARDWARE.get_device_type() == "tici":
|
||||
top_level_branches = ["release-tici", "staging-tici"]
|
||||
branches = [b for b in branches if b.endswith("-tici")]
|
||||
|
||||
top_level_nodes = [TreeNode(b, {'display_name': b}) for b in top_level_branches if b in branches]
|
||||
remaining_branches = [b for b in branches if b not in top_level_branches]
|
||||
prebuilt_nodes = [TreeNode(b, {'display_name': b}) for b in remaining_branches if b.endswith("-prebuilt")]
|
||||
non_prebuilt_nodes = [TreeNode(b, {'display_name': b}) for b in remaining_branches if not b.endswith("-prebuilt")]
|
||||
|
||||
folders = [
|
||||
TreeFolder("", top_level_nodes),
|
||||
TreeFolder("Prebuilt Branches", prebuilt_nodes),
|
||||
TreeFolder("Non-Prebuilt Branches", non_prebuilt_nodes),
|
||||
]
|
||||
top_level_nodes = [TreeNode(branch, {'display_name': branch}) for branch in branches]
|
||||
folders = [TreeFolder("", top_level_nodes)]
|
||||
|
||||
def _on_branch_selected(result):
|
||||
if result == DialogResult.CONFIRM and self._branch_dialog is not None:
|
||||
@@ -88,6 +78,7 @@ class SoftwareLayoutSP(SoftwareLayout):
|
||||
|
||||
def _update_state(self):
|
||||
super()._update_state()
|
||||
self._branch_btn.set_visible(ui_state.is_offroad())
|
||||
show_advanced = ui_state.params.get_bool("ShowAdvancedControls")
|
||||
self.disable_updates_toggle.action_item.set_enabled(ui_state.is_offroad())
|
||||
self.disable_updates_toggle.set_visible(show_advanced)
|
||||
|
||||
Reference in New Issue
Block a user