diff options
author | Robert Tari <robert@tari.in> | 2021-08-11 23:46:45 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-08-13 09:37:46 +0200 |
commit | bd2347fd5733565a4e6101cbd4bf4cd0af667088 (patch) | |
tree | 4370b86eae50e9888ba6776c025553e8791b71fe /src | |
parent | a3907f16d382648153b403c7f1130a3350fc4013 (diff) | |
download | ayatana-indicator-display-bd2347fd5733565a4e6101cbd4bf4cd0af667088.tar.gz ayatana-indicator-display-bd2347fd5733565a4e6101cbd4bf4cd0af667088.tar.bz2 ayatana-indicator-display-bd2347fd5733565a4e6101cbd4bf4cd0af667088.zip |
Check for ADBD socket before creating UsbManager
fixes https://github.com/AyatanaIndicators/ayatana-indicator-display/issues/13
Diffstat (limited to 'src')
-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! |