Skip to content

Commit

Permalink
Automagically select between the two video switching methods
Browse files Browse the repository at this point in the history
  • Loading branch information
silverchris committed Apr 28, 2022
1 parent 3abb35c commit 87cb015
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ target_link_libraries(autoapp aasdk_static)
target_link_libraries(autoapp aasdk_proto_static)
target_link_libraries(autoapp libusb)

target_include_directories(autoapp PRIVATE external/mINI/src/mini)


target_link_libraries(autoapp
${SIGC++_LIBRARIES}
${ALSA_LIBRARIES}
Expand Down
22 changes: 20 additions & 2 deletions src/autoapp/autoapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include <autoapp/Managers/NavigationManager.hpp>
#include <autoapp/Configuration/Configuration.hpp>

#define MINI_CASE_SENSITIVE
#include <ini.h>

using ThreadPool = std::vector<std::thread>;

class usbThreadPool {
Expand Down Expand Up @@ -103,6 +106,13 @@ void signalHandler(int signum) {
}
}

bool checkAapaVersion() {
mINI::INIFile file("/jci/version.ini");
mINI::INIStructure ini;
file.read(ini);
return ini["VersionInfo"].has("JCI_BLM_AAPA-IHU");
}

int main(int argc, char *argv[]) {
auto start_time = std::chrono::high_resolution_clock::now();
/* Do some Mazda Specific Setup */
Expand Down Expand Up @@ -178,8 +188,16 @@ int main(int argc, char *argv[]) {
std::shared_ptr<DBus::Connection> system_connection = dispatcher->create_connection(DBus::BusType::SYSTEM);

AudioManagerClient audioManager(signals.audioSignals, system_connection);
// VideoManager videoManager(signals.videoSignals, session_connection);
AAPA aapa(signals.videoSignals, session_connection);
AAPA *aapa;
VideoManager *videoManager;

if (checkAapaVersion()) {
LOG(DEBUG) << "Using Mazda Android Auto Video";
aapa = new AAPA(signals.videoSignals, session_connection);
} else {
LOG(DEBUG) << "Using internal Video handling";
videoManager = new VideoManager(signals.videoSignals, session_connection);
}

GPSManager gpsManager(signals.gpsSignals, system_connection);
HttpManager httpManager(signals.videoSignals, signals.aaSignals);
Expand Down
24 changes: 22 additions & 2 deletions src/installer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ void install_bds() {
}
}

bool checkAapaVersion() {
mINI::INIFile file("/jci/version.ini");
mINI::INIStructure ini;
file.read(ini);
return ini["VersionInfo"].has("JCI_BLM_AAPA-IHU");
}

void setup_sm() {
backup("/jci/sm/sm.conf");

Expand Down Expand Up @@ -109,9 +116,22 @@ void setup_sm() {
dependancy->SetAttribute("type", "service");
dependancy->SetAttribute("value", "audio_manager");

doc.SaveFile("/jci/sm/sm.conf");
LOG(INFO) << "/jci/sm/sm.conf configured";
}
if (checkAapaVersion()) {
for (tinyxml2::XMLElement *e = serviceconfig->FirstChildElement(); e != nullptr; e = e->NextSiblingElement()) {
if (std::string(e->Attribute("name")) == "jciAAPA") {
LOG(INFO) << "Disabling jciAAPA";
e->SetAttribute("autorun", false);
}
if (std::string(e->Attribute("name")) == "aap_service") {
LOG(INFO) << "Disabling aap_service";
e->SetAttribute("autorun", false);
}
}
}
doc.SaveFile("/jci/sm/sm.conf");
LOG(INFO) << "/jci/sm/sm.conf configured";

}

}
Expand Down

0 comments on commit 87cb015

Please sign in to comment.