add configured_resolution policy 37/228837/4
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 26 Mar 2020 04:25:28 +0000 (13:25 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 26 Mar 2020 05:58:07 +0000 (14:58 +0900)
Change-Id: Ibf8a5d5f8c9c147f3bf784831c2cc4542de56a0e

configure.ac
packaging/e-mod-tizen-wm-policy.spec
src/Makefile.am
src/e_mod_configured_resolution.c [new file with mode: 0644]
src/e_mod_configured_resolution.h [new file with mode: 0644]
src/e_mod_main.c

index a8f4e76..627db81 100644 (file)
@@ -39,7 +39,7 @@ if test "x${have_wayland_only}" != "xno"; then
 fi
 AM_CONDITIONAL(HAVE_WAYLAND_ONLY, [test "x${have_wayland_only}" = xyes])
 
-PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment])
+PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment, aul, pkgmgr-info])
 AC_SUBST(ENLIGHTENMENT_CFLAGS)
 AC_SUBST(ENLIGHTENMENT_LIBS)
 
index e909688..5c5f40c 100644 (file)
@@ -21,6 +21,8 @@ BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(edje)
 %endif
 BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(pkgmgr-info)
 
 %if 0%{?TZ_SYS_RO_SHARE:1}
 # TZ_SYS_RO_SHARE is defined
index 0194a93..6a07f4b 100644 (file)
@@ -36,6 +36,8 @@ module_la_SOURCES      = e_mod_config.c \
                          e_mod_main.h \
                          e_mod_pol_pingpong.c \
                          e_mod_pol_pingpong.h \
+                         e_mod_configured_resolution.c \
+                         e_mod_configured_resolution.h \
                          $(WL_SRC) \
                          $(ROT_SRC)
 
diff --git a/src/e_mod_configured_resolution.c b/src/e_mod_configured_resolution.c
new file mode 100644 (file)
index 0000000..f4ba0b2
--- /dev/null
@@ -0,0 +1,92 @@
+#include "e_mod_main.h"
+#include "e_mod_ivi_home.h"
+#include "e_policy_wl.h"
+#include "e_appinfo.h"
+#include <aul/aul.h>
+#include <pkgmgr-info.h>
+
+#define RESOLUTION_360X360 360
+#define RESOLUTION_440X440 440
+
+static Eina_List *e_policy_wl_hook_handlers;
+
+static void
+_e_wm_policy_cb_base_output_resolution_get(void *data, pid_t pid)
+{
+   int ret = 0;
+   int width = 0, height = 0;
+   char appid[256] = {0};
+   char *resolution = NULL;
+   E_Appinfo *epai = NULL;
+   pkgmgrinfo_appinfo_h appinfo = NULL;
+
+   ret = aul_app_get_appid_bypid(pid, appid, sizeof(appid));
+   if (ret < 0)
+     {
+        ELOGF("CONFIGURED_RES", "APP_ID_GET|failed to get appid", NULL);
+        return;
+     }
+
+   ret = pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo);
+   if (ret != PMINFO_R_OK || appinfo == NULL)
+     {
+        ELOGF("CONFIGURED_RES", "PKG_INFO_GET|failed to get appinfo", NULL);
+        return;
+     }
+
+   ret = pkgmgrinfo_appinfo_get_metadata_value(appinfo,
+            "http://tizen.org/metadata/app_ui_type/base_screen_resolution",
+            &resolution);
+
+   if (ret != PMINFO_R_OK || resolution == NULL)
+     {
+        ELOGF("CONFIGURED_RES", "MEAT_DATA_GET|failed to get metadata", NULL);
+        return;
+     }
+
+   ELOGF("CONFIGURED_RES", "screen size(%dx%d), user apptype(%s)", NULL,
+          e_comp->w, e_comp->h, resolution);
+
+   // set the 440x440 base_screen_resolution when the meta_data from app_info is 4k
+   // TODO: 4k value is used temporary one. AppFW has to define the new value for the 440x440 resolution.
+   if (!e_util_strcmp(resolution, "4k"))
+     {
+        width  = RESOLUTION_440X440;
+        height = RESOLUTION_440X440;
+     }
+   else
+      {
+         ELOGF("CONFIGURED_RES", "ERROR: Wrong apptype was used : resolution(%s)", NULL, resolution);
+         width  = RESOLUTION_360X360;
+         height = RESOLUTION_360X360;
+      }
+
+   epai = e_appinfo_find_with_pid(pid);
+   if (!epai)
+     {
+        ELOGF("CONFIGURED_RES", "APPINFO_GET|fail to find pid.(pid:%d)", NULL, pid);
+        return;
+     }
+
+   if (!e_appinfo_base_output_resolution_set(epai, width, height))
+     {
+        ELOGF("CONFIGURED_RES", "RESOLUTION_SET|fail to set base_output_resolution (pid:%d)", NULL, pid);
+        return;
+     }
+
+   ELOGF("CONFIGURED_RES", "RESOLUTION_SET|SET base_output_resolution(%d, %d) (pid:%d)", NULL, width, height, pid);
+}
+
+EINTERN void
+e_mod_configured_resolution_init(void)
+{
+   e_policy_wl_hook_handlers = eina_list_append(e_policy_wl_hook_handlers, e_policy_wl_hook_add(E_POLICY_WL_HOOK_BASE_OUTPUT_RESOLUTION_GET,
+                                                                                    _e_wm_policy_cb_base_output_resolution_get,
+                                                                                    NULL));
+}
+
+EINTERN void
+e_mod_configured_resolution_shutdown(void)
+{
+   E_FREE_LIST(e_policy_wl_hook_handlers, e_policy_wl_hook_del);
+}
diff --git a/src/e_mod_configured_resolution.h b/src/e_mod_configured_resolution.h
new file mode 100644 (file)
index 0000000..af0d4fb
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef E_MOD_COMFIGURED_RESOLUTION_H
+#define E_MOD_COMFIGURED_RESOLUTION_H
+
+EINTERN void e_mod_configured_resolution_init(void);
+EINTERN void e_mod_configured_resolution_shutdown(void);
+
+#endif /* end of E_MOD_COMFIGURED_RESOLUTION_H */
\ No newline at end of file
index b474868..1ba1cba 100644 (file)
@@ -2,6 +2,7 @@
 #include "e_mod_rotation.h"
 #include "e_mod_pol_pingpong.h"
 #include "e_mod_ivi_home.h"
+#include "e_mod_configured_resolution.h"
 #include <stdlib.h>
 #include <system_info.h>
 
@@ -70,6 +71,7 @@ e_modapi_init(E_Module *m)
    e_mod_pol_conf_init(mod);
    e_mod_pol_rotation_init();
    e_mod_pol_pingpong_init();
+   e_mod_configured_resolution_init();
    if (_tz_profile_type_get() == TZ_PROFILE_TYPE_IVI)
      e_mod_ivi_home_init();
 
@@ -81,6 +83,7 @@ e_modapi_shutdown(E_Module *m)
 {
    Mod *mod = m->data;
 
+   e_mod_configured_resolution_shutdown();
    e_mod_pol_pingpong_shutdown();
    e_mod_pol_rotation_shutdown();
    e_mod_pol_conf_shutdown(mod);