if (NULL != fail) *fail = f;
}
+/* 0: disable udev
+ * 1: enable udev */
+static void control_udev(int val)
+{
+ static const char *ctl[] = { "stop", "start" };
+ int retdbus;
+ int retval;
+ GVariant *reply;
+
+ const char *control = ctl[(!!val)];
+
+ retdbus = gdbus_call_sync_with_reply(DEVICED_BUS_NAME,
+ DEVICED_PATH_SYSNOTI,
+ DEVICED_INTERFACE_SYSNOTI,
+ "udev",
+ g_variant_new("(sis)", "udev", 1, control),
+ &reply);
+
+ if (retdbus < 0) {
+ _D("Failed to %s udev", control);
+ return;
+ }
+
+ if (!g_variant_get_safe(reply, "(i)", &retval)) {
+ _D("Failed to get reply gvariant");
+ return;
+ }
+
+ if (retval != 0) {
+ _D("Failed to %s udev, %d", control, retval);
+ return;
+ }
+
+ _D("udev: %s", control);
+}
+
static void battery_init(void *data)
{
int success = 0;
int fail = 0;
+ control_udev(0);
_I("Start test.");
battery_test_all(&success, &fail);
_I("Total=%d Success=%d Fail=%d", success+fail, success, fail);
+ control_udev(1);
}
static void battery_exit(void *data)
{
_I("End test.");
-
}
static int battery_unit(int argc, char **argv)
char *power_source = NULL;
struct device_battery_info info;
+ control_udev(0);
+
if (argc < 4) {
int success = 0;
int fail = 0;
_E("Unknown test case.");
}
+ control_udev(1);
+
return 0;
}