* UltraPowerSaving through D-bus interface.
* @param [in] obj Instance of SystemPassPmqos
* @param [in] invoc Instance of GDBusMethodInvocation
+ * @param [in] name Specific scenario name or mode name
* @param [in] duration Duration to keep scenario during demanded time
* @param [in] user_data Unused parameter
* @return @c true if success, otherwise @c false if fail
*/
-static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj,
+static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj,
GDBusMethodInvocation *invoc,
+ const char *name,
int duration,
gpointer user_data)
{
- const char *name_from;
- char *name;
- bool support;
- int max_duration_ms;
- int i, ret = 0;
+ int i, ret = -ENOTSUP;
gboolean ret_out = TRUE;
if (!g_pmqos) {
goto out;
}
- name_from = g_dbus_method_invocation_get_method_name(invoc);
- ret = -ENOTSUP;
- if (g_pmqos) {
- for (i = 0; i < g_pmqos->num; i++) {
- name = g_pmqos->list[i].name;
- support = g_pmqos->list[i].support;
- max_duration_ms = g_pmqos->list[i].max_duration_ms;
-
- if (!strcmp(name, name_from) && support) {
- ret = 0;
- if (duration > max_duration_ms)
- duration = max_duration_ms;
- break;
- }
+ for (i = 0; i < g_pmqos->num; i++) {
+ char *supported_name = g_pmqos->list[i].name;
+ bool support = g_pmqos->list[i].support;
+
+ if (!strcmp(supported_name, name) && support) {
+ int max_duration_ms = g_pmqos->list[i].max_duration_ms;
+
+ if (duration > max_duration_ms)
+ duration = max_duration_ms;
+ ret = 0;
+ break;
}
}
if (ret < 0) {
_E("cannot set the PMQoS scenario: "
- "%s is not supported\n", name_from);
+ "%s is not supported\n", name);
ret_out = FALSE;
goto out_dbus;
}
if (duration)
- ret = pmqos_request(name_from, duration);
+ ret = pmqos_request(name, duration);
else
- ret = pmqos_cancel(name_from);
+ ret = pmqos_cancel(name);
out_dbus:
g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
-
out:
return ret_out;
}
/**
+ * @brief Callback function when receive the scenario like AppLaunch,
+ * UltraPowerSaving through D-bus interface.
+ * @param [in] obj Instance of SystemPassPmqos
+ * @param [in] invoc Instance of GDBusMethodInvocation
+ * @param [in] duration Duration to keep scenario during demanded time
+ * @param [in] user_data Unused parameter
+ * @return @c true if success, otherwise @c false if fail
+ */
+static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj,
+ GDBusMethodInvocation *invoc,
+ int duration,
+ gpointer user_data)
+{
+ const char *name;
+
+ if (!g_pmqos) {
+ _E("PASS PMQoS is stopped\n");
+ return FALSE;
+ }
+
+ name = g_dbus_method_invocation_get_method_name(invoc);
+ return dbus_cb_pmqos_set_scenario(obj, invoc, name, duration, user_data);
+}
+
+/**
* @brief Define the supported D-bus signal information for PMQoS
* feature. It contains the signal name and callback function
* pointer which is executed when receives the defined signal.
.cb_data = NULL,
.ret_id = 0,
}, {
+ .handler = DBUS_PMQOS_I_SET_SCENARIO_HANDLER,
+ .cb = G_CALLBACK(dbus_cb_pmqos_set_scenario),
+ .cb_data = NULL,
+ .ret_id = 0,
+ }, {
.handler = DBUS_PMQOS_I_START_HANDLER,
.cb = G_CALLBACK(dbus_cb_pmqos_start),
.cb_data = NULL,