context: add test-no-suspend-resume cli parameter

Disables suspend/resume support at runtime.
This is useful for modems which are never turned off
or suspended when the host suspends.
This commit is contained in:
Dylan Van Assche
2021-01-31 15:38:31 +01:00
committed by Aleksander Morgado
parent 12329ac788
commit 7159b8e27a
3 changed files with 32 additions and 7 deletions

View File

@@ -195,9 +195,13 @@ main (int argc, char *argv[])
{
MMSleepMonitor *sleep_monitor;
sleep_monitor = mm_sleep_monitor_get ();
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_SLEEPING, G_CALLBACK (sleeping_cb), NULL);
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_RESUMING, G_CALLBACK (resuming_cb), NULL);
if (mm_context_get_test_no_suspend_resume())
mm_dbg ("Suspend/resume support disabled at runtime");
else {
sleep_monitor = mm_sleep_monitor_get ();
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_SLEEPING, G_CALLBACK (sleeping_cb), NULL);
g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_RESUMING, G_CALLBACK (resuming_cb), NULL);
}
}
#endif

View File

@@ -225,6 +225,9 @@ static gchar *test_plugin_dir;
#if defined WITH_UDEV
static gboolean test_no_udev;
#endif
#if defined WITH_SYSTEMD_SUSPEND_RESUME
static gboolean test_no_suspend_resume;
#endif
static const GOptionEntry test_entries[] = {
{
@@ -248,6 +251,13 @@ static const GOptionEntry test_entries[] = {
"Run without udev support even if available",
NULL
},
#endif
#if defined WITH_SYSTEMD_SUSPEND_RESUME
{
"test-no-suspend-resume", 0, 0, G_OPTION_ARG_NONE, &test_no_suspend_resume,
"Disable suspend/resume support at runtime even if available",
NULL
},
#endif
{ NULL }
};
@@ -292,6 +302,14 @@ mm_context_get_test_no_udev (void)
}
#endif
#if defined WITH_SYSTEMD_SUSPEND_RESUME
gboolean
mm_context_get_test_no_suspend_resume (void)
{
return test_no_suspend_resume;
}
#endif
/*****************************************************************************/
static void

View File

@@ -43,11 +43,14 @@ gboolean mm_context_get_log_timestamps (void);
gboolean mm_context_get_log_relative_timestamps (void);
/* Testing support */
gboolean mm_context_get_test_session (void);
gboolean mm_context_get_test_enable (void);
const gchar *mm_context_get_test_plugin_dir (void);
gboolean mm_context_get_test_session (void);
gboolean mm_context_get_test_enable (void);
const gchar *mm_context_get_test_plugin_dir (void);
#if defined WITH_UDEV
gboolean mm_context_get_test_no_udev (void);
gboolean mm_context_get_test_no_udev (void);
#endif
#if defined WITH_SYSTEMD_SUSPEND_RESUME
gboolean mm_context_get_test_no_suspend_resume (void);
#endif
#endif /* MM_CONTEXT_H */