diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-08-13 09:38:22 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-08-13 09:38:22 +0200 |
commit | 07df9869efb56d623c96959bfaf9a2fd251f6df7 (patch) | |
tree | 4370b86eae50e9888ba6776c025553e8791b71fe | |
parent | a3907f16d382648153b403c7f1130a3350fc4013 (diff) | |
parent | bd2347fd5733565a4e6101cbd4bf4cd0af667088 (diff) | |
download | ayatana-indicator-display-07df9869efb56d623c96959bfaf9a2fd251f6df7.tar.gz ayatana-indicator-display-07df9869efb56d623c96959bfaf9a2fd251f6df7.tar.bz2 ayatana-indicator-display-07df9869efb56d623c96959bfaf9a2fd251f6df7.zip |
Merge branch 'tari01-pr/check-for-adbd-socket'
Attributes GH PR #25: https://github.com/AyatanaIndicators/ayatana-indicator-display/pull/25
-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! |