display: headed: Add plugin-util.c for plugin utility 13/297513/1
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Aug 2023 07:09:04 +0000 (16:09 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Aug 2023 07:29:11 +0000 (16:29 +0900)
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 <y0.cho@samsung.com>
plugins/iot-headed/display/core.c
plugins/iot-headed/display/key-filter.c
plugins/iot-headed/display/plugin-util.c [new file with mode: 0644]
plugins/iot-headed/display/plugin-util.h [new file with mode: 0644]

index 3b2b814c95a72ae1f0702300a635d160b0dc494e..38fa14cc818c4776b8cd80850674432a3b00fd08 100644 (file)
@@ -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;
index 2ef1ed9faf14b8dc292db6846ba2f30281895a70..ef86c4ff0b5ee88bba54df5527b50fedd601ee45 100644 (file)
 #include "display-config.h"
 #include "display-misc.h"
 #include "display-state-transition.h"
-#include "shared/apps.h"
 #include <libsyscommon/log.h>
 #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 (file)
index 0000000..5cfc9e5
--- /dev/null
@@ -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 <string.h>
+#include <stdarg.h>
+#include <glib.h>
+#include <libsyscommon/libgdbus.h>
+#include <libsyscommon/resource-manager.h>
+#include <libsyscommon/log.h>
+#include <syscommon-plugin-deviced-common-interface.h>
+#include <syscommon-plugin-deviced-display-interface.h>
+
+#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 (file)
index 0000000..ac7c2d6
--- /dev/null
@@ -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__ */
+