#define INIT_PID 1
#define INIT_PROC_VAL -1
#define HZ 100
+#define POWER_OFF_DIRECT 2
static int current_lcd_state;
_I("disabled VIP by unmounting VIP cgroup");
}
-static void dbus_pre_poweroff(GDBusMethodInvocation *invocation, GVariant *params)
+static void proc_poweroff()
{
_D("pre power off: unmounting cgroup fs");
proc_sweep_memory(PROC_SWEEP_EXCLUDE_ACTIVE, INIT_PID);
resourced_notify(RESOURCED_NOTIFIER_POWER_OFF, NULL);
turn_off_vip();
+}
+static void dbus_pre_poweroff(GDBusMethodInvocation *invocation, GVariant *params)
+{
+ proc_poweroff();
g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", -1));
}
resourced_notify(RESOURCED_NOTIFIER_LOW_BATTERY, NULL);
}
+static void poweroff_signal_handler(GVariant *params)
+{
+ int response;
+
+ do_expr_unless_g_variant_get_typechecked(return, params, "(i)", &response);
+
+ /* This code does not check for values which could be too high.
+ * This is for legacy reasons (we inherited the code without such
+ * checks so potentially somebody might be using it that way). */
+ if (response < POWER_OFF_DIRECT) {
+ _D("Invalid power off status: %d", response);
+ return;
+ }
+
+ proc_poweroff();
+}
+
static void systemtime_changed_signal_handler(GVariant *params)
{
resourced_notify(RESOURCED_NOTIFIER_SYSTEMTIME_CHANGED, NULL);
on purpose - DeviceD sends the signal earlier than supposed to. Nothing
is lost though because at some point DeviceD also sends a SIGTERM,
which is handled the same way (i.e. quits the main loop). */
+ {DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF,
+ SIGNAL_DEVICED_POWEROFF_STATE, poweroff_signal_handler, NULL},
{DEVICED_PATH_BATTERY, DEVICED_INTERFACE_BATTERY,
SIGNAL_DEVICED_LOW_BATTERY, low_battery_signal_handler, NULL},
{DUMP_SERVICE_OBJECT_PATH, DUMP_SERVICE_INTERFACE_NAME,