#include <stdbool.h>
enum device_notifier_type {
- DEVICE_NOTIFIER_BOOTING_DONE,
+ DEVICE_NOTIFIER_INIT_DONE,
DEVICE_NOTIFIER_PMQOS,
DEVICE_NOTIFIER_THERMAL,
DEVICE_NOTIFIER_MAX,
static GDBusConnection *g_dbus_sys_conn[PASS_DBUS_MAX] = {NULL, };
-int pass_gdbus_register_systemd_startup_callback(GDBusSignalCallback cb,
- gpointer user_data, guint *id)
-{
- GDBusConnection *conn = g_dbus_sys_conn[PASS_DBUS_CORE];
- guint tmp_id;
-
- if (conn == NULL) {
- _E("cannot get the dbus connection "
- "to the system message bus\n");
- return -ENOSYS;
- }
-
- tmp_id = g_dbus_connection_signal_subscribe(conn,
- SYSTEMD_DBUS_NAME,
- SYSTEMD_DBUS_IFACE_MANAGER,
- "StartupFinished",
- SYSTEMD_DBUS_OBJECT_PATH,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- cb,
- user_data,
- NULL);
- if (!tmp_id)
- return -ENOTSUP;
-
- *id = tmp_id;
-
- return 0;
-}
-
-int pass_gdbus_unregister_systemd_startup_callback(guint id)
-{
- GDBusConnection *conn = g_dbus_sys_conn[PASS_DBUS_CORE];
-
- if (conn == NULL) {
- _E("cannot get the dbus connection "
- "to the system message bus\n");
- return -ENOSYS;
- }
-
- if (!id)
- return -EINVAL;
-
- g_dbus_connection_signal_unsubscribe(conn, id);
-
- return 0;
-}
-
-int pass_gdbus_get_systemd_dbus_property_string(const char *iface,
- const char *prop, const char **value)
-{
- GDBusConnection *conn = g_dbus_sys_conn[PASS_DBUS_CORE];
- GError *error = NULL;
- GVariant *reply;
- GVariant *result;
-
- if (conn == NULL) {
- _E("cannot get the dbus connection "
- "to the system message bus\n");
- return -ENOSYS;
- }
-
- reply = g_dbus_connection_call_sync(conn,
- SYSTEMD_DBUS_NAME,
- SYSTEMD_DBUS_OBJECT_PATH,
- SYSTEMD_DBUS_IFACE_FOR_PROPS,
- SYSTEMD_DBUS_METHOD_GET_PROP,
- g_variant_new(SYSTEMD_DBUS_METHOD_GET_PROP_ARG_TYPE,
- iface,
- prop),
- G_VARIANT_TYPE(SYSTEMD_DBUS_METHOD_GET_PROP_RET_TYPE),
- G_DBUS_SIGNAL_FLAGS_NONE,
- -1,
- NULL,
- &error);
- if (error != NULL) {
- _E("cannot get property: %s\n", error->message);
- return -EINVAL;
- }
-
- g_variant_get(reply, SYSTEMD_DBUS_METHOD_GET_PROP_RET_TYPE, &result);
- *value = g_variant_get_string(result, NULL);
- if (*value == NULL) {
- _E("cannot get property: not string value property\n");
- return -EINVAL;
- }
-
- return 0;
-}
-
int pass_gdbus_export_interface(passdbus idx, gpointer instance,
const char *obj_path)
{
#include <pass/gdbus-util.h>
#include <pass/log.h>
-unsigned int g_startup_cb_id;
GMainLoop *g_mainloop;
static void sig_quit(int signo)
g_main_loop_quit(g_mainloop);
}
-static bool check_systemd_state(void)
-{
- const char *prop = "SystemState";
- const char *prop_valid_values[] = {"running", "degraded", NULL};
- const char *value;
- int i, ret;
-
- ret = pass_gdbus_get_systemd_dbus_property_string(
- SYSTEMD_DBUS_IFACE_MANAGER,
- prop, &value);
- if (ret < 0)
- return false;
-
- i = 0;
- while (prop_valid_values[i] != NULL) {
- if (!strncmp(prop_valid_values[i], value,
- strlen(prop_valid_values[i])))
- return true;
-
- i++;
- }
-
- return false;
-}
-
-static void cb_systemd_startup_finished(GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- int ret;
-
- if (check_systemd_state()) {
- ret = 1;
- device_notify(DEVICE_NOTIFIER_BOOTING_DONE, &ret);
- }
-
- pass_gdbus_unregister_systemd_startup_callback(g_startup_cb_id);
- g_startup_cb_id = 0;
-}
-
static int late_init(void)
{
int ret;
if (ret < 0)
return ret;
- if (check_systemd_state()) {
- ret = 1;
- device_notify(DEVICE_NOTIFIER_BOOTING_DONE, &ret);
- } else {
- ret = pass_gdbus_register_systemd_startup_callback(
- cb_systemd_startup_finished,
- NULL,
- &g_startup_cb_id);
- if (ret < 0)
- return ret;
- }
+ ret = 1;
+ device_notify(DEVICE_NOTIFIER_INIT_DONE, &ret);
return 0;
}
*/
static void pass_exit(void *data)
{
- unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ unregister_notifier(DEVICE_NOTIFIER_INIT_DONE,
pass_init_done, NULL);
pass_gdbus_disconnect_signal(g_gdbus_instance,
* initialization of the daemon is performed by this notifier after
* booting is completely done.
*/
- ret = register_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ ret = register_notifier(DEVICE_NOTIFIER_INIT_DONE,
pass_init_done, NULL);
if (ret < 0) {
_E("cannot register booting-done notifier for the pass (%d)\n",
*/
static void pmqos_exit(void *data)
{
- unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ unregister_notifier(DEVICE_NOTIFIER_INIT_DONE,
pmqos_init_done, NULL);
pass_gdbus_disconnect_signal(g_gdbus_instance,
* initialization of the daemon is performed by this notifier after
* booting is completely done.
*/
- ret = register_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ ret = register_notifier(DEVICE_NOTIFIER_INIT_DONE,
pmqos_init_done, NULL);
if (ret < 0) {
_E("cannot register a callback function \
*/
static void thermal_exit(void *data)
{
- unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ unregister_notifier(DEVICE_NOTIFIER_INIT_DONE,
thermal_init_done, NULL);
pass_gdbus_disconnect_signal(g_gdbus_instance,
* initialization of the daemon is performed by this notifier after
* booting is completely done.
*/
- ret = register_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ ret = register_notifier(DEVICE_NOTIFIER_INIT_DONE,
thermal_init_done, NULL);
if (ret < 0) {
_E("failed to register a callback function \
return 0;
out_booting_done:
- unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
+ unregister_notifier(DEVICE_NOTIFIER_INIT_DONE,
thermal_init_done, NULL);
out_disconnect:
pass_gdbus_disconnect_signal(g_gdbus_instance,