e_policy_wl: impelment the tizen_launch_appinfo interface
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 23 Apr 2019 07:56:43 +0000 (16:56 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 23 Apr 2019 08:41:07 +0000 (17:41 +0900)
Change-Id: I934ea32dbf55df43ac17dd58feddde99fa107613

configure.ac
packaging/enlightenment.spec
src/bin/Makefile.mk
src/bin/e_policy_wl.c

index 2e88f95d049af7b17bb2a823f19c56d075577171..6860c6b4fcb53c848790bdc9227fc537c0918f82 100755 (executable)
@@ -569,6 +569,11 @@ fi
 
 AM_CONDITIONAL([HAVE_WAYLAND_ONLY], [test "x${have_wayland_only}" = "xyes"])
 
+#aul
+PKG_CHECK_MODULES([AUL], [aul])
+#pkgmgr-info
+PKG_CHECK_MODULES([PKGMGR_INFO], [pkgmgr-info])
+
 PKG_CHECK_MODULES(E, [$e_requires])
 requirements_e="\
 evas >= ${efl_version} \
index 565ece77fa1cf9f322dd5382a9403e248ec9154f..33dfce1f0312b56ab7ca79ce5f5552ef3ec635be 100755 (executable)
@@ -50,6 +50,8 @@ BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-creds-socket)
 BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  pkgconfig(pixman-1)
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  systemd-devel
 BuildRequires:  pkgconfig(libinput)
 Requires:       libwayland-extension-server
index a71c73b13709c8a9c9573391817b06be5bc35b72..64ffb7a4c3e5dc76aee584c8cc3eca937c3d3eab 100644 (file)
@@ -266,7 +266,7 @@ src/bin/e_devicemgr_input.c \
 src/bin/e_devicemgr_inputgen.c \
 src/bin/e_devicemgr_wl.c
 
-src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=1 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS) $(DLOG_CFLAGS) $(PIXMAN_CFLAGS) $(POLICY_CFLAGS) @TIZEN_REMOTE_SURFACE_CFLAGS@
+src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=2 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS) $(DLOG_CFLAGS) $(PIXMAN_CFLAGS) $(POLICY_CFLAGS) $(AUL_CFLAGS) $(PKGMGR_INFO_CFLAGS) @TIZEN_REMOTE_SURFACE_CFLAGS@
 if HAVE_LIBGOMP
 src_bin_enlightenment_CPPFLAGS += -fopenmp
 endif
@@ -289,7 +289,7 @@ src_bin_enlightenment_LDFLAGS = -export-dynamic
 if HAVE_LIBGOMP
 src_bin_enlightenment_LDFLAGS += -fopenmp
 endif
-src_bin_enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ @WAYLAND_LIBS@ -lm @SHM_OPEN_LIBS@ $(TTRACE_LIBS) $(DLOG_LIBS) $(PIXMAN_LIBS) $(POLICY_LIBS) @TIZEN_REMOTE_SURFACE_LIBS@
+src_bin_enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ @WAYLAND_LIBS@ -lm @SHM_OPEN_LIBS@ $(TTRACE_LIBS) $(DLOG_LIBS) $(PIXMAN_LIBS) $(POLICY_LIBS) $(AUL_LIBS) $(PKGMGR_INFO_LIBS) @TIZEN_REMOTE_SURFACE_LIBS@
 if HAVE_WAYLAND_TBM
 src_bin_enlightenment_LDADD += @WAYLAND_TBM_LIBS@
 endif
index cb35cdf4bc1b2087ded0bcbeb9f721267cd43d02..65ed94fa5a14850093d5c4663f2a06b3793a649f 100644 (file)
@@ -9,6 +9,7 @@
 #include "e_policy_wl_display.h"
 #include "e_policy_conformant_internal.h"
 #include "e_policy_visibility.h"
+#include "e_policy_appinfo.h"
 
 #include <device/display.h>
 #include <wayland-server.h>
 #include <tizen-launch-server-protocol.h>
 #include <tzsh_server.h>
 
+#if 1 // APPINFO launch_app_info
+#include <aul.h>
+#include <pkgmgr-info.h>
+#endif
+
 #define APP_DEFINE_GROUP_NAME "effect"
 
 typedef enum _Tzsh_Srv_Role
@@ -153,6 +159,13 @@ typedef struct _E_Policy_Wl_Tzlaunch_Effect_Info
    int                        effect_type;       /* effect_type */
 } E_Policy_Wl_Tzlaunch_Effect_Info;
 
+#if 1 // 4K_UI
+typedef struct _E_Policy_Wl_Tzlaunch_Appinfo
+{
+   struct wl_resource        *res_tzlaunch_appinfo; /* tizen_launch_appinfo */
+} E_Policy_Wl_Tzlaunch_Appinfo;
+#endif
+
 typedef enum _Launch_Img_File_type
 {
    LAUNCH_IMG_FILE_TYPE_ERROR = -1,
@@ -192,7 +205,10 @@ typedef struct _E_Policy_Wl
    /* tizen_launch_effect_interface */
    Eina_List       *tzlaunch_effect;        /* list of E_Policy_Wl_Tzlaunch_Effect */
    Eina_List       *tzlaunch_effect_info;  /* list of E_Policy_Wl_Tzlaunch_Effect_Info */
-
+#if 1 // 4K_UI
+   /* tizen_launch_appinfo_interface */
+   Eina_List       *tzlaunch_appinfo;       /* list of E_Policy_Wl_Tzlaunch_Appinfo */
+#endif
    /* tizen_ws_shell_interface ver_2 */
    Eina_List       *tzsh_extensions;           /* list of E_Policy_Wl_Tzsh_Extension */
 } E_Policy_Wl;
@@ -5501,6 +5517,338 @@ err:
    wl_client_post_no_memory(client);
 }
 
+#if 1 // 4K_UI
+
+///////////////////////////////////////
+// APPINFO launch_appinfo startpoint //
+///////////////////////////////////////
+
+// register app pid
+static void
+_tzlaunch_appinfo_iface_cb_register_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
+                                            uint32_t pid)
+{
+   E_Policy_Wl_Tzlaunch_Appinfo *appinfo = NULL;
+   E_Policy_Appinfo *epai = NULL;
+
+   ELOGF("APPINFO", "tzlaunch_appinfo:: register_app_pid callback", NULL, NULL);
+
+   appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
+   if (!appinfo)
+     {
+        wl_resource_post_error(res_tzlaunch_appinfo,
+                               WL_DISPLAY_ERROR_INVALID_OBJECT,
+                               "Invalid tzlaunch_appinfo's user data");
+        return;
+     }
+
+   if (pid <= 0)
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: launch app pid is 0!!!! : |pid:%u|", NULL, NULL, pid);
+        return;
+     }
+
+   ELOGF("APPINFO", "tzlaunch_appinfo:: add pid to appinfo(%p) : %u", NULL, NULL, appinfo, pid);
+
+   epai = e_policy_appinfo_new();
+   EINA_SAFETY_ON_NULL_RETURN(epai);
+
+   if (!e_policy_appinfo_pid_set(epai, pid))
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: fail to set pid!!! : |pid:%u|", NULL, NULL, pid);
+        e_policy_appinfo_del(epai);
+        return;
+     }
+}
+
+// deregister app pid
+static void
+_tzlaunch_appinfo_iface_cb_deregister_pid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
+                                            uint32_t pid)
+{
+   E_Policy_Wl_Tzlaunch_Appinfo *appinfo = NULL;
+   E_Policy_Appinfo *epai = NULL;
+
+   ELOGF("APPINFO", "tzlaunch_appinfo:: register_app_pid callback", NULL, NULL);
+
+   appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
+   if (!appinfo)
+     {
+        wl_resource_post_error(res_tzlaunch_appinfo,
+                               WL_DISPLAY_ERROR_INVALID_OBJECT,
+                               "Invalid tzlaunch_appinfo's user data");
+        return;
+     }
+
+   ELOGF("APPINFO", "tzlaunch_appinfo:: add pid to appinfo(%p) : %u", NULL, NULL, appinfo, pid);
+
+   epai = e_policy_appinfo_find_with_pid(pid);
+   EINA_SAFETY_ON_NULL_RETURN(epai);
+
+   e_policy_appinfo_del(epai);
+}
+
+static void
+_e_module_base_resolution_get(const char *appid, int *width, int *height)
+{
+   int ret = 0;
+   char *resolution = NULL;
+   pkgmgrinfo_appinfo_h appinfo = NULL;
+
+   *width = 0;
+   *height = 0;
+
+   // 1. get appinfo
+   ret = pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo);
+   if (ret != PMINFO_R_OK || appinfo == NULL)
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: failed to get appinfo.", NULL, NULL);
+        goto err;
+     }
+
+   // 2. get metadata
+   ret = pkgmgrinfo_appinfo_get_metadata_value(appinfo,
+                          "http://tizen.org/metadata/app_ui_type/base_screen_resolution", &resolution);
+
+   if (ret != PMINFO_R_OK)
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: can't get base_screen_resolution from metadata.", NULL, NULL);
+        goto err;
+        // doing without metadata. using e_config preconfigued_resolution.
+     }
+
+   if (!e_util_strcmp(resolution, "2k"))
+     {
+        *width = 1920;
+        *height = 1080;
+     }
+   else if (!e_util_strcmp(resolution, "4k"))
+     {
+        *width = 3840;
+        *height = 2160;
+     }
+   else if (!e_util_strcmp(resolution, "max"))
+     {
+        *width = 1920;
+        *height = 1080;
+     }
+   else
+     {
+#if 1 // TODO: FIX ME
+        *width = 1920;
+        *height = 1080;
+#else
+        *width = ec->desk->geom.w;
+        *height = ec->desk->geom.h;
+#endif
+     }
+
+   ELOGF("APPINFO", "tzlaunch_appinfo:: get base_screen_resolution from metadata: %s.", NULL, NULL, resolution);
+
+   pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+
+   return;
+err:
+   *width = 1920;
+   *height = 1080;
+
+   if (appinfo)
+     pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+}
+
+// launch doing!
+static void
+_tzlaunch_appinfo_iface_cb_set_appid(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
+                                      uint32_t pid, const char *appid)
+{
+   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
+   E_Policy_Appinfo *epai = NULL;
+   int width = 0;
+   int height = 0;
+
+   ELOGF("APPINFO", "tzlaunch_appinfo:: launch_app callback", NULL, NULL);
+
+   tzlaunch_appinfo = wl_resource_get_user_data(res_tzlaunch_appinfo);
+   if (!tzlaunch_appinfo)
+     {
+        wl_resource_post_error(res_tzlaunch_appinfo,
+                               WL_DISPLAY_ERROR_INVALID_OBJECT,
+                               "Invalid tzlaunch_appinfo's user data");
+        return;
+     }
+
+   if (pid <= 0)
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: launch app pid is 0!!!! : |pid:%u|appid:%s|", NULL, NULL, pid, appid);
+        return;
+     }
+
+   ELOGF("APPINFO", "tzlaunch_appinfo:: launch app with tzlaunch_appinfo(%p) : |pid:%u|appid:%s|", NULL, NULL, tzlaunch_appinfo, pid, appid);
+
+   epai = e_policy_appinfo_find_with_pid(pid);
+   EINA_SAFETY_ON_NULL_RETURN(epai);
+
+   if (!e_policy_appinfo_appid_set(epai, appid))
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: fail to set appid.!!!! : |pid:%u|appid:%s|", NULL, NULL, pid, appid);
+        return;
+     }
+
+   // TODO: call the HOOK to get the base screen resolution from e20 module.
+   //       1. send HOOK with pid
+   //       2. module must set the base_output_resolution.
+   _e_module_base_resolution_get(appid, &width, &height);
+   if (!e_policy_appinfo_base_output_resolution_set(epai, width, height))
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: fail to set base_output_resolution.!!!! : |pid:%u|appid:%s|", NULL, NULL, pid, appid);
+        return;
+     }
+   //       3. server has to get the base_screern_resolution via e_policy_appinfo_base_output_resolution_get.
+   //         3-1. if success, use the base_rescreen_resolution
+   //         3-2. if fail, get the base_output_resolution from the E_Comp_Wl_Output.
+   /////////////////////////////////////////////
+
+   //       4. send output.
+   if (!e_comp_wl_pid_output_configured_resolution_send(pid, width, height))
+     {
+        ELOGF("APPINFO", "tzlaunch_appinfo:: fail to set e_comp_wl_pid_output_configured_resolution_send.!!!! : |pid:%u|appid:%s|", NULL, NULL, pid, appid);
+        return;
+     }
+
+   return;
+}
+
+static void
+_tzlaunch_appinfo_iface_cb_destroy(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo)
+{
+   wl_resource_destroy(res_tzlaunch_appinfo);
+}
+
+static void
+_tzlaunch_appinfo_iface_cb_get_base_output_resolution(struct wl_client *client, struct wl_resource *res_tzlaunch_appinfo,
+                                    uint32_t pid)
+{
+   E_Policy_Appinfo *epai = NULL;
+   int width = 0, height = 0;
+
+   ELOGF("APPINFO", "tzpol_appinfo:: size_get callback", NULL, NULL);
+
+   if (pid <= 0)
+     {
+        ELOGF("APPINFO", "tzpol_appinfo:: size get from client::  pid is 0!!!! : |pid:%u|", NULL, NULL, pid);
+        goto err;
+     }
+
+   ELOGF("APPINFO", "tzpol_appinfo:: get size from client : |pid:%u|", NULL, NULL, pid);
+
+   epai = e_policy_appinfo_find_with_pid(pid);
+   if (!epai)
+     {
+        ELOGF("APPINFO", "tzpol_appinfo:: fail to get epol_appinfo.!!!! : |pid:%u|", NULL, NULL, pid);
+        goto err;
+     }
+
+   if (!e_policy_appinfo_base_output_resolution_get(epai, &width, &height))
+     {
+        ELOGF("APPINFO", "tzpol_appinfo:: fail to read size.!!!! : |pid:%u|", NULL, NULL, pid);
+        goto err;
+     }
+
+   tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
+   ELOGF("APPINFO", "tzpol_appinfo:: send APPINFO base_output_resolution(%d, %d) : pid(%u)", NULL, NULL, width, height, pid);
+
+   return;
+
+err:
+   if (!e_comp_wl_pid_output_configured_resolution_get(pid, &width, &height))
+     ELOGF("APPINFO", "tzpol_appinfo:: ERROR failed to get Output base_output_resolution send size(%d, %d) : pid(%u)", NULL, NULL, width, height, pid);
+   else
+     ELOGF("APPINFO", "tzpol_appinfo:: send Output base_output_resolution size(%d, %d) : pid(%u)", NULL, NULL, width, height, pid);
+   tizen_launch_appinfo_send_base_output_resolution_done(res_tzlaunch_appinfo, pid, width, height);
+}
+
+static const struct tizen_launch_appinfo_interface _tzlaunch_appinfo_iface =
+{
+   _tzlaunch_appinfo_iface_cb_destroy,
+   _tzlaunch_appinfo_iface_cb_register_pid,
+   _tzlaunch_appinfo_iface_cb_deregister_pid,
+   _tzlaunch_appinfo_iface_cb_set_appid,
+   _tzlaunch_appinfo_iface_cb_get_base_output_resolution,
+};
+
+static void
+_tzlaunch_appinfo_del(E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo)
+{
+   EINA_SAFETY_ON_NULL_RETURN(tzlaunch_appinfo);
+
+   // remove appinfo datas
+   ELOGF("APPINFO", "APPINFO_DEL:: delete appinfo.", NULL, NULL);
+
+   polwl->tzlaunch_appinfo = eina_list_remove(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
+
+   memset(tzlaunch_appinfo, 0x0, sizeof(E_Policy_Wl_Tzlaunch_Appinfo));
+   E_FREE(tzlaunch_appinfo);
+}
+
+static E_Policy_Wl_Tzlaunch_Appinfo *
+_tzlaunch_appinfo_add(struct wl_resource *res_tzlaunch_appinfo)
+{
+   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo;
+
+   tzlaunch_appinfo = E_NEW(E_Policy_Wl_Tzlaunch_Appinfo, 1);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(tzlaunch_appinfo, NULL);
+
+   tzlaunch_appinfo->res_tzlaunch_appinfo = res_tzlaunch_appinfo;
+
+   polwl->tzlaunch_appinfo = eina_list_append(polwl->tzlaunch_appinfo, tzlaunch_appinfo);
+
+   return tzlaunch_appinfo;
+}
+
+static void
+_tzlaunch_appinfo_cb_unbind(struct wl_resource *res_tzlaunch_appinfo)
+{
+   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo= NULL;
+   Eina_List *l, *ll;
+
+   EINA_LIST_FOREACH_SAFE(polwl->tzlaunch_appinfo, l, ll, tzlaunch_appinfo)
+     {
+        if (tzlaunch_appinfo->res_tzlaunch_appinfo != res_tzlaunch_appinfo) continue;
+        _tzlaunch_appinfo_del(tzlaunch_appinfo);
+        break;
+     }
+}
+
+static void
+_tzlaunch_appinfo_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t ver, uint32_t id)
+{
+   E_Policy_Wl_Tzlaunch_Appinfo *tzlaunch_appinfo = NULL;
+   struct wl_resource *res_tzlaunch_appinfo;
+
+   EINA_SAFETY_ON_NULL_GOTO(polwl, err);
+
+   res_tzlaunch_appinfo = wl_resource_create(client,
+                                     &tizen_launch_appinfo_interface,
+                                     ver,
+                                     id);
+   EINA_SAFETY_ON_NULL_GOTO(res_tzlaunch_appinfo, err);
+
+   tzlaunch_appinfo = _tzlaunch_appinfo_add(res_tzlaunch_appinfo);
+   EINA_SAFETY_ON_NULL_GOTO(tzlaunch_appinfo, err);
+
+   wl_resource_set_implementation(res_tzlaunch_appinfo,
+                                  &_tzlaunch_appinfo_iface,
+                                  tzlaunch_appinfo,
+                                  _tzlaunch_appinfo_cb_unbind);
+
+   return;
+
+err:
+   ERR("Could not create tizen_launch_appinfo_interface res: %m");
+   wl_client_post_no_memory(client);
+}
+#endif // APPINFO launch_appinfo
+
 static Eina_Bool
 _e_policy_wl_cb_hook_intercept_show_helper(void *data, E_Client *ec)
 {
@@ -6204,6 +6552,15 @@ e_policy_wl_defer_job(void)
 
    polwl->globals = eina_list_append(polwl->globals, global);
 
+   global = wl_global_create(e_comp_wl->wl.disp,
+                             &tizen_launch_appinfo_interface,
+                             1,
+                             NULL,
+                             _tzlaunch_appinfo_cb_bind);
+   EINA_SAFETY_ON_NULL_GOTO(global, err);
+
+   polwl->globals = eina_list_append(polwl->globals, global);
+
    return EINA_TRUE;
 
 err: