From c7dd344f2e41c1cf587d2c2dcb7f13428ab74883 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 25 Feb 2021 22:19:53 -0800 Subject: [PATCH] neos networking (#20165) * neos networking * tethering * cleanup * stretch * cleanup Co-authored-by: Comma Device --- SConstruct | 120 ++++++++++++++-------------- selfdrive/ui/qt/offroad/settings.cc | 34 +++++++- 2 files changed, 92 insertions(+), 62 deletions(-) diff --git a/SConstruct b/SConstruct index a353e2c2d..fbd3a2e4c 100644 --- a/SConstruct +++ b/SConstruct @@ -263,71 +263,69 @@ else: Export('envCython') # Qt build environment -qt_env = None -if arch in ["x86_64", "Darwin", "larch64", "aarch64"]: - qt_env = env.Clone() +qt_env = env.Clone() - qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia"] - if arch != "aarch64": - qt_modules += ["DBus", "WebEngine", "WebEngineWidgets"] +qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia"] +if arch != "aarch64": + qt_modules += ["DBus", "WebEngine", "WebEngineWidgets"] - qt_libs = [] - if arch == "Darwin": - qt_env['QTDIR'] = "/usr/local/opt/qt" - QT_BASE = "/usr/local/opt/qt/" - qt_dirs = [ - QT_BASE + "include/", - ] - qt_dirs += [f"{QT_BASE}include/Qt{m}" for m in qt_modules] - qt_env["LINKFLAGS"] += ["-F" + QT_BASE + "lib"] - qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"] - elif arch == "aarch64": - qt_env['QTDIR'] = "/system/comma/usr" - qt_dirs = [ - f"/system/comma/usr/include/qt", - ] - qt_dirs += [f"/system/comma/usr/include/qt/Qt{m}" for m in qt_modules] - - qt_libs = [f"Qt5{m}" for m in qt_modules] - qt_libs += ['EGL', 'GLESv3', 'c++_shared'] - else: - qt_env['QTDIR'] = "/usr" - qt_dirs = [ - f"/usr/include/{real_arch}-linux-gnu/qt5", - f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.5.1/QtGui", - f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.12.8/QtGui", - ] - qt_dirs += [f"/usr/include/{real_arch}-linux-gnu/qt5/Qt{m}" for m in qt_modules] - - qt_libs = [f"Qt5{m}" for m in qt_modules] - if arch == "larch64": - qt_libs += ["GLESv2", "wayland-client"] - elif arch != "Darwin": - qt_libs += ["GL"] - - qt_env.Tool('qt') - qt_env['CPPPATH'] += qt_dirs + ["#selfdrive/ui/qt/"] - qt_flags = [ - "-D_REENTRANT", - "-DQT_NO_DEBUG", - "-DQT_WIDGETS_LIB", - "-DQT_GUI_LIB", - "-DQT_CORE_LIB" +qt_libs = [] +if arch == "Darwin": + qt_env['QTDIR'] = "/usr/local/opt/qt" + QT_BASE = "/usr/local/opt/qt/" + qt_dirs = [ + QT_BASE + "include/", ] - qt_env['CXXFLAGS'] += qt_flags - qt_env['LIBPATH'] += ['#selfdrive/ui'] - qt_env['LIBS'] = qt_libs + qt_dirs += [f"{QT_BASE}include/Qt{m}" for m in qt_modules] + qt_env["LINKFLAGS"] += ["-F" + QT_BASE + "lib"] + qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"] +elif arch == "aarch64": + qt_env['QTDIR'] = "/system/comma/usr" + qt_dirs = [ + f"/system/comma/usr/include/qt", + ] + qt_dirs += [f"/system/comma/usr/include/qt/Qt{m}" for m in qt_modules] - if GetOption("clazy"): - checks = [ - "level0", - "level1", - "no-range-loop", - "no-non-pod-global-static", - ] - qt_env['CXX'] = 'clazy' - qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0] - qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks) + qt_libs = [f"Qt5{m}" for m in qt_modules] + qt_libs += ['EGL', 'GLESv3', 'c++_shared'] +else: + qt_env['QTDIR'] = "/usr" + qt_dirs = [ + f"/usr/include/{real_arch}-linux-gnu/qt5", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.5.1/QtGui", + f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.12.8/QtGui", + ] + qt_dirs += [f"/usr/include/{real_arch}-linux-gnu/qt5/Qt{m}" for m in qt_modules] + + qt_libs = [f"Qt5{m}" for m in qt_modules] + if arch == "larch64": + qt_libs += ["GLESv2", "wayland-client"] + elif arch != "Darwin": + qt_libs += ["GL"] + +qt_env.Tool('qt') +qt_env['CPPPATH'] += qt_dirs + ["#selfdrive/ui/qt/"] +qt_flags = [ + "-D_REENTRANT", + "-DQT_NO_DEBUG", + "-DQT_WIDGETS_LIB", + "-DQT_GUI_LIB", + "-DQT_CORE_LIB" +] +qt_env['CXXFLAGS'] += qt_flags +qt_env['LIBPATH'] += ['#selfdrive/ui'] +qt_env['LIBS'] = qt_libs + +if GetOption("clazy"): + checks = [ + "level0", + "level1", + "no-range-loop", + "no-non-pod-global-static", + ] + qt_env['CXX'] = 'clazy' + qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0] + qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks) Export('qt_env') diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index a68f53d76..377fd53dd 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -151,7 +151,7 @@ QWidget * device_panel() { for (auto &l : labels) { device_layout->addWidget(labelWidget(QString::fromStdString(l.first), QString::fromStdString(l.second)), 0, Qt::AlignTop); } - + QPushButton* dcam_view = new QPushButton("Driver camera view"); device_layout->addWidget(dcam_view, 0, Qt::AlignBottom); device_layout->addWidget(horizontal_line(), Qt::AlignBottom); @@ -237,7 +237,39 @@ QWidget * developer_panel() { QWidget * network_panel(QWidget * parent) { #ifdef QCOM + QVBoxLayout *layout = new QVBoxLayout; + layout->setMargin(100); + layout->setSpacing(30); + + // TODO: can probably use the ndk for this + // simple wifi + tethering buttons + std::vector> btns = { + {"Open WiFi Settings", "am start -n com.android.settings/.wifi.WifiPickerActivity \ + -a android.net.wifi.PICK_WIFI_NETWORK \ + --ez extra_prefs_show_button_bar true \ + --es extra_prefs_set_next_text ''"}, + {"Open Tethering Settings", "am start -n com.android.settings/.TetherSettings \ + --ez extra_prefs_show_button_bar true \ + --es extra_prefs_set_next_text ''"}, + }; + for (auto &b : btns) { + QPushButton *btn = new QPushButton(b.first); + layout->addWidget(btn, 0, Qt::AlignTop); + QObject::connect(btn, &QPushButton::released, [=]() { std::system(b.second); }); + } + layout->addStretch(1); + QWidget *w = new QWidget; + w->setLayout(layout); + w->setStyleSheet(R"( + QPushButton { + padding: 0; + height: 120px; + border-radius: 15px; + background-color: #393939; + } + )"); + #else Networking *w = new Networking(parent); #endif