#define DBUS_THERMAL_I_START_HANDLER "handle_start"
#define DBUS_THERMAL_I_STOP_HANDLER "handle_stop"
#define DBUS_THERMAL_SIGNAL "CoolDownModeChanged"
+#define DBUS_THERMAL_METHOD "handle_get_cool_down_status"
/* Dbus definition for systemd */
#define SYSTEMD_DBUS_NAME "org.freedesktop.systemd1"
*/
static struct thermal_scenario *g_thermal = NULL;
+static gboolean dbus_cb_thermal_method(SystemThermal *obj,
+ GDBusMethodInvocation *invoc, gpointer user_data)
+{
+ GVariant *status;
+ int scenario_idx;
+
+ if (!g_thermal || !g_thermal->support) {
+ _E("Thermal service is not available");
+ return FALSE;
+ }
+
+ scenario_idx = g_thermal->cur_scenario_idx;
+ if (scenario_idx < 0) {
+ _E("CoolDownMode is not set yet");
+ return FALSE;
+ } else if (scenario_idx >= g_thermal->num) {
+ _E("CoolDownMode index is invalid: %d", scenario_idx);
+ return FALSE;
+ }
+
+ status = g_variant_new("(s)", g_thermal->list[scenario_idx].name);
+
+ g_dbus_method_invocation_return_value(invoc, status);
+
+ return TRUE;
+}
+
/**
* @brief Free the resources of Thermal Monitor feature.
* @return N/A
return ret;
}
+ g_thermal->cur_scenario_idx = -1;
+
for (i = 0; i < g_thermal->num; i++)
if (g_thermal->list[i].support)
_I("Support \'%s\' scenario", g_thermal->list[i].name);
.cb = G_CALLBACK(dbus_cb_thermal_stop),
.cb_data = NULL,
.ret_id = 0,
+ }, {
+ .handler = DBUS_THERMAL_METHOD,
+ .cb = G_CALLBACK(dbus_cb_thermal_method),
+ .cb_data = NULL,
+ .ret_id = 0,
},
};
return 0;
}
+ g_thermal->cur_scenario_idx = i;
+
/* If there is available thermal scenario, send the broadcast signal */
gvar = g_variant_new("(s)", data);
ret = pass_gdbus_send_broadcast_signal(PASS_DBUS_THERMAL,