From: jk7744.park Date: Tue, 8 Sep 2015 13:13:29 +0000 (+0900) Subject: tizen 2.3.1 release X-Git-Tag: submit/tizen_2.3.1/20150915.080118^0 X-Git-Url: http://review.tizen.org/git/?p=framework%2Fappfw%2Fapp-core.git;a=commitdiff_plain;h=3552376471df823576c72e67b430dd80d21cbaf0 tizen 2.3.1 release --- diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..6ab0cd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +build_log +*.log +*.pyc +usr +opt +*.o +*.os +*.exe +packages +binaries +*.ipk +*~ +build-stamp +cmake_build_tmp/ +configure-stamp +debian/files +debian/*.install +debian/*.substvars +debian/*.debhelper +debian/app-template/ +debian/libappcore-common-0/ +debian/libappcore-common-dev/ +debian/libappcore-dbg/ +debian/libappcore-efl-0/ +debian/libappcore-efl-dev/ +debian/libappcore-gtk-0/ +debian/libappcore-gtk-dev/ diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 44f491e..fb908e8 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,11 +31,19 @@ SET(HEADERS_common appcore-common.h) INCLUDE(FindPkgConfig) #pkg_check_modules(pkg_common REQUIRED pmapi vconf sensor aul rua dlog x11) -pkg_check_modules(pkg_common REQUIRED vconf sensor aul dlog x11 ecore-x) +pkg_check_modules(pkg_common REQUIRED vconf sensor aul dlog x11 ecore-x ) FOREACH(flag ${pkg_common_CFLAGS}) SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} ${flag}") ENDFOREACH(flag) +IF(_APPFW_FEATURE_PROCESS_POOL) + ADD_DEFINITIONS("-D_APPFW_FEATURE_PROCESS_POOL") +ENDIF(_APPFW_FEATURE_PROCESS_POOL) + +IF(_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS) + ADD_DEFINITIONS("-D_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS") +ENDIF(_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS) + ADD_LIBRARY(${APPCORE_COMMON} SHARED ${SRCS_common}) SET_TARGET_PROPERTIES(${APPCORE_COMMON} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES(${APPCORE_COMMON} PROPERTIES VERSION ${VERSION}) @@ -55,11 +63,12 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/SLP_Appcore_PG.h DESTINATION i # Build appcore-efl Library # ------------------------------ SET(APPCORE_EFL "appcore-efl") -SET(SRCS_efl src/appcore-efl.c) +SET(SRCS_efl src/appcore-efl.c src/virtual_canvas.c) + SET(HEADERS_efl appcore-efl.h) INCLUDE(FindPkgConfig) -pkg_check_modules(pkg_efl REQUIRED elementary dlog sysman ecore ecore-x gobject-2.0 glib-2.0) +pkg_check_modules(pkg_efl REQUIRED elementary dlog ecore ecore-x gobject-2.0 glib-2.0 x11 xcomposite ecore-evas ecore-input aul evas vconf) FOREACH(flag ${pkg_efl_CFLAGS}) SET(EXTRA_CFLAGS_efl "${EXTRA_CFLAGS_efl} ${flag}") ENDFOREACH(flag) diff --git a/app-core.manifest b/app-core.manifest new file mode 100644 index 0000000..97e8c31 --- /dev/null +++ b/app-core.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/include/appcore-common.h b/include/appcore-common.h index cd61e01..f0b5b44 100755 --- a/include/appcore-common.h +++ b/include/appcore-common.h @@ -52,7 +52,9 @@ extern "C" { #endif +#ifndef _ #define _(str) gettext(str) /**< gettext alias */ +#endif #define gettext_noop(str) (str) /**< keyword for xgettext to extract translatable strings */ #define N_(str) gettext_noop(str) /**< gettext_noop alias */ @@ -201,7 +203,7 @@ int add_callbacks(struct appdata *data) * */ int appcore_set_event_callback(enum appcore_event event, - int (*cb)(void *), void *data); + int (*cb)(void *, void *), void *data); /** * @par Description: @@ -255,7 +257,7 @@ static int _rot_cb(enum appcore_rm, void *); * @endcode * */ -int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *), +int appcore_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data); /** @@ -705,6 +707,7 @@ static int _open_cb(enum appcore_rm, void *); */ int appcore_set_open_cb(int (*cb) (void *), void *data); +char *appcore_get_caller_appid(void); #ifdef __cplusplus } diff --git a/include/appcore-efl.h b/include/appcore-efl.h index 794734a..9ffd34b 100755 --- a/include/appcore-efl.h +++ b/include/appcore-efl.h @@ -61,7 +61,7 @@ extern "C" { * To develop an application using EFL on this platform. * * @par Method of function operation: - * Initialize the EFL, internationalization, and notifications + * Initialize the EFL, internationalization, and notifications * for receiving system events such as rotation, low battery, etc.\n * And, start an ecore mainloop. * @@ -158,6 +158,14 @@ int _create(void *data) */ int appcore_set_system_resource_reclaiming(bool enable); +int appcore_efl_goto_pause(); + +int appcore_set_prelaunching(bool value); + +#ifdef _APPFW_FEATURE_PROCESS_POOL +int appcore_set_preinit_window_name(const char* win_name); +#endif + #ifdef __cplusplus } #endif diff --git a/include/appcore-internal.h b/include/appcore-internal.h index 975d308..cca466b 100755 --- a/include/appcore-internal.h +++ b/include/appcore-internal.h @@ -24,7 +24,7 @@ #ifndef __APPCORE_INTERNAL_H__ #define __APPCORE_INTERNAL_H__ -#define LOG_TAG "Appcore" +#define LOG_TAG "APP_CORE" #include #include @@ -35,28 +35,9 @@ # define EXPORT_API __attribute__ ((visibility("default"))) #endif -#ifndef _DLOG_H_ -# define _ERR(fmt, arg...) \ - do { fprintf(stderr, "appcore: "fmt"\n", ##arg); } while (0) - -# define _INFO(fmt, arg...) \ - do { fprintf(stdout, fmt"\n", ##arg); } while (0) - -# define _DBG(fmt, arg...) \ - do { \ - if (getenv("APPCORE_DEBUG")) { \ - fprintf(stdout, fmt"\n", ##arg); \ - } \ - } while (0) -#else -# define _ERR(fmt, arg...) \ - do { \ - fprintf(stderr, "appcore: "fmt"\n", ##arg); \ - LOGE(fmt, ##arg); \ - } while (0) +# define _ERR(fmt, arg...) LOGE(fmt, ##arg) # define _INFO(...) LOGI(__VA_ARGS__) # define _DBG(...) LOGD(__VA_ARGS__) -#endif #define _warn_if(expr, fmt, arg...) do { \ if (expr) { \ @@ -90,6 +71,27 @@ } \ } while (0) +#define goto_if(expr, val) do { \ + if(expr) { \ + _ERR("(%s) -> goto", #expr); \ + goto val; \ + } \ + } while (0) + +#define break_if(expr) { \ + if(expr) { \ + _ERR("(%s) -> break", #expr); \ + break; \ + } \ + } + +#define continue_if(expr) { \ + if(expr) { \ + _ERR("(%s) -> continue", #expr); \ + continue; \ + } \ + } + /** * Appcore internal state */ @@ -132,7 +134,7 @@ enum sys_event { * Appcore system event operation */ struct sys_op { - int (*func) (void *); + int (*func) (void *, void *); void *data; }; @@ -169,9 +171,19 @@ extern int x_raise_win(pid_t pid); int appcore_pause_rotation_cb(void); int appcore_resume_rotation_cb(void); +struct ui_wm_rotate { + int (*set_rotation_cb) (int (*cb) (void *event_info, enum appcore_rm, void *), void *data); + int (*unset_rotation_cb) (void); + int (*get_rotation_state) (enum appcore_rm *curr); + int (*pause_rotation_cb) (void); + int (*resume_rotation_cb) (void); +}; +int appcore_set_wm_rotation(struct ui_wm_rotate* wm_rotate); #define ENV_START "APP_START_TIME" #define MEMORY_FLUSH_ACTIVATE +#define APPID_MAX 256 + #endif /* __APPCORE_INTERNAL_H__ */ diff --git a/include/virtual_canvas.h b/include/virtual_canvas.h new file mode 100644 index 0000000..2d523f8 --- /dev/null +++ b/include/virtual_canvas.h @@ -0,0 +1,34 @@ +/* + * starter + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungtaek Chung , Mi-Ju Lee , Xi Zhichan + * + * 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 __STARTER_VIRTUAL_CANVAS_H__ +#define __STARTER_VIRTUAL_CANVAS_H__ + +#include +#include + +extern Evas *virtual_canvas_create(int w, int h); +extern bool virtual_canvas_flush_to_file(Evas *e, const char *filename, int w, int h); +extern bool virtual_canvas_destroy(Evas *e); + +#endif //__STARTER_VIRTUAL_CANVAS_H__ + +// End of a file diff --git a/packaging/app-core.spec b/packaging/app-core.spec old mode 100644 new mode 100755 index 7f3fd9f..d71c1b0 --- a/packaging/app-core.spec +++ b/packaging/app-core.spec @@ -1,26 +1,33 @@ - Name: app-core Summary: Application basic -Version: 1.2 -Release: 28 +Version: 1.3.40 +Release: 1 Group: TO_BE/FILLED_IN -License: Apache License, Version 2.0 +License: Apache-2.0 Source0: app-core-%{version}.tar.gz +Source101: packaging/core-efl.target BuildRequires: pkgconfig(sensor) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(rua) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(x11) -BuildRequires: pkgconfig(sysman) +BuildRequires: pkgconfig(xcomposite) +BuildRequires: pkgconfig(xext) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(ecore-evas) +BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(edje) +BuildRequires: pkgconfig(eet) +BuildRequires: pkgconfig(eina) BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: cmake -BuildRequires: sysman-devel - +%if "%{?tizen_profile_name}" == "wearable" +BuildRequires: pkgconfig(system-resource) +%endif %description SLP common application basic @@ -62,6 +69,7 @@ Requires: pkgconfig(sensor) Requires: pkgconfig(vconf) Requires: pkgconfig(elementary) Requires: pkgconfig(aul) +Requires: pkgconfig(x11) %description common-devel Application basics common (devel) @@ -74,21 +82,50 @@ Group: Development/Libraries Application basics template +%define appfw_feature_visibility_check_by_lcd_status 1 %prep -%setup -q +%setup -q %build -CFLAGS="-I/usr/lib/glib-2.0/include/ -I/usr/include/glib-2.0 -I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0 -I/usr/include/e_dbus-1 -I/usr/include/ethumb-0 -I/usr/include/edje-1 -I/usr/include/efreet-1 -I/usr/include/embryo-1 -I/usr/include/ecore-1 -I/usr/include/eet-1 -I/usr/include/evas-1 -I/usr/include/eina-1 -I/usr/include/eina-1/eina $(CFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DENABLE_GTK=OFF - +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" +%if 0%{?appfw_feature_visibility_check_by_lcd_status} +export CFLAGS="$CFLAGS -D_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS" +#_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS=ON +%endif + +#export CFLAGS="$CFLAGS -Wall -Werror -Wno-unused-function" +cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} -DENABLE_GTK=OFF \ + -D_APPFW_FEATURE_PROCESS_POOL:BOOL=ON \ + -D_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS:BOOL=${_APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS} \ + . + +%if "%{?tizen_profile_name}" == "wearable" +export CFLAGS="$CFLAGS -DWEARABLE" +%elseif "%{?tizen_profile_name}" == "mobile" +export CFLAGS="$CFLAGS -DMOBILE" +%endif make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install +install -d %{buildroot}%{_libdir}/systemd/user/core-efl.target.wants +install -m0644 %{SOURCE101} %{buildroot}%{_libdir}/systemd/user/ +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name}-efl +cp LICENSE %{buildroot}/usr/share/license/%{name}-common + +%post efl -%post efl -p /sbin/ldconfig +/sbin/ldconfig +mkdir -p /opt/usr/share/app_capture +chmod 777 /opt/usr/share/app_capture +chsmack -a "system::homedir" /opt/usr/share/app_capture +chsmack -t /opt/usr/share/app_capture %postun efl -p /sbin/ldconfig @@ -101,8 +138,10 @@ rm -rf %{buildroot} %files efl +%manifest app-core.manifest %defattr(-,root,root,-) %{_libdir}/libappcore-efl.so.* +/usr/share/license/%{name}-efl %files efl-devel %defattr(-,root,root,-) @@ -111,8 +150,12 @@ rm -rf %{buildroot} %{_libdir}/pkgconfig/appcore-efl.pc %files common +%manifest app-core.manifest %defattr(-,root,root,-) %{_libdir}/libappcore-common.so.* +%{_libdir}/systemd/user/core-efl.target +%{_libdir}/systemd/user/core-efl.target.wants/ +/usr/share/license/%{name}-common %files common-devel %defattr(-,root,root,-) diff --git a/packaging/core-efl.target b/packaging/core-efl.target new file mode 100644 index 0000000..67ec56e --- /dev/null +++ b/packaging/core-efl.target @@ -0,0 +1,15 @@ +# +# This virtual unit maps the default core components and their dependencies. +# +# The real desktop services should go into the final desktop target +# folder, which should require this virtual target. While starting +# up, systemd will assure that the core EFL and daemons start before +# anything else. After the core target finishes, dependencies should +# not matter too much anymore and less fine-grained dependencies can +# be used. +# + +[Unit] +Description=Core EFL UI target +After=xorg.target +Requires=xorg.target diff --git a/src/appcore-X.c b/src/appcore-X.c index 8595860..34b987f 100755 --- a/src/appcore-X.c +++ b/src/appcore-X.c @@ -129,7 +129,7 @@ static int __raise_win(Display *d, Window win) return 0; } -int x_raise_win(pid_t pid) +EXPORT_API int x_raise_win(pid_t pid) { int r; @@ -152,7 +152,6 @@ int x_raise_win(pid_t pid) _retv_if(d == NULL, -1); win = XDefaultRootWindow(d); - if (!a_pid) a_pid = XInternAtom(d, "_NET_WM_PID", True); diff --git a/src/appcore-efl.c b/src/appcore-efl.c index 162619f..ea5eabf 100755 --- a/src/appcore-efl.c +++ b/src/appcore-efl.c @@ -19,25 +19,72 @@ * */ - +#include +#include +#include +#include +#include +#include #include #include #include #include #include +#include +#include +#include +#include +#ifdef WEARABLE +#include +#endif + #include +#include +#include +#include +#include #include #include #include -#include #include #include +#include #include "appcore-internal.h" #include "appcore-efl.h" +#include "virtual_canvas.h" +#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS +#include +#endif + +#define SYSMAN_MAXSTR 100 +#define SYSMAN_MAXARG 16 +#define SYSNOTI_SOCKET_PATH "/tmp/sn" +#define RETRY_READ_COUNT 10 +#define MAX_PACKAGE_STR_SIZE 512 + +#define PREDEF_BACKGRD "backgrd" +#define PREDEF_FOREGRD "foregrd" + +enum sysnoti_cmd { + ADD_SYSMAN_ACTION, + CALL_SYSMAN_ACTION +}; + +struct sysnoti { + int pid; + int cmd; + char *type; + char *path; + int argc; + char *argv[SYSMAN_MAXARG]; +}; static pid_t _pid; static bool resource_reclaiming = TRUE; +static bool prelaunching = FALSE; + + struct ui_priv { const char *name; @@ -46,11 +93,19 @@ struct ui_priv { Ecore_Event_Handler *hshow; Ecore_Event_Handler *hhide; Ecore_Event_Handler *hvchange; + Ecore_Event_Handler *hcmsg; /* WM_ROTATE */ Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */ struct appcore_ops *ops; void (*mfcb) (void); /* Memory Flushing Callback */ + + /* WM_ROTATE */ + int wm_rot_supported; + int rot_started; + int (*rot_cb) (void *event_info, enum appcore_rm, void *); + void *rot_cb_data; + enum appcore_rm rot_mode; }; static struct ui_priv priv; @@ -74,12 +129,249 @@ static const char *_as_name[] = { [AS_DYING] = "DYING", }; -static bool b_active = 1; +static int b_active = -1; +static bool first_launch = 1; +static int is_legacy_lifecycle = 0; + struct win_node { unsigned int win; bool bfobscured; }; +static struct ui_wm_rotate wm_rotate; + +static inline int send_int(int fd, int val) +{ + return write(fd, &val, sizeof(int)); +} + +static inline int send_str(int fd, char *str) +{ + int len; + int ret; + if (str == NULL) { + len = 0; + ret = write(fd, &len, sizeof(int)); + } else { + len = strlen(str); + if (len > SYSMAN_MAXSTR) + len = SYSMAN_MAXSTR; + write(fd, &len, sizeof(int)); + ret = write(fd, str, len); + } + return ret; +} + +static int sysnoti_send(struct sysnoti *msg) +{ + int client_len; + int client_sockfd; + int result; + int r; + int retry_count = 0; + struct sockaddr_un clientaddr; + int i; + + client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (client_sockfd == -1) { + _ERR("%s: socket create failed\n", __FUNCTION__); + return -1; + } + bzero(&clientaddr, sizeof(clientaddr)); + clientaddr.sun_family = AF_UNIX; + strncpy(clientaddr.sun_path, SYSNOTI_SOCKET_PATH, sizeof(clientaddr.sun_path) - 1); + client_len = sizeof(clientaddr); + + if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) < + 0) { + _ERR("%s: connect failed\n", __FUNCTION__); + close(client_sockfd); + return -1; + } + + send_int(client_sockfd, msg->pid); + send_int(client_sockfd, msg->cmd); + send_str(client_sockfd, msg->type); + send_str(client_sockfd, msg->path); + send_int(client_sockfd, msg->argc); + for (i = 0; i < msg->argc; i++) + send_str(client_sockfd, msg->argv[i]); + + while (retry_count < RETRY_READ_COUNT) { + r = read(client_sockfd, &result, sizeof(int)); + if (r < 0) { + if (errno == EINTR) { + _ERR("Re-read for error(EINTR)"); + retry_count++; + continue; + } + _ERR("Read fail for str length"); + result = -1; + break; + + } + break; + } + if (retry_count == RETRY_READ_COUNT) { + _ERR("Read retry failed"); + } + + close(client_sockfd); + return result; +} + +void __trm_app_info_send_socket(char *write_buf) +{ + const char trm_socket_for_app_info[] = "/dev/socket/app_info"; + int socket_fd = 0; + int ret = 0; + struct sockaddr_un addr; + + _DBG("__trm_app_info_send_socket"); + + if (access(trm_socket_for_app_info, F_OK) != 0) { + _ERR("access"); + goto trm_end; + } + + socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + if (socket_fd < 0) { + _ERR("socket"); + goto trm_end; + } + + memset(&addr, 0, sizeof(addr)); + sprintf(addr.sun_path, "%s", trm_socket_for_app_info); + addr.sun_family = AF_LOCAL; + + ret = connect(socket_fd, (struct sockaddr *) &addr ,sizeof(sa_family_t) + strlen(trm_socket_for_app_info) ); + if (ret != 0) { + close(socket_fd); + goto trm_end; + } + + send(socket_fd, write_buf, strlen(write_buf), MSG_DONTWAIT | MSG_NOSIGNAL); + _DBG("send"); + + close(socket_fd); +trm_end: + return; +} + +#ifdef _APPFW_FEATURE_CPU_BOOST +static void __stop_cpu_boost(void) +{ + const char trm_sock_for_cpu_boost[] = "/dev/socket/scenario_info"; + int sock_fd = 0; + int ret = 0; + struct sockaddr_un addr; + const char command[] = "AppLaunchUnlock"; + + _DBG("__stop_cpu_boost enter"); + + if (access(trm_sock_for_cpu_boost, F_OK) != 0) { + _ERR("access() failed, errno: %d (%s)", errno, strerror(errno)); + goto error; + } + + sock_fd = socket(AF_LOCAL, SOCK_STREAM, 0); + if (sock_fd < 0) { + _ERR("socket() failed, errno: %d (%s)", errno, strerror(errno)); + goto error; + } + + memset(&addr, 0, sizeof(addr)); + sprintf(addr.sun_path, "%s", trm_sock_for_cpu_boost); + addr.sun_family = AF_LOCAL; + + ret = connect(sock_fd, (struct sockaddr *) &addr, sizeof(sa_family_t) + strlen(trm_sock_for_cpu_boost)); + if (ret != 0) { + _ERR("connect() failed, errno: %d (%s)", errno, strerror(errno)); + close(sock_fd); + goto error; + } + + ret = send(sock_fd, command, strlen(command), MSG_DONTWAIT | MSG_NOSIGNAL); + if (ret < 0) { + _ERR("send() failed, errno: %d (%s)", errno, strerror(errno)); + close(sock_fd); + goto error; + } + + close(sock_fd); + _DBG("__stop_cpu_boost ok"); + +error: + return; +} +#endif + +static int _call_predef_action(const char *type, int num, ...) +{ + struct sysnoti *msg; + int ret; + va_list argptr; + + int i; + char *args = NULL; + + if (type == NULL || num > SYSMAN_MAXARG) { + errno = EINVAL; + return -1; + } + + msg = malloc(sizeof(struct sysnoti)); + + if (msg == NULL) { + /* Do something for not enought memory error */ + return -1; + } + + msg->pid = getpid(); + msg->cmd = CALL_SYSMAN_ACTION; + msg->type = (char *)type; + msg->path = NULL; + + msg->argc = num; + va_start(argptr, num); + for (i = 0; i < num; i++) { + args = va_arg(argptr, char *); + msg->argv[i] = args; + } + va_end(argptr); + + ret = sysnoti_send(msg); + free(msg); + + return ret; +} + +static int _inform_foregrd(void) +{ + char buf[255]; + snprintf(buf, sizeof(buf), "%d", getpid()); + return _call_predef_action(PREDEF_FOREGRD, 1, buf); +} + +static int _inform_backgrd(void) +{ + char buf[255]; + snprintf(buf, sizeof(buf), "%d", getpid()); + return _call_predef_action(PREDEF_BACKGRD, 1, buf); +} + + + +char appid[APPID_MAX]; + +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER +bool taskmanage; +static void _capture_and_make_file(Ecore_X_Window win, int pid, const char *package); +#endif + +static bool __check_skip(Ecore_X_Window xwin); + + static int WIN_COMP(gconstpointer data1, gconstpointer data2) { struct win_node *a = (struct win_node *)data1; @@ -87,7 +379,7 @@ static int WIN_COMP(gconstpointer data1, gconstpointer data2) return (int)((a->win)-(b->win)); } -GSList *g_winnode_list; +GSList *g_winnode_list = NULL; #if defined(MEMORY_FLUSH_ACTIVATE) static Eina_Bool __appcore_memory_flush_cb(void *data) @@ -96,7 +388,6 @@ static Eina_Bool __appcore_memory_flush_cb(void *data) appcore_flush_memory(); ui->mftimer = NULL; - printf("test\n"); return ECORE_CALLBACK_CANCEL; } @@ -104,7 +395,7 @@ static Eina_Bool __appcore_memory_flush_cb(void *data) static int __appcore_low_memory_post_cb(struct ui_priv *ui) { if (ui->state == AS_PAUSED) { - appcore_flush_memory(); + // appcore_flush_memory(); } else { malloc_trim(0); } @@ -139,20 +430,45 @@ static int __appcore_low_memory_post_cb(ui_priv *ui) static void __appcore_efl_memory_flush_cb(void) { - _DBG("[APP %d] __appcore_efl_memory_flush_cb()", _pid); + //_DBG("[APP %d] __appcore_efl_memory_flush_cb()", _pid); elm_cache_all_flush(); } +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER +static Eina_Bool __appcore_mimiapp_capture_cb(void *data) +{ + GSList *iter = NULL; + struct win_node *entry = NULL; + + for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) { + entry = iter->data; + if(__check_skip(entry->win) == FALSE) + break; + } + if(iter) { + entry = iter->data; + if(taskmanage) { + _capture_and_make_file(entry->win, getpid(), appid); + } + } + + return ECORE_CALLBACK_CANCEL; +} +#endif + static void __do_app(enum app_event event, void *data, bundle * b) { int r = -1; struct ui_priv *ui = data; + char trm_buf[MAX_PACKAGE_STR_SIZE]; +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + const char *miniapp = NULL; +#endif - _DBG("[APP %d] Event: %d", _pid, event); _ret_if(ui == NULL || event >= AE_MAX); _DBG("[APP %d] Event: %s State: %s", _pid, _ae_name[event], _as_name[ui->state]); - printf("test"); + if (event == AE_MEM_FLUSH) { ui->mfcb(); return; @@ -179,12 +495,43 @@ static void __do_app(enum app_event event, void *data, bundle * b) case AE_RESET: _DBG("[APP %d] RESET", _pid); LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", - ui->name); + ui->name); if (ui->ops->reset) r = ui->ops->reset(b, ui->ops->data); + LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name); + + if(first_launch) { + first_launch = 0; + is_legacy_lifecycle = aul_get_support_legacy_lifecycle(); + + _INFO("Legacy lifecycle: %d", is_legacy_lifecycle); + if (!is_legacy_lifecycle) { + _INFO("[APP %d] Initial Launching, call the resume_cb", _pid); + if (ui->ops->resume) + r = ui->ops->resume(ui->ops->data); + } + } else { + _INFO("Legacy lifecycle: %d", is_legacy_lifecycle); + if (!is_legacy_lifecycle) { + _INFO("[APP %d] App already running, raise the window", _pid); + x_raise_win(getpid()); + + if (ui->state == AS_PAUSED) { + _INFO("[APP %d] Call the resume_cb", _pid); + if (ui->ops->resume) + r = ui->ops->resume(ui->ops->data); + } + } + } + ui->state = AS_RUNNING; - LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", - ui->name); + +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + miniapp = bundle_get_val(b, "http://tizen.org/appcontrol/data/miniapp"); + if(miniapp && strncmp(miniapp, "on", 2) == 0) { + ecore_timer_add(0.5, __appcore_mimiapp_capture_cb, NULL); + } +#endif break; case AE_PAUSE: if (ui->state == AS_RUNNING) { @@ -198,7 +545,12 @@ static void __do_app(enum app_event event, void *data, bundle * b) /* TODO : rotation stop */ //r = appcore_pause_rotation_cb(); - sysman_inform_backgrd(); + snprintf(trm_buf, MAX_PACKAGE_STR_SIZE, "appinfo_pause:[PID]%d", getpid()); + __trm_app_info_send_socket(trm_buf); +#ifdef WEARABLE + proc_group_change_status(PROC_CGROUP_SET_BACKGRD, getpid(), NULL); +#endif + //_inform_backgrd(); break; case AE_RESUME: LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]", @@ -215,7 +567,22 @@ static void __do_app(enum app_event event, void *data, bundle * b) ui->name); LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:Launching:done]", ui->name); - sysman_inform_foregrd(); + +#ifdef _GATE_TEST_ENABLE + if(strncmp(ui->name, "wrt-client", 10) != 0) { + LOG(LOG_DEBUG, "GATE-M", "APP_FULLY_LOADED_%s", ui->name); + } +#endif + +#ifdef WEARABLE + proc_group_change_status(PROC_CGROUP_SET_FOREGRD, getpid(), NULL); +#endif + snprintf(trm_buf, MAX_PACKAGE_STR_SIZE,"appinfo_resume:[PID]%d", getpid()); + __trm_app_info_send_socket(trm_buf); +#ifdef _APPFW_FEATURE_CPU_BOOST + __stop_cpu_boost(); +#endif + //_inform_foregrd(); break; default: @@ -235,17 +602,45 @@ static bool __check_visible(void) GSList *iter = NULL; struct win_node *entry = NULL; - _DBG("[EVENT_TEST][EVENT] __check_visible\n"); - for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) { - entry = iter->data; - _DBG("win : %x obscured : %d\n", entry->win, entry->bfobscured); + entry = iter->data; + //_DBG("win : %x obscured : %d\n", entry->win, entry->bfobscured); if(entry->bfobscured == FALSE) - return TRUE; + return TRUE; } return FALSE; } +static bool __check_skip(Ecore_X_Window xwin) +{ + unsigned int i, num; + Ecore_X_Window_State *state; + int ret; + + ret = ecore_x_netwm_window_state_get(xwin, &state, &num); + _DBG("ret(%d), win(%x), state(%x), num(%d)", ret, xwin, state, num); + if (state) { + for (i = 0; i < num; i++) { + _DBG("state[%d] : %d", i, state[i]); + switch (state[i]) { + case ECORE_X_WINDOW_STATE_SKIP_TASKBAR: + free(state); + return TRUE; + break; + case ECORE_X_WINDOW_STATE_SKIP_PAGER: + free(state); + return TRUE; + break; + default: + /* Ignore */ + break; + } + } + } + free(state); + return FALSE; +} + static bool __exist_win(unsigned int win) { struct win_node temp; @@ -272,7 +667,7 @@ static bool __add_win(unsigned int win) return FALSE; t->win = win; - t->bfobscured = FALSE; + t->bfobscured = TRUE; _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win); @@ -306,9 +701,8 @@ static bool __delete_win(unsigned int win) return 0; } - g_winnode_list = g_slist_remove_link(g_winnode_list, f); - free(f->data); + g_winnode_list = g_slist_delete_link(g_winnode_list, f); return TRUE; } @@ -333,9 +727,8 @@ static bool __update_win(unsigned int win, bool bfobscured) return FALSE; } - g_winnode_list = g_slist_remove_link(g_winnode_list, f); - free(f->data); + g_winnode_list = g_slist_delete_link(g_winnode_list, f); t = calloc(1, sizeof(struct win_node)); if (t == NULL) @@ -345,12 +738,75 @@ static bool __update_win(unsigned int win, bool bfobscured) t->bfobscured = bfobscured; g_winnode_list = g_slist_append(g_winnode_list, t); - + return TRUE; } +/* WM_ROTATE */ +static Ecore_X_Atom _WM_WINDOW_ROTATION_SUPPORTED = 0; +static Ecore_X_Atom _WM_WINDOW_ROTATION_CHANGE_REQUEST = 0; + +static int __check_wm_rotation_support(void) +{ + _DBG("Disable window manager rotation"); + return -1; +#if 0 + Ecore_X_Window root, win, win2; + int ret; + + if (!_WM_WINDOW_ROTATION_SUPPORTED) { + _WM_WINDOW_ROTATION_SUPPORTED = + ecore_x_atom_get("_E_WINDOW_ROTATION_SUPPORTED"); + } + + if (!_WM_WINDOW_ROTATION_CHANGE_REQUEST) { + _WM_WINDOW_ROTATION_CHANGE_REQUEST = + ecore_x_atom_get("_E_WINDOW_ROTATION_CHANGE_REQUEST"); + } + + root = ecore_x_window_root_first_get(); + ret = ecore_x_window_prop_xid_get(root, + _WM_WINDOW_ROTATION_SUPPORTED, + ECORE_X_ATOM_WINDOW, + &win, 1); + if ((ret == 1) && (win)) + { + ret = ecore_x_window_prop_xid_get(win, + _WM_WINDOW_ROTATION_SUPPORTED, + ECORE_X_ATOM_WINDOW, + &win2, 1); + if ((ret == 1) && (win2 == win)) + return 0; + } + + return -1; +#endif +} + +static void __set_wm_rotation_support(unsigned int win, unsigned int set) +{ + GSList *iter = NULL; + struct win_node *entry = NULL; + + if (0 == win) { + for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) { + entry = iter->data; + if (entry->win) { + ecore_x_window_prop_card32_set(entry->win, + _WM_WINDOW_ROTATION_SUPPORTED, + &set, 1); + } + } + } else { + ecore_x_window_prop_card32_set(win, + _WM_WINDOW_ROTATION_SUPPORTED, + &set, 1); + } +} + Ecore_X_Atom atom_parent; +Ecore_X_Atom xsend_Atom; static Eina_Bool __show_cb(void *data, int type, void *event) { @@ -369,8 +825,13 @@ static Eina_Bool __show_cb(void *data, int type, void *event) _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x\n", ev->win); - if (!__exist_win((unsigned int)ev->win)) + if (!__exist_win((unsigned int)ev->win)) { + /* WM_ROTATE */ + if ((priv.wm_rot_supported) && (1 == priv.rot_started)) { + __set_wm_rotation_support(ev->win, 1); + } __add_win((unsigned int)ev->win); + } else __update_win((unsigned int)ev->win, FALSE); @@ -388,12 +849,19 @@ static Eina_Bool __hide_cb(void *data, int type, void *event) if (__exist_win((unsigned int)ev->win)) { __delete_win((unsigned int)ev->win); - + bvisibility = __check_visible(); - if (!bvisibility && b_active == 1) { + if (!bvisibility && b_active != 0) { _DBG(" Go to Pasue state \n"); b_active = 0; __do_app(AE_PAUSE, data, NULL); +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + if(taskmanage) { + _capture_and_make_file(ev->win, getpid(), appid); + } else if ( aul_is_subapp() ) { + _capture_and_make_file(ev->win, getpid(), appcore_get_caller_appid()); + } +#endif } } @@ -404,21 +872,39 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event) { Ecore_X_Event_Window_Visibility_Change *ev; int bvisibility = 0; +#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS + int lcd_status = 0; +#endif ev = event; __update_win((unsigned int)ev->win, ev->fully_obscured); bvisibility = __check_visible(); - if (bvisibility && b_active == 0) { + _DBG("bvisibility %d, b_active %d", bvisibility, b_active); + + if (bvisibility && b_active != 1) { _DBG(" Go to Resume state\n"); b_active = 1; - __do_app(AE_RESUME, data, NULL); - } else if (!bvisibility && b_active == 1) { +#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS + vconf_get_int(VCONFKEY_PM_STATE, &lcd_status); + if(lcd_status == VCONFKEY_PM_STATE_LCDOFF) { + return ECORE_CALLBACK_RENEW; + } +#endif + __do_app(AE_RESUME, data, NULL); + } else if (!bvisibility && (b_active != 0)) { _DBG(" Go to Pasue state \n"); b_active = 0; __do_app(AE_PAUSE, data, NULL); +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + if(taskmanage) { + _capture_and_make_file(ev->win, getpid(), appid); + } else if ( aul_is_subapp() ) { + _capture_and_make_file(ev->win, getpid(), appcore_get_caller_appid()); + } +#endif } else _DBG(" No change state \n"); @@ -426,6 +912,49 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event) } +/* WM_ROTATE */ +static Eina_Bool __cmsg_cb(void *data, int type, void *event) +{ + struct ui_priv *ui = (struct ui_priv *)data; + Ecore_X_Event_Client_Message *e = event; + +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + if (e->message_type == xsend_Atom) { + _DBG("_E_ILLUME_ATOM_APPCORE_RECAPTURE_REQUEST win(%x)", e->win); + _capture_and_make_file(e->win, getpid(), appid); + return ECORE_CALLBACK_PASS_ON; + } +#endif + + if (!ui) return ECORE_CALLBACK_PASS_ON; + if (e->format != 32) return ECORE_CALLBACK_PASS_ON; + if (e->message_type == _WM_WINDOW_ROTATION_CHANGE_REQUEST) { + if ((0 == ui->wm_rot_supported) || + (0 == ui->rot_started) || + (NULL == ui->rot_cb)) { + return ECORE_CALLBACK_PASS_ON; + } + + enum appcore_rm rm; + switch (e->data.l[1]) + { + case 0: rm = APPCORE_RM_PORTRAIT_NORMAL; break; + case 90: rm = APPCORE_RM_LANDSCAPE_REVERSE; break; + case 180: rm = APPCORE_RM_PORTRAIT_REVERSE; break; + case 270: rm = APPCORE_RM_LANDSCAPE_NORMAL; break; + default: rm = APPCORE_RM_UNKNOWN; break; + } + + ui->rot_mode = rm; + + if (APPCORE_RM_UNKNOWN != rm) { + ui->rot_cb((void *)&rm, rm, ui->rot_cb_data); + } + } + + return ECORE_CALLBACK_PASS_ON; +} + static void __add_climsg_cb(struct ui_priv *ui) { _ret_if(ui == NULL); @@ -434,21 +963,37 @@ static void __add_climsg_cb(struct ui_priv *ui) if (!atom_parent) { // Do Error Handling + _ERR("atom_parent is NULL"); + } + xsend_Atom = ecore_x_atom_get("_E_ILLUME_ATOM_APPCORE_RECAPTURE_REQUEST"); + if (!xsend_Atom) + { + // Do Error Handling + _ERR("xsend_Atom is NULL"); } - ui->hshow = - ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui); - ui->hhide = - ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui); - ui->hvchange = - ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, - __visibility_cb, ui); + ui->hshow = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui); + ui->hhide = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui); + ui->hvchange = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, ui); + +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + ui->hcmsg = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __cmsg_cb, ui); +#endif + /* Add client message callback for WM_ROTATE */ + if(!__check_wm_rotation_support()) + { + //ui->hcmsg = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __cmsg_cb, ui); + ui->wm_rot_supported = 1; + appcore_set_wm_rotation(&wm_rotate); + } } static int __before_loop(struct ui_priv *ui, int *argc, char ***argv) { int r; + char *hwacc = NULL; + char *tm_tmp = NULL; if (argc == NULL || argv == NULL) { _ERR("argc/argv is NULL"); @@ -459,15 +1004,42 @@ static int __before_loop(struct ui_priv *ui, int *argc, char ***argv) g_type_init(); elm_init(*argc, *argv); + hwacc = getenv("HWACC"); + if(hwacc == NULL) { + _DBG("elm_config_preferred_engine_set is not called"); + } else if(strcmp(hwacc, "USE") == 0) { + elm_config_preferred_engine_set("opengl_x11"); + _DBG("elm_config_preferred_engine_set : opengl_x11"); + } else if(strcmp(hwacc, "NOT_USE") == 0) { + elm_config_preferred_engine_set("software_x11"); + _DBG("elm_config_preferred_engine_set : software_x11"); + } else { + _DBG("elm_config_preferred_engine_set is not called"); + } +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + tm_tmp = getenv("TASKMANAGE"); + if(tm_tmp == NULL) { + _DBG("taskmanage is null"); + taskmanage = 1; + } else if(strcmp(tm_tmp, "false") == 0) { + _DBG("taskmanage is false"); + taskmanage = 0; + } else { + _DBG("taskmanage is true %s", tm_tmp); + taskmanage = 1; + } +#endif r = appcore_init(ui->name, &efl_ops, *argc, *argv); _retv_if(r == -1, -1); LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:appcore_init:done]", ui->name); if (ui->ops && ui->ops->create) { r = ui->ops->create(ui->ops->data); - if (r == -1) { + if (r < 0) { _ERR("create() return error"); appcore_exit(); + if (ui->ops && ui->ops->terminate) + ui->ops->terminate(ui->ops->data); errno = ECANCELED; return -1; } @@ -486,6 +1058,12 @@ static void __after_loop(struct ui_priv *ui) appcore_unset_rotation_cb(); appcore_exit(); + if (ui->state == AS_RUNNING) { + _DBG("[APP %d] PAUSE before termination", _pid); + if (ui->ops && ui->ops->pause) + ui->ops->pause(ui->ops->data); + } + if (ui->ops && ui->ops->terminate) ui->ops->terminate(ui->ops->data); @@ -499,6 +1077,12 @@ static void __after_loop(struct ui_priv *ui) __appcore_timer_del(ui); elm_shutdown(); + +#ifdef _GATE_TEST_ENABLE + if((ui->name) && (strncmp(ui->name, "wrt-client", 10) != 0)) { + LOG(LOG_DEBUG, "GATE-M", "APP_CLOSED_%s", ui->name); + } +#endif } static int __set_data(struct ui_priv *ui, const char *name, @@ -531,6 +1115,13 @@ static int __set_data(struct ui_priv *ui, const char *name, _pid = getpid(); + /* WM_ROTATE */ + ui->wm_rot_supported = 0; + ui->rot_started = 0; + ui->rot_cb = NULL; + ui->rot_cb_data = NULL; + ui->rot_mode = APPCORE_RM_UNKNOWN; + return 0; } @@ -542,13 +1133,449 @@ static void __unset_data(struct ui_priv *ui) memset(ui, 0, sizeof(struct ui_priv)); } +/* WM_ROTATE */ +static int __wm_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data) +{ + if (cb == NULL) { + errno = EINVAL; + return -1; + } + + if ((priv.wm_rot_supported) && (0 == priv.rot_started)) { + __set_wm_rotation_support(0, 1); + } + + priv.rot_cb = cb; + priv.rot_cb_data = data; + priv.rot_started = 1; + + return 0; +} + +static int __wm_unset_rotation_cb(void) +{ + if ((priv.wm_rot_supported) && (1 == priv.rot_started)) { + __set_wm_rotation_support(0, 0); + } + + priv.rot_cb = NULL; + priv.rot_cb_data = NULL; + priv.rot_started = 0; + + return 0; +} + +static int __wm_get_rotation_state(enum appcore_rm *curr) +{ + if (curr == NULL) { + errno = EINVAL; + return -1; + } + + *curr = priv.rot_mode; + + return 0; +} + +static int __wm_pause_rotation_cb(void) +{ + if ((1 == priv.rot_started) && (priv.wm_rot_supported)) { + __set_wm_rotation_support(0, 0); + } + + priv.rot_started = 0; + + return 0; +} + +static int __wm_resume_rotation_cb(void) +{ + if ((0 == priv.rot_started) && (priv.wm_rot_supported)) { + __set_wm_rotation_support(0, 1); + } + + priv.rot_started = 1; + + return 0; +} + +static struct ui_wm_rotate wm_rotate = { + __wm_set_rotation_cb, + __wm_unset_rotation_cb, + __wm_get_rotation_state, + __wm_pause_rotation_cb, + __wm_resume_rotation_cb +}; + +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER +static Window _get_parent_window(Window id) +{ + Window root; + Window parent; + Window *children; + unsigned int num; + + if (!XQueryTree(ecore_x_display_get(), id, &root, &parent, &children, &num)) { + return 0; + } + + if (children) { + XFree(children); + } + + return parent; +} + +static Window _find_capture_window(Window id, Visual **visual, int *depth, int *width, int *height) +{ + XWindowAttributes attr; + Window parent = id; + Window orig_id = id; + + if (id == 0) { + return (Window)-1; + } + + do { + id = parent; + + if (!XGetWindowAttributes(ecore_x_display_get(), id, &attr)) { + return (Window)-1; + } + + parent = _get_parent_window(id); + + if (attr.map_state == IsViewable + && attr.override_redirect == True + && attr.class == InputOutput && parent == attr.root) { + *depth = attr.depth; + *width = attr.width; + *height = attr.height; + *visual = attr.visual; + return id; + } + } while (parent != attr.root && parent != 0); + + XGetWindowAttributes(ecore_x_display_get(), orig_id, &attr); + *depth = attr.depth; + *width = attr.width; + *height = attr.height; + *visual = attr.visual; + + return (Window) 0; + +} + +static char *_capture_window(Window id, Visual *visual, int width, int height, int depth, int *size) +{ + XShmSegmentInfo si; + XImage *xim; + int img_size; + char *captured_img = NULL; + + /* (depth >> 3) + 1 == 4 byte */ + si.shmid = + shmget(IPC_PRIVATE, width * height * ((depth >> 3) + 1), + IPC_CREAT | 0666); + + if (si.shmid < 0) { + _ERR("shmget"); + return NULL; + } + + si.readOnly = False; + si.shmaddr = shmat(si.shmid, NULL, 0); + + if (si.shmaddr == (char *)-1) { + shmdt(si.shmaddr); + shmctl(si.shmid, IPC_RMID, 0); + return NULL; + } + + xim = XShmCreateImage(ecore_x_display_get(), visual, depth, ZPixmap, NULL, &si, + width, height); + + if (xim == 0) { + shmdt(si.shmaddr); + shmctl(si.shmid, IPC_RMID, 0); + + return NULL; + } + + img_size = xim->bytes_per_line * xim->height; + xim->data = si.shmaddr; + + XSync(ecore_x_display_get(), False); + XShmAttach(ecore_x_display_get(), &si); + XShmGetImage(ecore_x_display_get(), id, xim, 0, 0, 0xFFFFFFFF); + XSync(ecore_x_display_get(), False); + + captured_img = calloc(1, img_size); + if (captured_img) { + memcpy(captured_img, xim->data, img_size); + } else { + _ERR("calloc"); + } + + XShmDetach(ecore_x_display_get(), &si); + XDestroyImage(xim); + + + shmdt(si.shmaddr); + shmctl(si.shmid, IPC_RMID, 0); + + *size = img_size; + + return captured_img; + +} + +#define _WND_REQUEST_ANGLE_IDX 0 +#define _WND_CURR_ANGLE_IDX 1 +int _get_angle(Ecore_X_Window win) +{ + int after = -1; + int before = -1; + + do { + int ret, count; + int angle[2] = {-1, -1}; + unsigned char* prop_data = NULL; + + ret = ecore_x_window_prop_property_get(win, + ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, + ECORE_X_ATOM_CARDINAL, + 32, + &prop_data, + &count); + if (ret <= 0) { + if (prop_data) free(prop_data); + break; + } + + if (prop_data) { + memcpy(&angle, prop_data, sizeof (int) *count); + free(prop_data); + } + + after= angle[_WND_REQUEST_ANGLE_IDX]; + before = angle[_WND_CURR_ANGLE_IDX]; + } while (0); + + if (-1 == after) after = 0; + + return after; +} + +static void _rotate_img(Evas_Object *image_object, int angle, int cx, int cy) +{ + Evas_Map *em; + + _ret_if(NULL == image_object); + + em = evas_map_new(4); + _ret_if(NULL == em); + + evas_map_util_points_populate_from_object(em, image_object); + evas_map_util_rotate(em, (double) angle, cx, cy); + + evas_object_map_set(image_object, em); + evas_object_map_enable_set(image_object, EINA_TRUE); + + evas_map_free(em); +} + +#define EXTENSION_LEN 128 +#define CAPTURE_FILE_PATH "/opt/usr/share/app_capture" +bool _make_capture_file(const char *package, int width, int height, char *img, int angle) +{ + int len; + char *filename; + Evas *e; + Evas_Object *image_object; + int canvas_width, canvas_height; + int cx = 0, cy = 0; + int mx = 0; + int r = 0; + + _retv_if(NULL == package, false); + + len = strlen(package) + EXTENSION_LEN; + filename = malloc(len); + _retv_if(NULL == filename, false); + snprintf(filename, len, CAPTURE_FILE_PATH"/%s.jpg", package); + + if (90 == angle || 270 == angle) { + canvas_width = height; + canvas_height = width; + } else { + canvas_width = width; + canvas_height = height; + } + + e = virtual_canvas_create(canvas_width, canvas_height); + goto_if(NULL == e, error); + + image_object = evas_object_image_add(e); + goto_if(NULL == image_object, error); + + evas_object_image_size_set(image_object, width, height); + evas_object_image_data_set(image_object, img); + evas_object_image_data_update_add(image_object, 0, 0, width, height); + evas_object_resize(image_object, width, height); + evas_object_image_filled_set(image_object, EINA_TRUE); + switch (angle) { + case 90: + cx = canvas_width - width / 2; + cy = canvas_height / 2; + mx = canvas_width - width; + break; + case 180: + cx = width / 2; + cy = height / 2; + break; + case 270: + cx = width / 2; + cy = canvas_height / 2; + break; + default: + break; + } + evas_object_move(image_object, mx, 0); + _rotate_img(image_object, angle, cx, cy); + evas_object_show(image_object); + + if (access(CAPTURE_FILE_PATH, F_OK) != 0) { + r = mkdir(CAPTURE_FILE_PATH, 0777); + goto_if(r < 0, error); + } + goto_if(false == virtual_canvas_flush_to_file(e, filename, canvas_width, canvas_height), error); + + evas_object_del(image_object); + virtual_canvas_destroy(e); + free(filename); + + return true; + +error: + do { + free(filename); + + if (!e) break; + virtual_canvas_destroy(e); + + if (!image_object) break; + evas_object_del(image_object); + } while (0); + + return false; +} + +int __resize8888(const char* pDataIn, char* pDataOut, int inWidth, int inHeight, int outWidth, int outHeight) +{ + int scaleX = 0; + int scaleY = 0; + int i = 0; + int j = 0; + int iRow = 0; + int iIndex = 0; + char* pOutput = pDataOut; + char* pOut = pDataOut; + const char* pIn = NULL; + int *pColLUT = malloc(sizeof(int) * outWidth); + + /* Calculate X Scale factor */ + scaleX = inWidth * 256 / outWidth; + /* Calculate Y Scale factor, aspect ratio is not maintained */ + scaleY = inHeight * 256 / outHeight; + for (j = 0; j < outWidth; j++) + { + /* Get input index based on column scale factor */ + /* To get more optimization, this is calculated once and + * is placed in a LUT and used for indexing + */ + pColLUT [j] = ((j * scaleX) >> 8) * 4; + } + pOut = pOutput; + for (i = 0; i < outHeight; i++) + { + /* Get input routWidth index based on routWidth scale factor */ + iRow = (i * scaleY >> 8) * inWidth * 4; + /* Loop could be unrolled for more optimization */ + for (j = 0; j < (outWidth); j++) + { + /* Get input index based on column scale factor */ + iIndex = iRow + pColLUT [j]; + pIn = pDataIn + iIndex; + *pOut++ = *pIn++; + *pOut++ = *pIn++; + *pOut++ = *pIn++; + *pOut++ = *pIn++; + } + } + + free(pColLUT); + return 0; +} + +static void _capture_and_make_file(Ecore_X_Window win, int pid, const char *package) +{ + Visual *visual; + Window redirected_id; + + int width, height, depth; + int width_out, height_out; + int size = 0; + int angle; + + char *img; + + redirected_id = _find_capture_window(win, &visual, &depth, &width, &height); + _ret_if(redirected_id == (Window) -1 || + redirected_id == (Window) 0); + + SECURE_LOGD("Capture : win[%x] -> redirected win[%x] for %s[%d]", win, redirected_id, package, pid); + + img = _capture_window(redirected_id, visual, width, height, depth, &size); + _ret_if(NULL == img); + + width_out = width/2; + height_out = height/2; + + if ( width_out < 1 || height_out < 1 ) { + free(img); + return; + } + + __resize8888(img, img, width, height, width_out, height_out); + + angle = _get_angle(win); + if (false == _make_capture_file(package, width_out, height_out, img, angle)) { + _ERR("cannot a capture file for the package of [%s]", package); + } + + free(img); +} +#endif + +extern int aul_status_update(int status); + EXPORT_API int appcore_efl_main(const char *name, int *argc, char ***argv, struct appcore_ops *ops) { int r; + GSList *iter = NULL; + struct win_node *entry = NULL; + int pid; LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", name); + pid = getpid(); + r = aul_app_get_appid_bypid(pid, appid, APPID_MAX); + if( r < 0) { + _ERR("aul_app_get_appid_bypid fail"); + } + r = __set_data(&priv, name, ops); _retv_if(r == -1, -1); @@ -560,6 +1587,22 @@ EXPORT_API int appcore_efl_main(const char *name, int *argc, char ***argv, elm_run(); + aul_status_update(STATUS_DYING); + +#ifdef _APPFW_FEATURE_CAPTURE_FOR_TASK_MANAGER + for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) { + entry = iter->data; + if(__check_skip(entry->win) == FALSE) + break; + } + if(iter) { + entry = iter->data; + if(taskmanage) { + _capture_and_make_file(entry->win, pid, appid); + } + } +#endif + __after_loop(&priv); __unset_data(&priv); @@ -573,3 +1616,57 @@ EXPORT_API int appcore_set_system_resource_reclaiming(bool enable) return 0; } + +EXPORT_API int appcore_set_app_state(int state) +{ + priv.state = state; + + return 0; +} + +EXPORT_API int appcore_efl_goto_pause() +{ + _DBG(" Go to Pasue state \n"); + b_active = 0; + __do_app(AE_PAUSE, &priv, NULL); + + return 0; +} + +EXPORT_API int appcore_set_prelaunching(bool value) +{ + prelaunching = value; + + return 0; +} + +#ifdef _APPFW_FEATURE_PROCESS_POOL +EXPORT_API int appcore_set_preinit_window_name(const char* win_name) +{ + int ret = -1; + void *preinit_window = NULL; + + if(!win_name) { + _ERR("invalid input param"); + return -1; + } + + preinit_window = aul_get_preinit_window(win_name); + if(!preinit_window) { + _ERR("no preinit window"); + return -1; + } + + const Evas *e = evas_object_evas_get((const Evas_Object *)preinit_window); + if(e) { + Ecore_Evas *ee = ecore_evas_ecore_evas_get(e); + if(ee) { + ecore_evas_name_class_set(ee, win_name, win_name); + _DBG("name class set success : %s", win_name); + ret = 0; + } + } + + return ret; +} +#endif diff --git a/src/appcore-i18n.c b/src/appcore-i18n.c index de03620..974f81f 100755 --- a/src/appcore-i18n.c +++ b/src/appcore-i18n.c @@ -33,17 +33,16 @@ static int _set; void update_lang(void) { - char *lang; - char *r; - - lang = vconf_get_str(VCONFKEY_LANGSET); + char *lang = vconf_get_str(VCONFKEY_LANGSET); if (lang) { setenv("LANG", lang, 1); setenv("LC_MESSAGES", lang, 1); - r = setlocale(LC_ALL, ""); + char *r = setlocale(LC_ALL, ""); if (r == NULL) { - r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET)); - _DBG("*****appcore setlocale=%s\n", r); + r = setlocale(LC_ALL, lang); + if (r) { + _DBG("*****appcore setlocale=%s\n", r); + } } free(lang); } @@ -52,6 +51,7 @@ void update_lang(void) void update_region(void) { char *region; + char *r; region = vconf_get_str(VCONFKEY_REGIONFORMAT); if (region) { @@ -66,6 +66,10 @@ void update_region(void) setenv("LC_TELEPHONE", region, 1); setenv("LC_MEASUREMENT", region, 1); setenv("LC_IDENTIFICATION", region, 1); + r = setlocale(LC_ALL, ""); + if (r != NULL) { + _DBG("*****appcore setlocale=%s\n", r); + } free(region); } } @@ -82,20 +86,36 @@ static int __set_i18n(const char *domain, const char *dir) r = setlocale(LC_ALL, ""); /* if locale is not set properly, try again to set as language base */ if (r == NULL) { - r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET)); - _DBG("*****appcore setlocale=%s\n", r); + char *lang = vconf_get_str(VCONFKEY_LANGSET); + r = setlocale(LC_ALL, lang); + if (r) { + _DBG("*****appcore setlocale=%s\n", r); + } + if (lang) { + free(lang); + } + } + if (r == NULL) { + _ERR("appcore: setlocale() error"); } - _retvm_if(r == NULL, -1, "appcore: setlocale() error"); + //_retvm_if(r == NULL, -1, "appcore: setlocale() error"); r = bindtextdomain(domain, dir); - _retvm_if(r == NULL, -1, "appcore: bindtextdomain() error"); + if (r == NULL) { + _ERR("appcore: bindtextdomain() error"); + } + //_retvm_if(r == NULL, -1, "appcore: bindtextdomain() error"); r = textdomain(domain); - _retvm_if(r == NULL, -1, "appcore: textdomain() error"); + if (r == NULL) { + _ERR("appcore: textdomain() error"); + } + //_retvm_if(r == NULL, -1, "appcore: textdomain() error"); return 0; } + EXPORT_API int appcore_set_i18n(const char *domainname, const char *dirname) { int r; diff --git a/src/appcore-rotation.c b/src/appcore-rotation.c index 78b60ba..d99dace 100755 --- a/src/appcore-rotation.c +++ b/src/appcore-rotation.c @@ -24,7 +24,9 @@ #include #include -#include +#include +//#include + #include #include #include @@ -40,49 +42,48 @@ } while(0) #define STR_ATOM_ROTATION_LOCK "_E_ROTATION_LOCK" +#define MAX_LOCAL_BUFSZ 128 static Ecore_X_Atom ATOM_ROTATION_LOCK = 0; static Ecore_X_Window root; struct rot_s { int handle; - int (*callback) (enum appcore_rm, void *); + int (*callback) (void *event_info, enum appcore_rm, void *); enum appcore_rm mode; int lock; void *cbdata; int cb_set; int sf_started; + + struct ui_wm_rotate* wm_rotate; }; static struct rot_s rot; struct rot_evt { - enum accelerometer_rotate_state re; + int re; enum appcore_rm rm; }; static struct rot_evt re_to_rm[] = { { - ROTATION_EVENT_0, - APPCORE_RM_PORTRAIT_NORMAL, + AUTO_ROTATION_DEGREE_0, + APPCORE_RM_PORTRAIT_NORMAL, }, { - ROTATION_EVENT_90, - APPCORE_RM_LANDSCAPE_NORMAL, + AUTO_ROTATION_DEGREE_90, + APPCORE_RM_LANDSCAPE_NORMAL, }, { - ROTATION_EVENT_180, - APPCORE_RM_PORTRAIT_REVERSE, + AUTO_ROTATION_DEGREE_180, + APPCORE_RM_PORTRAIT_REVERSE, }, { - ROTATION_EVENT_270, - APPCORE_RM_LANDSCAPE_REVERSE, + AUTO_ROTATION_DEGREE_270, + APPCORE_RM_LANDSCAPE_REVERSE, }, }; -static enum appcore_rm changed_m; -static void *changed_data; -static Ecore_Event_Handler *changed_handle; - static enum appcore_rm __get_mode(int event_data) { int i; @@ -100,39 +101,17 @@ static enum appcore_rm __get_mode(int event_data) return m; } -static Eina_Bool __property(void *data, int type, void *event) -{ - Ecore_X_Event_Window_Property *ev = event; - - if (!ev) - return ECORE_CALLBACK_PASS_ON; - - if (ev->atom == ATOM_ROTATION_LOCK) { - _DBG("[APP %d] Rotation: %d -> %d, cb_set : %d", getpid(), rot.mode, changed_m, rot.cb_set); - if (rot.cb_set && rot.mode != changed_m) { - rot.callback(changed_m, changed_data); - rot.mode = changed_m; - } - - ecore_event_handler_del(changed_handle); - changed_handle = NULL; - } - - return ECORE_CALLBACK_PASS_ON; -} - static void __changed_cb(unsigned int event_type, sensor_event_data_t *event, void *data) { int *cb_event_data; enum appcore_rm m; int ret; - int val; if (rot.lock) return; - if (event_type != ACCELEROMETER_EVENT_ROTATION_CHECK) { + if (event_type != AUTO_ROTATION_EVENT_CHANGE_STATE) { errno = EINVAL; return; } @@ -142,38 +121,29 @@ static void __changed_cb(unsigned int event_type, sensor_event_data_t *event, m = __get_mode(*cb_event_data); _DBG("[APP %d] Rotation: %d -> %d", getpid(), rot.mode, m); - if (rot.callback) { if (rot.cb_set && rot.mode != m) { - ret = ecore_x_window_prop_card32_get(root, ATOM_ROTATION_LOCK, &val, 1); - - _DBG("[APP %d] Rotation: %d -> %d, val : %d, ret : %d", getpid(), rot.mode, m, val, ret); - if (!val || ret < 1) { - rot.callback(m, data); - rot.mode = m; - } else { - changed_data = data; - if(changed_handle) { - ecore_event_handler_del(changed_handle); - changed_handle = NULL; - } - changed_handle = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, __property, NULL); - } + _DBG("[APP %d] Rotation: %d -> %d", getpid(), rot.mode, m); + rot.callback((void *)&m, m, data); + rot.mode = m; } - changed_m = m; } + } static void __lock_cb(keynode_t *node, void *data) { int r; enum appcore_rm m; - int ret; - int val; - rot.lock = vconf_keynode_get_bool(node); + rot.lock = !vconf_keynode_get_bool(node); if (rot.lock) { + m = APPCORE_RM_PORTRAIT_NORMAL; + if (rot.mode != m) { + rot.callback((void *)&m, m, data); + rot.mode = m; + } _DBG("[APP %d] Rotation locked", getpid()); return; } @@ -185,21 +155,9 @@ static void __lock_cb(keynode_t *node, void *data) _DBG("[APP %d] Rotmode prev %d -> curr %d", getpid(), rot.mode, m); if (!r && rot.mode != m) { - if(!val) { - rot.callback(m, data); - rot.mode = m; - } else { - changed_data = data; - if(changed_handle) { - ecore_event_handler_del(changed_handle); - changed_handle = NULL; - } - changed_handle = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, __property, NULL); - } + rot.callback((void *)&m, m, data); + rot.mode = m; } - - if(!r) - changed_m = m; } } } @@ -210,168 +168,190 @@ static void __add_rotlock(void *data) int lock; lock = 0; - r = vconf_get_bool(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, &lock); + r = vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &lock); if (r) { _DBG("[APP %d] Rotation vconf get bool failed", getpid()); } - rot.lock = lock; + rot.lock = !lock; - vconf_notify_key_changed(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, __lock_cb, + vconf_notify_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, __lock_cb, data); } static void __del_rotlock(void) { - vconf_ignore_key_changed(VCONFKEY_SETAPPL_ROTATE_LOCK_BOOL, __lock_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, __lock_cb); rot.lock = 0; } -EXPORT_API int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *), +EXPORT_API int appcore_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data) { - int r; - int handle; - - if (cb == NULL) { - errno = EINVAL; - return -1; - } - - if (rot.callback != NULL) { - errno = EALREADY; - return -1; - } + if (rot.wm_rotate) { + return rot.wm_rotate->set_rotation_cb(cb, data); + } else { + int r; + int handle; + + if (cb == NULL) { + errno = EINVAL; + return -1; + } - handle = sf_connect(ACCELEROMETER_SENSOR); - if (handle < 0) { - _ERR("sf_connect failed: %d", handle); - return -1; - } + if (rot.callback != NULL) { + errno = EALREADY; + return -1; + } - r = sf_register_event(handle, ACCELEROMETER_EVENT_ROTATION_CHECK, - NULL, __changed_cb, data); - if (r < 0) { - _ERR("sf_register_event failed: %d", r); - sf_disconnect(handle); - return -1; - } + handle = sf_connect(AUTO_ROTATION_SENSOR); + if (handle < 0) { + _ERR("sf_connect failed: %d", handle); + return -1; + } - rot.cb_set = 1; - rot.callback = cb; - rot.cbdata = data; + r = sf_register_event(handle, AUTO_ROTATION_EVENT_CHANGE_STATE, + NULL, __changed_cb, data); + if (r < 0) { + _ERR("sf_register_event failed: %d", r); + sf_disconnect(handle); + return -1; + } - r = sf_start(handle, 0); - if (r < 0) { - _ERR("sf_start failed: %d", r); - sf_unregister_event(handle, ACCELEROMETER_EVENT_ROTATION_CHECK); - rot.callback = NULL; - rot.cbdata = NULL; - rot.cb_set = 0; - rot.sf_started = 0; - sf_disconnect(handle); - return -1; - } - rot.sf_started = 1; + rot.cb_set = 1; + rot.callback = cb; + rot.cbdata = data; - rot.handle = handle; - __add_rotlock(data); + r = sf_start(handle, 0); + if (r < 0) { + _ERR("sf_start failed: %d", r); + r = sf_unregister_event(handle, AUTO_ROTATION_EVENT_CHANGE_STATE); + if (r < 0) { + _ERR("sf_unregister_event failed: %d", r); + } + rot.callback = NULL; + rot.cbdata = NULL; + rot.cb_set = 0; + rot.sf_started = 0; + sf_disconnect(handle); + return -1; + } + rot.sf_started = 1; - _MAKE_ATOM(ATOM_ROTATION_LOCK, STR_ATOM_ROTATION_LOCK ); - root = ecore_x_window_root_first_get(); - XSelectInput(ecore_x_display_get(), root, PropertyChangeMask); + rot.handle = handle; + __add_rotlock(data); + _MAKE_ATOM(ATOM_ROTATION_LOCK, STR_ATOM_ROTATION_LOCK ); + root = ecore_x_window_root_first_get(); + XSelectInput(ecore_x_display_get(), root, PropertyChangeMask); + } return 0; } EXPORT_API int appcore_unset_rotation_cb(void) { - int r; + if (rot.wm_rotate) { + return rot.wm_rotate->unset_rotation_cb(); + } + else { + int r; - _retv_if(rot.callback == NULL, 0); + _retv_if(rot.callback == NULL, 0); - __del_rotlock(); + __del_rotlock(); - if (rot.cb_set) { - r = sf_unregister_event(rot.handle, - ACCELEROMETER_EVENT_ROTATION_CHECK); - if (r < 0) { - _ERR("sf_unregister_event failed: %d", r); - return -1; + if (rot.cb_set) { + r = sf_unregister_event(rot.handle, + AUTO_ROTATION_EVENT_CHANGE_STATE); + if (r < 0) { + _ERR("sf_unregister_event failed: %d", r); + return -1; + } + rot.cb_set = 0; + } + rot.callback = NULL; + rot.cbdata = NULL; + + if (rot.sf_started == 1) { + r = sf_stop(rot.handle); + if (r < 0) { + _ERR("sf_stop failed: %d", r); + return -1; + } + rot.sf_started = 0; } - rot.cb_set = 0; - } - rot.callback = NULL; - rot.cbdata = NULL; - if (rot.sf_started == 1) { - r = sf_stop(rot.handle); + r = sf_disconnect(rot.handle); if (r < 0) { - _ERR("sf_stop failed: %d", r); + _ERR("sf_disconnect failed: %d", r); return -1; } - rot.sf_started = 0; - } - - r = sf_disconnect(rot.handle); - if (r < 0) { - _ERR("sf_disconnect failed: %d", r); - return -1; + rot.handle = -1; } - rot.handle = -1; - return 0; } EXPORT_API int appcore_get_rotation_state(enum appcore_rm *curr) { - int r; - unsigned long event; - - if (curr == NULL) { - errno = EINVAL; - return -1; + if (rot.wm_rotate) { + return rot.wm_rotate->get_rotation_state(curr); } + else { + int r; + unsigned long event; + sensor_data_t data; - r = sf_check_rotation(&event); - if (r < 0) { - _ERR("sf_check_rotation failed: %d", r); - *curr = APPCORE_RM_UNKNOWN; - return -1; - } + if (curr == NULL) { + errno = EINVAL; + return -1; + } - *curr = __get_mode(event); + r = sf_get_data(rot.handle, AUTO_ROTATION_BASE_DATA_SET, &data); + if (r == 0 && data.value_count > 0) { + event = data.values[0]; + } else { + _ERR("sf_get_data for AUTO_ROTATION_BASE_DATA_SET failed: %d", r); + *curr = APPCORE_RM_UNKNOWN; + return -1; + } + *curr = __get_mode(event); + } return 0; } EXPORT_API int appcore_pause_rotation_cb(void) { - int r; + if (rot.wm_rotate) { + return rot.wm_rotate->pause_rotation_cb(); + } + else { + int r; - _retv_if(rot.callback == NULL, 0); - _DBG("[APP %d] appcore_pause_rotation_cb is called", getpid()); + _retv_if(rot.callback == NULL, 0); + _DBG("[APP %d] appcore_pause_rotation_cb is called", getpid()); - __del_rotlock(); + __del_rotlock(); - if (rot.cb_set) { - r = sf_unregister_event(rot.handle, - ACCELEROMETER_EVENT_ROTATION_CHECK); - if (r < 0) { - _ERR("sf_unregister_event in appcore_internal_sf_stop failed: %d", r); - return -1; + if (rot.cb_set) { + r = sf_unregister_event(rot.handle, + AUTO_ROTATION_EVENT_CHANGE_STATE); + if (r < 0) { + _ERR("sf_unregister_event in appcore_internal_sf_stop failed: %d", r); + return -1; + } + rot.cb_set = 0; } - rot.cb_set = 0; - } - if (rot.sf_started == 1) { - r = sf_stop(rot.handle); - if (r < 0) { - _ERR("sf_stop in appcore_internal_sf_stop failed: %d", - r); - return -1; + if (rot.sf_started == 1) { + r = sf_stop(rot.handle); + if (r < 0) { + _ERR("sf_stop in appcore_internal_sf_stop failed: %d", + r); + return -1; + } + rot.sf_started = 0; } - rot.sf_started = 0; } return 0; @@ -379,44 +359,63 @@ EXPORT_API int appcore_pause_rotation_cb(void) EXPORT_API int appcore_resume_rotation_cb(void) { - int r; - enum appcore_rm m; - - _retv_if(rot.callback == NULL, 0); - _DBG("[APP %d] appcore_resume_rotation_cb is called", getpid()); + if (rot.wm_rotate) { + return rot.wm_rotate->resume_rotation_cb(); + } + else { + int r,ret; + enum appcore_rm m; + + _retv_if(rot.callback == NULL, 0); + _DBG("[APP %d] appcore_resume_rotation_cb is called", getpid()); + + if (rot.cb_set == 0) { + r = sf_register_event(rot.handle, + AUTO_ROTATION_EVENT_CHANGE_STATE, NULL, + __changed_cb, rot.cbdata); + if (r < 0) { + _ERR("sf_register_event in appcore_internal_sf_start failed: %d", r); + return -1; + } + rot.cb_set = 1; + } - if (rot.cb_set == 0) { - r = sf_register_event(rot.handle, - ACCELEROMETER_EVENT_ROTATION_CHECK, NULL, - __changed_cb, rot.cbdata); - if (r < 0) { - _ERR("sf_register_event in appcore_internal_sf_start failed: %d", r); - return -1; + if (rot.sf_started == 0) { + r = sf_start(rot.handle, 0); + if (r < 0) { + _ERR("sf_start in appcore_internal_sf_start failed: %d", + r); + ret = sf_unregister_event(rot.handle, + AUTO_ROTATION_EVENT_CHANGE_STATE); + if (ret < 0) + _ERR("sf_unregister_event failed: %d", ret); + rot.cb_set = 0; + return -1; + } + rot.sf_started = 1; } - rot.cb_set = 1; - } - if (rot.sf_started == 0) { - r = sf_start(rot.handle, 0); - if (r < 0) { - _ERR("sf_start in appcore_internal_sf_start failed: %d", - r); - sf_unregister_event(rot.handle, - ACCELEROMETER_EVENT_ROTATION_CHECK); - rot.cb_set = 0; - return -1; + __add_rotlock(rot.cbdata); + + r = appcore_get_rotation_state(&m); + _DBG("[APP %d] Rotmode prev %d -> curr %d", getpid(), rot.mode, m); + if (!r && rot.mode != m && rot.lock == 0) { + rot.callback((void *)&m, m, rot.cbdata); + rot.mode = m; } - rot.sf_started = 1; } + return 0; +} - __add_rotlock(rot.cbdata); +EXPORT_API int appcore_set_wm_rotation(struct ui_wm_rotate* wm_rotate) +{ + if (!wm_rotate) return -1; - r = appcore_get_rotation_state(&m); - _DBG("[APP %d] Rotmode prev %d -> curr %d", getpid(), rot.mode, m); - if (!r && rot.mode != m && rot.lock == 0) { - rot.callback(m, rot.cbdata); - rot.mode = m; + if (rot.callback) { + wm_rotate->set_rotation_cb(rot.callback, rot.cbdata); + appcore_unset_rotation_cb(); } - + rot.wm_rotate = wm_rotate; + _DBG("[APP %d] Support wm rotate:%p", getpid(), wm_rotate); return 0; } diff --git a/src/appcore.c b/src/appcore.c index fa316b8..2205330 100755 --- a/src/appcore.c +++ b/src/appcore.c @@ -40,13 +40,14 @@ #define SQLITE_FLUSH_MAX (1024*1024) #define PKGNAME_MAX 256 -#define PATH_APP_ROOT "/opt/apps" +#define PATH_APP_ROOT "/opt/usr/apps" #define PATH_RO_APP_ROOT "/usr/apps" #define PATH_RES "/res" #define PATH_LOCALE "/locale" static struct appcore core; static pid_t _pid; +char caller_appid[APPID_MAX]; static enum appcore_event to_ae[SE_MAX] = { APPCORE_EVENT_UNKNOWN, /* SE_UNKNOWN */ @@ -91,6 +92,10 @@ static struct open_s open; static int __app_terminate(void *data); static int __app_resume(void *data); static int __app_reset(void *data, bundle *k); +#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS +static int __app_resume_lcd_on(void *data); +static int __app_pause_lcd_off(void *data); +#endif static int __sys_lowmem_post(void *data, void *evt); static int __sys_lowmem(void *data, void *evt); @@ -135,7 +140,7 @@ static struct evt_ops evtops[] = { static int __get_dir_name(char *dirname) { - char pkg_name[PKGNAME_MAX]; + char pkgid[PKGNAME_MAX]; int r; int pid; @@ -143,13 +148,14 @@ static int __get_dir_name(char *dirname) if (pid < 0) return -1; - aul_app_get_pkgname_bypid(pid, pkg_name, PKGNAME_MAX); + if (aul_app_get_pkgid_bypid(pid, pkgid, PKGNAME_MAX) != AUL_R_OK) + return -1; - r = snprintf(dirname, PATH_MAX, PATH_APP_ROOT "/%s" PATH_RES PATH_LOCALE,pkg_name); + r = snprintf(dirname, PATH_MAX, PATH_APP_ROOT "/%s" PATH_RES PATH_LOCALE,pkgid); if (r < 0) return -1; if (access(dirname, R_OK) == 0) return 0; - r = snprintf(dirname, PATH_MAX, PATH_RO_APP_ROOT "/%s" PATH_RES PATH_LOCALE,pkg_name); + r = snprintf(dirname, PATH_MAX, PATH_RO_APP_ROOT "/%s" PATH_RES PATH_LOCALE,pkgid); if (r < 0) return -1; @@ -198,6 +204,22 @@ static int __app_resume(void *data) return 0; } +#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS +static int __app_resume_lcd_on(void *data) +{ + struct appcore *ac = data; + ac->ops->cb_app(AE_RESUME, ac->ops->data, NULL); + return 0; +} + +static int __app_pause_lcd_off(void *data) +{ + struct appcore *ac = data; + ac->ops->cb_app(AE_PAUSE, ac->ops->data, NULL); + return 0; +} +#endif + static int __sys_do_default(struct appcore *ac, enum sys_event event) { int r; @@ -215,7 +237,7 @@ static int __sys_do_default(struct appcore *ac, enum sys_event event) return r; } -static int __sys_do(struct appcore *ac, enum sys_event event) +static int __sys_do(struct appcore *ac, void *event_info, enum sys_event event) { struct sys_op *op; @@ -226,23 +248,38 @@ static int __sys_do(struct appcore *ac, enum sys_event event) if (op->func == NULL) return __sys_do_default(ac, event); - return op->func(op->data); + return op->func(event_info, op->data); } static int __sys_lowmem_post(void *data, void *evt) { + keynode_t *key = evt; + int val; + + val = vconf_keynode_get_int(key); + + if (val >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) { #if defined(MEMORY_FLUSH_ACTIVATE) - struct appcore *ac = data; - ac->ops->cb_app(AE_LOWMEM_POST, ac->ops->data, NULL); + struct appcore *ac = data; + ac->ops->cb_app(AE_LOWMEM_POST, ac->ops->data, NULL); #else - malloc_trim(0); + malloc_trim(0); #endif + } return 0; } static int __sys_lowmem(void *data, void *evt) { - return __sys_do(data, SE_LOWMEM); + keynode_t *key = evt; + int val; + + val = vconf_keynode_get_int(key); + + if (val >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) + return __sys_do(data, (void *)&val, SE_LOWMEM); + + return 0; } static int __sys_lowbatt(void *data, void *evt) @@ -254,7 +291,7 @@ static int __sys_lowbatt(void *data, void *evt) /* VCONFKEY_SYSMAN_BAT_CRITICAL_LOW or VCONFKEY_SYSMAN_POWER_OFF */ if (val <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW) - return __sys_do(data, SE_LOWBAT); + return __sys_do(data, (void *)&val, SE_LOWBAT); return 0; } @@ -267,7 +304,12 @@ static int __sys_langchg_pre(void *data, void *evt) static int __sys_langchg(void *data, void *evt) { - return __sys_do(data, SE_LANGCHG); + keynode_t *key = evt; + char *val; + + val = vconf_keynode_get_str(key); + + return __sys_do(data, (void *)val, SE_LANGCHG); } static int __sys_regionchg_pre(void *data, void *evt) @@ -278,7 +320,15 @@ static int __sys_regionchg_pre(void *data, void *evt) static int __sys_regionchg(void *data, void *evt) { - return __sys_do(data, SE_REGIONCHG); + keynode_t *key = evt; + char *val = NULL; + const char *name; + + name = vconf_keynode_get_name(key); + if (name && !strcmp(name, VCONFKEY_REGIONFORMAT)) + val = vconf_keynode_get_str(key); + + return __sys_do(data, (void *)val, SE_REGIONCHG); } static void __vconf_do(struct evt_ops *eo, keynode_t * key, void *data) @@ -366,11 +416,18 @@ static int __del_vconf(void) static int __aul_handler(aul_type type, bundle *b, void *data) { int ret; + const char *str = NULL; switch (type) { case AUL_START: _DBG("[APP %d] AUL event: AUL_START", _pid); __app_reset(data, b); + str = bundle_get_val(b, AUL_K_CALLER_APPID); + SECURE_LOGD("caller_appid : %s", str); + if(str) { + strncpy(caller_appid, str, APPID_MAX-1); + caller_appid[APPID_MAX-1] = '\0'; + } break; case AUL_RESUME: _DBG("[APP %d] AUL event: AUL_RESUME", _pid); @@ -386,6 +443,16 @@ static int __aul_handler(aul_type type, bundle *b, void *data) _DBG("[APP %d] AUL event: AUL_TERMINATE", _pid); __app_terminate(data); break; +#ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS + case AUL_RESUME_LCD_ON: + _DBG("[APP %d] AUL event: AUL_RESUME_LCD_ON", _pid); + __app_resume_lcd_on(data); + break; + case AUL_PAUSE_LCD_OFF: + _DBG("[APP %d] AUL event: AUL_PAUSE_LCD_OFF", _pid); + __app_pause_lcd_off(data); + break; +#endif default: _DBG("[APP %d] AUL event: %d", _pid, type); /* do nothing */ @@ -401,6 +468,11 @@ static void __clear(struct appcore *ac) memset(ac, 0, sizeof(struct appcore)); } +EXPORT_API char *appcore_get_caller_appid() +{ + return caller_appid; +} + EXPORT_API int appcore_set_open_cb(int (*cb) (void *), void *data) { @@ -411,7 +483,7 @@ EXPORT_API int appcore_set_open_cb(int (*cb) (void *), } EXPORT_API int appcore_set_event_callback(enum appcore_event event, - int (*cb) (void *), void *data) + int (*cb) (void *, void *), void *data) { struct appcore *ac = &core; struct sys_op *op; @@ -457,6 +529,7 @@ EXPORT_API int appcore_init(const char *name, const struct ui_ops *ops, } r = __get_dir_name(dirname); + SECURE_LOGD("dir : %s", dirname); r = set_i18n(name, dirname); _retv_if(r == -1, -1); @@ -511,7 +584,7 @@ EXPORT_API int appcore_flush_memory(void) return -1; } - _DBG("[APP %d] Flushing memory ...", _pid); + //_DBG("[APP %d] Flushing memory ...", _pid); if (ac->ops->cb_app) { ac->ops->cb_app(AE_MEM_FLUSH, ac->ops->data, NULL); @@ -528,7 +601,7 @@ EXPORT_API int appcore_flush_memory(void) *stack_trim(); */ - _DBG("[APP %d] Flushing memory DONE", _pid); + //_DBG("[APP %d] Flushing memory DONE", _pid); return 0; } diff --git a/src/virtual_canvas.c b/src/virtual_canvas.c new file mode 100755 index 0000000..3b8308f --- /dev/null +++ b/src/virtual_canvas.c @@ -0,0 +1,139 @@ +/* + * starter + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Seungtaek Chung , Mi-Ju Lee , Xi Zhichan + * + * 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 "appcore-internal.h" +#include "virtual_canvas.h" + + +#define QUALITY_N_COMPRESS "quality=100 compress=1" + + + +Evas *virtual_canvas_create(int w, int h) +{ + Ecore_Evas *internal_ee; + Evas *internal_e; + + // Create virtual canvas + internal_ee = ecore_evas_buffer_new(w, h); + if (!internal_ee) { + _DBG("Failed to create a new canvas buffer\n"); + return NULL; + } + + ecore_evas_alpha_set(internal_ee, EINA_TRUE); + ecore_evas_manual_render_set(internal_ee, EINA_TRUE); + + // Get the "Evas" object from a virtual canvas + internal_e = ecore_evas_get(internal_ee); + if (!internal_e) { + ecore_evas_free(internal_ee); + _DBG("Faield to get Evas object\n"); + return NULL; + } + + return internal_e; +} + + + +static bool _flush_data_to_file(Evas *e, char *data, const char *filename, int w, int h) +{ + Evas_Object *output; + + output = evas_object_image_add(e); + if (!output) { + _DBG("Failed to create an image object\n"); + return false; + } + + evas_object_image_data_set(output, NULL); + evas_object_image_colorspace_set(output, EVAS_COLORSPACE_ARGB8888); + evas_object_image_alpha_set(output, EINA_TRUE); + evas_object_image_size_set(output, w, h); + evas_object_image_smooth_scale_set(output, EINA_TRUE); + evas_object_image_data_set(output, data); + evas_object_image_data_update_add(output, 0, 0, w, h); + + if (evas_object_image_save(output, filename, NULL, QUALITY_N_COMPRESS) == EINA_FALSE) { + evas_object_del(output); + _DBG("Faild to save a captured image (%s)\n", filename); + return false; + } + + evas_object_del(output); + + if (access(filename, F_OK) != 0) { + _DBG("File %s is not found\n", filename); + return false; + } + + return true; +} + + + +bool virtual_canvas_flush_to_file(Evas *e, const char *filename, int w, int h) +{ + void *data; + Ecore_Evas *internal_ee; + + internal_ee = ecore_evas_ecore_evas_get(e); + if (!internal_ee) { + _DBG("Failed to get ecore evas\n"); + return false; + } + + ecore_evas_manual_render(internal_ee); + + // Get a pointer of a buffer of the virtual canvas + data = (void *) ecore_evas_buffer_pixels_get(internal_ee); + if (!data) { + _DBG("Failed to get pixel data\n"); + return false; + } + + return _flush_data_to_file(e, data, filename, w, h); +} + + + +bool virtual_canvas_destroy(Evas *e) +{ + Ecore_Evas *ee; + + ee = ecore_evas_ecore_evas_get(e); + if (!ee) { + _DBG("Failed to ecore evas object\n"); + return false; + } + + ecore_evas_free(ee); + return true; +} + + + +// End of a file