diff options
-rw-r--r-- | src/main.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index 004b21d..f145504 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,8 @@ #include <gio/gio.h> #include <locale.h> +#include <sys/stat.h> +#include <errno.h> extern "C" { @@ -63,15 +65,31 @@ main(int /*argc*/, char** /*argv*/) exporters.push_back(exporter); } + gboolean bHasSocket = FALSE; + if (ayatana_common_utils_is_lomiri()) { - // We need the ADBD handler running, - // even though it doesn't have an indicator component yet - static constexpr char const * ADB_SOCKET_PATH {"/dev/socket/adbd"}; - static constexpr char const * PUBLIC_KEYS_FILENAME {"/data/misc/adb/adb_keys"}; - auto usb_monitor = std::make_shared<GUDevUsbMonitor>(); - auto greeter = std::make_shared<Greeter>(); - UsbManager usb_manager {ADB_SOCKET_PATH, PUBLIC_KEYS_FILENAME, usb_monitor, greeter}; + struct stat cStat; + + if (stat("/dev/socket/adbd", &cStat) == 0) + { + if (S_ISSOCK(cStat.st_mode)) + { + // We need the ADBD handler running, + // even though it doesn't have an indicator component yet + static constexpr char const * ADB_SOCKET_PATH {"/dev/socket/adbd"}; + static constexpr char const * PUBLIC_KEYS_FILENAME {"/data/misc/adb/adb_keys"}; + auto usb_monitor = std::make_shared<GUDevUsbMonitor>(); + auto greeter = std::make_shared<Greeter>(); + UsbManager usb_manager {ADB_SOCKET_PATH, PUBLIC_KEYS_FILENAME, usb_monitor, greeter}; + bHasSocket = TRUE; + } + } + } + + if (bHasSocket == FALSE) + { + g_message("No /dev/socket/adbd socket found, skipping UsbManager"); } // let's go! |