context: allow disabling QRTR on runtime even if support is built

This commit is contained in:
Aleksander Morgado
2021-01-17 15:16:08 +01:00
parent 591d904f5c
commit 768d76e0aa
3 changed files with 48 additions and 17 deletions

View File

@@ -1455,19 +1455,6 @@ initable_init (GInitable *initable,
{
MMBaseManager *self = MM_BASE_MANAGER (initable);
#if defined WITH_QRTR
/* Create and setup the QrtrBusWatcher */
self->priv->qrtr_bus_watcher = mm_qrtr_bus_watcher_new ();
mm_qrtr_bus_watcher_start (self->priv->qrtr_bus_watcher, NULL, NULL);
/* If autoscan enabled, list for QrtrBusWatcher events */
if (self->priv->auto_scan) {
g_object_connect (self->priv->qrtr_bus_watcher,
"swapped-signal::" MM_QRTR_BUS_WATCHER_DEVICE_ADDED, G_CALLBACK (handle_qrtr_device_added), self,
"swapped-signal::" MM_QRTR_BUS_WATCHER_DEVICE_REMOVED, G_CALLBACK (handle_qrtr_device_removed), self,
NULL);
}
#endif
/* Create filter */
self->priv->filter = mm_filter_new (self->priv->filter_policy, error);
if (!self->priv->filter)
@@ -1487,6 +1474,21 @@ initable_init (GInitable *initable,
g_signal_connect_swapped (self->priv->udev, "uevent", G_CALLBACK (handle_uevent), initable);
#endif
#if defined WITH_QRTR
if (!mm_context_get_test_no_qrtr ()) {
/* Create and setup the QrtrBusWatcher */
self->priv->qrtr_bus_watcher = mm_qrtr_bus_watcher_new ();
mm_qrtr_bus_watcher_start (self->priv->qrtr_bus_watcher, NULL, NULL);
/* If autoscan enabled, list for QrtrBusWatcher events */
if (self->priv->auto_scan) {
g_object_connect (self->priv->qrtr_bus_watcher,
"swapped-signal::" MM_QRTR_BUS_WATCHER_DEVICE_ADDED, G_CALLBACK (handle_qrtr_device_added), self,
"swapped-signal::" MM_QRTR_BUS_WATCHER_DEVICE_REMOVED, G_CALLBACK (handle_qrtr_device_removed), self,
NULL);
}
}
#endif
/* Export the manager interface */
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (initable),
self->priv->connection,

View File

@@ -25,12 +25,12 @@
/*****************************************************************************/
/* Application context */
#if defined WITH_UDEV
#if defined WITH_UDEV || defined WITH_QRTR
# define NO_AUTO_SCAN_OPTION_FLAG 0
# define NO_AUTO_SCAN_DEFAULT FALSE
#else
/* Keep the option when udev disabled, just so that the unit test setup can
* unconditionally use --no-auto-scan */
/* Keep the option when udev and QRTR disabled, just so that the unit test
* setup can unconditionally use --no-auto-scan */
# define NO_AUTO_SCAN_OPTION_FLAG G_OPTION_FLAG_HIDDEN
# define NO_AUTO_SCAN_DEFAULT TRUE
#endif
@@ -228,6 +228,9 @@ static gboolean test_no_udev;
#if defined WITH_SYSTEMD_SUSPEND_RESUME
static gboolean test_no_suspend_resume;
#endif
#if defined WITH_QRTR
static gboolean test_no_qrtr;
#endif
static const GOptionEntry test_entries[] = {
{
@@ -258,6 +261,13 @@ static const GOptionEntry test_entries[] = {
"Disable suspend/resume support at runtime even if available",
NULL
},
#endif
#if defined WITH_QRTR
{
"test-no-qrtr", 0, 0, G_OPTION_ARG_NONE, &test_no_qrtr,
"Run without qrtr support even if available",
NULL
},
#endif
{ NULL }
};
@@ -310,6 +320,13 @@ mm_context_get_test_no_suspend_resume (void)
}
#endif
#if defined WITH_QRTR
gboolean
mm_context_get_test_no_qrtr (void)
{
return test_no_qrtr;
}
#endif
/*****************************************************************************/
static void
@@ -376,13 +393,22 @@ mm_context_init (gint argc,
}
/* Initial kernel events processing may only be used if autoscan is disabled */
#if defined WITH_UDEV
#if defined WITH_UDEV || defined WITH_QRTR
if (!no_auto_scan && initial_kernel_events) {
g_warning ("error: --initial-kernel-events must be used only if --no-auto-scan is also used");
exit (1);
}
# if defined WITH_UDEV
/* Force skipping autoscan if running test without udev */
if (test_no_udev)
no_auto_scan = TRUE;
# endif
# if defined WITH_QRTR
/* Force skipping autoscan if running test without qrtr */
if (test_no_qrtr)
no_auto_scan = TRUE;
# endif
#endif
}

View File

@@ -52,5 +52,8 @@ gboolean mm_context_get_test_no_udev (void);
#if defined WITH_SYSTEMD_SUSPEND_RESUME
gboolean mm_context_get_test_no_suspend_resume (void);
#endif
#if defined WITH_QRTR
gboolean mm_context_get_test_no_qrtr (void);
#endif
#endif /* MM_CONTEXT_H */