From 5bd31e980f96123d37b870a842d62dbf85383d32 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 21 Aug 2023 16:09:04 +0900 Subject: [PATCH] display: headed: Add plugin-util.c for plugin utility int launch_system_app() : Remove dependency to the src/shared/apps.h. This is copy of function at the src/shared/apps.h so that it makes plugin be able to separated from the deviced core. int display_plugin_config_touch_wakeup() : Remove dependency to the extern g_display_plugin at display-plugin.h As the actual data resides in the plugin, it is able to access it without referring the core display-plugin.h. For now, only the one member, touch_wakeup, is being accessed. Therefore, the function dedicated to that member is added. Change-Id: I6e25d4dd108ffe97da4502a5597822c16743ad15 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 6 ++ plugins/iot-headed/display/key-filter.c | 4 +- plugins/iot-headed/display/plugin-util.c | 111 +++++++++++++++++++++++++++++++ plugins/iot-headed/display/plugin-util.h | 33 +++++++++ 4 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 plugins/iot-headed/display/plugin-util.c create mode 100644 plugins/iot-headed/display/plugin-util.h diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 3b2b814..38fa14c 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -95,6 +95,12 @@ static struct syscommon_deviced_display_config display_conf = { .display_dpms_type = SYSCOMMON_DEVICED_DPMS_TYPE_WINDOW_MANAGER, }; +/* Temporary helper for accessing member of display_conf */ +int display_plugin_config_touch_wakeup(void) +{ + return display_conf.touch_wakeup; +} + inline const struct syscommon_deviced_display_config* get_var_display_config() { return &display_conf; diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 2ef1ed9..ef86c4f 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -35,10 +35,10 @@ #include "display-config.h" #include "display-misc.h" #include "display-state-transition.h" -#include "shared/apps.h" #include #include "display-lock.h" #include "input/input.h" +#include "plugin-util.h" #ifndef KEY_SCREENLOCK #define KEY_SCREENLOCK 0x98 @@ -715,7 +715,7 @@ static void check_key_filter(struct timeval time, unsigned short type, unsigned break; case EV_ABS: if (display_misc_is_touch_event_blocked() - && !g_display_plugin.config->touch_wakeup + && !display_plugin_config_touch_wakeup() && pinput->value == KEY_BEING_PRESSED) return; diff --git a/plugins/iot-headed/display/plugin-util.c b/plugins/iot-headed/display/plugin-util.c new file mode 100644 index 0000000..5cfc9e5 --- /dev/null +++ b/plugins/iot-headed/display/plugin-util.c @@ -0,0 +1,111 @@ +/* + * deviced + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "plugin-util.h" + +#define POPUP_METHOD "PopupLaunch" + +static const struct app_dbus_match { + const char *type; + const char *bus; + const char *path; + const char *iface; + const char *method; +} app_match[] = { + { APP_DEFAULT , POPUP_BUS_NAME, POPUP_PATH_SYSTEM , POPUP_INTERFACE_SYSTEM , POPUP_METHOD }, + { APP_POWERKEY, POPUP_BUS_NAME, POPUP_PATH_POWERKEY, POPUP_INTERFACE_POWERKEY, POPUP_METHOD }, + { APP_OVERHEAT, POPUP_BUS_NAME, POPUP_PATH_OVERHEAT, POPUP_INTERFACE_OVERHEAT, POPUP_METHOD }, + { APP_ABNORMAL, POPUP_BUS_NAME, POPUP_PATH_SYSTEM , POPUP_INTERFACE_SYSTEM , POPUP_METHOD }, + { APP_REMOVE , POPUP_BUS_NAME, POPUP_PATH_SYSTEM , POPUP_INTERFACE_SYSTEM , POPUP_METHOD }, +}; + +#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) + +static void __cb(GVariant *var, void *user_data, GError *err) +{ + int ret; + + if (!var) { + _E("No message: %s", err->message); + return; + } + + if (!g_variant_get_safe(var, "(i)", &ret)) { + _E("No message: %s", g_variant_get_type_string(var)); + goto out; + } + + _D("Reply value: %d", ret); + +out: + g_variant_unref(var); +} + +int launch_system_app(char *type, int num, ...) +{ + char *app_type; + va_list args; + int i, match, ret; + + if (type) + app_type = type; + else + app_type = APP_DEFAULT; + + match = -1; + for (i = 0 ; i < ARRAY_SIZE(app_match) ; i++) { + if (strncmp(app_type, app_match[i].type, strlen(app_type))) + continue; + match = i; + break; + } + if (match < 0) { + _E("Failed to find matched app type(%s).", app_type); + return -EINVAL; + } + + va_start(args, num); + + ret = gdbus_call_pairs_async_with_reply(app_match[match].bus, + app_match[match].path, + app_match[match].iface, + app_match[match].method, + num, + args, + __cb, + -1, + NULL); + + va_end(args); + + syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY), + DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE, + SYSCOMMON_DEVICED_DISPLAY_STATE_ON, + DEVICED_EVENT_MISC_POPUP); + + return ret; +} diff --git a/plugins/iot-headed/display/plugin-util.h b/plugins/iot-headed/display/plugin-util.h new file mode 100644 index 0000000..ac7c2d6 --- /dev/null +++ b/plugins/iot-headed/display/plugin-util.h @@ -0,0 +1,33 @@ +/* + * deviced + * + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __PLUGIN_UTIL_H__ +#define __PLUGIN_UTIL_H__ + +#define APP_POWERKEY "powerkey" +#define APP_OVERHEAT "overheat" +#define APP_DEFAULT "system" +#define APP_ABNORMAL "abnormal" +#define APP_REMOVE "remove" +#define APP_KEY_TYPE "_SYSPOPUP_CONTENT_" + +int launch_system_app(char *type, int num, ...); +int display_plugin_config_touch_wakeup(void); + +#endif /* __PLUGIN_UTIL_H__ */ + -- 2.7.4