From 6efe571fc288e5a8bc203ccd6dae443a05e525b0 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Wed, 31 May 2017 15:30:40 +0900 Subject: [PATCH 2/9] Unify mobile/wearable/tv/ivi/common profiles. Change-Id: Ied0664d78a3a75d99313023fe045229571c09c97 Signed-off-by: Bowon Ryu --- LICENSE | 178 ++++++++++++++++ Makefile.am | 3 + autogen.sh | 4 + configure.ac | 33 +++ packaging/efl-config-ondemand.service.in | 7 + packaging/efl-config-post.service.in | 7 + packaging/efl-config.manifest | 5 + packaging/efl-config.service.in | 10 + packaging/efl-config.socket | 10 + packaging/efl-config.spec | 73 +++++++ src/Makefile.am | 8 + src/efl_config.c | 356 +++++++++++++++++++++++++++++++ 12 files changed, 694 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 packaging/efl-config-ondemand.service.in create mode 100644 packaging/efl-config-post.service.in create mode 100644 packaging/efl-config.manifest create mode 100644 packaging/efl-config.service.in create mode 100644 packaging/efl-config.socket create mode 100644 packaging/efl-config.spec create mode 100644 src/Makefile.am create mode 100644 src/efl_config.c diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4544429 --- /dev/null +++ b/LICENSE @@ -0,0 +1,178 @@ +Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..eb13ac9 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,3 @@ +MAINTAINERCLEANFILES = Makefile.in Makefile +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = src diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..33f7df8 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +libtoolize +autoreconf -ivf diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..3a643bd --- /dev/null +++ b/configure.ac @@ -0,0 +1,33 @@ +AC_PREREQ([2.68]) +AC_INIT([efl-config], [0.1], [jae.hwan.kim@samsung.com]) +AC_CONFIG_SRCDIR([src/efl_config.c]) +#AC_CONFIG_HEADERS([efl_config.h]) + +AC_CONFIG_AUX_DIR([.]) +AM_INIT_AUTOMAKE([foreign]) +# Checks for programs. +AC_PROG_CC +AC_CONFIG_MACRO_DIR([m4]) +# Checks for libraries. +DESKTOP=0 +AC_CHECK_LIB([elementary]) +# Checks for header files. +# Checks for typedefs, structures, and compiler characteristics. +AC_LIBTOOL_DLOPEN +LT_INIT +AC_PROG_LIBTOOL +# Checks for library functions. +PKG_CHECK_MODULES([ELEMENTARY],[elementary]) +PKG_CHECK_MODULES([ECOREWAYLAND],[ecore-wayland]) +PKG_CHECK_MODULES([CAPISYSTEMINFO],[capi-system-info]) + +AC_SUBST([DESKTOP]) +AC_DEFINE_UNQUOTED([DESKTOP],[${DESKTOP}],["Desktop build is enabled"]) +AC_SUBST(TZ_SYS_BIN) +AC_CONFIG_FILES([Makefile + src/Makefile + packaging/efl-config.service + packaging/efl-config-post.service + packaging/efl-config-ondemand.service + ]) +AC_OUTPUT diff --git a/packaging/efl-config-ondemand.service.in b/packaging/efl-config-ondemand.service.in new file mode 100644 index 0000000..f6d7309 --- /dev/null +++ b/packaging/efl-config-ondemand.service.in @@ -0,0 +1,7 @@ +[Unit] +Description=Change the efl configures. + +[Service] +Type=simple +ExecStart=@TZ_SYS_BIN@/efl_config --with-message +EnvironmentFile=-/run/tizen-system-env diff --git a/packaging/efl-config-post.service.in b/packaging/efl-config-post.service.in new file mode 100644 index 0000000..a79b9e6 --- /dev/null +++ b/packaging/efl-config-post.service.in @@ -0,0 +1,7 @@ +[Unit] +Description=Change the efl configures. + +[Service] +Type=simple +ExecStart=@TZ_SYS_BIN@/efl_config +EnvironmentFile=-/run/tizen-system-env diff --git a/packaging/efl-config.manifest b/packaging/efl-config.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/packaging/efl-config.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/efl-config.service.in b/packaging/efl-config.service.in new file mode 100644 index 0000000..c7b7d19 --- /dev/null +++ b/packaging/efl-config.service.in @@ -0,0 +1,10 @@ +[Unit] +Description=Change the efl configures. +DefaultDependencies=no +Before=starter.service +After=enlightenment-user.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/sh -c "while [ ! -f /run/.wm_ready ] ; do /usr/bin/sleep .1 ; done ; exec @TZ_SYS_BIN@/efl_config" +EnvironmentFile=-/run/tizen-system-env diff --git a/packaging/efl-config.socket b/packaging/efl-config.socket new file mode 100644 index 0000000..ec67c4f --- /dev/null +++ b/packaging/efl-config.socket @@ -0,0 +1,10 @@ +[Unit] +Description=EFL Config Service socket + +[Socket] +ListenStream=/run/user_ext/%U/.efl-config.sock +Service=efl-config-ondemand.service +SocketMode=0777 + +[Install] +WantedBy=sockets.target diff --git a/packaging/efl-config.spec b/packaging/efl-config.spec new file mode 100644 index 0000000..74728f1 --- /dev/null +++ b/packaging/efl-config.spec @@ -0,0 +1,73 @@ +%define alias efl-config +Name: efl-config +Summary: EFL Config daemon +Version: 0.1 +Release: 0 +Provides: efl-config = %{version}-%{release} +Group: System/Libraries +License: Apache-2.0 +Source: %{name}-%{version}.tar.gz +Source2: %{alias}.manifest +BuildRequires: automake +BuildRequires: libtool +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(ecore-wayland) +BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(libsystemd) +BuildRequires: pkgconfig(capi-system-info) + +%description +EFL config daemon + +%prep +%setup -q +cp %{SOURCE2} . + +%build +./autogen.sh +TZ_SYS_BIN=%{TZ_SYS_BIN} ./configure --prefix %{_prefix}/ + +export TZ_SYS_RO_SHARE="%{TZ_SYS_RO_SHARE}" +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +mkdir -p %{buildroot}%{_unitdir_user}/basic.target.wants +mkdir -p %{buildroot}%{_unitdir_user}/default.target.wants +mkdir -p %{buildroot}%{_unitdir_user}/sockets.target.wants + +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}.service %{buildroot}%{_unitdir_user}/%{alias}.service +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}-post.service %{buildroot}%{_unitdir_user}/%{alias}-post.service +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}-ondemand.service %{buildroot}%{_unitdir_user}/%{alias}-ondemand.service +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}.socket %{buildroot}%{_unitdir_user}/%{alias}.socket + +ln -s ../%{alias}.service %{buildroot}%{_unitdir_user}/basic.target.wants/%{alias}.service +ln -s ../%{alias}-post.service %{buildroot}%{_unitdir_user}/default.target.wants/%{alias}-post.service +ln -s ../%{alias}.socket %{buildroot}%{_unitdir_user}/sockets.target.wants/%{alias}.socket + +%post +/sbin/ldconfig +mkdir -p /opt/share/.elementary +chmod -R 775 /opt/share/.elementary +chown -R :users /opt/share/.elementary +chsmack -a 'User::App::Shared' /opt/share/.elementary +chsmack -t /opt/share/.elementary + +%postun +/sbin/ldconfig +rm -f %{buildroot}%{_unitdir_user}/basic.target.wants/%{alias}.service +rm -f %{buildroot}%{_unitdir_user}/default.target.wants/%{alias}-post.service + +%files +%defattr(-,root,root,-) +%{TZ_SYS_BIN}/efl_config +%{_unitdir_user}/%{alias}.service +%{_unitdir_user}/%{alias}-post.service +%{_unitdir_user}/%{alias}-ondemand.service +%{_unitdir_user}/basic.target.wants/%{alias}.service +%{_unitdir_user}/default.target.wants/%{alias}-post.service +%{_unitdir_user}/sockets.target.wants/%{alias}.socket +%{_unitdir_user}/%{alias}.socket +%manifest %{alias}.manifest diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..2882bd5 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,8 @@ +MAINTAINERCLEANFILES = Makefile.in Makefile + +bin_PROGRAMS = efl_config +efl_config_SOURCES = efl_config.c + +efl_config_CFLAGS = $(ELEMENTARY_CFLAGS) $(ECOREWAYLAND_CFLAGS) $(CAPISYSTEMINFO_CFLAGS) -ggdb -I../lib -I../ -fPIE +efl_config_LDADD = $(ELEMENTARY_LIBS) $(ECOREWAYLAND_LIBS) $(CAPISYSTEMINFO_LIBS) -lutil -ldl -lsystemd +efl_config_LDFLAGS = -pie diff --git a/src/efl_config.c b/src/efl_config.c new file mode 100644 index 0000000..9be9032 --- /dev/null +++ b/src/efl_config.c @@ -0,0 +1,356 @@ +#include +#include + +#include +#include +#include +#include +#include + +#define BUF_SIZE 512 + +#define EFL_CONFIG_LOG_LEVEL "4" +#define EFL_CONFIG_RUN_TIMER_TIME 0.2 + +/* Determine Tizen profile at runtime */ +#include + +typedef enum { + TIZEN_PROFILE_UNKNOWN = 0, + TIZEN_PROFILE_MOBILE = 0x1, + TIZEN_PROFILE_WEARABLE = 0x2, + TIZEN_PROFILE_TV = 0x4, + TIZEN_PROFILE_IVI = 0x8, + TIZEN_PROFILE_COMMON = 0x10, +} tizen_profile_t; + +static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN; + +static tizen_profile_t _get_tizen_profile() +{ + char *profileName; + int *ret; + ret = system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); + if (ret != SYSTEM_INFO_ERROR_NONE) + { + EINA_LOG_ERR("efl-config :: fails to get profile, set as TIZEN_PROFILE_COMMON"); + profile = TIZEN_PROFILE_COMMON; + return profile; + } + + switch (*profileName) { + case 'm': + case 'M': + profile = TIZEN_PROFILE_MOBILE; + break; + case 'w': + case 'W': + profile = TIZEN_PROFILE_WEARABLE; + break; + case 't': + case 'T': + profile = TIZEN_PROFILE_TV; + break; + case 'i': + case 'I': + profile = TIZEN_PROFILE_IVI; + break; + default: // common or unknown ==> ALL ARE COMMON. + profile = TIZEN_PROFILE_COMMON; + } + free(profileName); + + return profile; +} + +static inline tizen_profile_t get_tizen_profile() +{ + if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1)) + return profile; + return _get_tizen_profile(); +} + +static void +_scale_set(void) +{ + Evas_Coord w, h; + float inch, scale = 0.0, saved_scale = 0.0, profile_factor = 1.0; + int dpi; + + ecore_wl_sync(); + dpi = ecore_wl_dpi_get(); + + tizen_profile_t prof = get_tizen_profile(); + if (prof == TIZEN_PROFILE_MOBILE || prof == TIZEN_PROFILE_IVI || prof == TIZEN_PROFILE_COMMON) + { + ecore_wl_screen_size_get(&w, &h); + + inch = floor(sqrt((w * w) + (h * h)) / dpi * 10 + 0.5) / 10; + + if (inch <= 4.5) profile_factor = 0.7; + else profile_factor = 0.8; + + scale = floor((double)dpi * profile_factor / 90.0 * 10 + 0.5) / 10; + } + else if (prof == TIZEN_PROFILE_WEARABLE) + { + profile_factor = 0.4; + scale = floor((double)dpi * profile_factor / 90.0 * 10 + 0.5) / 10; + } + else /* prof == TIZEN_PROFILE_TV */ + { + ecore_wl_screen_size_get(&w, &h); + + profile_factor = 2.0; + scale = floor((double)w * profile_factor / 1920 * 10 + 0.5) / 10; + } + + saved_scale = elm_config_scale_get(); + + if (scale != saved_scale && !getenv("ELM_SCALE")) + { + EINA_LOG_DBG("efl-config :: save new scale [%f], old scale [%f]", scale, saved_scale); + elm_config_scale_set(scale); + elm_config_save(); + elm_config_all_flush(); + } +} + +static void +_font_set(const char *font_name, int font_size) +{ + Eina_List *text_classes = NULL; + Elm_Text_Class *etc = NULL; + Eina_List *l = NULL; + + text_classes = elm_config_text_classes_list_get(); + + /* Legacy text_classes for Tizen */ + elm_config_font_overlay_set("tizen_medium", (const char *)font_name, -100); + elm_config_font_overlay_set("tizen_roman", (const char *)font_name, -100); + elm_config_font_overlay_set("tizen_bold", (const char *)font_name, -100); + elm_config_font_overlay_set("tizen_regular", (const char *)font_name, -100); + + /* "tizen" text_class is used only for changing font name */ + elm_config_font_overlay_set("tizen", (const char *)font_name, -100); + + EINA_LIST_FOREACH(text_classes, l, etc) + elm_config_font_overlay_set(etc->name, font_name, font_size); + + elm_config_text_classes_list_free(text_classes); + text_classes = NULL; + + elm_config_font_overlay_apply(); +} + +static Eina_Bool +_efl_config_message_parse(char *buf) +{ + char *token = NULL; + Eina_Bool need_to_save = EINA_FALSE; + const char *font_name = NULL; + int font_size = -100; /* 100% size based on each font_size */ + + token = strtok(buf, ": "); + + while (token) + { + if (!strncmp(token, "font_name", strlen("font_name"))) + { + /* Get Font Name */ + token = strtok(NULL, ","); + + if (token) + { + while (*token == ' ') token++; + + if (strcmp(token, "")) + font_name = token; + } + + EINA_LOG_DBG("efl-config :: font_name [%s]", font_name); + } + else if (!strncmp(token, "font_size", strlen("font_size"))) + { + /* Get Font Size */ + token = strtok(NULL, ","); + + if (token) + { + while (*token == ' ') token++; + font_size = atoi(token); + } + + if (font_size == 0) + { + EINA_LOG_ERR("efl-config :: font_size is zero [%d]", font_size); + font_size = -100; + } + + EINA_LOG_DBG("efl-config :: font_size [%d]", font_size); + } + /* TODO: Parse more config values here */ + + token = strtok(NULL, ": "); + } + + if (font_name) + { + EINA_LOG_INFO("efl-config :: sets font_name [%s], font_size [%d]", font_name, font_size); + _font_set(font_name, font_size); + need_to_save = EINA_TRUE; + } + /* TODO: Apply more config values here */ + + if (get_tizen_profile() == TIZEN_PROFILE_IVI || get_tizen_profile() == TIZEN_PROFILE_COMMON) + { + if (need_to_save) + { + EINA_LOG_DBG("efl-config :: calls elm_config_save!"); + elm_config_all_flush(); + elm_config_save(); + } + } + + return need_to_save; +} + +static int _create_sock_activation(void) +{ + int fds; + + fds = sd_listen_fds(0); + if (fds == 1) + return SD_LISTEN_FDS_START; + + EINA_LOG_ERR("efl-config :: ERROR :: fds > 1 ... fds [%d]", fds); + return -1; +} + + +static Eina_Bool +_efl_config_run_internal(void) +{ + int fd, client_fd, flags, size, i = 0; + char buf[BUF_SIZE] = { 0 }; + Eina_Bool need_to_save = EINA_FALSE; + + fd = _create_sock_activation(); + if (fd < 0) + { + EINA_LOG_ERR("efl-config :: fails to get socket fd[%d]!", fd); + return EINA_FALSE; + } + + /* Sets O_NONBLOCK flag to socket fd. + * It prevents blocking at accept() function when listen() queue is empty. */ + flags = fcntl(fd, F_GETFL, 0); + if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) + EINA_LOG_ERR("efl-config :: fails to set O_NONBLOCK flage to socket fd[%d].", fd); + + /* Gets a file descriptor while listen() queue is not empty */ + while ((client_fd = accept(fd, NULL, 0)) > 0) + { + /* Gets a message from client's fd */ + while ((size = read(client_fd, buf, BUF_SIZE - 1)) > 0) + { + EINA_LOG_INFO("efl-config :: %d. message received ... msg [%s], size [%d]", i++, buf, size); + + need_to_save |= _efl_config_message_parse(buf); + } + + close(client_fd); + } + + /* Save elementary's config */ + if (need_to_save) + { + EINA_LOG_INFO("efl-config :: calls elm_config_save!"); + elm_config_all_flush(); + elm_config_save(); + + return EINA_TRUE; + } + + return EINA_FALSE; +} + +static Eina_Bool +_efl_config_run_timer_cb(void *data) +{ + EINA_LOG_INFO("efl-config :: _efl_config_run_timer_cb START!"); + + /* Renew the timer if there is a additional message. */ + if (_efl_config_run_internal()) + { + EINA_LOG_INFO("efl-config :: _efl_config_run_timer_cb RENEW!"); + return ECORE_CALLBACK_RENEW; + } + + EINA_LOG_INFO("efl-config :: calls elm_exit()..."); + elm_exit(); + + EINA_LOG_INFO("efl-config :: _efl_config_run_timer_cb DONE!"); + return ECORE_CALLBACK_DONE; +} + +static void +_efl_config_run(double interval_time) +{ + static Ecore_Timer *efl_config_run_timer = NULL; + + if (efl_config_run_timer) ecore_timer_del(efl_config_run_timer); + + _efl_config_run_internal(); + + /* Run the efl-config process by elm_run() for a very short time. + * If there is no additional message, the timer will call elm_exit() to exit the process. */ + efl_config_run_timer = ecore_timer_add(interval_time, _efl_config_run_timer_cb, NULL); + + EINA_LOG_INFO("efl-config :: calls elm_run()..."); + elm_run(); +} + +int main(int argc, char **argv) +{ + int i = 0; + Eina_Bool opt_with_message = EINA_FALSE; + + setenv("EINA_LOG_LEVEL", EFL_CONFIG_LOG_LEVEL, 1); + + elm_init(argc, argv); + + EINA_LOG_INFO("efl-config :: START"); + + elm_win_add(NULL, "config", ELM_WIN_BASIC); + + if (argc > 1) + { + /* do if this daemon launched by system socket */ + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "--with-message")) + { + opt_with_message = EINA_TRUE; + EINA_LOG_DBG("efl-config :: + option with-message"); + } + } + } + else + { + EINA_LOG_DBG("efl-config :: Launching without option. Call _scale_set()"); + _scale_set(); + } + + if (opt_with_message) + { + EINA_LOG_INFO("efl-config :: Calls _efl_config_run()..."); + _efl_config_run(EFL_CONFIG_RUN_TIMER_TIME); + } + + EINA_LOG_INFO("efl-config :: DONE"); + + elm_shutdown(); + + return 0; +} -- 2.7.4 From 977ed8f472b8cd002ab4779df316152e9344e87a Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Fri, 8 Sep 2017 15:17:42 +0900 Subject: [PATCH 3/9] remove build warning Change-Id: Ia77e5a7dfa3b1f8ba42dfb8df369ee7d3e00fb38 --- src/efl_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/efl_config.c b/src/efl_config.c index 9be9032..579ab93 100644 --- a/src/efl_config.c +++ b/src/efl_config.c @@ -29,7 +29,7 @@ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN; static tizen_profile_t _get_tizen_profile() { char *profileName; - int *ret; + int ret; ret = system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); if (ret != SYSTEM_INFO_ERROR_NONE) { -- 2.7.4 From 1747283bd9cf91056951a500d9c75e97205bad8a Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Mon, 19 Mar 2018 13:52:15 +0900 Subject: [PATCH 4/9] Modify to support ecore_wl2 this patch replaces ecore_wayland by ecore_wl2 for efl 1.20 upgrade. Change-Id: I847cf9dfb9ebc79912e1259f89db4ea5b33bf4f6 Signed-off-by: Wonki Kim --- configure.ac | 2 +- packaging/efl-config.spec | 4 +++- src/efl_config.c | 20 ++++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 3a643bd..eafb272 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ LT_INIT AC_PROG_LIBTOOL # Checks for library functions. PKG_CHECK_MODULES([ELEMENTARY],[elementary]) -PKG_CHECK_MODULES([ECOREWAYLAND],[ecore-wayland]) +PKG_CHECK_MODULES([ECOREWAYLAND],[ecore-wl2]) PKG_CHECK_MODULES([CAPISYSTEMINFO],[capi-system-info]) AC_SUBST([DESKTOP]) diff --git a/packaging/efl-config.spec b/packaging/efl-config.spec index 74728f1..0a6790e 100644 --- a/packaging/efl-config.spec +++ b/packaging/efl-config.spec @@ -11,7 +11,7 @@ Source2: %{alias}.manifest BuildRequires: automake BuildRequires: libtool BuildRequires: pkgconfig(elementary) -BuildRequires: pkgconfig(ecore-wayland) +BuildRequires: pkgconfig(ecore-wl2) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(capi-system-info) @@ -24,6 +24,8 @@ EFL config daemon cp %{SOURCE2} . %build +export CFLAGS+=" -DEFL_BETA_API_SUPPORT " + ./autogen.sh TZ_SYS_BIN=%{TZ_SYS_BIN} ./configure --prefix %{_prefix}/ diff --git a/src/efl_config.c b/src/efl_config.c index 579ab93..3230c9a 100644 --- a/src/efl_config.c +++ b/src/efl_config.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -71,19 +71,23 @@ static inline tizen_profile_t get_tizen_profile() } static void -_scale_set(void) +_scale_set(Evas_Object *win) { Evas_Coord w, h; float inch, scale = 0.0, saved_scale = 0.0, profile_factor = 1.0; int dpi; - ecore_wl_sync(); - dpi = ecore_wl_dpi_get(); + Ecore_Wl2_Window *wlwin = elm_win_wl_window_get(win); + Ecore_Wl2_Output *wlout = ecore_wl2_window_output_find(wlwin); + Ecore_Wl2_Display *wldp = ecore_wl2_window_display_get(wlwin); + + ecore_wl2_sync(); + dpi = ecore_wl2_output_dpi_get(wlout); tizen_profile_t prof = get_tizen_profile(); if (prof == TIZEN_PROFILE_MOBILE || prof == TIZEN_PROFILE_IVI || prof == TIZEN_PROFILE_COMMON) { - ecore_wl_screen_size_get(&w, &h); + ecore_wl2_display_screen_size_get(wldp, &w, &h); inch = floor(sqrt((w * w) + (h * h)) / dpi * 10 + 0.5) / 10; @@ -99,7 +103,7 @@ _scale_set(void) } else /* prof == TIZEN_PROFILE_TV */ { - ecore_wl_screen_size_get(&w, &h); + ecore_wl2_display_screen_size_get(wldp, &w, &h); profile_factor = 2.0; scale = floor((double)w * profile_factor / 1920 * 10 + 0.5) / 10; @@ -322,7 +326,7 @@ int main(int argc, char **argv) EINA_LOG_INFO("efl-config :: START"); - elm_win_add(NULL, "config", ELM_WIN_BASIC); + Evas_Object *win = elm_win_add(NULL, "config", ELM_WIN_BASIC); if (argc > 1) { @@ -339,7 +343,7 @@ int main(int argc, char **argv) else { EINA_LOG_DBG("efl-config :: Launching without option. Call _scale_set()"); - _scale_set(); + _scale_set(win); } if (opt_with_message) -- 2.7.4 From 17564c2072497b32e3a3582b5ac58ec88c5ce154 Mon Sep 17 00:00:00 2001 From: Youngbok Shin Date: Wed, 14 Mar 2018 14:56:29 +0900 Subject: [PATCH 5/9] Change socket path which is synced with "efl_extension_config.c" We recieved a request to change socket path. In addition, the opposite side of the socket in system_setting is moved to efl-ext package. So, the path has to be synced with efl-ext. Change-Id: I3250bc1b7c1b589ffb207fe1bf72291c0fff8de9 --- packaging/efl-config.socket | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/efl-config.socket b/packaging/efl-config.socket index ec67c4f..39572dc 100644 --- a/packaging/efl-config.socket +++ b/packaging/efl-config.socket @@ -2,7 +2,7 @@ Description=EFL Config Service socket [Socket] -ListenStream=/run/user_ext/%U/.efl-config.sock +ListenStream=/run/user_ext/%U/system_share/.efl-config.sock Service=efl-config-ondemand.service SocketMode=0777 -- 2.7.4 From 2e4bf5677980ff9ca7ae2ca80ba60f8426a806e2 Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Tue, 3 Apr 2018 13:07:12 +0900 Subject: [PATCH 6/9] Fix booting performance issue The efl_config is setting device scale information in booting time. After EFL 1.20 migration, the booting time became longer than before. It is because The Efl.Ui.Win uses a frame object which is NOT used on Tizen. Please refer to following stack. The evas_font_load needs around 3 seconds. evas_font_load _evas_text_font_reload efl_text_properties_font_set efl_gfx_scale_set _edje_text_recalc_apply _edje_part_recalc_single_text _edje_part_recalc_single _edje_part_recalc _edje_recalc_do _edje_program_run _edje_program_run _edje_program_run _edje_emit_handle _edje_message_process _edje_object_message_signal_process_do _efl_canvas_layout_efl_layout_signal_signal_process efl_layout_signal_process edje_object_message_signal_process _elm_win_frame_style_update _elm_win_frame_add _efl_win_finalize_internal _efl_ui_win_efl_object_finalize efl_finalize _efl_add_end main () Setting device scale information does not need to use the frame object. Moreover Tizen does not use the frame object. So we was about to use Efl.Ui.Win without the frame object by checking _elm_config->win_no_border. BUT, we might use Efl.Ui.Win frame object some day. This patch set is making Efl.Ui.Win keep creating the frame object by checking ecore_wl2 only (without Efl.Ui.Win). Change-Id: Ib46fb752e195d41aa0a42169e24e0b5b85b27aa6 --- src/efl_config.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/efl_config.c b/src/efl_config.c index 3230c9a..1e854f8 100644 --- a/src/efl_config.c +++ b/src/efl_config.c @@ -71,15 +71,22 @@ static inline tizen_profile_t get_tizen_profile() } static void -_scale_set(Evas_Object *win) +_scale_set(void) { Evas_Coord w, h; float inch, scale = 0.0, saved_scale = 0.0, profile_factor = 1.0; int dpi; - Ecore_Wl2_Window *wlwin = elm_win_wl_window_get(win); + Ecore_Wl2_Display *wldp = ecore_wl2_display_connect(NULL); + Ecore_Wl2_Window *wlwin = ecore_wl2_window_new(wldp, NULL, 0, 0, 1, 1); Ecore_Wl2_Output *wlout = ecore_wl2_window_output_find(wlwin); - Ecore_Wl2_Display *wldp = ecore_wl2_window_display_get(wlwin); + + if (!wldp || !wlwin || !wlout) + { + EINA_LOG_ERR("efl-config :: %s is NULL", + !wldp ? "display" : (!wlwin ? "window" : "output")); + return; + } ecore_wl2_sync(); dpi = ecore_wl2_output_dpi_get(wlout); @@ -118,6 +125,8 @@ _scale_set(Evas_Object *win) elm_config_save(); elm_config_all_flush(); } + + ecore_wl2_window_free(wlwin); } static void @@ -326,8 +335,6 @@ int main(int argc, char **argv) EINA_LOG_INFO("efl-config :: START"); - Evas_Object *win = elm_win_add(NULL, "config", ELM_WIN_BASIC); - if (argc > 1) { /* do if this daemon launched by system socket */ @@ -343,7 +350,7 @@ int main(int argc, char **argv) else { EINA_LOG_DBG("efl-config :: Launching without option. Call _scale_set()"); - _scale_set(win); + _scale_set(); } if (opt_with_message) -- 2.7.4 From 9029c1f6d70308bcc69be69e6dcef3b9b10830de Mon Sep 17 00:00:00 2001 From: Jongmin Lee Date: Mon, 18 Jun 2018 10:59:48 +0900 Subject: [PATCH 7/9] config: change the location of socket file Change-Id: Idba92155898df31a17cb46d532d6465c570d7c2f --- packaging/efl-config.socket | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/efl-config.socket b/packaging/efl-config.socket index 39572dc..cde0933 100644 --- a/packaging/efl-config.socket +++ b/packaging/efl-config.socket @@ -2,7 +2,7 @@ Description=EFL Config Service socket [Socket] -ListenStream=/run/user_ext/%U/system_share/.efl-config.sock +ListenStream=/run/user/%U/system_share/.efl-config.sock Service=efl-config-ondemand.service SocketMode=0777 -- 2.7.4 From 489b8643fff72ba44dab1f1975f95c1f230c0a27 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Thu, 16 Aug 2018 10:08:59 +0900 Subject: [PATCH 8/9] Add RemainAfterExit=yes to efl-config.service Because efl-config.service belongs to basic.target.wants, this service runs whenever any other service in the user session is run on-demand. (The logs show that at-spi-dbus-bus.service runs on-demand.) Signed-off-by: INSUN PYO Change-Id: Ib16d8aaa94a08d366ae7aab46dd8c6913c4f4256 --- packaging/efl-config.service.in | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/efl-config.service.in b/packaging/efl-config.service.in index c7b7d19..8c7c463 100644 --- a/packaging/efl-config.service.in +++ b/packaging/efl-config.service.in @@ -6,5 +6,6 @@ After=enlightenment-user.service [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/usr/bin/sh -c "while [ ! -f /run/.wm_ready ] ; do /usr/bin/sleep .1 ; done ; exec @TZ_SYS_BIN@/efl_config" EnvironmentFile=-/run/tizen-system-env -- 2.7.4 From 6969613dc8659c1ae60b5841bb3b40bc77605d8f Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Fri, 19 Apr 2019 13:28:34 +0200 Subject: [PATCH 9/9] tizen: Add additional unit for "unified" user session The unified user session is about moving user session units, managed by systemd --user, to main systemd, where it's managed as part of newly created user@.target. user@.target will contain same units as previously available in user/, with same UID and environment setup. systemd instance is used for unit to be able to specify UID (inherited from user@.target). The rationale behind this work is following: * VD requirement to remove user session support * boot time optimization requirements, due to: + 'systemd --user' taking 1s its own startup that could be used for unit startup + ability to better rearrange units if these managed by one systemd instance Unit installed by this commit will not be used till user login mechanism will be changed in systemd package (via changing pam_systemd to start user@.target, rather than user@.service). Change-Id: I26e2fb649b1cb509c8d067899e5c55be53b36d74 --- configure.ac | 3 +++ packaging/efl-config-ondemand@.service.in | 12 ++++++++++++ packaging/efl-config-post@.service.in | 12 ++++++++++++ packaging/efl-config.spec | 21 +++++++++++++++++++++ packaging/efl-config@.service.in | 16 ++++++++++++++++ packaging/efl-config@.socket | 14 ++++++++++++++ 6 files changed, 78 insertions(+) create mode 100644 packaging/efl-config-ondemand@.service.in create mode 100644 packaging/efl-config-post@.service.in create mode 100644 packaging/efl-config@.service.in create mode 100644 packaging/efl-config@.socket diff --git a/configure.ac b/configure.ac index eafb272..31e7f87 100644 --- a/configure.ac +++ b/configure.ac @@ -29,5 +29,8 @@ AC_CONFIG_FILES([Makefile packaging/efl-config.service packaging/efl-config-post.service packaging/efl-config-ondemand.service + packaging/efl-config@.service + packaging/efl-config-post@.service + packaging/efl-config-ondemand@.service ]) AC_OUTPUT diff --git a/packaging/efl-config-ondemand@.service.in b/packaging/efl-config-ondemand@.service.in new file mode 100644 index 0000000..f081bbf --- /dev/null +++ b/packaging/efl-config-ondemand@.service.in @@ -0,0 +1,12 @@ +[Unit] +PartOf=userlogin@%i.target +Description=Change the efl configures. + +[Service] +User=%i +Environment=DBUS_SESSION_BUS_ADDRESS=kernel:path=/sys/fs/kdbus/%i-user/bus;unix:path=/run/user/%i/bus +Environment=XDG_RUNTIME_DIR=/run/user/%i +SmackProcessLabel=User +Type=simple +ExecStart=@TZ_SYS_BIN@/efl_config --with-message +EnvironmentFile=-/run/tizen-system-env diff --git a/packaging/efl-config-post@.service.in b/packaging/efl-config-post@.service.in new file mode 100644 index 0000000..b08699b --- /dev/null +++ b/packaging/efl-config-post@.service.in @@ -0,0 +1,12 @@ +[Unit] +PartOf=userlogin@%i.target +Description=Change the efl configures. + +[Service] +User=%i +Environment=DBUS_SESSION_BUS_ADDRESS=kernel:path=/sys/fs/kdbus/%i-user/bus;unix:path=/run/user/%i/bus +Environment=XDG_RUNTIME_DIR=/run/user/%i +SmackProcessLabel=User +Type=simple +ExecStart=@TZ_SYS_BIN@/efl_config +EnvironmentFile=-/run/tizen-system-env diff --git a/packaging/efl-config.spec b/packaging/efl-config.spec index 0a6790e..05725c8 100644 --- a/packaging/efl-config.spec +++ b/packaging/efl-config.spec @@ -39,16 +39,28 @@ rm -rf %{buildroot} mkdir -p %{buildroot}%{_unitdir_user}/basic.target.wants mkdir -p %{buildroot}%{_unitdir_user}/default.target.wants mkdir -p %{buildroot}%{_unitdir_user}/sockets.target.wants +mkdir -p %{buildroot}%{_unitdir}/user-basic@.target.wants +mkdir -p %{buildroot}%{_unitdir}/user-default@.target.wants +mkdir -p %{buildroot}%{_unitdir}/user-sockets@.target.wants install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}.service %{buildroot}%{_unitdir_user}/%{alias}.service install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}-post.service %{buildroot}%{_unitdir_user}/%{alias}-post.service install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}-ondemand.service %{buildroot}%{_unitdir_user}/%{alias}-ondemand.service install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}.socket %{buildroot}%{_unitdir_user}/%{alias}.socket +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}@.service %{buildroot}%{_unitdir}/%{alias}@.service +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}-post@.service %{buildroot}%{_unitdir}/%{alias}-post@.service +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}-ondemand@.service %{buildroot}%{_unitdir}/%{alias}-ondemand@.service +install -m 0644 %{_builddir}/%{name}-%{version}/packaging/%{alias}@.socket %{buildroot}%{_unitdir}/%{alias}@.socket + ln -s ../%{alias}.service %{buildroot}%{_unitdir_user}/basic.target.wants/%{alias}.service ln -s ../%{alias}-post.service %{buildroot}%{_unitdir_user}/default.target.wants/%{alias}-post.service ln -s ../%{alias}.socket %{buildroot}%{_unitdir_user}/sockets.target.wants/%{alias}.socket +ln -s ../%{alias}@.service %{buildroot}%{_unitdir}/user-basic@.target.wants/%{alias}@.service +ln -s ../%{alias}-post@.service %{buildroot}%{_unitdir}/user-default@.target.wants/%{alias}-post@.service +ln -s ../%{alias}@.socket %{buildroot}%{_unitdir}/user-sockets@.target.wants/%{alias}@.socket + %post /sbin/ldconfig mkdir -p /opt/share/.elementary @@ -61,6 +73,8 @@ chsmack -t /opt/share/.elementary /sbin/ldconfig rm -f %{buildroot}%{_unitdir_user}/basic.target.wants/%{alias}.service rm -f %{buildroot}%{_unitdir_user}/default.target.wants/%{alias}-post.service +rm -f %{buildroot}%{_unitdir}/user-basic@.target.wants/%{alias}@.service +rm -f %{buildroot}%{_unitdir}/user-default@.target.wants/%{alias}-post@.service %files %defattr(-,root,root,-) @@ -72,4 +86,11 @@ rm -f %{buildroot}%{_unitdir_user}/default.target.wants/%{alias}-post.service %{_unitdir_user}/default.target.wants/%{alias}-post.service %{_unitdir_user}/sockets.target.wants/%{alias}.socket %{_unitdir_user}/%{alias}.socket +%{_unitdir}/%{alias}@.service +%{_unitdir}/%{alias}-post@.service +%{_unitdir}/%{alias}-ondemand@.service +%{_unitdir}/user-basic@.target.wants/%{alias}@.service +%{_unitdir}/user-default@.target.wants/%{alias}-post@.service +%{_unitdir}/user-sockets@.target.wants/%{alias}@.socket +%{_unitdir}/%{alias}@.socket %manifest %{alias}.manifest diff --git a/packaging/efl-config@.service.in b/packaging/efl-config@.service.in new file mode 100644 index 0000000..d2c7cb6 --- /dev/null +++ b/packaging/efl-config@.service.in @@ -0,0 +1,16 @@ +[Unit] +PartOf=userlogin@%i.target +Description=Change the efl configures. +DefaultDependencies=no +Before=starter@%i.service +After=enlightenment-user@%i.service + +[Service] +User=%i +Environment=DBUS_SESSION_BUS_ADDRESS=kernel:path=/sys/fs/kdbus/%i-user/bus;unix:path=/run/user/%i/bus +Environment=XDG_RUNTIME_DIR=/run/user/%i +SmackProcessLabel=User +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/sh -c "while [ ! -f /run/.wm_ready ] ; do /usr/bin/sleep .1 ; done ; exec /usr/bin/efl_config" +EnvironmentFile=-/run/tizen-system-env diff --git a/packaging/efl-config@.socket b/packaging/efl-config@.socket new file mode 100644 index 0000000..ab9f30b --- /dev/null +++ b/packaging/efl-config@.socket @@ -0,0 +1,14 @@ +[Unit] +PartOf=userlogin@%i.target +DefaultDependencies=no +After=systemd-logind.service +Description=EFL Config Service socket + +[Socket] +SocketUser=%i +ListenStream=/run/user/%i/system_share/.efl-config.sock +Service=efl-config-ondemand@%i.service +SocketMode=0777 + +[Install] +WantedBy=user-sockets@.target -- 2.7.4