filter out touches while in android activity (#20515)
* filter touches while in android activity * only check after launching activity * move to hw abstraction layer * little cleanup * remove print Co-authored-by: Comma Device <device@comma.ai>albatross
parent
318fa3f50a
commit
a2084c2a60
|
@ -40,4 +40,26 @@ public:
|
|||
std::string cmd = util::string_format("setprop persist.neos.ssh %d", enabled ? 1 : 0);
|
||||
std::system(cmd.c_str());
|
||||
};
|
||||
|
||||
// android only
|
||||
inline static bool launched_activity = false;
|
||||
static void check_activity() {
|
||||
int ret = std::system("dumpsys SurfaceFlinger --list | grep -Fq 'com.android.settings'");
|
||||
launched_activity = ret == 0;
|
||||
}
|
||||
static void launch_activity(std::string activity, std::string opts = "") {
|
||||
if (!launched_activity) {
|
||||
std::string cmd = "am start -n " + activity + " " + opts +
|
||||
" --ez extra_prefs_show_button_bar true \
|
||||
--es extra_prefs_set_next_text ''";
|
||||
std::system(cmd.c_str());
|
||||
}
|
||||
launched_activity = true;
|
||||
}
|
||||
static void launch_wifi() {
|
||||
launch_activity("com.android.settings/.wifi.WifiPickerActivity", "-a android.net.wifi.PICK_WIFI_NETWORK");
|
||||
}
|
||||
static void launch_tethering() {
|
||||
launch_activity("com.android.settings/.TetherSettings");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -203,22 +203,13 @@ QWidget * network_panel(QWidget * parent) {
|
|||
layout->setMargin(100);
|
||||
layout->setSpacing(30);
|
||||
|
||||
// simple wifi + tethering buttons
|
||||
const char* launch_wifi = "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 ''";
|
||||
// wifi + tethering buttons
|
||||
layout->addWidget(new ButtonControl("WiFi Settings", "OPEN", "",
|
||||
[=]() { std::system(launch_wifi); }));
|
||||
|
||||
[=]() { HardwareEon::launch_wifi(); }));
|
||||
layout->addWidget(horizontal_line());
|
||||
|
||||
const char* launch_tethering = "am start -n com.android.settings/.TetherSettings \
|
||||
--ez extra_prefs_show_button_bar true \
|
||||
--es extra_prefs_set_next_text ''";
|
||||
layout->addWidget(new ButtonControl("Tethering Settings", "OPEN", "",
|
||||
[=]() { std::system(launch_tethering); }));
|
||||
|
||||
[=]() { HardwareEon::launch_tethering(); }));
|
||||
layout->addWidget(horizontal_line());
|
||||
|
||||
// SSH key management
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "window.hpp"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
|
||||
main_layout = new QStackedLayout;
|
||||
|
@ -54,8 +55,20 @@ void MainWindow::reviewTrainingGuide() {
|
|||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *obj, QEvent *event){
|
||||
// wake screen on tap
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
homeWindow->glWindow->wake();
|
||||
}
|
||||
|
||||
// filter out touches while in android activity
|
||||
#ifdef QCOM
|
||||
const QList<QEvent::Type> filter_events = {QEvent::MouseButtonPress, QEvent::MouseMove, QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd};
|
||||
if (HardwareEon::launched_activity && filter_events.contains(event->type())) {
|
||||
HardwareEon::check_activity();
|
||||
if (HardwareEon::launched_activity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue