}
-/* LCOV_EXCL_START */
-int
-get_service_name_by_pid(guint pid, char** pAppId) {
- GError* error = NULL;
- GVariant *unit = NULL;
- unit = g_dbus_connection_call_sync(gdbusConnection, "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "GetUnitByPID",
- g_variant_new("(u)", pid),
- G_VARIANT_TYPE("(o)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
- if (!unit) {
- if (error) {
- LOG_LOGC("get_service_name_by_pid gdbus error [%s]", error->message);
- g_clear_error(&error);
- }
- *pAppId = NULL;
- return SYNC_ERROR_SYSTEM;
- }
-
- char* unitNode = NULL;
- g_variant_get(unit, "(o)", &unitNode);
-
- GVariant *service = NULL;
- service = g_dbus_connection_call_sync(gdbusConnection, "org.freedesktop.systemd1",
- unitNode,
- "org.freedesktop.DBus.Properties",
- "Get",
- g_variant_new("(ss)", "org.freedesktop.systemd1.Service", "BusName"),
- G_VARIANT_TYPE("(v)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
- if (!service) {
- if (error) {
- LOG_LOGC("get_service_name_by_pid gdbus error [%s]", error->message);
- g_clear_error(&error);
- }
- *pAppId = NULL;
- return SYNC_ERROR_SYSTEM;
- }
-
- GVariant *tmp = g_variant_get_child_value(service, 0);
- if (tmp) {
- GVariant* va = g_variant_get_variant(tmp);
- if (va) {
- char* name = NULL;
- g_variant_get(va, "s", &name);
- *pAppId = strdup(name);
- LOG_LOGD("DBus service [%s]", *pAppId);
- free(name);
- }
- }
-
- return SYNC_ERROR_NONE;
-}
-/* LCOV_EXCL_STOP */
-
-
int
get_num_of_sync_jobs(string pkgId) {
if (!pkgId.empty()) {