diff --git a/assets/aausb-hot.png b/assets/aausb-hot.png new file mode 100644 index 0000000..559d426 Binary files /dev/null and b/assets/aausb-hot.png differ diff --git a/assets/aawifi-hot.png b/assets/aawifi-hot.png new file mode 100644 index 0000000..2505c4d Binary files /dev/null and b/assets/aawifi-hot.png differ diff --git a/assets/resources.qrc b/assets/resources.qrc index 8a5dba6..74a55be 100644 --- a/assets/resources.qrc +++ b/assets/resources.qrc @@ -5,6 +5,8 @@ ico_setting.png ico_info.png ico_bluetooth.png + aausb-hot.png + aawifi-hot.png cursor-hot.png power-hot.png settings-hot.png diff --git a/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp index c272247..13fde30 100644 --- a/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp +++ b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp @@ -26,6 +26,8 @@ class ConnectDialog : public QDialog public: explicit ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITCPWrapper& tcpWrapper, openauto::autoapp::configuration::IRecentAddressesList& recentAddressesList, QWidget *parent = nullptr); ~ConnectDialog() override; + void autoconnect(); + void loadClientList(); signals: void connectToDevice(const QString& ipAddress); @@ -42,7 +44,6 @@ private slots: private: void insertIpAddress(const std::string& ipAddress); void loadRecentList(); - void loadTempRecentList(); void setControlsEnabledStatus(bool status); void connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket); diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index 18f05c4..34a0fe2 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -86,6 +86,8 @@ signals: void showAlphaSlider(); void showRearCam(); void hideRearCam(); + void TriggerAppStart(); + void TriggerAppStop(); private slots: void on_horizontalSliderBrightness_valueChanged(int value); @@ -143,6 +145,8 @@ private slots: void scanFiles(); void tmpChanged(); void setTrigger(); + void setRetryUSBConnect(); + void resetRetryUSBMessage(); private: Ui::MainWindow* ui_; diff --git a/include/f1x/openauto/autoapp/UI/Warning.hpp b/include/f1x/openauto/autoapp/UI/Warning.hpp new file mode 100644 index 0000000..0b72d93 --- /dev/null +++ b/include/f1x/openauto/autoapp/UI/Warning.hpp @@ -0,0 +1,30 @@ +#include + +namespace Ui { +class Warning; +} + +namespace f1x +{ +namespace openauto +{ +namespace autoapp +{ +namespace ui +{ + +class Warning : public QDialog +{ + Q_OBJECT + +public: + explicit Warning(QWidget *parent = nullptr); + ~Warning() override; + + Ui::Warning* ui_; +}; + +} +} +} +} diff --git a/src/autoapp/Service/AndroidAutoEntity.cpp b/src/autoapp/Service/AndroidAutoEntity.cpp index 50aabf8..81c6702 100644 --- a/src/autoapp/Service/AndroidAutoEntity.cpp +++ b/src/autoapp/Service/AndroidAutoEntity.cpp @@ -157,13 +157,13 @@ void AndroidAutoEntity::onServiceDiscoveryRequest(const aasdk::proto::messages:: aasdk::proto::messages::ServiceDiscoveryResponse serviceDiscoveryResponse; serviceDiscoveryResponse.mutable_channels()->Reserve(256); - serviceDiscoveryResponse.set_head_unit_name("OpenAuto"); + serviceDiscoveryResponse.set_head_unit_name("Crankshaft-NG"); serviceDiscoveryResponse.set_car_model("Universal"); serviceDiscoveryResponse.set_car_year("2018"); serviceDiscoveryResponse.set_car_serial("20180301"); serviceDiscoveryResponse.set_left_hand_drive_vehicle(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE); serviceDiscoveryResponse.set_headunit_manufacturer("f1x"); - serviceDiscoveryResponse.set_headunit_model("OpenAuto Autoapp"); + serviceDiscoveryResponse.set_headunit_model("Crankshaft-NG Autoapp"); serviceDiscoveryResponse.set_sw_build("1"); serviceDiscoveryResponse.set_sw_version("1.0"); serviceDiscoveryResponse.set_can_play_native_media_during_vr(false); diff --git a/src/autoapp/Service/SensorService.cpp b/src/autoapp/Service/SensorService.cpp index 2308fef..6aa1489 100644 --- a/src/autoapp/Service/SensorService.cpp +++ b/src/autoapp/Service/SensorService.cpp @@ -19,8 +19,7 @@ #include #include #include -#include -#include +#include namespace f1x { @@ -123,16 +122,12 @@ void SensorService::sendDrivingStatusUnrestricted() void SensorService::sendNightData() { aasdk::proto::messages::SensorEventIndication indication; - - QFileInfo nightSwitchFile("/tmp/night_mode_enabled"); - bool nightSwitchExists = nightSwitchFile.exists(); - - if (!nightSwitchExists) { - OPENAUTO_LOG(error) << "[CS] [SensorService] Mode day triggered"; - indication.add_night_mode()->set_is_night(false); + if (!std::ifstream("/tmp/night_mode_enabled")) { + OPENAUTO_LOG(error) << "[CS] [SensorService] Mode day triggered"; + indication.add_night_mode()->set_is_night(false); } else { - indication.add_night_mode()->set_is_night(true); - OPENAUTO_LOG(error) << "[CS] [SensorService] Mode night triggered"; + indication.add_night_mode()->set_is_night(true); + OPENAUTO_LOG(error) << "[CS] [SensorService] Mode night triggered"; } auto promise = aasdk::channel::SendPromise::defer(strand_); diff --git a/src/autoapp/Service/VideoService.cpp b/src/autoapp/Service/VideoService.cpp index 6c680f6..35a363e 100644 --- a/src/autoapp/Service/VideoService.cpp +++ b/src/autoapp/Service/VideoService.cpp @@ -18,6 +18,7 @@ #include #include +#include namespace f1x { @@ -162,8 +163,14 @@ void VideoService::onVideoFocusRequest(const aasdk::proto::messages::VideoFocusR // stop video service on go back to openauto if (request.focus_mode() == 2) { - OPENAUTO_LOG(info) << "[VideoService] Stop video service..."; - VideoService::stop(); + OPENAUTO_LOG(info) << "[VideoService] Exit entity..."; + try { + if (!std::ifstream("/tmp/entityexit")) { + std::ofstream("/tmp/entityexit"); + } + } catch (...) { + OPENAUTO_LOG(error) << "[VideoService] Error in creating entityexit"; + } } } diff --git a/src/autoapp/UI/ConnectDialog.cpp b/src/autoapp/UI/ConnectDialog.cpp index 88ea194..45e7014 100644 --- a/src/autoapp/UI/ConnectDialog.cpp +++ b/src/autoapp/UI/ConnectDialog.cpp @@ -3,6 +3,7 @@ #include "ui_connectdialog.h" #include #include +#include namespace f1x { @@ -26,14 +27,11 @@ ConnectDialog::ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITC ui_->setupUi(this); connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &ConnectDialog::close); connect(ui_->pushButtonConnect, &QPushButton::clicked, this, &ConnectDialog::onConnectButtonClicked); - connect(ui_->listViewRecent, &QListView::clicked, this, &ConnectDialog::onRecentAddressClicked); connect(this, &ConnectDialog::connectionSucceed, this, &ConnectDialog::onConnectionSucceed); connect(this, &ConnectDialog::connectionFailed, this, &ConnectDialog::onConnectionFailed); connect(ui_->pushButtonUpdate, &QPushButton::clicked, this, &ConnectDialog::onUpdateButtonClicked); - ui_->listViewRecent->setModel(&recentAddressesModel_); this->loadRecentList(); - loadTempRecentList(); ui_->progressBarConnect->hide(); ui_->lineEditIPAddress->setFocus(); @@ -59,13 +57,12 @@ void ConnectDialog::onConnectButtonClicked() { emit connectionFailed(QString(se.what())); } - loadTempRecentList(); } void ConnectDialog::onUpdateButtonClicked() { system("/usr/local/bin/autoapp_helper updaterecent"); - loadTempRecentList(); + loadClientList(); } void ConnectDialog::connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket) @@ -101,11 +98,6 @@ void ConnectDialog::onConnectionFailed(const QString& message) void ConnectDialog::onRecentAddressClicked(const QModelIndex& index) { const auto& recentAddressesList = recentAddressesList_.getList(); - - if(static_cast(index.row()) <= recentAddressesList.size()) - { - ui_->lineEditIPAddress->setText(QString::fromStdString(recentAddressesList.at(index.row()))); - } } void ConnectDialog::setControlsEnabledStatus(bool status) @@ -113,7 +105,6 @@ void ConnectDialog::setControlsEnabledStatus(bool status) ui_->pushButtonConnect->setVisible(status); ui_->pushButtonCancel->setEnabled(status); ui_->lineEditIPAddress->setEnabled(status); - ui_->listViewRecent->setEnabled(status); } void ConnectDialog::loadRecentList() @@ -129,19 +120,44 @@ void ConnectDialog::loadRecentList() recentAddressesModel_.setStringList(stringList); } -void ConnectDialog::loadTempRecentList() +void ConnectDialog::loadClientList() { - QFileInfo recentFile("/tmp/temp_recent_list"); - if (recentFile.exists()) { + int cleaner = ui_->listWidgetClients->count(); + while (cleaner > -1) { + ui_->listWidgetClients->takeItem(cleaner); + cleaner--; + } + + if (std::ifstream("/tmp/temp_recent_list")) { QFile versionFile(QString("/tmp/temp_recent_list")); versionFile.open(QIODevice::ReadOnly); QTextStream data(&versionFile); while (!data.atEnd()) { QString ip = data.readLine(); - ConnectDialog::insertIpAddress(ip.toStdString()); + ui_->listWidgetClients->addItem(ip); + ui_->lineEditIPAddress->setText(ip); } versionFile.close(); + + if (ui_->listWidgetClients->count() == 1) { + this->setControlsEnabledStatus(false); + + const auto& ipAddress = ui_->lineEditIPAddress->text().toStdString(); + auto socket = std::make_shared(ioService_); + ui_->progressBarConnect->show(); + try + { + tcpWrapper_.asyncConnect(*socket, ipAddress, 5277, std::bind(&ConnectDialog::connectHandler, this, std::placeholders::_1, ipAddress, socket)); + } + catch(const boost::system::system_error& se) + { + emit connectionFailed(QString(se.what())); + } + } + + } else { + ui_->lineEditIPAddress->setText(""); } } diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index 4c86105..6519b70 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -30,6 +30,11 @@ #include #include #include +#include +#include +#include +#include +#include namespace f1x { @@ -171,13 +176,14 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi connect(ui_->pushButtonMusic2, &QPushButton::clicked, this, &MainWindow::playerShow); connect(ui_->pushButtonBack, &QPushButton::clicked, this, &MainWindow::playerHide); connect(ui_->pushButtonPlayerBack, &QPushButton::clicked, this, &MainWindow::playerHide); + connect(ui_->pushButtonAndroidAuto, &QPushButton::clicked, this, &MainWindow::TriggerAppStart); + connect(ui_->pushButtonAndroidAuto, &QPushButton::clicked, this, &MainWindow::setRetryUSBConnect); + connect(ui_->pushButtonAndroidAuto2, &QPushButton::clicked, this, &MainWindow::TriggerAppStart); + connect(ui_->pushButtonAndroidAuto2, &QPushButton::clicked, this, &MainWindow::setRetryUSBConnect); // by default hide bluetooth button on init ui_->pushButtonBluetooth->hide(); - // by default hide bluetooth button on init - ui_->pushButtonAndroidAuto->hide(); - // by default hide media player ui_->mediaWidget->hide(); ui_->pushButtonUSB->hide(); @@ -185,6 +191,10 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->SysinfoTopLeft->hide(); ui_->pushButtonWifiSetup->hide(); + //ui_->pushButtonNoDevice->hide(); + ui_->pushButtonAndroidAuto->hide(); + ui_->pushButtonAndroidAuto2->hide(); + QTimer *timer=new QTimer(this); connect(timer, SIGNAL(timeout()),this,SLOT(showTime())); timer->start(1000); @@ -236,16 +246,16 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->exitWidget->hide(); ui_->horizontalWidgetPower->hide(); - // as default hide phone connected label - ui_->phoneConnected->hide(); - // as default hide muted button ui_->pushButtonUnMute->hide(); // hide wifi if not forced if (!this->wifiButtonForce) { - ui_->pushButtonWifi->hide(); + //ui_->pushButtonWifi->hide(); ui_->pushButtonWifi2->hide(); + ui_->AAWIFIWidget->hide(); + } else { + ui_->AAUSBWidget->hide(); } // set custom buttons if file enabled by trigger file @@ -406,8 +416,7 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi } // read param file - QFileInfo audioparamFile("/boot/crankshaft/volume"); - if (audioparamFile.exists()) { + if (std::ifstream("/boot/crankshaft/volume")) { QFile audioparamFile(QString("/boot/crankshaft/volume")); audioparamFile.open(QIODevice::ReadOnly); QTextStream data_param(&audioparamFile); @@ -503,9 +512,9 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi } // hide alpha controls if enabled in settings - if (!configuration->hideAlpha()) { - ui_->pushButtonAlpha->show(); - } + //if (!configuration->hideAlpha()) { + // ui_->pushButtonAlpha->show(); + //} // init alpha values ui_->horizontalSliderAlpha->setValue(int(configuration->getAlphaTrans())); @@ -776,6 +785,9 @@ void f1x::openauto::autoapp::ui::MainWindow::on_horizontalSliderAlpha_valueChang ui_->pushButtonDummy3->setStyleSheet( "background-color: rgba(186, 189, 182, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); ui_->pushButtonDebug->setStyleSheet( "background-color: rgba(85, 87, 83, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); ui_->pushButtonMusic->setStyleSheet( "background-color: rgba(78, 154, 6, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); + ui_->pushButtonAndroidAuto->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); + ui_->pushButtonNoDevice->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); + ui_->pushButtonNoWiFiDevice->setStyleSheet( "background-color: rgba(252, 175, 62, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); } void f1x::openauto::autoapp::ui::MainWindow::switchGuiToNight() @@ -1185,6 +1197,20 @@ void f1x::openauto::autoapp::ui::MainWindow::setTrigger() QTimer::singleShot(10000, this, SLOT(scanFolders())); } +void f1x::openauto::autoapp::ui::MainWindow::setRetryUSBConnect() +{ + ui_->SysinfoTopLeft->setText("Trying USB reconnect ..."); + ui_->SysinfoTopLeft->show(); + + QTimer::singleShot(10000, this, SLOT(resetRetryUSBMessage())); +} + +void f1x::openauto::autoapp::ui::MainWindow::resetRetryUSBMessage() +{ + ui_->SysinfoTopLeft->setText(""); + ui_->SysinfoTopLeft->hide(); +} + void f1x::openauto::autoapp::ui::MainWindow::scanFolders() { try { @@ -1317,17 +1343,26 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonBackToPlayer_clicked() void f1x::openauto::autoapp::ui::MainWindow::on_StateChanged(QMediaPlayer::State state) { if (state == QMediaPlayer::StoppedState || state == QMediaPlayer::PausedState) { - system("rm -f /tmp/media_playing"); + std::remove("/tmp/media_playing"); } else { - system("touch /tmp/media_playing"); + std::ofstream("/tmp/media_playing"); } } void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() { + try { + if (std::ifstream("/tmp/entityexit")) { + MainWindow::TriggerAppStop(); + usleep(1000000); + std::remove("/tmp/entityexit"); + } + } catch (...) { + OPENAUTO_LOG(error) << "[OpenAuto] Error in entityexit"; + } + // check if system is in display off mode (tap2wake) - QFileInfo blankFile("/tmp/blankscreen"); - if (blankFile.exists()) { + if (std::ifstream("/tmp/blankscreen")) { if (ui_->centralWidget->isVisible() == true) { ui_->centralWidget->hide(); } @@ -1338,8 +1373,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // check if custom command needs black background - QFileInfo blackFile("/tmp/blackscreen"); - if (blackFile.exists()) { + if (std::ifstream("/tmp/blackscreen")) { if (ui_->centralWidget->isVisible() == true) { ui_->centralWidget->hide(); this->setStyleSheet("QMainWindow {background-color: rgb(0,0,0);}"); @@ -1353,15 +1387,18 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // check if phone is conencted to usb - QFileInfo phoneConnectedFile("/tmp/android_device"); - if (phoneConnectedFile.exists()) { - if (ui_->phoneConnected->isVisible() == false) { - ui_->phoneConnected->setText("USB connected"); - ui_->phoneConnected->show(); + + if (std::ifstream("/tmp/android_device")) { + if (ui_->pushButtonAndroidAuto->isVisible() == false) { + ui_->pushButtonAndroidAuto->show(); + ui_->pushButtonAndroidAuto2->show(); + ui_->pushButtonNoDevice->hide(); } } else { - if (ui_->phoneConnected->isVisible() == true) { - ui_->phoneConnected->hide(); + if (ui_->pushButtonAndroidAuto->isVisible() == true) { + ui_->pushButtonAndroidAuto->hide(); + ui_->pushButtonAndroidAuto2->hide(); + ui_->pushButtonNoDevice->show(); } } @@ -1380,8 +1417,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // check if a device is connected via bluetooth - QFileInfo phoneBTConnectedFile("/tmp/btdevice"); - if (phoneBTConnectedFile.exists()) { + if (std::ifstream("/tmp/btdevice")) { if (ui_->btDevice->isVisible() == false) { QFile phoneBTData(QString("/tmp/btdevice")); phoneBTData.open(QIODevice::ReadOnly); @@ -1402,9 +1438,9 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() QFileInfo debugInProgressFile("/tmp/debug_in_progress"); QFileInfo enablePairingFile("/tmp/enable_pairing"); - if (configInProgressFile.exists() || debugInProgressFile.exists() || enablePairingFile.exists()) { + if (std::ifstream("/tmp/config_in_progress") || std::ifstream("/tmp/debug_in_progress") || std::ifstream("/tmp/enable_pairing")) { if (ui_->systemConfigInProgress->isVisible() == false) { - if (configInProgressFile.exists()) { + if (std::ifstream("/tmp/config_in_progress")) { ui_->systemConfigInProgress->setText("System config in progress - please wait ..."); ui_->pushButtonSettings->hide(); ui_->pushButtonSettings2->hide(); @@ -1412,7 +1448,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() ui_->pushButtonLock2->show(); ui_->systemConfigInProgress->show(); } - if (debugInProgressFile.exists()) { + if (std::ifstream("/tmp/debug_in_progress")) { ui_->systemConfigInProgress->setText("Creating debug.zip on /boot - please wait ..."); ui_->pushButtonSettings->hide(); ui_->pushButtonSettings2->hide(); @@ -1422,7 +1458,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() ui_->pushButtonLock2->show(); ui_->systemConfigInProgress->show(); } - if (enablePairingFile.exists()) { + if (std::ifstream("/tmp/enable_pairing")) { ui_->systemConfigInProgress->setText("Auto Bluetooth Pairing enabled for 120 seconds!"); ui_->pushButtonDebug->hide(); ui_->pushButtonDebug2->hide(); @@ -1499,8 +1535,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // check if sutdown is external triggered and init clean app exit - QFileInfo externalExitFile("/tmp/external_exit"); - if (externalExitFile.exists()) { + if (std::ifstream("/tmp/external_exit")) { f1x::openauto::autoapp::ui::MainWindow::MainWindow::exit(); } @@ -1509,14 +1544,30 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() // hide wifi if not forced if (!this->hotspotActive) { - if ((ui_->pushButtonWifi->isVisible() == true) || (ui_->pushButtonWifi2->isVisible() == true)){ - ui_->pushButtonWifi->hide(); + if ((ui_->AAWIFIWidget->isVisible() == true) || (ui_->pushButtonWifi2->isVisible() == true)){ + //ui_->pushButtonWifi->hide(); + ui_->AAWIFIWidget->hide(); ui_->pushButtonWifi2->hide(); + ui_->AAUSBWidget->show(); } } else { - if ((ui_->pushButtonWifi->isVisible() == false) || (ui_->pushButtonWifi2->isVisible() == false)) { - ui_->pushButtonWifi->show(); + if ((ui_->AAWIFIWidget->isVisible() == false) || (ui_->pushButtonWifi2->isVisible() == false)) { + //ui_->pushButtonWifi->show(); + ui_->AAWIFIWidget->show(); ui_->pushButtonWifi2->show(); + ui_->AAUSBWidget->hide(); + } + } + + if (std::ifstream("/tmp/temp_recent_list")) { + if (ui_->pushButtonWifi->isVisible() == false) { + ui_->pushButtonWifi->show(); + ui_->pushButtonNoWiFiDevice->hide(); + } + } else { + if (ui_->pushButtonWifi->isVisible() == true) { + ui_->pushButtonNoWiFiDevice->show(); + ui_->pushButtonWifi->hide(); } } @@ -1525,30 +1576,14 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() if (ui_->pushButtonCameraShow2->isVisible() == true) { button_count = button_count + 1; } - if (ui_->pushButtonToggleGUI2->isVisible() == true) { - button_count = button_count + 1; - } if (ui_->pushButtonWifi2->isVisible() == true) { button_count = button_count + 1; } if (ui_->pushButtonDebug2->isVisible() == true) { button_count = button_count + 1; } - if (button_count >= 3) { - ui_->pushButtonDummyClassic1->hide(); - ui_->pushButtonDummyClassic2->hide(); - } - if (button_count == 2) { - ui_->pushButtonDummyClassic1->hide(); - ui_->pushButtonDummyClassic2->hide(); - } - if (button_count == 1) { - ui_->pushButtonDummyClassic1->show(); - ui_->pushButtonDummyClassic2->hide(); - } - if (button_count == 0) { - ui_->pushButtonDummyClassic1->show(); - ui_->pushButtonDummyClassic2->show(); + if (ui_->pushButtonVolume2->isVisible() == true) { + button_count = button_count + 1; } // Hide auto day/night if needed @@ -1609,8 +1644,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // read value from tsl2561 - QFileInfo lightsensorFile("/tmp/tsl2561"); - if (lightsensorFile.exists() && this->configuration_->showLux()) { + if (std::ifstream("/tmp/tsl2561") && this->configuration_->showLux()) { QFile paramFile("/tmp/tsl2561"); paramFile.open(QIODevice::ReadOnly); QTextStream data(¶mFile); @@ -1618,12 +1652,15 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() paramFile.close(); if (ui_->label_left->isVisible() == false) { ui_->label_left->show(); + ui_->label_right->show(); } ui_->label_left->setText("Lux: " + value[0]); } else { if (ui_->label_left->isVisible() == true) { ui_->label_left->hide(); + ui_->label_right->hide(); ui_->label_left->setText(""); + ui_->label_right->setText(""); } } } diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index f05e8a9..c9c9b68 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace f1x { @@ -78,6 +79,7 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat ui_->labelBluetoothAdapterAddress->hide(); ui_->lineEditExternalBluetoothAdapterAddress->hide(); ui_->labelTestInProgress->hide(); + ui_->checkBoxHideAlpha->hide(); connect(ui_->pushButtonTab1, &QPushButton::clicked, this, &SettingsWindow::show_tab1); connect(ui_->pushButtonTab2, &QPushButton::clicked, this, &SettingsWindow::show_tab2); @@ -96,17 +98,22 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat ui_->spinBoxMinute->setValue((time_text_minute).toInt()); ui_->label_modeswitchprogress->hide(); - QFileInfo hotspotFile("/tmp/hotspot_active"); - if (hotspotFile.exists()) { + if (std::ifstream("/tmp/hotspot_active")) { ui_->pushButtonHotspotStop->show(); ui_->pushButtonHotspotStart->hide(); ui_->lineEdit_wifimode->setText("Hotspot"); ui_->lineEditWifiSSID->setText(this->hotspotssid); + ui_->lineEditPassword->show(); + ui_->label_password->show(); + ui_->lineEditPassword->setText("1234567890"); } else { ui_->pushButtonHotspotStart->show(); ui_->pushButtonHotspotStop->hide(); ui_->lineEdit_wifimode->setText("Client"); ui_->lineEditWifiSSID->setText(this->wifissid); + ui_->lineEditPassword->hide(); + ui_->label_password->hide(); + ui_->lineEditPassword->setText(""); } } @@ -463,9 +470,7 @@ void SettingsWindow::loadSystemValues() system("/usr/local/bin/autoapp_helper getinputs"); system("/usr/local/bin/autoapp_helper getparams"); - QFileInfo paramFile("/tmp/return_value"); - if (paramFile.exists()) { - + if (std::ifstream("/tmp/return_value")) { QFile paramFile(QString("/tmp/return_value")); paramFile.open(QIODevice::ReadOnly); QTextStream data_param(¶mFile); @@ -521,8 +526,7 @@ void SettingsWindow::loadSystemValues() // set cpu temp ui_->valueSystemCPUTemp->setText(getparams[20]); - QFileInfo inputsFile("/tmp/get_inputs"); - if (inputsFile.exists()) { + if (std::ifstream("/tmp/get_inputs")) { QFile inputsFile(QString("/tmp/get_inputs")); inputsFile.open(QIODevice::ReadOnly); QTextStream data_return(&inputsFile); @@ -541,8 +545,7 @@ void SettingsWindow::loadSystemValues() } } - QFileInfo outputsFile("/tmp/get_outputs"); - if (outputsFile.exists()) { + if (std::ifstream("/tmp/get_outputs")) { QFile outputsFile(QString("/tmp/get_outputs")); outputsFile.open(QIODevice::ReadOnly); QTextStream data_return(&outputsFile); @@ -561,8 +564,7 @@ void SettingsWindow::loadSystemValues() } } - QFileInfo defaultoutputFile("/tmp/get_default_output"); - if (defaultoutputFile.exists()) { + if (std::ifstream("/tmp/get_default_output")) { QFile defaultoutputFile(QString("/tmp/get_default_output")); defaultoutputFile.open(QIODevice::ReadOnly); QTextStream data_return(&defaultoutputFile); @@ -571,8 +573,7 @@ void SettingsWindow::loadSystemValues() ui_->comboBoxPulseOutput->setCurrentText(defoutput[0]); } - QFileInfo defaultinputFile("/tmp/get_default_input"); - if (defaultinputFile.exists()) { + if (std::ifstream("/tmp/get_default_input")) { QFile defaultinputFile(QString("/tmp/get_default_input")); defaultinputFile.open(QIODevice::ReadOnly); QTextStream data_return(&defaultinputFile); @@ -581,8 +582,7 @@ void SettingsWindow::loadSystemValues() ui_->comboBoxPulseInput->setCurrentText(definput[0]); } - QFileInfo zoneFile("/tmp/timezone_listing"); - if (zoneFile.exists()) { + if (std::ifstream("/tmp/timezone_listing")) { QFile zoneFile(QString("/tmp/timezone_listing")); zoneFile.open(QIODevice::ReadOnly); QTextStream data_return(&zoneFile); @@ -778,6 +778,7 @@ void SettingsWindow::onStopHotspot() ui_->lineEdit_wifimode->setText(""); ui_->lineEdit_wlan0->setText(""); ui_->lineEditWifiSSID->setText(""); + ui_->lineEditPassword->setText(""); system("sudo systemctl stop hotspot &"); QTimer::singleShot(15000, this, SLOT(updateNetworkInfo())); } @@ -921,18 +922,23 @@ void f1x::openauto::autoapp::ui::SettingsWindow::updateNetworkInfo() ui_->lineEdit_wlan0->setText("interface down"); } - QFileInfo hotspotFile("/tmp/hotspot_active"); - if (hotspotFile.exists()) { + if (std::ifstream("/tmp/hotspot_active")) { ui_->pushButtonHotspotStop->show(); ui_->pushButtonHotspotStart->hide(); ui_->label_modeswitchprogress->hide(); ui_->lineEdit_wifimode->setText("Hotspot"); ui_->lineEditWifiSSID->setText(this->hotspotssid); + ui_->lineEditPassword->show(); + ui_->label_password->show(); + ui_->lineEditPassword->setText("1234567890"); } else { ui_->pushButtonHotspotStart->show(); ui_->pushButtonHotspotStop->hide(); ui_->label_modeswitchprogress->hide(); ui_->lineEdit_wifimode->setText("Client"); ui_->lineEditWifiSSID->setText(this->wifissid); + ui_->lineEditPassword->hide(); + ui_->label_password->hide(); + ui_->lineEditPassword->setText(""); } } diff --git a/src/autoapp/UI/Warning.cpp b/src/autoapp/UI/Warning.cpp new file mode 100644 index 0000000..1b6cada --- /dev/null +++ b/src/autoapp/UI/Warning.cpp @@ -0,0 +1,30 @@ +#include +#include + +namespace f1x +{ +namespace openauto +{ +namespace autoapp +{ +namespace ui +{ + +Warning::Warning(QWidget *parent) + : QDialog(parent) + , ui_(new Ui::Warning) +{ + ui_->setupUi(this); + + connect(ui_->pushButtonClose, &QPushButton::clicked, this, &Warning::close); +} + +Warning::~Warning() +{ + delete ui_; +} + +} +} +} +} diff --git a/src/autoapp/UI/connectdialog.ui b/src/autoapp/UI/connectdialog.ui index 106f67e..ae12aa9 100644 --- a/src/autoapp/UI/connectdialog.ui +++ b/src/autoapp/UI/connectdialog.ui @@ -7,7 +7,7 @@ 0 0 500 - 431 + 360 @@ -44,8 +44,21 @@ color: rgb(255, 255, 255); + + + 0 + 32 + + + + + 16777215 + 32 + + + 14 75 true @@ -54,6 +67,9 @@ color: rgb(255, 255, 255); background-color: rgb(85, 87, 83); color: rgb(255, 255, 255); + + + Qt::AlignCenter @@ -80,28 +96,17 @@ color: rgb(255, 255, 255); - Recent + Clients - + 9 - - - - 0 - 0 - - - - - 0 - 100 - - + + 14 75 true @@ -110,14 +115,206 @@ color: rgb(255, 255, 255); background-color: rgb(85, 87, 83); color: rgb(255, 255, 255); - - QAbstractItemView::NoEditTriggers + + + 0 + 30 + - - 100 + + false + + + + + 0 + 0 + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + 75 + true + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + Update + + + + + + + Qt::Vertical + + + + 20 + 10 + + + + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + true + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + 0 + + + 0 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + 75 + true + PreferDefault + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + Connect + + + + + + + Qt::Vertical + + + + 20 + 10 + + + + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + 75 + true + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + Close + + + + + + @@ -156,151 +353,6 @@ color: rgb(255, 255, 255); - - - - - 0 - 0 - - - - - - - - 0 - 0 - - - - - 120 - 30 - - - - - 75 - true - - - - background-color: rgba(186, 189, 182, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Update - - - - - - - - 0 - 0 - - - - - 120 - 30 - - - - - 75 - true - - - - background-color: rgba(186, 189, 182, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Cancel - - - - - - - - 0 - 0 - - - - - 120 - 30 - - - - - 75 - true - PreferDefault - - - - background-color: rgba(186, 189, 182, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Connect - - - - - - - - 0 - 0 - - - - - 120 - 30 - - - - - true - - - - background-color: rgba(186, 189, 182, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - 0 - - - 0 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index c1769b2..7f2ab11 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -398,32 +398,6 @@ color: rgb(78, 244, 37); 0 - - - - - 0 - 0 - - - - - 75 - true - - - - background-color: rgba(255, 255, 255, 0); -color: rgb(255, 255, 255); - - - USB Connected - - - Qt::AlignCenter - - - @@ -614,30 +588,192 @@ color: rgb(255, 255, 255); - + 0 0 - - - 75 - true - - - - background-color: rgba(14, 8, 137, 0.5); + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 75 + true + + + + background-color: rgba(48, 140, 198, 0.5); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); outline: none; + + + + + + + :/aausb-hot.png + + + + + 50 + 50 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + background-color: rgba(48, 140, 198, 0.5); +color: rgb(255, 255, 255); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +outline: none; + + + No +USB Device + + + + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + background-color: rgba(252, 175, 62, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); +outline: none; + + + + + + + :/aawifi-hot.png + + + + + 50 + 50 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + background-color: rgba(252, 175, 62, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); +outline: none; + + + No +WiFi Clients + + + + + + + + + + + 0 + 0 + + + + background-color: rgba(100, 62, 4, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +outline: none; - Android -Auto + Setup @@ -753,7 +889,7 @@ outline: none; - + 0 @@ -761,7 +897,7 @@ outline: none; - background-color: rgba(245, 121, 0, 0.5); + background-color: rgba(100, 62, 4, 0.5); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); outline: none; @@ -771,7 +907,7 @@ outline: none; - :/brightness-hot.png + :/camera-hot.png @@ -813,7 +949,7 @@ outline: none; - + 0 @@ -821,7 +957,7 @@ outline: none; - background-color: rgba(237, 164, 255, 0.5); + background-color: rgba(85, 87, 83, 0.5); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); outline: none; @@ -831,7 +967,7 @@ outline: none; - :/eye-hot.png + :/bug-hot.png @@ -842,71 +978,6 @@ outline: none; - - - - - 0 - 0 - - - - background-color: rgba(15, 54, 5, 0.5); -color: rgb(255, 255, 255); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -outline: none; - - - - - - - - :/lock-hot.png - - - - - 64 - 64 - - - - - - - - - 0 - 0 - - - - background-color: rgba(138, 226, 52, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -outline: none; - - - - - - - :/settings-hot.png - - - - - 64 - 64 - - - - true - - - @@ -1180,7 +1251,7 @@ outline: none; 0 - + 0 @@ -1188,48 +1259,19 @@ outline: none; - background-color: rgba(100, 62, 4, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -outline: none; - - - - - - - :/camera-hot.png - - - - - 64 - 64 - - - - - - - - - 0 - 0 - - - - background-color: rgba(252, 175, 62, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); + background-color: rgba(15, 54, 5, 0.5); color: rgb(255, 255, 255); -outline: none; +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +outline: none; + - :/wifi-hot.png + :/lock-hot.png @@ -1241,7 +1283,7 @@ outline: none; - + 0 @@ -1249,26 +1291,7 @@ outline: none; - background-color: rgba(100, 62, 4, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -outline: none; - - - Setup - - - - - - - - 0 - 0 - - - - background-color: rgba(85, 87, 83, 0.5); + background-color: rgba(138, 226, 52, 0.5); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); outline: none; @@ -1278,7 +1301,7 @@ outline: none; - :/bug-hot.png + :/settings-hot.png @@ -1287,6 +1310,9 @@ outline: none; 64 + + true + @@ -1326,6 +1352,66 @@ outline: none; + + + + + 0 + 0 + + + + background-color: rgba(245, 121, 0, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +outline: none; + + + + + + + :/brightness-hot.png + + + + + 64 + 64 + + + + + + + + + 0 + 0 + + + + background-color: rgba(237, 164, 255, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +outline: none; + + + + + + + :/eye-hot.png + + + + + 64 + 64 + + + + @@ -1584,7 +1670,7 @@ outline: none; - + 0 @@ -1600,63 +1686,7 @@ outline: none; - :/eye-hot.png - - - - - 50 - 50 - - - - - - - - - 0 - 0 - - - - background-color: rgba(136, 138, 133, 0.5); -outline: none; - - - - - - - :/day-hot.png - - - - - 50 - 50 - - - - - - - - - 0 - 0 - - - - background-color: rgba(136, 138, 133, 0.5); -outline: none; - - - - - - - :/night-hot.png + :/mp3-hot.png @@ -1695,6 +1725,34 @@ outline: none; + + + + + 0 + 0 + + + + background-color: rgba(136, 138, 133, 0.5); +outline: none; + + + + + + + :/eye-hot.png + + + + + 50 + 50 + + + + @@ -1889,6 +1947,118 @@ outline: none; 10 + + + + + 0 + 0 + + + + background-color: rgba(136, 138, 133, 0.5); +outline: none; + + + + + + + :/aausb-hot.png + + + + + 50 + 50 + + + + + + + + + 0 + 0 + + + + background-color: rgba(136, 138, 133, 0.5); +outline: none; + + + + + + + :/aawifi-hot.png + + + + + 50 + 50 + + + + + + + + + 0 + 0 + + + + background-color: rgba(136, 138, 133, 0.5); +outline: none; + + + + + + + :/day-hot.png + + + + + 50 + 50 + + + + + + + + + 0 + 0 + + + + background-color: rgba(136, 138, 133, 0.5); +outline: none; + + + + + + + :/night-hot.png + + + + + 50 + 50 + + + + @@ -1945,34 +2115,6 @@ outline: none; - - - - - 0 - 0 - - - - background-color: rgba(136, 138, 133, 0.5); -outline: none; - - - - - - - :/wifi-hot.png - - - - - 50 - 50 - - - - @@ -2001,92 +2143,6 @@ outline: none; - - - - - 0 - 0 - - - - background-color: rgba(136, 138, 133, 0.5); -outline: none; - - - - - - - :/mp3-hot.png - - - - - 50 - 50 - - - - - - - - - 0 - 0 - - - - - 62 - 0 - - - - background-color: rgba(136, 138, 133, 0.5); -outline: none; - - - - - - - 50 - 50 - - - - - - - - - 0 - 0 - - - - - 62 - 0 - - - - background-color: rgba(136, 138, 133, 0.5); -outline: none; - - - - - - - 50 - 50 - - - - diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index bdd4b62..31a8c79 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -7,7 +7,7 @@ 0 0 963 - 3033 + 3062 @@ -2499,7 +2499,7 @@ outline: none; - Used SSID: + SSID: @@ -2531,7 +2531,7 @@ outline: none; - + @@ -2550,7 +2550,7 @@ outline: none; - + @@ -2566,8 +2566,8 @@ outline: none; - - + + 0 @@ -2594,13 +2594,36 @@ outline: none; - + Yes + + + + + 200 + 0 + + + + + 200 + 16777215 + + + + + + + + Password (default) + + + diff --git a/src/autoapp/UI/warning.ui b/src/autoapp/UI/warning.ui new file mode 100644 index 0000000..43d9cf6 --- /dev/null +++ b/src/autoapp/UI/warning.ui @@ -0,0 +1,141 @@ + + + Warning + + + + 0 + 0 + 500 + 300 + + + + + 0 + 0 + + + + Warning + + + background-color: rgb(186, 189, 182); +border-color: rgb(0, 0, 0); + + + + + 4 + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + 14 + 75 + true + + + + background-color: rgb(136, 138, 133); +color: rgb(255, 255, 255); +border-color: rgb(186, 189, 182); + + + + Safety Information + + + Qt::AlignHCenter|Qt::AlignTop + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + 0 + 0 + + + + background-color: rgb(136, 138, 133); + + + 1 + + + <html><head/><body><p><span style=" font-weight:600; color:#271191;">WARNING!</span></p><p><span style=" font-weight:600; color:#271191;">Distraction may cause accidents. Do not attempt to operate while driving. Always concentrate on driving and obey Traffic Regulations. You assume total responsibility and risk for using this software.</span></p><p><span style=" font-weight:600; color:#271191;">This software is not certified by Google Inc. It is created for R&amp;D purposes and may not work as expected by the original authors. Do not use while driving.</span></p><p><span style=" font-weight:600; color:#271191;">You use this software at your own risk.</span></p></body></html> + + + Qt::AlignHCenter|Qt::AlignTop + + + true + + + + + + + + + + + 0 + 40 + + + + + 16777215 + 40 + + + + + 75 + true + + + + background-color: rgb(186, 189, 182); + + + OK + + + + + + + + + diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index f12ccf5..fac6f18 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include namespace aasdk = f1x::aasdk; @@ -98,7 +99,7 @@ int main(int argc, char* argv[]) autoapp::ui::SettingsWindow settingsWindow(configuration); settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint); - //settingsWindow.showFullScreen(); + settingsWindow.setFixedSize(width, height); settingsWindow.adjustSize(); @@ -114,7 +115,12 @@ int main(int argc, char* argv[]) autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper, recentAddressesList); connectDialog.setWindowFlags(Qt::WindowStaysOnTopHint); // center dialog - connectDialog.move((width - 500)/2,(height-440)/2); + connectDialog.move((width - 500)/2,(height-360)/2); + + autoapp::ui::Warning warning; + warning.setWindowFlags(Qt::WindowStaysOnTopHint); + // center dialog + warning.move((width - 500)/2,(height-300)/2); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { system("touch /tmp/shutdown"); std::exit(0); }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::reboot, []() { system("touch /tmp/reboot"); std::exit(0); }); @@ -229,13 +235,27 @@ int main(int argc, char* argv[]) app->start(std::move(socket)); }); - //QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAAStart, [&qApplication]() { - // OPENAUTO_LOG(info) << "[CS] Manual start android auto entity."; - //}); + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAppStart, [&app]() { + OPENAUTO_LOG(info) << "[CS] Manual start android auto entity by reset usb."; + if (std::ifstream("/tmp/android_device")) { + system("/usr/local/bin/autoapp_helper usbreset &"); + app->waitForUSBDevice(); + } + }); - //QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAAStop, [&qApplication]() { - // OPENAUTO_LOG(info) << "[CS] Manual stop android auto entity."; - //}); + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAppStop, [&app]() { + OPENAUTO_LOG(info) << "[CS] Manual stop android auto entity."; + if (std::ifstream("/tmp/android_device")) { + system("/usr/local/bin/autoapp_helper usbreset"); + usleep(500000); + app->stop(); + } else { + //app->onAndroidAutoQuit(); + app->stop(); + } + }); + + warning.show(); app->waitForUSBDevice();