Introduce UX for RW update 92/152192/11 accepted/tizen/4.0/unified/20171011.150243 submit/tizen_4.0/20171010.092649 submit/tizen_4.0/20171010.115426 tizen_4.0.IoT.p1_release
authorKichan Kwon <k_c.kwon@samsung.com>
Mon, 25 Sep 2017 08:08:14 +0000 (17:08 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Fri, 29 Sep 2017 02:44:07 +0000 (11:44 +0900)
It shows these informations below
  - Updated scripts / Total scripts
  - Progress circle
Current progress is stored in tmp

Change-Id: Ice8a0ab17c2a125a83b52cb91d504ade497396e2
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
27 files changed:
CMakeLists.txt [new file with mode: 0755]
packaging/system-rw-update-ani.manifest [new file with mode: 0644]
packaging/system-rw-update.spec
res/tw1/images/solis_fota_progress_000.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_0.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_1.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_2.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_3.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_4.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_5.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_6.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_7.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_8.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_9.png [new file with mode: 0755]
res/tw1/images/wc_fota_downloading_slash.png [new file with mode: 0755]
rw-update-ani/CMakeLists.txt [new file with mode: 0755]
rw-update-ani/rw-update-ani_new.c [new file with mode: 0755]
rw-update-ani/rw-update-ani_new.h [new file with mode: 0755]
rw-update-ani/rw-update-log.h [new file with mode: 0755]
rw-update-ani/rw-update_new_cairo.h [new file with mode: 0755]
rw-update-ani/rw-update_new_cairo_w_360_360.c [new file with mode: 0755]
rw-update-ani/rw-update_new_common.h [new file with mode: 0755]
rw-update-ani/rw-update_new_common_display.h [new file with mode: 0755]
rw-update-ani/rw-update_new_fb.h [new file with mode: 0755]
rw-update-ani/rw-update_new_fb_cairo.c [new file with mode: 0755]
rw-update-ani/rw-update_new_tdm_display.c [new file with mode: 0755]
upgrade/update.sh

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..bd272ca
--- /dev/null
@@ -0,0 +1,6 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(rw-updater C)
+
+#add sub directory
+ADD_SUBDIRECTORY(rw-update-ani)
+
diff --git a/packaging/system-rw-update-ani.manifest b/packaging/system-rw-update-ani.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
index 74ff7b336cc7af8ec2a9cf9ba3e668ba811fbb76..2fa425372b3b64afcfd910e731cbcbcdc83f341e 100644 (file)
@@ -1,25 +1,46 @@
-%define debug_package %{nil}
-
 Name:       system-rw-update
 Summary:    System RW update management
-Version:    0.1.4
-Release:    5
+Version:    0.2.0
+Release:    0
 Group:      Base/Startup
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.bz2
 Source1001: %{name}.manifest
+Source1002: %{name}-ani.manifest
+
+BuildRequires: cmake
 
 %description
 This package provides files for RW update
 which is implemented by using systemd offline update.
 
+%package ani
+Summary:        System RW Ani
+Group:          System/Utilities
+License:        Apache-2.0
+
+BuildRequires: pkgconfig(cairo)
+BuildRequires: pkgconfig(libtbm)
+BuildRequires: pkgconfig(libtdm)
+BuildRequires: pkgconfig(vconf)
+
+%description ani
+UX for system RW update/upgrade
+
 %prep
 %setup -q
 
 %build
 cp %{SOURCE1001} .
+cp %{SOURCE1002} .
+
+export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
+LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+%__make %{?_smp_mflags}
 
 %install
+%make_install
+
 mkdir -p %{buildroot}%{_datadir}
 cp -r upgrade %{buildroot}%{_datadir}
 mkdir -p %{buildroot}%{_unitdir}/system-update.target.wants
@@ -50,3 +71,10 @@ fi
 %{_unitdir}/offline-update.service
 %{_unitdir}/system-update.target.wants
 %{_unitdir}/udev-sdb-init.service
+
+%files ani
+%manifest %{name}-ani.manifest
+%license LICENSE.Apache-2.0
+%attr(550,system,system_share) %{_bindir}/rw-update-ani
+%{_prefix}/share/rw-updater/*
+
diff --git a/res/tw1/images/solis_fota_progress_000.png b/res/tw1/images/solis_fota_progress_000.png
new file mode 100755 (executable)
index 0000000..1292e6a
Binary files /dev/null and b/res/tw1/images/solis_fota_progress_000.png differ
diff --git a/res/tw1/images/wc_fota_downloading_0.png b/res/tw1/images/wc_fota_downloading_0.png
new file mode 100755 (executable)
index 0000000..9f1733c
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_0.png differ
diff --git a/res/tw1/images/wc_fota_downloading_1.png b/res/tw1/images/wc_fota_downloading_1.png
new file mode 100755 (executable)
index 0000000..711ea7a
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_1.png differ
diff --git a/res/tw1/images/wc_fota_downloading_2.png b/res/tw1/images/wc_fota_downloading_2.png
new file mode 100755 (executable)
index 0000000..e9aca8e
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_2.png differ
diff --git a/res/tw1/images/wc_fota_downloading_3.png b/res/tw1/images/wc_fota_downloading_3.png
new file mode 100755 (executable)
index 0000000..8538e35
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_3.png differ
diff --git a/res/tw1/images/wc_fota_downloading_4.png b/res/tw1/images/wc_fota_downloading_4.png
new file mode 100755 (executable)
index 0000000..081e84e
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_4.png differ
diff --git a/res/tw1/images/wc_fota_downloading_5.png b/res/tw1/images/wc_fota_downloading_5.png
new file mode 100755 (executable)
index 0000000..f015a4e
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_5.png differ
diff --git a/res/tw1/images/wc_fota_downloading_6.png b/res/tw1/images/wc_fota_downloading_6.png
new file mode 100755 (executable)
index 0000000..d548f5e
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_6.png differ
diff --git a/res/tw1/images/wc_fota_downloading_7.png b/res/tw1/images/wc_fota_downloading_7.png
new file mode 100755 (executable)
index 0000000..023aa8e
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_7.png differ
diff --git a/res/tw1/images/wc_fota_downloading_8.png b/res/tw1/images/wc_fota_downloading_8.png
new file mode 100755 (executable)
index 0000000..37f59ec
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_8.png differ
diff --git a/res/tw1/images/wc_fota_downloading_9.png b/res/tw1/images/wc_fota_downloading_9.png
new file mode 100755 (executable)
index 0000000..5350c7d
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_9.png differ
diff --git a/res/tw1/images/wc_fota_downloading_slash.png b/res/tw1/images/wc_fota_downloading_slash.png
new file mode 100755 (executable)
index 0000000..459b921
Binary files /dev/null and b/res/tw1/images/wc_fota_downloading_slash.png differ
diff --git a/rw-update-ani/CMakeLists.txt b/rw-update-ani/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..466fffc
--- /dev/null
@@ -0,0 +1,60 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(rw-update-ani C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(EDJDIR "\${prefix}/share/edje")
+SET(VERSION 0.1)
+SET(PKGDIR "${PREFIX}/share/rw-updater")
+SET(RESDIR "${PKGDIR}/res")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs_ani REQUIRED
+       vconf
+       cairo
+       libtbm
+       libtdm
+       dlog
+)
+SET(SRCS_ANI
+       rw-update-ani_new.c
+       rw-update_new_fb_cairo.c
+       rw-update_new_cairo_w_360_360.c
+       rw-update_new_tdm_display.c
+)
+
+ADD_DEFINITIONS("-DFEATURE_ROTATE")
+ADD_DEFINITIONS("-DCAIRO_LIB")
+
+FOREACH(flag ${pkgs_ani_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" MATCHES "^arm.*")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF()
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_EXECUTABLE(rw-update-ani ${SRCS_ANI})
+TARGET_LINK_LIBRARIES(rw-update-ani ${pkgs_ani_LDFLAGS})
+
+
+INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/rw-update-ani DESTINATION bin)
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/tw1/images DESTINATION ${RESDIR})
diff --git a/rw-update-ani/rw-update-ani_new.c b/rw-update-ani/rw-update-ani_new.c
new file mode 100755 (executable)
index 0000000..e7c061a
--- /dev/null
@@ -0,0 +1,450 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sched.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/poll.h>
+#include <linux/input.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <getopt.h>
+
+#ifdef CAIRO_LIB
+#include "rw-update_new_cairo.h"
+#endif
+#include <fnmatch.h>
+#include <vconf.h>
+#include <locale.h>
+
+#include "rw-update_new_common.h"
+#include "rw-update_new_fb.h"
+#ifdef FEATURE_ROTATE
+#include "rw-update_new_common_display.h"
+#endif
+
+#define EVT_LOOP_DURATION      1000
+
+#define MAX_KEY_PATH           4
+#define CMDLINE_SIZE           20
+
+#define FILE_IO_BUF_SIZE               128
+#define CHG_ENV_BATT_STATUS "/sys/class/power_supply/battery/status"
+
+FbInfo fbi;
+
+static pthread_t keyevent_thread;
+
+static char key_path[MAX_KEY_PATH+1][256];
+
+static const char granted_event[5][256] = {
+       "gpio-keys",
+       "sci-keypad",
+       "qpnp_pon",
+       "LPM_MOTION",
+       "s2mpw01-power-keys"
+};
+
+static void update_lang(void)
+{
+       _FUNC_ENTER;
+
+       char *lang = NULL;
+       char *r = NULL;
+
+       lang = vconf_get_str(VCONFKEY_LANGSET);
+       if (lang) {
+               setenv("LANG", lang, 1);
+               setenv("LC_MESSAGES", lang, 1);
+               r = setlocale(LC_ALL, "");
+               if (r == NULL) {
+                       r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET));
+                       if (r)
+                               _DEBUG_LOG("***** setlocale=%s\n", r);
+               }
+
+               free(lang);
+       }
+
+       _FUNC_EXIT;
+}
+
+int read_from_file(const char *path, char *buf, size_t size)
+{
+       _FUNC_ENTER;
+
+       if (path == NULL) {
+               _DEBUG_EXCEPTION("Inputted parameter is wrong");
+               return -1;
+       }
+
+       if (size == 0) {
+               _DEBUG_EXCEPTION("Inputted parameter is wrong");
+               return 0;
+       }
+
+       int fd;
+       ssize_t count;
+
+       fd = open(path, O_RDONLY, 0);
+       if (fd == -1) {
+               _DEBUG_EXCEPTION("Could not open '%s'", path);
+               _FUNC_EXIT;
+               return -1;
+       }
+       _DEBUG_LOG("open '%s'\n", path);
+
+       count = read(fd, buf, size);
+       if (count > 0) {
+               count = (count < (ssize_t)size) ? count : ((ssize_t)size - 1);
+               while (count > 0 && buf[count - 1] == '\n')
+                       count--;
+               buf[count] = '\0';
+       } else {
+               buf[0] = '\0';
+       }
+       _DEBUG_LOG("read '%s'\n", buf);
+
+       close(fd);
+
+       _FUNC_EXIT;
+       return (int)count;
+}
+
+static int read_event_node(void)
+{
+       _FUNC_ENTER;
+
+       FILE *fp = NULL;
+       char buffer[1024];
+       char *event_node = NULL;
+       int flag = 0;
+       int i = 0;
+       int node_cnt = 0;
+
+       for (i = 0; i < sizeof(granted_event) / sizeof(granted_event[0]); i++) {
+               fp = fopen("/proc/bus/input/devices", "r");
+               if (!fp) {
+                       _DEBUG_EXCEPTION("Unable to open file. %m");
+                       return -1;
+               }
+
+               memset(buffer, 0, sizeof(buffer));
+               while (fgets(buffer, sizeof(buffer), fp)) {
+                       char *ptr = NULL;
+                       if ((ptr = strstr(buffer, granted_event[i])))
+                               flag = 1;
+                       if (flag) {
+                               if ((ptr = strstr(buffer, "Handlers="))) {
+                                       ptr = strstr(ptr, "event");
+                                       if (ptr) {
+                                               char *ptr2 = strchr(ptr, ' ');
+                                               if (ptr2)
+                                                       *ptr2 = '\0';
+
+                                               flag = 0;
+
+                                               event_node = strndup(ptr, strlen(ptr));
+                                               if (!event_node) {
+                                                       fclose(fp);
+                                                       _DEBUG_EXCEPTION("event_node is null");
+                                                       _FUNC_EXIT;
+                                                       return -1;
+                                               } else {
+                                                       _DEBUG_LOG("event_node : %s", event_node);
+                                                       snprintf(key_path[node_cnt++], CMDLINE_SIZE, "/dev/input/%s", event_node);
+
+                                                       free(event_node);
+
+                                                       if (node_cnt > MAX_KEY_PATH) {
+                                                               _DEBUG_EXCEPTION("node_cnt(%d) bigger than MAX_KEY_PATH(%d)", node_cnt, MAX_KEY_PATH);
+                                                               fclose(fp);
+                                                               _FUNC_EXIT;
+                                                               return -1;
+                                                       }
+                                               }
+                                       }
+                               }
+                       } else {
+                               flag = 0;
+                       }
+               }
+
+               fclose(fp);
+       }
+
+       _FUNC_EXIT;
+       return node_cnt;
+}
+
+#ifdef FEATURE_ROTATE
+static int read_degree(FbInfo *fbi)
+{
+       _FUNC_ENTER;
+
+       char buffer[256] = {0,};
+       int value = 0;
+
+       if (read_from_file("/sys/class/sensors/ssp_sensor/fota_rotate_info", buffer, 256) < 0) {
+               value = -1;
+               _DEBUG_EXCEPTION("[%s] err %d", __func__, value);
+               fbi->degree = 0;
+
+               _FUNC_EXIT;
+               return value;
+        }
+
+       fbi->degree = atoi(buffer);
+       _DEBUG_LOG("fbi->degree : %d", fbi->degree);
+
+       _FUNC_EXIT;
+       return 0;
+}
+#endif
+
+int is_batt_status(void)
+{
+       int value = 0;
+       char buf[FILE_IO_BUF_SIZE];
+
+       if (read_from_file(CHG_ENV_BATT_STATUS, buf, FILE_IO_BUF_SIZE) < 0) {
+               _DEBUG_EXCEPTION("read_from_file error");
+               return -1;
+        }
+       if (strncmp(buf, "Charging", 8) == 0)
+               value = BATT_STATE_CHARGING;
+       else if (strncmp(buf, "Discharging", 11) == 0)
+               value = BATT_STATE_DISCONNECT;
+       else if (strncmp(buf, "Full", 4) == 0)
+               value = BATT_STATE_FULL;
+       else
+               value = BATT_STATE_NOTCHARGE;
+
+       return value;
+}
+
+/*-----------------------------------------------------------------------------
+  event_monitor_process()
+ ----------------------------------------------------------------------------*/
+void* event_monitor_process(void *arg)
+{
+       _FUNC_ENTER;
+
+       int readcount = 0;
+       int ret = 0;
+       int i = 0;
+       int num_arg = *(int *)arg;
+       static unsigned int sys_power_cnt = 0;
+       struct pollfd pollevents[MAX_KEY_PATH];
+       struct input_event event;
+
+       _DEBUG_LOG("[main] event_monitor_process() started. %d\n", num_arg);
+
+       memset(pollevents, 0, sizeof(pollevents));
+
+       for (i = 0; i < num_arg; i++) {
+               if ((pollevents[i].fd = open(key_path[i], O_RDWR)) < 0) {
+                       _DEBUG_EXCEPTION("%s: open error, fd = %d\n", key_path[i], pollevents[i].fd);
+
+                       _FUNC_EXIT;
+                       return (void *)i + 1;
+               }
+               pollevents[i].events = POLLIN | POLLERR;
+       }
+
+       while (1) {
+               ret = poll(pollevents, num_arg, EVT_LOOP_DURATION);
+               if (ret < 0)
+                       _DEBUG_EXCEPTION("poll error, ret = [%d]\n", ret);
+
+               /* key event */
+               for (i = 0; i < num_arg; i++) {
+                       if (pollevents[i].revents & POLLIN) {
+                               readcount = read(pollevents[i].fd, &event, sizeof(event));
+                               if (readcount != sizeof(event)) {
+                                       _DEBUG_EXCEPTION("key[%d] read error, readcount = [%d]\n", i, readcount);
+                                       continue;
+                               }
+                               _DEBUG_LOG("poll event:%d, fd:%d type=%d code=%d value=%d sys_power_cnt : %d, arg : %s", i, pollevents[i].fd, event.type, event.code, event.value, sys_power_cnt, key_path[i]);
+
+                               if (event.type == EV_KEY)
+                                       _DEBUG_LOG("keycode%d : 0x%x, value: %d\n", i, event.code, event.value);
+#ifdef FEATURE_ROTATE
+                               else if (event.type == EV_ABS) {
+                                       if (event.code == ABS_X) {
+                                               _DEBUG_LOG("LPM_MOTION event.code %d, event.value : %d ", event.code, event.value);
+                                               if (event.value == 1 || event.value == 3) {
+                                                       fbi.degree = event.value;
+
+                                                       int battery_state = is_batt_status();
+                                                       if (battery_state == BATT_STATE_CHARGING || battery_state == BATT_STATE_FULL)
+                                                               fb_draw_img_rotate_update(&fbi);
+                                               }
+                                       }
+                               } else {
+                                       _DEBUG_LOG("etc event.code %d, event.value : %d ", event.code, event.value);
+                               }
+#endif
+                       }
+               }
+       }
+
+       _FUNC_EXIT;
+       return (void *)0;
+}
+
+int rw_update_process(void)
+{
+       _FUNC_ENTER;
+
+       int delay = 50000;
+       //int progress = 0;
+
+       //initialize progress
+       vconf_set_int("db/SyncML/oma-dm-service/rw-updater-progress", 0);
+
+       while (1) {
+               usleep(delay);
+               fb_draw_screen(&fbi);
+               sleep(1);
+       }
+
+       _DEBUG_LOG("%s process killed!!", __func__);
+
+       _FUNC_EXIT;
+       return 0;
+}
+
+static int wait_ani_main_solis(void)
+{
+       _FUNC_ENTER;
+
+       int ret = 0;
+       int status = 0;
+       int event_cnt = 0;
+
+       event_cnt = read_event_node();
+       if (event_cnt < 0)
+               _DEBUG_EXCEPTION("read_event_node failed, event_cnt = [%d]", event_cnt);
+
+#ifdef FEATURE_ROTATE
+       /* get degree */
+       ret = read_degree(&fbi);
+       if (ret < 0)
+               _DEBUG_EXCEPTION("read_degree failed, ret = [%d]", ret);
+#endif
+       /* open display interface */
+       if (fb_open(&fbi) < 0) {
+               _DEBUG_EXCEPTION("fb_open failed");
+               goto main_err_exit;
+       }
+
+       /* cairo initialize */
+#ifdef CAIRO_LIB
+       cairo_ui_init(fbi.w, fbi.h);
+#endif
+
+       _DEBUG_LOG("charging-animation main function called.");
+
+       chg_common_lcd_on(&s_disp);
+
+       ret = pthread_create(&keyevent_thread, NULL, event_monitor_process, (void*)&event_cnt);
+       if (ret < 0) {
+               _DEBUG_LOG("[main] event_monitor_process ret : %d", ret);
+               goto main_exit;
+       }
+
+       /* image drawing main thread */
+       rw_update_process();
+
+main_exit:
+       _DEBUG_LOG("[main] main_exit \n");
+
+       fb_close(&fbi);
+
+#ifdef CAIRO_LIB
+       cairo_ui_exit();
+       pthread_join(keyevent_thread, (void *)&status);
+       _DEBUG_LOG("[main] keyevent_thread err_exit %d\n", status);
+#endif
+
+main_err_exit:
+       _DEBUG_EXCEPTION("[main] main_err_exit \n");
+       exit(0);
+
+       _FUNC_EXIT;
+       return 0;
+
+}
+
+int main(int argc, char *argv[])
+{
+       _FUNC_ENTER;
+
+       int opt = 0;
+       int index = 0;
+
+       struct option options[] = {
+               {"wait", 0, 0, 0},
+               {"", 0, 0, 0},
+               {"", 0, 0, 0},
+               {"", 0, 0, 0},
+               {"", 0, 0, 0},
+               {0, 0, 0, 0}
+       };
+
+       if (setpriority(PRIO_PROCESS, getpid(), -11) < 0)
+               _DEBUG_EXCEPTION("failed to setpriority\n");
+
+       opt = getopt_long(argc, argv, "", options, &index);
+       if (opt == -1) {
+               _DEBUG_EXCEPTION("getopt_long failed\n");
+               _FUNC_EXIT;
+               return 0;
+       }
+
+       switch (index)  {
+       case 0: {
+               update_lang();
+
+               int ret = wait_ani_main_solis();
+
+               _FUNC_EXIT;
+               return ret;
+               }
+       case 1:
+               break;
+       case 2:
+               break;
+       case 3:
+               break;
+       case 4:
+               break;
+       default:
+               break;
+       }
+
+       _FUNC_EXIT;
+       return 0;
+}
+
diff --git a/rw-update-ani/rw-update-ani_new.h b/rw-update-ani/rw-update-ani_new.h
new file mode 100755 (executable)
index 0000000..d88eb2e
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_ANI_NEW_H__
+#define __RW_UPDATE_ANI_NEW_H__
+
+int is_batt_status(void);
+
+#endif /* __RW_UPDATE_ANI_H__ */
+
diff --git a/rw-update-ani/rw-update-log.h b/rw-update-ani/rw-update-log.h
new file mode 100755 (executable)
index 0000000..023d15a
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FOTA_LOG_H__
+#define __FOTA_LOG_H__
+
+#include <stdio.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "FOTA_GUI_RW"
+
+#define COLOR_RED      "\033[0;31m"
+#define COLOR_GREEN    "\033[0;32m"
+#define COLOR_BROWN    "\033[0;33m"
+#define COLOR_BLUE     "\033[0;34m"
+#define COLOR_PURPLE   "\033[0;35m"
+#define COLOR_CYAN     "\033[0;36m"
+#define COLOR_LIGHTBLUE "\033[0;37m"
+#define COLOR_END      "\033[0;m"
+
+#define _DEBUG_SECURE_LOG(fmt, args...)                                SECURE_SLOGD(fmt, ##args)
+#define _DEBUG_SECURE_EXCEPTION(fmt, args...)          SECURE_SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+
+#define _DEBUG_LOG(fmt, args...)               SLOGI(fmt, ##args)
+#define _DEBUG_INFO(fmt, args...)              SLOGI(COLOR_GREEN fmt COLOR_END, ##args)
+#define _DEBUG_WARNING(fmt, args...)           SLOGW(COLOR_BLUE"* Warning * " fmt COLOR_END, ##args)
+#define _DEBUG_CHECK(fmt, args...)             SLOGI(COLOR_LIGHTBLUE fmt, ##args)
+#define _DEBUG_EXCEPTION(fmt, args...)         SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+#define _FUNC_ENTER                            SLOGI(COLOR_GREEN"ENTER >>>>"COLOR_END)
+#define _FUNC_EXIT                             SLOGI(COLOR_GREEN"EXIT <<<<"COLOR_END)
+
+/*
+ * DEBUGGING FEATURE
+ */
+
+extern unsigned int __log_level__;
+extern FILE *__log_out_file__;
+
+#define LOG_INFO       (1<<8)
+#define LOG_RWANI      (1<<7)
+#define LOG_FUNCS      (1<<6)
+#define LOG_GUI                (1<<5)
+#define LOG_DEBUG      (1<<4)
+#define LOG_FILE       (1<<3)
+#define LOG_FLASH      (1<<2)
+
+#define LOG_PRFIX      "FOTA_GUI"
+
+#define DEBUG_STDOUT
+//#define DEBUG_FILE
+
+#ifdef DEBUG_STDOUT
+#define LOGE(s, args...) printf(LOG_PRFIX "/ERROR(%s)  " s, __func__, ##args) // Error log
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+       printf(LOG_PRFIX "/(%s): " s, __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_FILE)
+#define LOGE(s, args...) fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s)  " s, __func__, ##args)
+#define LOGL(mask, s, args...) do { if ((mask) & __log_level__) \
+       fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s , __func__, ##args); } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#elif defined(DEBUG_STDOUT_FILE) // debug printf
+#define LOGE(s, args...) do {\
+                                               printf(LOG_PRFIX "/ERROR(%s)  " s, __func__, ##args);\
+                                               fprintf(__log_out_file__, LOG_PRFIX "/ERROR(%s)  " s, __func__, ##args);\
+                                       } while (0)
+#define LOGL(mask, s, args...) do { \
+                                               if ((mask) & __log_level__) {\
+                                                       printf(LOG_PRFIX "/(%s): " s , __func__, ##args);\
+                                                   fprintf(__log_out_file__, LOG_PRFIX "/(%s): " s, __func__, ##args);\
+                                               } \
+                                       } while (0)
+#define LOG(s, args...) LOGL(LOG_DEBUG, s, ##args)
+
+#else
+#define LOGE(s, args...)
+#define LOGL(mask, s, args...)
+#define LOG(s, args...)
+
+#endif
+
+
+#endif /* __FOTA_LOG_H__ */
+
diff --git a/rw-update-ani/rw-update_new_cairo.h b/rw-update-ani/rw-update_new_cairo.h
new file mode 100755 (executable)
index 0000000..a52592c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_NEW_CAIRO_H__
+#define __RW_UPDATE_NEW_CAIRO_H__
+
+#include <cairo.h>
+
+typedef struct _CairoInfo {
+       cairo_t *Cr;
+       cairo_surface_t *Surface;
+       int id;
+       int width;
+       int height;
+       int currentitem;
+       int currentfocus;
+       int currentselected;
+} CairoInfo;
+
+extern long check_existence(const char *file_path);
+extern int cairo_ui_init(int width, int height);
+extern void cairo_ui_exit(void);
+extern void cairo_clear_window(void);
+extern void cairo_backgound_image(void);
+extern void cairo_mask_image(void);
+extern void cairo_update_screen(unsigned int * buffer, unsigned int size);
+extern void cairo_draw_main_img(void);
+extern void cairo_draw_main_text_img(void);
+extern void cairo_draw_progress_bar(unsigned int progress);
+extern void cairo_draw_num_progress(int progress, int total);
+extern void cairo_draw_text(void);
+extern int cairo_get_text_status(void);
+
+#endif /* __RW_UPDATE_NEW_CAIRO_H__ */
diff --git a/rw-update-ani/rw-update_new_cairo_w_360_360.c b/rw-update-ani/rw-update_new_cairo_w_360_360.c
new file mode 100755 (executable)
index 0000000..112f08e
--- /dev/null
@@ -0,0 +1,492 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#define _USE_MATH_DEFINES
+#include <math.h>
+
+#include "rw-update_new_common.h"
+#include "rw-update_new_fb.h"
+#include "rw-update_new_cairo.h"
+
+#include <time.h>
+#include <sys/time.h>
+#include <unicode/udat.h>
+#include <unicode/udatpg.h>
+#include <unicode/ustring.h>
+#include <vconf.h>
+#include <glib.h>
+#include <sys/stat.h>
+
+#include <libintl.h>           // dgettext
+
+CairoInfo cairoinfo;
+
+#define DEFAULT_FONT   "SamsungOneUI"
+#define TEXT_COLOR     1, 1, 1 /* #12b4ff */
+#define TEXT_FONT_SIZE_MAX             32
+#define TEXT_FONT_SIZE_MIN             16
+
+#define RW_PROCESS_MSG dgettext("rw-updater", "WDS_FOTA_BODY_FINALISING_NUPDATE_ING_ABB")
+//#define RW_PROCESS_MSG "Finalising\nupdate..."
+
+
+#if !defined(RESDIR)
+#define RESDIR                 "/usr/share/rw-updater/res"
+#endif
+#define IMG_BASE       RESDIR "/images/"
+#define MAIN_IMG_NAME          "solis_fota_progress_000.png"
+#define POPUP_IMG_NAME         "wc_popup_line.png"
+#define PROGRESS_IMG_PREFIX    "solis_fota_progress_"
+#define PROGRESS_BAR_IMG_PREFIX "solis_fota_progress_"
+#define PROGRESS_NUM_PREFIX    "wc_fota_downloading_"
+#define SLASH_IMG_NAME "wc_fota_downloading_slash.png"
+
+#define RO_TEXT_IMG_FILE_PATH  "/opt/usr/data/fota/FotaBgImage2.png"
+
+#define MAX_FILE_PATH           512
+
+#define PROGRESS_IMG_CNT               101
+#define PROGRESS_NUM_CNT               10
+
+#define TEXT_FONT_SIZE_MAX             32
+#define TEXT_FONT_SIZE_MIN             16
+
+cairo_surface_t *img_surf_main = NULL;
+cairo_surface_t *img_surf_popup = NULL;
+cairo_surface_t *img_surf_main_txt = NULL;
+cairo_surface_t *img_surf_prog[PROGRESS_IMG_CNT] = {NULL,};
+cairo_surface_t *img_surf_num[PROGRESS_NUM_CNT] = {NULL,};
+cairo_surface_t *img_surf_slash = NULL;
+
+int main_img_x = 0;
+int main_img_y = 0;
+int main_img_w = 0;
+int main_img_h = 0;
+
+#define BG_COLOR       0.0, 0.0, 0.0
+
+#define MAX_BUF_LEN    512
+char s_rw_process_msg1[MAX_BUF_LEN];
+char s_rw_process_msg2[MAX_BUF_LEN];
+int s_bnewline = 0;
+
+static double s_text_x1 = 0.0;
+static double s_text_x2 = 0.0;
+static double s_text_y1 = 0.0;
+static double s_text_y2 = 0.0;
+
+static int s_font_sz = 0.0;
+
+int s_font_initialized = 0;
+
+/*-----------------------------------------------------------------------------
+  cairo_update_screen()
+ ----------------------------------------------------------------------------*/
+void cairo_update_screen(unsigned int *buffer, unsigned int size)
+{
+       _FUNC_ENTER;
+
+       unsigned char *temp_buffer = NULL;
+
+       /* get buffer pointer of cairo surface */
+       temp_buffer = cairo_image_surface_get_data(cairoinfo.Surface);
+       if (temp_buffer == NULL) {
+               _DEBUG_EXCEPTION("cairo_update_screen temp_buffer NULL error!!");
+               _FUNC_EXIT;
+               return;
+       }
+
+       memcpy((void*)buffer, (void*)temp_buffer, size);
+
+       _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------------------
+  cairo_clear_window()
+ ----------------------------------------------------------------------------*/
+void cairo_clear_window(void)
+{
+       _FUNC_ENTER;
+
+       /* set default color */
+       cairo_set_source_rgb(cairoinfo.Cr, BG_COLOR);
+
+       /* fill buffer to default color */
+       cairo_paint(cairoinfo.Cr);
+
+       _FUNC_EXIT;
+}
+
+long check_existence(const char *file_path)
+{
+       _FUNC_ENTER;
+
+       if (file_path == NULL) {
+               _DEBUG_EXCEPTION("Inputted paramter is wrong");
+               _FUNC_EXIT;
+               return 0;
+       }
+       _DEBUG_LOG("%s\n", file_path);
+
+       struct stat statbuf;
+       char filename[MAX_FILE_PATH] = {0,};
+
+       if (strncpy(filename, file_path, strlen(file_path) + 1) == NULL) {
+               _DEBUG_EXCEPTION("strncpy error=%s\n", filename);
+               _FUNC_EXIT;
+               return 0;
+       }
+       if (stat(filename, &statbuf)) {
+               if (ENOENT == errno) {
+                       _DEBUG_EXCEPTION("stat %s: %m\n", filename);
+                       _FUNC_EXIT;
+                       return 0;
+               }
+       }
+       _DEBUG_LOG("satbuf.st_size = %d\n", (int)statbuf.st_size);
+
+       _FUNC_EXIT;
+       return statbuf.st_size;
+}
+
+/*-----------------------------------------------------------------*
+  cairo_image_init()
+ ------------------------------------------------------------------*/
+static void cairo_image_init(void)
+{
+       _FUNC_ENTER;
+
+       int i = 0;
+       char img_name[1024] = {0,};
+
+       snprintf(img_name, 1024, "%s%s", IMG_BASE, MAIN_IMG_NAME);
+       _DEBUG_LOG("img name = %s\n", img_name);
+       img_surf_main = cairo_image_surface_create_from_png(img_name);
+
+       for (i = 0; i < PROGRESS_NUM_CNT; i++) {
+               snprintf(img_name, 1024, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, i);
+               _DEBUG_LOG("img name = %s\n", img_name);
+               img_surf_num[i] = cairo_image_surface_create_from_png(img_name);
+       }
+
+       snprintf(img_name, 1024, "%s%s", IMG_BASE, SLASH_IMG_NAME);
+       _DEBUG_LOG("img name = %s\n", img_name);
+       img_surf_slash = cairo_image_surface_create_from_png(img_name);
+
+       if (check_existence((char *)RO_TEXT_IMG_FILE_PATH) > 0)
+               img_surf_main_txt = cairo_image_surface_create_from_png(RO_TEXT_IMG_FILE_PATH);
+
+       main_img_w = cairo_image_surface_get_width(img_surf_main);
+       main_img_h = cairo_image_surface_get_height(img_surf_main);
+       main_img_x = (cairoinfo.width - main_img_w)/2;
+       main_img_y = 0;
+       _DEBUG_LOG("main_img_w = %d, main_img_h = %d\n", main_img_w, main_img_h);
+       _DEBUG_LOG("main_img_x = %d, main_img_y = %d\n", main_img_x, main_img_y);
+
+       _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------*
+  cairo_image_exit()
+ ------------------------------------------------------------------*/
+static void cairo_image_exit()
+{
+       _FUNC_ENTER;
+
+       int i = 0;
+
+       cairo_surface_destroy(img_surf_main);
+       for (i = 0; i < PROGRESS_NUM_CNT; i++)
+               cairo_surface_destroy(img_surf_num[i]);
+       cairo_surface_destroy(img_surf_slash);
+
+       if (check_existence((char *)RO_TEXT_IMG_FILE_PATH) > 0)
+               cairo_surface_destroy(img_surf_main_txt);
+
+       _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------------------
+  cairo_backgound_image()
+ ----------------------------------------------------------------------------*/
+void cairo_backgound_image(void)
+{
+}
+/*-----------------------------------------------------------------*
+  cairo_draw_main_img()
+ ------------------------------------------------------------------*/
+void cairo_draw_main_img(void)
+{
+       _FUNC_ENTER;
+
+       cairo_set_source_surface(cairoinfo.Cr, img_surf_main, main_img_x, main_img_y);
+       cairo_rectangle(cairoinfo.Cr, main_img_x, main_img_y, main_img_w, main_img_h);
+       cairo_fill(cairoinfo.Cr);
+
+       _FUNC_EXIT;
+}
+
+void cairo_mask_image(void)
+{
+#if 0
+       cairo_set_source_surface(cairoinfo.Cr, img_surf_black_mask, main_img_x, main_img_y);
+       cairo_rectangle(cairoinfo.Cr, main_img_x, main_img_y, main_img_w, main_img_h);
+       cairo_fill(cairoinfo.Cr);
+#endif
+}
+
+void cairo_draw_main_text_img(void)
+{
+       _FUNC_ENTER;
+
+       if (img_surf_main_txt) {
+               cairo_set_source_surface(cairoinfo.Cr, img_surf_main_txt, main_img_x, main_img_y);
+               cairo_rectangle(cairoinfo.Cr, main_img_x, main_img_y, main_img_w, main_img_h);
+               cairo_fill(cairoinfo.Cr);
+       }
+
+       _FUNC_EXIT;
+}
+
+void cairo_draw_progress_bar(unsigned int progress)
+{
+       _FUNC_ENTER;
+
+       double xc = 180.0;
+       double yc = 180.0;
+       double radius = 180.0;
+       double angle1 = 270.0  * (M_PI/180.0);
+       double angle2 = 360.0 * (M_PI/180.0);
+
+       if (progress > 100)
+               progress = 100;
+
+       if (progress <= 25)
+               angle2 = (270 + progress * 36 / 10) * (M_PI/180.0);
+       else if (progress > 25 && progress <= 99)
+               angle2 = (-90 + progress * 36 / 10) * (M_PI/180.0);
+       else
+               angle1 = 0;
+
+       cairo_set_line_width(cairoinfo.Cr, 17.0);
+       cairo_set_source_rgb(cairoinfo.Cr, 0.0, 0.7, 1.0);
+       cairo_arc(cairoinfo.Cr, xc, yc, radius, angle1, angle2);
+       cairo_stroke(cairoinfo.Cr);
+
+       _FUNC_EXIT;
+}
+
+void cairo_draw_num_progress(int progress, int total)
+{
+       _FUNC_ENTER;
+
+       int img_x = 110;
+       int img_y = 240;
+       int num;
+
+       cairo_set_source_rgb(cairoinfo.Cr, BG_COLOR);
+       cairo_rectangle(cairoinfo.Cr, img_x, img_y, 140, 40);
+       cairo_fill(cairoinfo.Cr);
+
+       if (total < 10)
+               img_x += 80;
+       else if (total < 100)
+               img_x += 90;
+       else
+               img_x += 100;
+
+       num = total;
+       while (num > 0) {
+               cairo_set_source_surface(cairoinfo.Cr, img_surf_num[num % 10], img_x, img_y);
+               cairo_paint(cairoinfo.Cr);
+               img_x -= 18;
+               num /= 10;
+       }
+
+       cairo_set_source_surface(cairoinfo.Cr, img_surf_slash, img_x, img_y);
+       cairo_paint(cairoinfo.Cr);
+       img_x -= 17;
+
+       num = progress;
+       while (num > 0) {
+               cairo_set_source_surface(cairoinfo.Cr, img_surf_num[num % 10], img_x, img_y);
+               cairo_paint(cairoinfo.Cr);
+               img_x -= 18;
+               num /= 10;
+       }
+
+       _FUNC_EXIT;
+}
+
+void cairo_draw_text(void)
+{
+       _FUNC_ENTER;
+
+       _DEBUG_LOG("s_font_initialized");
+
+       /* set text color */
+       cairo_set_source_rgb(cairoinfo.Cr, TEXT_COLOR);
+
+       /* set text font */
+       cairo_set_font_size(cairoinfo.Cr, (double)s_font_sz);
+       cairo_select_font_face(cairoinfo.Cr, DEFAULT_FONT, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+
+       /* set text position */
+       cairo_move_to(cairoinfo.Cr, s_text_x1, s_text_y1);
+
+       if (s_bnewline)
+               /* set text position */
+               cairo_move_to(cairoinfo.Cr, s_text_x2, s_text_y2);
+
+       _FUNC_EXIT;
+       return;
+}
+
+static void *__thread_font_init(void *arg)
+{
+       _FUNC_ENTER;
+
+       double text_x1;
+       double text_x2;
+       double text_y;
+       int font_sz = 0;
+       char* pos_newline;
+
+       /* separate text based on new line */
+       s_rw_process_msg1[MAX_BUF_LEN - 1] = 0x00;
+       s_rw_process_msg2[MAX_BUF_LEN - 1] = 0x00;
+       strncpy(s_rw_process_msg1, RW_PROCESS_MSG, MAX_BUF_LEN - 1);
+       strncpy(s_rw_process_msg2, RW_PROCESS_MSG, MAX_BUF_LEN - 1);
+       _DEBUG_LOG("[%s], [%s]\n", s_rw_process_msg1, s_rw_process_msg2);
+
+       pos_newline = strchr(s_rw_process_msg1, '\n');
+       if (pos_newline != NULL) {
+               strncpy(s_rw_process_msg2, pos_newline + 1, MAX_BUF_LEN - 1);
+               *pos_newline = 0x00;
+               s_bnewline = 1;
+       }
+
+       /* set text font */
+       cairo_select_font_face(cairoinfo.Cr, DEFAULT_FONT, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+
+       /* calculate proper font size */
+       for (font_sz = TEXT_FONT_SIZE_MAX; font_sz >= TEXT_FONT_SIZE_MIN; font_sz -= 2) {
+               /* set font size */
+               cairo_set_font_size(cairoinfo.Cr, (double)font_sz);
+       }
+
+       if (font_sz < TEXT_FONT_SIZE_MIN)
+               font_sz = TEXT_FONT_SIZE_MIN;
+
+       /* set text position */
+       text_x1 = (double)cairoinfo.width / 2;
+       text_x2 = (double)cairoinfo.width / 2;
+
+       if (s_bnewline)
+               text_y = 180 - font_sz;
+       else
+               text_y = 180;
+
+       /* keep for later use */
+       s_text_x1 = text_x1;
+       s_text_y1 = text_y;
+       s_text_x2 = text_x2;
+       s_text_y2 = text_y + ((double)(font_sz)) * 1.2;
+       s_font_sz = font_sz;
+
+       s_font_initialized = 1;
+
+       _FUNC_EXIT;
+       return NULL;
+}
+
+/*-----------------------------------------------------------------------------
+  cairo_ui_init()
+ ----------------------------------------------------------------------------*/
+int cairo_ui_init(int width, int height)
+{
+       _FUNC_ENTER;
+
+       _DEBUG_LOG("cairo_image_init w :%d , h :%d", width, height);
+
+       cairo_status_t status;
+
+       /* get LCD resolution from fbinfo */
+       cairoinfo.width = width;
+       cairoinfo.height = height;
+
+       /* create cairo image surface(image surface means memory buffer) */
+       cairoinfo.Surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,     cairoinfo.width, cairoinfo.height);
+       status = cairo_surface_status(cairoinfo.Surface);
+       if (status != CAIRO_STATUS_SUCCESS) {
+               _DEBUG_EXCEPTION("cairo_image_init surface not create!!");
+               _FUNC_EXIT;
+               return -1;
+       }
+
+       /* create cairo context */
+       cairoinfo.Cr = cairo_create(cairoinfo.Surface);
+       status = cairo_status(cairoinfo.Cr);
+       if (status != CAIRO_STATUS_SUCCESS) {
+               _DEBUG_EXCEPTION("cairo_image_init cairo_create fail!!");
+               _FUNC_EXIT;
+               return -1;
+       }
+
+       cairo_image_init();
+
+       cairo_clear_window();
+
+       /* draw main text image */
+       if (check_existence((char *)RO_TEXT_IMG_FILE_PATH) > 0) {
+               cairo_draw_main_text_img();
+       } else {
+               pthread_t th_id;
+
+               int error = pthread_create(&th_id, NULL, __thread_font_init, NULL);
+               if (error != 0) {
+                       _DEBUG_EXCEPTION("Thread creation failed errno [%d]\n", errno);
+                       _FUNC_EXIT;
+                       return -1;
+               }
+       }
+
+       _FUNC_EXIT;
+       return 0;
+}
+
+void cairo_ui_exit(void)
+{
+       _FUNC_ENTER;
+
+       cairo_image_exit();
+       cairo_destroy(cairoinfo.Cr);
+
+       _FUNC_EXIT;
+}
+
+int cairo_get_text_status(void)
+{
+       _FUNC_ENTER;
+       _FUNC_EXIT;
+       return s_font_initialized;
+}
diff --git a/rw-update-ani/rw-update_new_common.h b/rw-update-ani/rw-update_new_common.h
new file mode 100755 (executable)
index 0000000..77bf179
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_NEW_COMMON_H__
+#define __RW_UPDATE_NEW_COMMON_H__
+
+#include <stdio.h>
+#include <errno.h>
+#include <dlog.h>
+#include <stdbool.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "FOTA_GUI_RW"
+
+#define COLOR_RED      "\033[0;31m"
+#define COLOR_GREEN    "\033[0;32m"
+#define COLOR_BROWN    "\033[0;33m"
+#define COLOR_BLUE     "\033[0;34m"
+#define COLOR_PURPLE   "\033[0;35m"
+#define COLOR_CYAN     "\033[0;36m"
+#define COLOR_LIGHTBLUE "\033[0;37m"
+#define COLOR_END      "\033[0;m"
+
+#define _DEBUG_SECURE_LOG(fmt, args...)                        SECURE_SLOGD(fmt, ##args)
+#define _DEBUG_SECURE_EXCEPTION(fmt, args...)          SECURE_SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+
+#define _DEBUG_LOG(fmt, args...)               SLOGI(fmt, ##args)
+#define _DEBUG_INFO(fmt, args...)              SLOGI(COLOR_GREEN fmt COLOR_END, ##args)
+#define _DEBUG_WARNING(fmt, args...)           SLOGW(COLOR_BLUE"* Warning * " fmt COLOR_END, ##args)
+#define _DEBUG_CHECK(fmt, args...)             SLOGI(COLOR_LIGHTBLUE fmt, ##args)
+#define _DEBUG_EXCEPTION(fmt, args...)         SLOGE(COLOR_RED"* Critical * " fmt COLOR_END, ##args)
+#define _FUNC_ENTER                            SLOGI(COLOR_GREEN"ENTER >>>>"COLOR_END)
+#define _FUNC_EXIT                             SLOGI(COLOR_GREEN"EXIT <<<<"COLOR_END)
+
+#define FILE_IO_BUF_SIZE       128
+
+#define TRUE 1
+#define FALSE 0
+
+#define UNUSED(x) (void)(x)
+
+#ifdef FEATURE_ROTATE
+enum {
+       BATT_STATE_CHARGING = 0,
+       BATT_STATE_FULL,
+       BATT_STATE_ERROR,
+       BATT_STATE_DISCONNECT,
+       BATT_STATE_LOWBATT,
+       BATT_STATE_OVERVOLTAGE,
+       BATT_STATE_OVERHEAT,
+       BATT_STATE_NOTCHARGE,
+       BATT_STATE_COLD
+};
+#endif
+
+#endif /* __RW_UPDATE_NEW_COMMON_H__ */
diff --git a/rw-update-ani/rw-update_new_common_display.h b/rw-update-ani/rw-update_new_common_display.h
new file mode 100755 (executable)
index 0000000..d3073f3
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RW_UPDATE_NEW_COMMON_DISPLAY_H__
+#define __RW_UPDATE_NEW_COMMON_DISPLAY_H__
+
+#include <tdm.h>
+#include <tbm_bufmgr.h>
+
+#include <tdm_helper.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+
+#define MAX_BUF 2
+#define RGB32_BPP 32
+#define RGB32_PITCH 4
+
+typedef struct chg_common_disp {
+       tdm_display *disp;
+       tdm_output *output;
+       tdm_layer *layer;
+       tdm_pp *pp;
+       int tdm_fd;
+       int drm_fd;
+
+       tbm_surface_h surf[MAX_BUF];
+       tbm_surface_h pp_surf[MAX_BUF];
+       tbm_bufmgr bufmgr;
+       unsigned int handle[MAX_BUF];
+       unsigned int pp_handle[MAX_BUF];
+       tbm_bo bo[MAX_BUF];
+       tbm_bo_handle bo_handle[MAX_BUF];
+       tbm_bo pp_bo[MAX_BUF];
+       tbm_bo_handle pp_bo_handle[MAX_BUF];
+       void *buffer[MAX_BUF];
+       void *pp_buffer[MAX_BUF];
+       int buffer_size;
+       int width;
+       int height;
+       int stride;
+       int current_buf_id;
+       int degree;
+} common_disp;
+
+typedef enum {
+       FRONT_BUFFER = 0,
+       BACK_BUFFER
+} BUFFER_TYPE;
+
+enum {
+       CHG_DEGREE_0 = 0,
+       CHG_DEGREE_90 = 1,
+       CHG_DEGREE_180 = 2,
+       CHG_DEGREE_270 = 3,
+};
+
+extern common_disp s_disp;
+
+int chg_common_display_init(common_disp *st_disp);
+void chg_common_display_deinit(common_disp *st_disp);
+void chg_common_display_update(common_disp *st_disp);
+void chg_common_lcd_on(common_disp *st_disp);
+void chg_common_lcd_suspend(common_disp *st_disp);
+void chg_common_lcd_off(common_disp *st_disp);
+void chg_common_display_rotate(common_disp *st_disp);
+#endif /* __RW_UPDATE_NEW_COMMON_DISPLAY_H__ */
diff --git a/rw-update-ani/rw-update_new_fb.h b/rw-update-ani/rw-update_new_fb.h
new file mode 100755 (executable)
index 0000000..58ef866
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __CHG_FB_H__
+#define __CHG_FB_H__
+
+typedef enum _CHG_SLEEP_TYPE {
+       CHG_SLEEP_TYPE_NORMAL,
+       CHG_SLEEP_TYPE_EFFECT,
+       CHG_SLEEP_TYPE_TEMP_ERROR
+} CHG_SLEEP_TYPE;
+
+typedef struct _FbInfo {
+       unsigned char *buf[2];
+       unsigned int current_fb_id;
+       int w;
+       int h;
+       int sz;
+       int degree;
+       CHG_SLEEP_TYPE sleep_type;
+       int full_flag;
+} FbInfo;
+
+extern int fb_open(FbInfo *fbi);
+extern void fb_close(FbInfo *fbi);
+extern int fb_display(FbInfo *fbi);
+extern void fb_clear_screen(FbInfo *fbi, unsigned int color);
+extern void fb_fill_rect(FbInfo *fbi, int x1, int y1, int x2, int y2,
+                        unsigned int color);
+extern void fb_draw_screen(FbInfo *fbi);
+#ifdef FEATURE_ROTATE
+extern void fb_draw_img_rotate_update(FbInfo *fbi);
+#endif
+#endif /* __CHG_FB_H__ */
diff --git a/rw-update-ani/rw-update_new_fb_cairo.c b/rw-update-ani/rw-update_new_fb_cairo.c
new file mode 100755 (executable)
index 0000000..a140ac6
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include "rw-update-ani_new.h"
+#include "rw-update_new_common.h"
+#include "rw-update_new_fb.h"
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <vconf.h>
+
+#ifdef CAIRO_LIB
+#include "rw-update_new_cairo.h"
+#endif
+#include "rw-update_new_common_display.h"
+
+common_disp s_disp;
+
+/*-----------------------------------------------------------------------------
+  fb_open()
+ ----------------------------------------------------------------------------*/
+int fb_open(FbInfo *fbi)
+{
+       _FUNC_ENTER;
+
+       memset(&s_disp, 0x00, sizeof(struct chg_common_disp));
+
+       if (chg_common_display_init(&s_disp)) {
+               _DEBUG_EXCEPTION("chg_common_display_init fail!!");
+               _FUNC_EXIT;
+               return -1;
+       }
+
+       fbi->buf[FRONT_BUFFER] = s_disp.buffer[FRONT_BUFFER];
+       fbi->buf[BACK_BUFFER] = s_disp.buffer[BACK_BUFFER];
+       fbi->current_fb_id = s_disp.current_buf_id;
+       fbi->w = s_disp.width;
+       fbi->h = s_disp.height;
+       fbi->sz = s_disp.buffer_size;
+
+       _FUNC_EXIT;
+       return 0;
+}
+
+/*-----------------------------------------------------------------------------
+  fb_close()
+ ----------------------------------------------------------------------------*/
+void fb_close(FbInfo *fbi)
+{
+       _FUNC_ENTER;
+
+       chg_common_display_deinit(&s_disp);
+
+       _FUNC_EXIT;
+}
+
+/*------------------------------------------------------------------------------
+ fb_display()
+------------------------------------------------------------------------------*/
+int fb_display(FbInfo *fbi)
+{
+       s_disp.current_buf_id = fbi->current_fb_id;
+
+       //_DEBUG_LOG("current_fb_id : %d", fbi->current_fb_id);
+#ifdef FEATURE_ROTATE
+       s_disp.degree = fbi->degree;
+
+       int battery_state = is_batt_status();
+
+       if ((fbi->degree != CHG_DEGREE_0) &&
+               (battery_state == BATT_STATE_CHARGING || battery_state == BATT_STATE_FULL)) {
+               chg_common_display_rotate(&s_disp);
+       } else
+#endif
+       {
+               chg_common_display_update(&s_disp);
+       }
+
+       return 0;
+}
+
+#ifdef FEATURE_ROTATE
+/*------------------------------------------------------------------------------
+ fb_rotate()
+------------------------------------------------------------------------------*/
+int fb_rotate(FbInfo *fbi)
+{
+       s_disp.current_buf_id = fbi->current_fb_id;
+       _DEBUG_LOG("current_fb_id : %d", fbi->current_fb_id);
+       s_disp.degree = fbi->degree;
+       chg_common_display_rotate(&s_disp);
+
+       return 0;
+}
+
+/*-----------------------------------------------------------------------------
+  fb_draw_img_rotate_update()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_rotate_update(FbInfo *fbi)
+{
+       int ret = 0;
+
+       ret = fb_rotate(fbi);
+       _DEBUG_LOG("ret : %d", ret);
+}
+#endif
+
+/*-----------------------------------------------------------------------------
+  fb_draw_img_forced_update()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_forced_update(FbInfo *fbi)
+{
+       int ret = 0;
+       ret = fb_display(fbi);
+       _DEBUG_LOG("current_fb_id : %d, ret : %d", fbi->current_fb_id, ret);
+}
+/*-----------------------------------------------------------------------------
+  fb_draw_img_check_lcd_on()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_check_lcd_on(FbInfo *fbi)
+{
+       _FUNC_ENTER;
+
+       int ret = 0;
+
+       fbi->current_fb_id = FRONT_BUFFER;
+       //_DEBUG_LOG("current_fb_id :%d", fbi->current_fb_id);
+
+       ret = fb_display(fbi);
+       _DEBUG_LOG("%s - drawing... ret : %d", __func__, ret);
+
+       _FUNC_EXIT;
+}
+
+/*-----------------------------------------------------------------------------
+  fb_clear_screen()
+ ----------------------------------------------------------------------------*/
+void fb_clear_screen(FbInfo *fbi, unsigned int color)
+{
+       unsigned int *fb_buf_cur = NULL;
+       int loop_count = fbi->w * fbi->h;
+
+       fb_buf_cur = (unsigned int *)fbi->buf[FRONT_BUFFER];
+
+       if (fb_buf_cur == NULL) {
+               _DEBUG_LOG("fb_buf_cur is null error...");
+               return;
+       }
+       while (loop_count--)
+               *(fb_buf_cur++) = color;
+}
+
+#ifdef CAIRO_LIB
+
+/*-----------------------------------------------------------------------------
+  fb_update_screen()
+ ----------------------------------------------------------------------------*/
+void fb_update_screen(FbInfo *fbi)
+{
+       _FUNC_ENTER;
+
+       unsigned int *fb_buf_cur = NULL;
+
+       fb_buf_cur = (unsigned int *)fbi->buf[FRONT_BUFFER];
+       if (fb_buf_cur == NULL) {
+               _DEBUG_EXCEPTION("fb_buf_cur is null error...");
+               _FUNC_EXIT;
+               return;
+       }
+
+       cairo_update_screen(fb_buf_cur, fbi->sz);
+
+       _FUNC_EXIT;
+}
+
+static int progress_before = -1;
+static int total = 0;
+
+void fb_draw_screen(FbInfo *fbi)
+{
+       _FUNC_ENTER;
+
+       int acc;
+       int progress = 0;
+       static int b_text_drawn = 0;
+       FILE *fp;
+
+       if (total <= 0 && access("/tmp/upgrade/total", R_OK) == 0) {
+               fp = fopen("/tmp/upgrade/total", "r");
+               if (fp) {
+                       if (fscanf(fp, "%d", &total) == EOF)
+                               _DEBUG_LOG("Error occurs at reading total");
+                       if (total < 0)
+                               total = 0;
+                       if (total > 0xffffff)
+                               total = 0xffffff;
+                       fclose(fp);
+               } else
+                       total = 0;
+       }
+
+       if (access("/tmp/upgrade/progress", R_OK) == 0) {
+               fp = fopen("/tmp/upgrade/progress", "r");
+               if (fp) {
+                       if (fscanf(fp, "%d", &progress) == EOF)
+                               _DEBUG_LOG("Error occurs at reading progress");
+                       if (progress < 0)
+                               progress = 0;
+                       if (progress > total)
+                               progress = total;
+                       fclose(fp);
+               } else
+                       progress = 0;
+       }
+
+       _DEBUG_LOG("progress: %d/%d", progress, total);
+
+       if (total > 0 && progress > progress_before) {
+               for (acc = progress_before + 1; acc <= progress; acc++) {
+                       /* draw image */
+                       cairo_draw_main_img();
+
+                       cairo_draw_progress_bar(100 * acc / total);
+                       cairo_draw_num_progress(acc, total);
+
+                       if (cairo_get_text_status() == 1) {
+                               if (b_text_drawn == 0) {
+                                       cairo_draw_text();
+                                       b_text_drawn = 1;
+                               }
+                       }
+
+                       fb_update_screen(fbi);
+                       fb_draw_img_check_lcd_on(fbi);
+               }
+               progress_before = progress;
+       }
+
+       _FUNC_EXIT;
+}
+#endif
diff --git a/rw-update-ani/rw-update_new_tdm_display.c b/rw-update-ani/rw-update_new_tdm_display.c
new file mode 100755 (executable)
index 0000000..ecf8ec5
--- /dev/null
@@ -0,0 +1,421 @@
+/*
+ * rw-update animator
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/poll.h>
+#include <sys/time.h>
+#include <tdm.h>
+#include <tdm_helper.h>
+#include "rw-update_new_common.h"
+#include "rw-update_new_common_display.h"
+
+static void chg_common_display_commit_handler_cb(tdm_output *output, unsigned int sequence,
+               unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+       _DEBUG_LOG("commit_handle_cb!!\n");
+       return;
+}
+
+int chg_common_display_init(common_disp *st_disp)
+{
+       _FUNC_ENTER;
+
+       int color = 0;
+       int buf_cnt;
+       int output_count = 0;
+       int i = 0;
+
+       tdm_error err = TDM_ERROR_NONE;
+       tdm_output *output = NULL;
+       tdm_output_type output_type = TDM_OUTPUT_TYPE_Unknown;
+       tdm_output_conn_status conn_status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
+       const tdm_output_mode *output_mode;
+       tdm_info_layer layer_info;
+       tbm_surface_info_s surf_info;
+
+       st_disp->disp = tdm_display_init(&err);
+       if (!st_disp->disp) {
+               _DEBUG_EXCEPTION("failed to init tdm_display. error num = %d\n", err);
+               goto exit;
+       }
+
+       err = tdm_display_get_fd(st_disp->disp, &st_disp->tdm_fd);
+       if (err != TDM_ERROR_NONE) {
+               _DEBUG_EXCEPTION("failed to get tdm fd. error num = %d\n", err);
+               goto exit;
+       }
+
+       st_disp->drm_fd = tdm_helper_get_fd("TDM_DRM_MASTER_FD");
+       if (st_disp->drm_fd == -1) {
+               _DEBUG_EXCEPTION("failed to get tdm fd. error num = %d\n", err);
+               goto exit;
+       }
+
+       err = tdm_display_get_output_count(st_disp->disp, &output_count);
+       if (err != TDM_ERROR_NONE) {
+               _DEBUG_EXCEPTION("failed to get output count. error num = %d\n", err);
+               goto exit;
+       }
+
+       for (i = 0; i < output_count; i++) {
+               output = tdm_display_get_output(st_disp->disp, i, &err);
+               if (err != TDM_ERROR_NONE) {
+                       _DEBUG_EXCEPTION("failed to get outout. error num = %d\n", err);
+                       goto exit;
+               }
+
+               err = tdm_output_get_output_type(output, &output_type);
+               if (err != TDM_ERROR_NONE) {
+                       _DEBUG_EXCEPTION("failed to get output type. error num = %d\n", err);
+                       goto exit;
+               }
+
+               err = tdm_output_get_conn_status(output, &conn_status);
+               if (err != TDM_ERROR_NONE) {
+                       _DEBUG_EXCEPTION("failed to get output connection status. error num = %d\n", err);
+                       goto exit;
+               }
+
+               _DEBUG_LOG("output_type=%d  conn_status=%d\n", output_type, conn_status);
+               if ((output_type == TDM_OUTPUT_TYPE_LVDS || output_type == TDM_OUTPUT_TYPE_DSI) &&
+                       (conn_status == TDM_OUTPUT_CONN_STATUS_CONNECTED)) {
+                       int cnt = 0;
+                       err = tdm_output_get_available_modes(output, &output_mode, &cnt);
+                       if (err != TDM_ERROR_NONE) {
+                               _DEBUG_EXCEPTION("failed to get output available modes. error num = %d\n", err);
+                               goto exit;
+                       }
+
+                       /* GET MODE INFO */
+                       st_disp->output = output;
+                       st_disp->width = output_mode->hdisplay;
+                       st_disp->height = output_mode->vdisplay;
+
+                       unsigned int width_mm = 0;
+                       unsigned int height_mm = 0;
+
+                       err = tdm_output_get_physical_size(output, &width_mm, &height_mm);
+                       _DEBUG_LOG("err = [%d]", err);
+                       _DEBUG_LOG("TDM_OUTPUT_MODE:name[%s] mode:wh[%d %d] mm[%d %d]", output_mode->name, st_disp->width, st_disp->height, width_mm, height_mm);
+
+                       break;
+               }
+       }
+
+       /* MEMORY ALLOCATION */
+       st_disp->bufmgr = tbm_bufmgr_init(st_disp->drm_fd);
+       if (!st_disp->bufmgr) {
+               _DEBUG_EXCEPTION("failed to tbm_bufmgr_init\n");
+               goto exit;
+       }
+
+       st_disp->buffer_size = st_disp->width * st_disp->height * RGB32_PITCH;
+       st_disp->stride = st_disp->width * RGB32_PITCH;
+
+       surf_info.width = st_disp->width;
+       surf_info.height = st_disp->height;
+       surf_info.format = TBM_FORMAT_ARGB8888;
+       surf_info.bpp = 32;
+       surf_info.size = st_disp->buffer_size;
+       surf_info.num_planes = 1;
+       surf_info.planes[0].size = st_disp->buffer_size;
+       surf_info.planes[0].offset = 0;
+       surf_info.planes[0].stride = st_disp->stride;
+
+       for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+               st_disp->bo[buf_cnt] = tbm_bo_alloc(st_disp->bufmgr, st_disp->buffer_size, TBM_BO_NONCACHABLE);
+               if (!st_disp->bo[buf_cnt]) {
+                       _DEBUG_EXCEPTION("failed to tbm_bo_alloc\n");
+                       goto exit;
+               }
+
+               st_disp->bo_handle[buf_cnt] = tbm_bo_map(st_disp->bo[buf_cnt], TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+               st_disp->buffer[buf_cnt] = st_disp->bo_handle[buf_cnt].ptr;
+               st_disp->handle[buf_cnt] = tbm_bo_get_handle(st_disp->bo[buf_cnt], TBM_DEVICE_2D).u32;
+
+               memset(st_disp->buffer[buf_cnt], color, st_disp->stride * st_disp->height);
+
+               tbm_bo_unmap(st_disp->bo[buf_cnt]);
+
+               st_disp->surf[buf_cnt] = tbm_surface_internal_create_with_bos(&surf_info, &st_disp->bo[buf_cnt], 1);
+               if (!st_disp->surf[buf_cnt]) {
+                       _DEBUG_EXCEPTION("failed to create tbm_surface!!\n");
+                       goto exit;
+               }
+       }
+
+#ifdef FEATURE_ROTATE
+       for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+               st_disp->pp_bo[buf_cnt] = tbm_bo_alloc(st_disp->bufmgr, st_disp->buffer_size, TBM_BO_NONCACHABLE);
+               if (!st_disp->pp_bo[buf_cnt]) {
+                       _DEBUG_EXCEPTION("failed to tbm_bo_alloc pp\n");
+                       goto exit;
+               }
+
+               st_disp->pp_bo_handle[buf_cnt] = tbm_bo_map(st_disp->pp_bo[buf_cnt], TBM_DEVICE_CPU, TBM_OPTION_WRITE);
+               st_disp->pp_buffer[buf_cnt] = st_disp->pp_bo_handle[buf_cnt].ptr;
+               st_disp->pp_handle[buf_cnt] = tbm_bo_get_handle(st_disp->pp_bo[buf_cnt], TBM_DEVICE_2D).u32;
+
+               memset(st_disp->pp_buffer[buf_cnt], 0x00, st_disp->stride * st_disp->height);
+
+               tbm_bo_unmap(st_disp->pp_bo[buf_cnt]);
+
+               st_disp->pp_surf[buf_cnt] = tbm_surface_internal_create_with_bos(&surf_info, &st_disp->pp_bo[buf_cnt], 1);
+               if (!st_disp->surf[buf_cnt]) {
+                       _DEBUG_EXCEPTION("failed to create tbm_surface for pp!!\n");
+                       goto exit;
+               }
+               _DEBUG_LOG("pp:b[%d]hdl[%d]", buf_cnt, st_disp->pp_handle[buf_cnt]);
+       }
+#endif
+
+       /* SET LAYER */
+       tdm_layer_capability layer_caps;
+       tdm_layer *tmp_layer = NULL;
+
+       for (i = 0; i < output_count; i++) {
+               tmp_layer = tdm_output_get_layer(st_disp->output, output_count, &err);
+               tdm_layer_get_capabilities(tmp_layer, &layer_caps);
+               if (layer_caps & TDM_LAYER_CAPABILITY_PRIMARY)
+                       break;
+       }
+
+       if (!tmp_layer) {
+               _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err);
+               goto exit;
+       }
+
+       st_disp->layer = tmp_layer;
+
+       layer_info.src_config.size.h = st_disp->width;
+       layer_info.src_config.size.v = st_disp->height;
+       layer_info.src_config.pos.x = 0;
+       layer_info.src_config.pos.y = 0;
+       layer_info.src_config.pos.w = st_disp->width;
+       layer_info.src_config.pos.h = st_disp->height;
+       layer_info.src_config.format = TBM_FORMAT_ARGB8888;
+       layer_info.dst_pos.x = 0;
+       layer_info.dst_pos.y = 0;
+       layer_info.dst_pos.w = st_disp->width;
+       layer_info.dst_pos.h = st_disp->height;
+       layer_info.transform = TDM_TRANSFORM_NORMAL;
+
+       err = tdm_layer_set_info(st_disp->layer, &layer_info);
+       if (err != TDM_ERROR_NONE) {
+               _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err);
+               goto exit;
+       }
+
+       /* SETUP PP */
+#ifdef FEATURE_ROTATE
+       st_disp->pp = tdm_display_create_pp(st_disp->disp, &err);
+       if (err != TDM_ERROR_NONE) {
+               _DEBUG_EXCEPTION("failed to get output layer. error num = %d\n", err);
+               goto exit;
+       }
+#endif
+
+       st_disp->current_buf_id = 0;
+       _DEBUG_LOG("done");
+       _FUNC_EXIT;
+       return 0;
+
+exit:
+       chg_common_display_deinit(st_disp);
+       _FUNC_EXIT;
+       return -1;
+}
+
+void chg_common_display_deinit(common_disp *st_disp)
+{
+       _FUNC_ENTER;
+
+       int buf_cnt = 0;
+
+       if (st_disp->disp != NULL) {
+               /* RELEASE RESOURCE */
+               for (buf_cnt = 0; buf_cnt < MAX_BUF; buf_cnt++) {
+                       if (st_disp->surf[buf_cnt] != NULL)
+                               tbm_surface_destroy(st_disp->surf[buf_cnt]);
+
+                       if (st_disp->bo[buf_cnt] != NULL)
+                               tbm_bo_unref(st_disp->bo[buf_cnt]);
+
+#ifdef FEATURE_ROTATE
+                       if (st_disp->pp_surf[buf_cnt] != NULL)
+                               tbm_surface_destroy(st_disp->pp_surf[buf_cnt]);
+
+                       if (st_disp->pp_bo[buf_cnt] != NULL)
+                               tbm_bo_unref(st_disp->pp_bo[buf_cnt]);
+#endif
+               }
+
+               if (st_disp->bufmgr != NULL)
+                       tbm_bufmgr_deinit(st_disp->bufmgr);
+               st_disp->bufmgr = NULL;
+
+#ifdef FEATURE_ROTATE
+               if (st_disp->pp) {
+                       tdm_pp_destroy(st_disp->pp);
+                       st_disp->pp = NULL;
+               }
+#endif
+
+               tdm_display_deinit(st_disp->disp);
+               st_disp->disp = NULL;
+       }
+
+       _FUNC_EXIT;
+}
+
+#ifdef FEATURE_ROTATE
+void chg_common_display_rotate(common_disp *st_disp)
+{
+       int buf_cnt = 0;
+       int dst_degree = st_disp->degree;
+
+       tdm_error err = TDM_ERROR_NONE;
+       tdm_info_pp pp_info;
+
+       memset(&pp_info, 0x00, sizeof(tdm_info_pp));
+
+       pp_info.src_config.size.h = st_disp->width;
+       pp_info.src_config.size.v = st_disp->height;
+       pp_info.src_config.pos.x = 0;
+       pp_info.src_config.pos.y = 0;
+       pp_info.src_config.pos.w = st_disp->width;
+       pp_info.src_config.pos.h = st_disp->height;
+       pp_info.src_config.format = TBM_FORMAT_ARGB8888;
+
+       pp_info.dst_config.size.h = st_disp->width;
+       pp_info.dst_config.size.v = st_disp->height;
+       pp_info.dst_config.pos.x = 0;
+       pp_info.dst_config.pos.y = 0;
+       pp_info.dst_config.pos.w = st_disp->width;
+       pp_info.dst_config.pos.h = st_disp->height;
+       pp_info.dst_config.format = TBM_FORMAT_ARGB8888;
+
+       pp_info.sync = 1;
+       pp_info.flags = 0;
+
+       switch (dst_degree) {
+       case CHG_DEGREE_0:
+               pp_info.transform = TDM_TRANSFORM_NORMAL;
+               break;
+       case CHG_DEGREE_90:
+               pp_info.transform = TDM_TRANSFORM_90;
+               break;
+       case CHG_DEGREE_180:
+               pp_info.transform = TDM_TRANSFORM_180;
+               break;
+       case CHG_DEGREE_270:
+               pp_info.transform = TDM_TRANSFORM_270;
+               break;
+       default:
+               pp_info.transform = TDM_TRANSFORM_NORMAL;
+               break;
+       }
+
+       _DEBUG_LOG("dst_degree : %d", dst_degree);
+
+       buf_cnt = st_disp->current_buf_id;
+
+       err = tdm_pp_set_info(st_disp->pp, &pp_info);
+       if (err != TDM_ERROR_NONE) {
+               _DEBUG_LOG("failed to set pp info. error num = %d\n", err);
+               return;
+       }
+
+       err = tdm_pp_attach(st_disp->pp, st_disp->surf[buf_cnt], st_disp->pp_surf[buf_cnt]);
+       if (err != TDM_ERROR_NONE) {
+               _DEBUG_LOG("failed to attach pp. error num = %d\n", err);
+               return;
+       }
+
+       err = tdm_pp_commit(st_disp->pp);
+       if (err != TDM_ERROR_NONE) {
+               _DEBUG_LOG("failed to attach pp. error num = %d\n", err);
+               return;
+       }
+
+       tdm_layer_set_buffer(st_disp->layer, st_disp->pp_surf[buf_cnt]);
+
+       // TODO: sync or async??
+       tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp);
+}
+#endif
+
+
+void chg_common_display_update(common_disp *st_disp)
+{
+       /* DISPLAY UPDATE */
+       int buf_cnt = 0;
+
+       buf_cnt = st_disp->current_buf_id;
+       //st_disp->current_buf_id = (++st_disp->current_buf_id)%MAX_BUF;
+
+       tdm_layer_set_buffer(st_disp->layer, st_disp->surf[buf_cnt]);
+
+       // TODO: sync or async??
+       tdm_output_commit(st_disp->output, 1, chg_common_display_commit_handler_cb, st_disp);
+
+       return;
+}
+
+void chg_common_lcd_on(common_disp *st_disp)
+{
+       _FUNC_ENTER;
+
+       /* SET DPMS ON */
+       _DEBUG_LOG("DPMS ON!\n");
+       tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_ON);
+
+       _FUNC_EXIT;
+       return;
+}
+
+void chg_common_lcd_suspend(common_disp *st_disp)
+{
+       /* SET DPMS SUSPEND */
+       _DEBUG_LOG("DPMS SUSPEND!\n");
+       tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_SUSPEND);
+
+       return;
+}
+
+void chg_common_lcd_off(common_disp *st_disp)
+{
+       /* SET DPMS OFF */
+       _DEBUG_LOG("DPMS OFF!\n");
+       tdm_output_set_dpms(st_disp->output, TDM_OUTPUT_DPMS_OFF);
+
+       return;
+}
index 26545247819db58fbbdfcf096b8f9c0efecd6f39..b0c44fe8e6dfe47374c51d84077d0de5f66fbf5b 100755 (executable)
@@ -4,6 +4,7 @@
 #
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
+TMP_DIR=/tmp/upgrade
 PATCH_DIR=/usr/share/upgrade/scripts
 RESULT_FILE=/opt/data/recovery/rw_result
 SDB_RULE=/opt/data/recovery/99-sdb-switch.rules
@@ -11,14 +12,36 @@ VERSION_FILE=/opt/etc/version
 RW_MACRO=/usr/share/upgrade/rw-update-macro.inc
 RUN=/bin/sh
 
+RW_GUI=
+RW_ANI=/usr/bin/rw-update-ani
+
+# Check GUI availability
+if [ -e ${RW_ANI} ]; then
+       RW_GUI=1
+fi
+
 # Execute update scripts
 if [ ! -d ${PATCH_DIR} ]
 then
        echo "FAIL: Upgrade directory does not exist" > ${RESULT_FILE}
 else
+       if [ "${RW_GUI}" = "1" ]; then
+               progress=0
+               total=`ls -l ${PATCH_DIR} | grep -c '^-'`
+               mkdir -p ${TMP_DIR}
+               echo ${total} > ${TMP_DIR}/total
+               export XDG_RUNTIME_DIR=/run
+               export TBM_DISPLAY_SERVER=1
+               /usr/bin/rw-update-ani --wait &
+       fi
+
        PATCHES=`/bin/ls ${PATCH_DIR}`
 
        for PATCH in ${PATCHES}; do
+               if [ "${RW_GUI}" = "1" ]; then
+                       progress=$((progress+1))
+                       echo ${progress} > ${TMP_DIR}/progress
+               fi
                ${RUN} ${PATCH_DIR}/${PATCH}
        done