--- /dev/null
+/*
+ * firmware-update-system-ui
+ *
+ * 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 "base_gui.h"
+#include "base_gui_direct.h"
+#include "gui_direct.h"
+
+static int s_percent_to_draw = 0;
+static int s_saved_percent = -1;
+
+/*-----------------------------------------------------------------------------
+ fota_gr_init
+ ----------------------------------------------------------------------------*/
+int fota_gr_init(void)
+{
+ return fota_gr_direct_init();
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_deinit
+ ----------------------------------------------------------------------------*/
+void fota_gr_deinit(void)
+{
+ fota_gr_direct_deinit();
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_clear_screen
+ ----------------------------------------------------------------------------*/
+void fota_gr_clear_screen(u32 color)
+{
+ fota_gr_direct_clear_screen(color);
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_update_progress
+ ----------------------------------------------------------------------------*/
+int fota_gr_update_progress(void)
+{
+ int percent = 0;
+ percent = fota_gr_direct_update_progress(&s_saved_percent, &s_percent_to_draw);
+ return percent;
+}
+
--- /dev/null
+/*
+ * firmware-update-system-ui
+ *
+ * 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 __BASE_GUI_H__
+#define __BASE_GUI_H__
+
+extern int fota_gr_init(void);
+extern void fota_gr_deinit(void);
+extern int fota_gr_update_progress(void);
+extern void fota_gr_clear_screen(unsigned int color);
+
+#endif /* __BASE_GUI_H__ */
+
--- /dev/null
+/*
+ * firmware-update-system-ui
+ *
+ * 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.
+ */
+
+/*****************************************************************************
+** header files
+*****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <pixman.h>
+
+#include "gui_general.h"
+#include "fota_png.h"
+#include "fbinfo.h"
+#include "tdm-if.h"
+
+#define UNUSED(x) (void)(x)
+
+#define COLOR_BLACK 0xFF000000
+
+#define MAX_PATH 256
+#define MAX_FILE_PATH 512
+
+#if !defined(ROTATE)
+#define ROTATE 0
+#endif
+
+/*****************************************************************************
+** global variables
+*****************************************************************************/
+const int x_offset_main_bg_text_pos = 518;
+const int y_offset_main_bg_text_pos = 300;
+const int x_offset_prog_bar_img_pos = 240;
+const int y_offset_prog_bar_img_pos = 355;
+int rotate_step = 0;
+int rollback_step = 0;
+int img_buf_width = 0;
+int img_buf_height = 0;
+
+FbInfo s_fbi;
+tdm_if_disp s_disp;
+
+int s_percent_to_draw = 0;
+int s_saved_percent = -1;
+
+/*-----------------------------------------------------------------------------
+ fb_open()
+ ----------------------------------------------------------------------------*/
+int fb_open(FbInfo *fbi)
+{
+ memset(&s_disp, 0x00, sizeof(struct _tdm_if_disp));
+
+ if (tdm_if_display_init(&s_disp)) {
+ LOGE("tdm_if_display_init fail!!\n");
+ 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;
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fb_close()
+ ----------------------------------------------------------------------------*/
+void fb_close(FbInfo *fbi)
+{
+ UNUSED(fbi);
+ tdm_if_display_deinit(&s_disp);
+}
+
+/*------------------------------------------------------------------------------
+ fb_display()
+------------------------------------------------------------------------------*/
+int fb_display(FbInfo *fbi)
+{
+ s_disp.current_buf_id = fbi->current_fb_id;
+ LOG("current_fb_id : %d\n", fbi->current_fb_id);
+ tdm_if_display_update(&s_disp);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fb_draw_img_forced_update()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_forced_update(FbInfo *fbi)
+{
+ int ret = 0;
+ ret = fb_display(fbi);
+ LOG("current_fb_id : %d, ret : %d\n", fbi->current_fb_id, ret);
+}
+/*-----------------------------------------------------------------------------
+ fb_draw_img_check_lcd_on()
+ ----------------------------------------------------------------------------*/
+void fb_draw_img_check_lcd_on(FbInfo *fbi)
+{
+
+ int ret = 0;
+
+ fbi->current_fb_id = FRONT_BUFFER;
+
+ LOG("current_fb_id :%d\n", fbi->current_fb_id);
+
+ ret = fb_display(fbi);
+
+ LOG("%s - drawing... ret : %d\n", __func__, ret);
+}
+
+/*-----------------------------------------------------------------------------
+ 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) {
+ LOG("fb_buf_cur is null error...\n");
+ return;
+ }
+ while (loop_count--)
+ *(fb_buf_cur++) = color;
+
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_fill_rect
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_fill_rect(tbm_surface_info_s *surface_info, s32 x, s32 y, s32 w, s32 h, u32 color)
+{
+ unsigned int *fb_buf_int = NULL;
+ unsigned int *fb_buf_cur = NULL;
+ s32 dx = 0;
+ s32 dy = 0;
+ s32 wb = 0;
+
+ if (NULL == surface_info)
+ return;
+
+ dx = w;
+ dy = h;
+ wb = w * sizeof(u32);
+
+ fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
+ fb_buf_int += y * surface_info->width + x;
+ fb_buf_cur = fb_buf_int;
+
+ while (dx--)
+ *fb_buf_cur++ = color;
+
+ fb_buf_cur -= w;
+ fb_buf_cur += surface_info->width;
+ dy--;
+ while (dy--) {
+ memcpy((void*)fb_buf_cur, (void*)fb_buf_int, wb);
+ fb_buf_cur += surface_info->width;
+ }
+
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_clear_screen
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_clear_screen(FbInfo *fbi, u32 color)
+{
+ unsigned int *fb_buf_int = NULL;
+ unsigned int *fb_buf_cur = NULL;
+ s32 dx = 0;
+ s32 dy = 0;
+ s32 w = 0;
+
+ if (NULL == fbi)
+ return;
+
+ dx = fbi->w;
+ dy = fbi->h;
+ w = fbi->w * sizeof(u32);
+
+ fb_buf_int = (unsigned int *)fbi->buf[FRONT_BUFFER];
+ fb_buf_cur = fb_buf_int;
+
+ while (dx--)
+ *fb_buf_cur++ = color;
+
+ dy--;
+ while (dy--) {
+ memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
+ fb_buf_cur += fbi->w;
+ }
+}
+
+static void _gr_direct_clear_screen_init(tbm_surface_info_s *surface_info, u32 color)
+{
+ unsigned int *fb_buf_int = NULL;
+ unsigned int *fb_buf_cur = NULL;
+ s32 dx = 0;
+ s32 dy = 0;
+ s32 w = 0;
+
+ if (NULL == surface_info)
+ return;
+
+ dx = surface_info->width;
+ dy = surface_info->height;
+ w = surface_info->width * sizeof(u32);
+
+ fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
+ fb_buf_cur = fb_buf_int;
+
+ while (dx--)
+ *fb_buf_cur++ = color;
+
+ dy--;
+ while (dy--) {
+ memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
+ fb_buf_cur += surface_info->width;
+ }
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_draw_text
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_draw_text(tbm_surface_info_s *surface_info, int percent)
+{
+ char img_name[MAX_PATH];
+ int img_x;
+ int img_y;
+ int num;
+
+ img_x = 588;
+ img_y = 395;
+
+ if (percent < 10)
+ img_x += 7;
+ else if (percent < 100)
+ img_x += 14;
+ else if (percent == 100)
+ img_x += 21;
+
+ if (percent == 100) {
+ snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, 1);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ //draw_png_img_xy(fbi, img_x, img_y);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+ }
+
+ img_x += 14;
+ if (percent >= 10) {
+ num = percent / 10;
+ if (num == 10)
+ num = 0;
+
+ snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ //draw_png_img_xy(fbi, img_x, img_y);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+ }
+
+ img_x += 14;
+ num = percent % 10;
+
+ snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ //draw_png_img_xy(fbi, img_x, img_y);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+
+ img_x += 13;
+
+ snprintf(img_name, MAX_PATH, "%s%s", IMG_BASE, PERCENT_IMG_NAME);
+ if (read_png_file(img_name) < 0)
+ return;
+
+ //draw_png_img_xy(fbi, img_x, img_y);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_draw_prog_text
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_draw_prog_text(tbm_surface_info_s *surface_info, int percent)
+{
+ if (percent <= 0)
+ percent = 0;
+
+ if (percent > 100)
+ percent = 100;
+
+ _gr_direct_fill_rect(surface_info, 610, 395, 65, 41, COLOR_BLACK);
+ _gr_direct_draw_text(surface_info, percent);
+}
+
+static void _gr_direct_draw_main_prog_img(tbm_surface_info_s *surface_info, int percent)
+{
+ int img_x = 0;
+ int img_y = 0;
+
+ if (read_png_file(IMG_BASE MAIN_PG_IMG_NAME) < 0)
+ return;
+
+ img_x = x_offset_prog_bar_img_pos;
+ img_y = y_offset_prog_bar_img_pos;
+
+ //draw_png_img_xy(fbi, img_x, img_y);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_draw_main_img
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_draw_main_img(tbm_surface_info_s *surface_info)
+{
+ int img_x = 0;
+ int img_y = 0;
+
+ if (read_png_file(IMG_BASE MAIN_IMG_NAME) < 0)
+ return;
+
+ img_x = 0;
+ img_y = 0;
+
+ //draw_png_img_xy(fbi, img_x, img_y);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+
+#if !TW_RO_PROGRESS
+ if (read_png_file(IMG_BASE MAIN_TEXT_NAME) < 0)
+ return;
+
+ img_x = x_offset_main_bg_text_pos;
+ img_y = y_offset_main_bg_text_pos;
+
+ //draw_png_img_xy(fbi, img_x, img_y);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+#endif
+}
+
+
+void _copy_buffers_by_rotate(void *srcptr, int srcw, int srch, int srcstride,
+ void *dstptr, int dstw, int dsth, int dststride,
+ int sx, int sy, int sw, int sh,
+ int dx, int dy, int dw, int dh, int rstep)
+{
+ pixman_image_t *src_img = NULL, *dst_img = NULL;
+ pixman_op_t op;
+
+ int buf_width;
+
+ buf_width = srcstride/4;
+ src_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, srch, (uint32_t*)srcptr, srcstride);
+ if(!src_img)
+ {
+ LOG("No source image.\n");
+ return;
+ }
+
+ buf_width = dststride/4;
+ dst_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, dsth, (uint32_t*)dstptr, dststride);
+
+ struct pixman_f_transform ft;
+ double scale_x, scale_y;
+ pixman_transform_t t;
+ pixman_f_transform_init_identity(&ft);
+
+ if (rstep > 0) {
+ int c = 0, s = 0, tx = 0, ty = 0;
+ switch (rstep) {
+ case 1:
+ c = 0, s = -1, tx = -dw;
+ break;
+ case 2:
+ c = -1, s = 0, tx = -dw, ty = -dh;
+ break;
+ case 3:
+ c = 0, s = 1, ty = -dh;
+ break;
+ }
+ pixman_f_transform_translate(&ft, NULL, tx, ty);
+ pixman_f_transform_rotate(&ft, NULL, c, s);
+ }
+
+ if (rstep % 2 == 0) {
+ scale_x = (double)sw / dw;
+ scale_y = (double)sh / dh;
+ } else {
+ scale_x = (double)sw / dh;
+ scale_y = (double)sh / dw;
+ }
+ pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
+ pixman_f_transform_translate(&ft, NULL, sx, sy);
+ pixman_transform_from_pixman_f_transform(&t, &ft);
+ pixman_image_set_transform(src_img, &t);
+
+
+ op = PIXMAN_OP_SRC;
+ pixman_image_composite(op, src_img, NULL, dst_img, 0, 0, 0, 0, dx, dy, dw, dh);
+
+ if (src_img)
+ pixman_image_unref(src_img);
+ if (dst_img)
+ pixman_image_unref(dst_img);
+}
+
+/*-----------------------------------------------------------------------------
+ __init_screen
+ ----------------------------------------------------------------------------*/
+static void __init_screen(FbInfo *fbi)
+{
+ /* create tbm_surface for original image */
+ tbm_surface_h tbm_surface_ori = NULL;
+ tbm_surface_info_s surface_info_ori;
+ tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
+ if(!tbm_surface_ori){
+ LOG("failed to tbm_surface_create\n");
+ }
+ tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
+
+
+ _gr_direct_clear_screen_init(&surface_info_ori, COLOR_BLACK);
+
+ _gr_direct_draw_main_img(&surface_info_ori);
+
+ _gr_direct_draw_main_prog_img(&surface_info_ori, 0);
+
+ _gr_direct_draw_prog_text(&surface_info_ori, 0);
+
+
+ _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
+ fbi->buf[0], fbi->w, fbi->h, fbi->w * RGB32_PITCH,
+ 0,0,surface_info_ori.width, surface_info_ori.height,
+ 0,0,fbi->w, fbi->h, rotate_step);
+ tbm_surface_unmap(tbm_surface_ori);
+ tbm_surface_destroy(tbm_surface_ori);
+}
+
+static void _gr_direct_progress_bar(tbm_surface_info_s *surface_info, int progress)
+{
+ char img_name[MAX_PATH];
+
+ static int prog_pre = 0;
+ int count = 0;
+ int prog_cnt = 0;
+ int img_x = 0;
+ int img_y = 0;
+
+ if (progress <= 0)
+ return;
+
+ if (progress > 100)
+ progress = 100;
+
+ prog_cnt = progress;
+
+
+ img_x = x_offset_prog_bar_img_pos;
+ img_y = y_offset_prog_bar_img_pos;
+
+ for (; prog_pre <= prog_cnt; prog_pre++) {
+ LOG("prog_pre/prog_cnt : %d, %d \n", prog_pre , prog_cnt);
+
+ // draw current progress image
+ snprintf(img_name, MAX_PATH, "%s%s%03d.png", IMG_BASE, PROGRESS_BAR_IMG_PREFIX, prog_pre);
+ if (read_png_file(img_name) < 0) {
+ LOG("ERROR \n");
+ return;
+ }
+
+ //draw_png_img_xy(fbi, 240, 355);
+ draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
+ release_png_res();
+
+ s_saved_percent = prog_pre;
+
+ if(progress != 100)
+ {
+ count++;
+ if (count > 3)
+ break;
+ }
+ }
+}
+
+/*-----------------------------------------------------------------------------
+ _gr_direct_update_screen
+ ----------------------------------------------------------------------------*/
+static void _gr_direct_update_screen()
+{
+ s_disp.current_buf_id = s_fbi.current_fb_id;
+
+ tdm_if_display_update(&s_disp);
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_update_progress
+ ----------------------------------------------------------------------------*/
+void fota_gr_direct_progress(int * saved_percent, int * percent_to_draw)
+{
+ s_saved_percent = *saved_percent;
+ s_percent_to_draw = *percent_to_draw;
+
+ if (s_percent_to_draw > 0) {
+ /* create tbm_surface for original image */
+ tbm_surface_h tbm_surface_ori = NULL;
+ tbm_surface_info_s surface_info_ori;
+
+ tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
+ if(!tbm_surface_ori){
+ LOG("failed to tbm_surface_create\n");
+ }
+ tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
+ // need to keep previous image
+ _copy_buffers_by_rotate(s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
+ surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
+ 0,0,s_fbi.w, s_fbi.h,
+ 0,0,surface_info_ori.width, surface_info_ori.height, rollback_step);
+
+ _gr_direct_progress_bar(&surface_info_ori, s_percent_to_draw);
+ _gr_direct_draw_prog_text(&surface_info_ori, s_saved_percent);
+
+ _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
+ s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
+ 0,0,surface_info_ori.width, surface_info_ori.height,
+ 0,0,s_fbi.w, s_fbi.h, rotate_step);
+ tbm_surface_unmap(tbm_surface_ori);
+ tbm_surface_destroy(tbm_surface_ori);
+ } else if (s_percent_to_draw == 0) {
+ s_saved_percent = 0;
+ }
+ *saved_percent = s_saved_percent;
+ *percent_to_draw = s_percent_to_draw;
+
+ _gr_direct_update_screen();
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_clear_screen
+ ----------------------------------------------------------------------------*/
+void fota_gr_direct_clear_screen(u32 color)
+{
+ _gr_direct_clear_screen(&s_fbi, color);
+ _gr_direct_update_screen();
+}
+
+void _get_rotate(void)
+{
+ char *rotate_state = getenv("ROTATE_STATE");
+ int rotate_angle = -1;
+ if(!rotate_state)
+ {
+ rotate_angle = ROTATE;
+ }
+ else
+ {
+ rotate_angle = atoi(rotate_state);
+ }
+
+ if(rotate_angle < -360 || rotate_angle > 360) // for prevent interger overflow
+ rotate_angle = 0;
+ LOG("Print Rotate Angle value = %d\n", rotate_angle);
+
+ rotate_step = (rotate_angle + 360) / 90 % 4;
+ if(rotate_step < 0 || rotate_step > 4) // for prevent interger overflow
+ rotate_step = 0;
+ rollback_step = (4 - rotate_step) % 4;
+ LOG("rotate_step = %d, rollback_step = %d\n", rotate_step, rollback_step);
+
+ if (rotate_step % 2 == 0) {
+ img_buf_width = s_fbi.w;
+ img_buf_height = s_fbi.h;
+ } else {
+ img_buf_width = s_fbi.h;
+ img_buf_height = s_fbi.w;
+ }
+ LOG("Print Img buffer(=image w,h) width = %d, height = %d\n", img_buf_width, img_buf_height);
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_init
+ ----------------------------------------------------------------------------*/
+int fota_gr_direct_init(void)
+{
+ /* open display interface */
+ if (fb_open(&s_fbi) < 0)
+ LOG("fb_open failed \n");
+
+ _get_rotate();
+ __init_screen(&s_fbi);
+
+ tdm_if_lcd_on(&s_disp);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------------------
+ fota_gr_direct_deinit
+ ----------------------------------------------------------------------------*/
+void fota_gr_direct_deinit(void)
+{
+ fb_close(&s_fbi);
+}
+
--- /dev/null
+/*
+ * firmware-update-system-ui
+ *
+ * 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 __BASE_GUI_DIRECT_H__
+#define __BASE_GUI_DIRECT_H__
+
+#include "gui_general.h"
+
+extern int fota_gr_direct_init(void);
+extern void fota_gr_direct_deinit(void);
+extern void fota_gr_direct_clear_screen(u32 color);
+//extern int fota_gr_direct_ro_update_progress(void);
+extern void fota_gr_direct_progress(int * saved_percent, int * percent_to_draw);
+
+#endif /* __BASE_GUI_DIRECT_H__ */
--- /dev/null
+/*
+ * firmware-update-system-ui
+ *
+ * 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 <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <getopt.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include "gui_general.h"
+#include "gui_util.h"
+#include "base_gui.h"
+
+unsigned int __log_level__ =
+ (LOG_DEBUG | LOG_FLASH | LOG_FILE | LOG_FUNCS | LOG_GUI | LOG_SSENGINE | LOG_INFO);
+FILE *__log_out_file__;
+
+int s_prog_percent = 0;
+int s_last_prog_percent = 0;
+
+int s_pid = -1;
+
+static int wait_main(void)
+{
+ int delay = 20000;
+
+ if (setpriority(PRIO_PROCESS, getpid(), -11) < 0)
+ LOG("failed to setpriority\n");
+
+ if (fota_gr_init() < 0) {
+ LOG("fota_gr_init() failed.\n");
+ _exit_stdio();
+ return -1;
+ }
+
+ while (1) {
+ usleep(delay);
+ s_prog_percent = fota_gr_update_progress();
+ if (s_prog_percent == -1) break;
+ sleep(1);
+ }
+
+ fota_gr_deinit();
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+#if WAIT
+ 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}
+ };
+
+ opt = getopt_long(argc, argv, "", options, &index);
+ if (opt == -1) {
+ LOGE("getopt_long failed\n");
+ return 0;
+ }
+
+ switch (index) {
+ case 0: {
+ int ret = wait_main();
+ return ret;
+ }
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ default:
+ break;
+ }
+#else
+ int ret = 0;
+ ret = wait_main();
+#endif
+ _exit_stdio();
+ return 0;
+}
--- /dev/null
+/*
+ * firmware-update-system-ui
+ *
+ * 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 __GUI_DIRECT_H__
+#define __GUI_DIRECT_H__
+
+#include "gui_general.h"
+
+extern int fota_gr_direct_update_progress(int * s_saved_percent, int * s_percent_to_draw);
+
+#endif /* __GUI_DIRECT_H__ */
typedef signed long long s64;
typedef unsigned long long u64;
+#if RO_PROGRESS
+#if !defined(WAIT)
+#define WAIT 0
+#endif
+#if !defined(RESDIR)
+#define RESDIR "/usr/share/res"
+#endif
+#define IMG_BASE RESDIR "/images/"
+
+#define MAIN_IMG_NAME "common_base_rect_bg.png"
+#define MAIN_TEXT_NAME "common_ro_bg_text.png"
+#define MAIN_PG_IMG_NAME "common_progress_bar.png"
+#define PROGRESS_BAR_IMG_PREFIX "common_progress_"
+#define PROGRESS_NUM_PREFIX "common_downloading_"
+#define PERCENT_IMG_NAME "common_downloading_percent.png"
+
+#endif
+
+#if RECOVERY_PROGRESS
+
+#if !defined(WAIT)
+#define WAIT 0
+#endif
+#if !defined(RESDIR)
+#define RESDIR "/usr/share/res"
+#endif
+#define IMG_BASE RESDIR "/images/"
+
+#define MAIN_IMG_NAME "common_base_rect_bg.png"
+#define MAIN_TEXT_NAME "common_recovery_bg_text.png"
+#define MAIN_PG_IMG_NAME "common_progress_bar.png"
+#define PROGRESS_BAR_IMG_PREFIX "common_progress_"
+#define PROGRESS_NUM_PREFIX "common_downloading_"
+#define PERCENT_IMG_NAME "common_downloading_percent.png"
+
+#endif
+
+
+#if RW_PROGRESS
+
+#if !defined(WAIT)
+#define WAIT 0
+#endif
+#if !defined(RESDIR)
+#define RESDIR "/usr/share/res"
+#endif
+#define IMG_BASE RESDIR "/images/"
+
+#define MAIN_IMG_NAME "common_base_rect_bg.png"
+#define MAIN_TEXT_NAME "common_rw_bg_text.png"
+#define MAIN_PG_IMG_NAME "common_progress_bar.png"
+#define PROGRESS_BAR_IMG_PREFIX "common_progress_"
+#define PROGRESS_NUM_PREFIX "common_downloading_"
+#define PERCENT_IMG_NAME "common_downloading_percent.png"
+
+#endif
#endif /* __GUI_GENERAL_H__ */
${BASE_DIR}/fota_png.c
${BASE_DIR}/gui_util.c
${BASE_DIR}/tdm-if.c
+ ${BASE_DIR}/base_gui.c
+ ${BASE_DIR}/base_gui_direct.c
+ ${BASE_DIR}/base_main.c
)
SET(GUI_SRCS
${BASE_SRCS}
- fota_gui_ro_common_main.c
- fota_gr_ro_common.c
+# fota_gui_ro_common_main.c
+# fota_gr_ro_common.c
)
MESSAGE(${GUI_SRCS})
ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
ADD_DEFINITIONS("-DROTATE=0")
ADD_DEFINITIONS("-DLOG_PRFIX=\"FOTA_RO\"")
+ADD_DEFINITIONS("-DRO_PROGRESS=1")
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON})
INSTALL(TARGETS ${FOTA_GUI_COMMON} DESTINATION ${BINDIR})
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <pixman.h>
-#include "gui_general.h"
-#include "fota_png.h"
-#include "fbinfo.h"
-#include "tdm-if.h"
-
-#define UNUSED(x) (void)(x)
-
-#define COLOR_BLACK 0xFF000000
-
-#define MAX_PATH 256
-#define MAX_FILE_PATH 512
-
-#if !defined(ROTATE)
-#define ROTATE 0
-#endif
-
-#if !defined(RESDIR)
-#define RESDIR "/usr/share/res"
-#endif
-#define IMG_BASE RESDIR "/images/"
-
-#define MAIN_IMG_NAME "common_base_rect_bg.png"
-#define MAIN_TEXT_NAME "common_ro_bg_text.png"
-#define MAIN_PG_IMG_NAME "common_progress_bar.png"
-#define PROGRESS_BAR_IMG_PREFIX "common_progress_"
-#define PROGRESS_NUM_PREFIX "common_downloading_"
-#define PERCENT_IMG_NAME "common_downloading_percent.png"
-
-/*****************************************************************************
-** global variables
-*****************************************************************************/
-const int x_offset_main_bg_text_pos = 518;
-const int y_offset_main_bg_text_pos = 300;
-const int x_offset_prog_bar_img_pos = 240;
-const int y_offset_prog_bar_img_pos = 355;
-int rotate_step = 0;
-int rollback_step = 0;
-int img_buf_width = 0;
-int img_buf_height = 0;
-
-FbInfo s_fbi;
-tdm_if_disp s_disp;
-
-int s_percent_to_draw = 0;
-int s_saved_percent = -1;
-
-/*-----------------------------------------------------------------------------
- fb_open()
- ----------------------------------------------------------------------------*/
-int fb_open(FbInfo *fbi)
-{
- memset(&s_disp, 0x00, sizeof(struct _tdm_if_disp));
-
- if (tdm_if_display_init(&s_disp)) {
- LOGE("tdm_if_display_init fail!!\n");
- 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;
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fb_close()
- ----------------------------------------------------------------------------*/
-void fb_close(FbInfo *fbi)
-{
- UNUSED(fbi);
- tdm_if_display_deinit(&s_disp);
-}
-
-/*------------------------------------------------------------------------------
- fb_display()
-------------------------------------------------------------------------------*/
-int fb_display(FbInfo *fbi)
-{
- s_disp.current_buf_id = fbi->current_fb_id;
- LOG("current_fb_id : %d\n", fbi->current_fb_id);
- tdm_if_display_update(&s_disp);
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fb_draw_img_forced_update()
- ----------------------------------------------------------------------------*/
-void fb_draw_img_forced_update(FbInfo *fbi)
-{
- int ret = 0;
- ret = fb_display(fbi);
- LOG("current_fb_id : %d, ret : %d\n", fbi->current_fb_id, ret);
-}
-/*-----------------------------------------------------------------------------
- fb_draw_img_check_lcd_on()
- ----------------------------------------------------------------------------*/
-void fb_draw_img_check_lcd_on(FbInfo *fbi)
-{
-
- int ret = 0;
-
- fbi->current_fb_id = FRONT_BUFFER;
-
- LOG("current_fb_id :%d\n", fbi->current_fb_id);
-
- ret = fb_display(fbi);
-
- LOG("%s - drawing... ret : %d\n", __func__, ret);
-}
-
-/*-----------------------------------------------------------------------------
- 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) {
- LOG("fb_buf_cur is null error...\n");
- return;
- }
- while (loop_count--)
- *(fb_buf_cur++) = color;
-
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_fill_rect
- ----------------------------------------------------------------------------*/
-static void _gr_direct_fill_rect(tbm_surface_info_s *surface_info, s32 x, s32 y, s32 w, s32 h, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 wb = 0;
-
- if (NULL == surface_info)
- return;
-
- dx = w;
- dy = h;
- wb = w * sizeof(u32);
-
- fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
- fb_buf_int += y * surface_info->width + x;
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- fb_buf_cur -= w;
- fb_buf_cur += surface_info->width;
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, wb);
- fb_buf_cur += surface_info->width;
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_clear_screen
- ----------------------------------------------------------------------------*/
-static void _gr_direct_clear_screen(FbInfo *fbi, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 w = 0;
-
- if (NULL == fbi)
- return;
-
- dx = fbi->w;
- dy = fbi->h;
- w = fbi->w * sizeof(u32);
-
- fb_buf_int = (unsigned int *)fbi->buf[FRONT_BUFFER];
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
- fb_buf_cur += fbi->w;
- }
-}
-
-static void _gr_direct_clear_screen_init(tbm_surface_info_s *surface_info, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 w = 0;
-
- if (NULL == surface_info)
- return;
-
- dx = surface_info->width;
- dy = surface_info->height;
- w = surface_info->width * sizeof(u32);
-
- fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
- fb_buf_cur += surface_info->width;
- }
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_text
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_text(tbm_surface_info_s *surface_info, int percent)
-{
- char img_name[MAX_PATH];
- int img_x;
- int img_y;
- int num;
-
- img_x = 588;
- img_y = 395;
-
- if (percent < 10)
- img_x += 7;
- else if (percent < 100)
- img_x += 14;
- else if (percent == 100)
- img_x += 21;
-
- if (percent == 100) {
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, 1);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
- }
-
- img_x += 14;
- if (percent >= 10) {
- num = percent / 10;
- if (num == 10)
- num = 0;
-
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
- }
-
- img_x += 14;
- num = percent % 10;
-
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- img_x += 13;
-
- snprintf(img_name, MAX_PATH, "%s%s", IMG_BASE, PERCENT_IMG_NAME);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_prog_text
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_prog_text(tbm_surface_info_s *surface_info, int percent)
-{
- if (percent <= 0)
- percent = 0;
-
- if (percent > 100)
- percent = 100;
-
- _gr_direct_fill_rect(surface_info, 610, 395, 65, 41, COLOR_BLACK);
- _gr_direct_draw_text(surface_info, percent);
-}
-
-static void _gr_direct_draw_main_prog_img(tbm_surface_info_s *surface_info, int percent)
-{
- int img_x = 0;
- int img_y = 0;
-
- if (read_png_file(IMG_BASE MAIN_PG_IMG_NAME) < 0)
- return;
-
- img_x = x_offset_prog_bar_img_pos;
- img_y = y_offset_prog_bar_img_pos;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_main_img
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_main_img(tbm_surface_info_s *surface_info)
-{
- int img_x = 0;
- int img_y = 0;
-
- if (read_png_file(IMG_BASE MAIN_IMG_NAME) < 0)
- return;
-
- img_x = 0;
- img_y = 0;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- if (read_png_file(IMG_BASE MAIN_TEXT_NAME) < 0)
- return;
-
- img_x = x_offset_main_bg_text_pos;
- img_y = y_offset_main_bg_text_pos;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
-}
-
-
-void _copy_buffers_by_rotate(void *srcptr, int srcw, int srch, int srcstride,
- void *dstptr, int dstw, int dsth, int dststride,
- int sx, int sy, int sw, int sh,
- int dx, int dy, int dw, int dh, int rstep)
-{
- pixman_image_t *src_img = NULL, *dst_img = NULL;
- pixman_op_t op;
-
- int buf_width;
-
- buf_width = srcstride/4;
- src_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, srch, (uint32_t*)srcptr, srcstride);
- if(!src_img)
- {
- LOG("No source image.\n");
- return;
- }
-
- buf_width = dststride/4;
- dst_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, dsth, (uint32_t*)dstptr, dststride);
-
- struct pixman_f_transform ft;
- double scale_x, scale_y;
- pixman_transform_t t;
- pixman_f_transform_init_identity(&ft);
-
- if (rstep > 0) {
- int c = 0, s = 0, tx = 0, ty = 0;
- switch (rstep) {
- case 1:
- c = 0, s = -1, tx = -dw;
- break;
- case 2:
- c = -1, s = 0, tx = -dw, ty = -dh;
- break;
- case 3:
- c = 0, s = 1, ty = -dh;
- break;
- }
- pixman_f_transform_translate(&ft, NULL, tx, ty);
- pixman_f_transform_rotate(&ft, NULL, c, s);
- }
-
- if (rstep % 2 == 0) {
- scale_x = (double)sw / dw;
- scale_y = (double)sh / dh;
- } else {
- scale_x = (double)sw / dh;
- scale_y = (double)sh / dw;
- }
- pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
- pixman_f_transform_translate(&ft, NULL, sx, sy);
- pixman_transform_from_pixman_f_transform(&t, &ft);
- pixman_image_set_transform(src_img, &t);
-
-
- op = PIXMAN_OP_SRC;
- pixman_image_composite(op, src_img, NULL, dst_img, 0, 0, 0, 0, dx, dy, dw, dh);
-
- if (src_img)
- pixman_image_unref(src_img);
- if (dst_img)
- pixman_image_unref(dst_img);
-}
-
-/*-----------------------------------------------------------------------------
- __init_screen
- ----------------------------------------------------------------------------*/
-static void __init_screen(FbInfo *fbi)
-{
- /* create tbm_surface for original image */
- tbm_surface_h tbm_surface_ori = NULL;
- tbm_surface_info_s surface_info_ori;
- tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
- if(!tbm_surface_ori){
- LOG("failed to tbm_surface_create\n");
- }
- tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
-
-
- _gr_direct_clear_screen_init(&surface_info_ori, COLOR_BLACK);
-
- _gr_direct_draw_main_img(&surface_info_ori);
-
- _gr_direct_draw_main_prog_img(&surface_info_ori, 0);
-
- _gr_direct_draw_prog_text(&surface_info_ori, 0);
-
-
- _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- fbi->buf[0], fbi->w, fbi->h, fbi->w * RGB32_PITCH,
- 0,0,surface_info_ori.width, surface_info_ori.height,
- 0,0,fbi->w, fbi->h, rotate_step);
- tbm_surface_unmap(tbm_surface_ori);
- tbm_surface_destroy(tbm_surface_ori);
-}
-
-static void _gr_direct_progress_bar(tbm_surface_info_s *surface_info, int progress)
-{
- char img_name[MAX_PATH];
-
- static int prog_pre = 0;
- int count = 0;
- int prog_cnt = 0;
- int img_x = 0;
- int img_y = 0;
-
- if (progress <= 0)
- return;
-
- if (progress > 100)
- progress = 100;
-
- prog_cnt = progress;
-
-
- img_x = x_offset_prog_bar_img_pos;
- img_y = y_offset_prog_bar_img_pos;
-
- for (; prog_pre <= prog_cnt; prog_pre++) {
- LOG("prog_pre/prog_cnt : %d, %d \n", prog_pre , prog_cnt);
-
- // draw current progress image
- snprintf(img_name, MAX_PATH, "%s%s%03d.png", IMG_BASE, PROGRESS_BAR_IMG_PREFIX, prog_pre);
- if (read_png_file(img_name) < 0) {
- LOG("ERROR \n");
- return;
- }
-
- //draw_png_img_xy(fbi, 240, 355);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- s_saved_percent = prog_pre;
-
- if(progress != 100)
- {
- count++;
- if (count > 3)
- break;
- }
- }
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_update_screen
- ----------------------------------------------------------------------------*/
-static void _gr_direct_update_screen()
-{
- s_disp.current_buf_id = s_fbi.current_fb_id;
-
- tdm_if_display_update(&s_disp);
-}
+#include "base_gui_direct.h"
/*-----------------------------------------------------------------------------
fota_gr_direct_update_progress
----------------------------------------------------------------------------*/
-void fota_gr_direct_progress(void)
+int fota_gr_direct_update_progress(int * s_saved_percent, int * s_percent_to_draw)
{
- LOG("fota_gr_direct_progress progress : %d \n", s_percent_to_draw);
-
- if (s_percent_to_draw > 0) {
- /* create tbm_surface for original image */
- tbm_surface_h tbm_surface_ori = NULL;
- tbm_surface_info_s surface_info_ori;
-
- tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
- if(!tbm_surface_ori){
- LOG("failed to tbm_surface_create\n");
- }
- tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
- // need to keep previous image
- _copy_buffers_by_rotate(s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
- surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- 0,0,s_fbi.w, s_fbi.h,
- 0,0,surface_info_ori.width, surface_info_ori.height, rollback_step);
-
- _gr_direct_progress_bar(&surface_info_ori, s_percent_to_draw);
- _gr_direct_draw_prog_text(&surface_info_ori, s_saved_percent);
-
- _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
- 0,0,surface_info_ori.width, surface_info_ori.height,
- 0,0,s_fbi.w, s_fbi.h, rotate_step);
- tbm_surface_unmap(tbm_surface_ori);
- tbm_surface_destroy(tbm_surface_ori);
- } else if (s_percent_to_draw == 0) {
- s_saved_percent = 0;
- }
-
- _gr_direct_update_screen();
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_update_progress
- ----------------------------------------------------------------------------*/
-int fota_gr_direct_ro_update_progress(void)
-{
- int percent = s_percent_to_draw;
+ int percent = *s_percent_to_draw;
FILE *fp;
if (fp) {
if (fscanf(fp, "%d", &percent) == EOF)
LOG("Error occurs at reading ro_progress");
- if (percent == -1 && s_saved_percent > 0) {
+ if (percent == -1 && *s_saved_percent > 0) {
LOG("END ro update\n");
fclose(fp);
return -1;
percent = 0xffffff;
fclose(fp);
} else
- percent = s_percent_to_draw;
- }
-
- if (s_percent_to_draw < percent)
- s_percent_to_draw = percent;
- if (s_saved_percent < s_percent_to_draw) {
- LOG("s_saved_percent %d , s_percent_to_draw %d \n", s_saved_percent, s_percent_to_draw);
- fota_gr_direct_progress();
- }
- return s_saved_percent;
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_clear_screen
- ----------------------------------------------------------------------------*/
-void fota_gr_direct_clear_screen(u32 color)
-{
- _gr_direct_clear_screen(&s_fbi, color);
- _gr_direct_update_screen();
-}
-
-void _get_rotate(void)
-{
- char *rotate_state = getenv("ROTATE_STATE");
- int rotate_angle = -1;
- if(!rotate_state)
- {
- rotate_angle = ROTATE;
- }
- else
- {
- rotate_angle = atoi(rotate_state);
+ percent = *s_percent_to_draw;
}
- if(rotate_angle < -360 || rotate_angle > 360) // for prevent interger overflow
- rotate_angle = 0;
- LOG("Print Rotate Angle value = %d\n", rotate_angle);
-
- rotate_step = (rotate_angle + 360) / 90 % 4;
- if(rotate_step < 0 || rotate_step > 4) // for prevent interger overflow
- rotate_step = 0;
- rollback_step = (4 - rotate_step) % 4;
- LOG("rotate_step = %d, rollback_step = %d\n", rotate_step, rollback_step);
-
- if (rotate_step % 2 == 0) {
- img_buf_width = s_fbi.w;
- img_buf_height = s_fbi.h;
- } else {
- img_buf_width = s_fbi.h;
- img_buf_height = s_fbi.w;
+ if (*s_percent_to_draw < percent)
+ *s_percent_to_draw = percent;
+ if (*s_saved_percent < *s_percent_to_draw) {
+ LOG("s_saved_percent %d , s_percent_to_draw %d \n", *s_saved_percent, *s_percent_to_draw);
+ fota_gr_direct_progress(s_saved_percent, s_percent_to_draw);
}
- LOG("Print Img buffer(=image w,h) width = %d, height = %d\n", img_buf_width, img_buf_height);
+ return *s_saved_percent;
}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_init
- ----------------------------------------------------------------------------*/
-int fota_gr_direct_init(void)
-{
- /* open display interface */
- if (fb_open(&s_fbi) < 0)
- LOG("fb_open failed \n");
-
- _get_rotate();
- __init_screen(&s_fbi);
-
- tdm_if_lcd_on(&s_disp);
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_deinit
- ----------------------------------------------------------------------------*/
-void fota_gr_direct_deinit(void)
-{
- fb_close(&s_fbi);
-}
-
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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_GR_DIRECT_RO_COMMON_H__
-#define __FOTA_GR_DIRECT_RO_COMMON_H__
-
-#include "gui_general.h"
-
-extern int fota_gr_direct_init(void);
-extern void fota_gr_direct_deinit(void);
-extern void fota_gr_direct_clear_screen(u32 color);
-extern int fota_gr_direct_ro_update_progress(void);
-
-#endif /* __FOTA_GR_DIRECT_RO_COMMON_H__ */
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 "fota_gr_ro_common.h"
-#include "fota_gr_direct_ro_common.h"
-
-/*-----------------------------------------------------------------------------
- fota_gr_init
- ----------------------------------------------------------------------------*/
-int fota_gr_init(void)
-{
- return fota_gr_direct_init();
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_deinit
- ----------------------------------------------------------------------------*/
-void fota_gr_deinit(void)
-{
- fota_gr_direct_deinit();
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_clear_screen
- ----------------------------------------------------------------------------*/
-void fota_gr_clear_screen(u32 color)
-{
- fota_gr_direct_clear_screen(color);
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_update_progress
- ----------------------------------------------------------------------------*/
-int fota_gr_update_progress(void)
-{
- int percent = 0;
- percent = fota_gr_direct_ro_update_progress();
- return percent;
-}
-
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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_GR_RO_COMMON_H__
-#define __FOTA_GR_RO_COMMON_H__
-
-extern int fota_gr_init(void);
-extern void fota_gr_deinit(void);
-extern int fota_gr_update_progress(void);
-extern void fota_gr_clear_screen(unsigned int color);
-
-#endif /* __FOTA_GR_RO_COMMON_H__ */
-
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#include "gui_general.h"
-#include "gui_util.h"
-#include "fota_gr_ro_common.h"
-
-//#define WAIT
-//#undef WAIT
-
-unsigned int __log_level__ =
- (LOG_DEBUG | LOG_FLASH | LOG_FILE | LOG_FUNCS | LOG_GUI | LOG_SSENGINE | LOG_INFO);
-FILE *__log_out_file__;
-
-int s_prog_percent = 0;
-int s_last_prog_percent = 0;
-
-int s_pid = -1;
-
-static int wait_main_fota_ro(void)
-{
- int delay = 20000;
-
- if (setpriority(PRIO_PROCESS, getpid(), -11) < 0)
- LOG("failed to setpriority\n");
-
- if (fota_gr_init() < 0) {
- LOG("fota_gr_init() failed.\n");
- _exit_stdio();
- return -1;
- }
-
- while (1) {
- usleep(delay);
- s_prog_percent = fota_gr_update_progress();
- if (s_prog_percent == -1) break;
- sleep(1);
- }
-
- fota_gr_deinit();
-
- return 0;
-}
-
-int main(int argc, char **argv)
-{
-#ifdef WAIT
- 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}
- };
-
- opt = getopt_long(argc, argv, "", options, &index);
- if (opt == -1) {
- LOGE("getopt_long failed\n");
- return 0;
- }
-
- switch (index) {
- case 0: {
- int ret = wait_main_fota_ro();
- return ret;
- }
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
- default:
- break;
- }
-#else
- int ret = 0;
- ret = wait_main_fota_ro();
-#endif
- _exit_stdio();
- return 0;
-}
${BASE_DIR}/gui_util.c
${BASE_DIR}/tdm-if.c
${BASE_DIR}/fota_png.c
+ ${BASE_DIR}/base_gui.c
+ ${BASE_DIR}/base_gui_direct.c
+ ${BASE_DIR}/base_main.c
)
SET(GUI_SRCS
${BASE_SRCS}
- recovery_gui_common_main.c
- recovery_gr_common.c
)
FOREACH(flag ${gui_pkgs_CFLAGS})
ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
ADD_DEFINITIONS("-DROTATE=0")
+ADD_DEFINITIONS("-DRECOVERY_PROGRESS=1")
#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON})
INSTALL(TARGETS ${RECOVERY_GUI_COMMON} DESTINATION ${BINDIR})
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 "recovery_gr_common.h"
-#include "recovery_gr_direct_common.h"
-
-/*-----------------------------------------------------------------------------
- recovery_gr_init
- ----------------------------------------------------------------------------*/
-int recovery_gr_init(void)
-{
- return recovery_gr_direct_init();
-}
-
-/*-----------------------------------------------------------------------------
- recovery_gr_deinit
- ----------------------------------------------------------------------------*/
-void recovery_gr_deinit(void)
-{
- recovery_gr_direct_deinit();
-}
-
-/*-----------------------------------------------------------------------------
- recovery_gr_clear_screen
- ----------------------------------------------------------------------------*/
-void recovery_gr_clear_screen(u32 color)
-{
- recovery_gr_direct_clear_screen(color);
-}
-
-/*-----------------------------------------------------------------------------
- recovery_gr_update_progress
- ----------------------------------------------------------------------------*/
-int recovery_gr_update_progress(void)
-{
- int percent = 0;
- percent = recovery_gr_direct_update_progress();
- return percent;
-}
-
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 __RECOVERY_GR_COMMON_H__
-#define __RECOVERY_GR_COMMON_H__
-
-extern int recovery_gr_init(void);
-extern void recovery_gr_deinit(void);
-extern int recovery_gr_update_progress(void);
-extern void recovery_gr_clear_screen(unsigned int color);
-
-#endif /* __RECOVERY_GR_COMMON_H__ */
-
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <pixman.h>
-#include "gui_general.h"
-#include "fota_png.h"
-#include "fbinfo.h"
-#include "tdm-if.h"
-
-#define UNUSED(x) (void)(x)
-
-#define COLOR_BLACK 0xFF000000
-
-#define MAX_PATH 256
-#define MAX_FILE_PATH 512
-
-#if !defined(ROTATE)
-#define ROTATE 0
-#endif
-
-#if !defined(RESDIR)
-#define RESDIR "/usr/share/res"
-#endif
-#define IMG_BASE RESDIR "/images/"
-
-#define MAIN_IMG_NAME "common_base_rect_bg.png"
-#define MAIN_TEXT_NAME "common_recovery_bg_text.png"
-#define MAIN_PG_IMG_NAME "common_progress_bar.png"
-#define PROGRESS_BAR_IMG_PREFIX "common_progress_"
-#define PROGRESS_NUM_PREFIX "common_downloading_"
-#define PERCENT_IMG_NAME "common_downloading_percent.png"
-
-/*****************************************************************************
-** global variables
-*****************************************************************************/
-const int x_offset_main_bg_text_pos = 518;
-const int y_offset_main_bg_text_pos = 300;
-const int x_offset_prog_bar_img_pos = 240;
-const int y_offset_prog_bar_img_pos = 355;
-int rotate_step = 0;
-int rollback_step = 0;
-int img_buf_width = 0;
-int img_buf_height = 0;
-
-FbInfo s_fbi;
-tdm_if_disp s_disp;
-
-int s_percent_to_draw = 0;
-int s_saved_percent = -1;
-
-/*-----------------------------------------------------------------------------
- fb_open()
- ----------------------------------------------------------------------------*/
-int fb_open(FbInfo *fbi)
-{
- memset(&s_disp, 0x00, sizeof(struct _tdm_if_disp));
-
- if (tdm_if_display_init(&s_disp)) {
- LOGE("tdm_if_display_init fail!!\n");
- 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;
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fb_close()
- ----------------------------------------------------------------------------*/
-void fb_close(FbInfo *fbi)
-{
- UNUSED(fbi);
- tdm_if_display_deinit(&s_disp);
-}
-
-/*------------------------------------------------------------------------------
- fb_display()
-------------------------------------------------------------------------------*/
-int fb_display(FbInfo *fbi)
-{
- s_disp.current_buf_id = fbi->current_fb_id;
- LOG("current_fb_id : %d\n", fbi->current_fb_id);
- tdm_if_display_update(&s_disp);
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fb_draw_img_forced_update()
- ----------------------------------------------------------------------------*/
-void fb_draw_img_forced_update(FbInfo *fbi)
-{
- int ret = 0;
- ret = fb_display(fbi);
- LOG("current_fb_id : %d, ret : %d\n", fbi->current_fb_id, ret);
-}
-/*-----------------------------------------------------------------------------
- fb_draw_img_check_lcd_on()
- ----------------------------------------------------------------------------*/
-void fb_draw_img_check_lcd_on(FbInfo *fbi)
-{
-
- int ret = 0;
-
- fbi->current_fb_id = FRONT_BUFFER;
-
- LOG("current_fb_id :%d\n", fbi->current_fb_id);
-
- ret = fb_display(fbi);
-
- LOG("%s - drawing... ret : %d\n", __func__, ret);
-}
-
-/*-----------------------------------------------------------------------------
- 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) {
- LOG("fb_buf_cur is null error...\n");
- return;
- }
- while (loop_count--)
- *(fb_buf_cur++) = color;
-
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_fill_rect
- ----------------------------------------------------------------------------*/
-static void _gr_direct_fill_rect(tbm_surface_info_s *surface_info, s32 x, s32 y, s32 w, s32 h, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 wb = 0;
-
- if (NULL == surface_info)
- return;
-
- dx = w;
- dy = h;
- wb = w * sizeof(u32);
-
- fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
- fb_buf_int += y * surface_info->width + x;
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- fb_buf_cur -= w;
- fb_buf_cur += surface_info->width;
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, wb);
- fb_buf_cur += surface_info->width;
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_clear_screen
- ----------------------------------------------------------------------------*/
-static void _gr_direct_clear_screen(FbInfo *fbi, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 w = 0;
-
- if (NULL == fbi)
- return;
-
- dx = fbi->w;
- dy = fbi->h;
- w = fbi->w * sizeof(u32);
-
- fb_buf_int = (unsigned int *)fbi->buf[FRONT_BUFFER];
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
- fb_buf_cur += fbi->w;
- }
-}
-
-static void _gr_direct_clear_screen_init(tbm_surface_info_s *surface_info, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 w = 0;
-
- if (NULL == surface_info)
- return;
-
- dx = surface_info->width;
- dy = surface_info->height;
- w = surface_info->width * sizeof(u32);
-
- fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
- fb_buf_cur += surface_info->width;
- }
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_text
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_text(tbm_surface_info_s *surface_info, int percent)
-{
- char img_name[MAX_PATH];
- int img_x;
- int img_y;
- int num;
-
- img_x = 588;
- img_y = 395;
-
- if (percent < 10)
- img_x += 7;
- else if (percent < 100)
- img_x += 14;
- else if (percent == 100)
- img_x += 21;
-
- if (percent == 100) {
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, 1);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
- }
-
- img_x += 14;
- if (percent >= 10) {
- num = percent / 10;
- if (num == 10)
- num = 0;
-
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
- }
-
- img_x += 14;
- num = percent % 10;
-
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- img_x += 13;
-
- snprintf(img_name, MAX_PATH, "%s%s", IMG_BASE, PERCENT_IMG_NAME);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_prog_text
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_prog_text(tbm_surface_info_s *surface_info, int percent)
-{
- if (percent <= 0)
- percent = 0;
-
- if (percent > 100)
- percent = 100;
-
- _gr_direct_fill_rect(surface_info, 610, 395, 65, 41, COLOR_BLACK);
- _gr_direct_draw_text(surface_info, percent);
-}
-
-static void _gr_direct_draw_main_prog_img(tbm_surface_info_s *surface_info, int percent)
-{
- int img_x = 0;
- int img_y = 0;
-
- if (read_png_file(IMG_BASE MAIN_PG_IMG_NAME) < 0)
- return;
-
- img_x = x_offset_prog_bar_img_pos;
- img_y = y_offset_prog_bar_img_pos;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_main_img
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_main_img(tbm_surface_info_s *surface_info)
-{
- int img_x = 0;
- int img_y = 0;
-
- if (read_png_file(IMG_BASE MAIN_IMG_NAME) < 0)
- return;
-
- img_x = 0;
- img_y = 0;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- if (read_png_file(IMG_BASE MAIN_TEXT_NAME) < 0)
- return;
-
- img_x = x_offset_main_bg_text_pos;
- img_y = y_offset_main_bg_text_pos;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
-}
-
-void _copy_buffers_by_rotate(void *srcptr, int srcw, int srch, int srcstride,
- void *dstptr, int dstw, int dsth, int dststride,
- int sx, int sy, int sw, int sh,
- int dx, int dy, int dw, int dh, int rstep)
-{
- pixman_image_t *src_img = NULL, *dst_img = NULL;
- pixman_op_t op;
-
- int buf_width;
-
- buf_width = srcstride/4;
- src_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, srch, (uint32_t*)srcptr, srcstride);
- if(!src_img)
- {
- LOG("No source image.\n");
- return;
- }
-
- buf_width = dststride/4;
- dst_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, dsth, (uint32_t*)dstptr, dststride);
-
- struct pixman_f_transform ft;
- double scale_x, scale_y;
- pixman_transform_t t;
- pixman_f_transform_init_identity(&ft);
-
- if (rstep > 0) {
- int c = 0, s = 0, tx = 0, ty = 0;
- switch (rstep) {
- case 1:
- c = 0, s = -1, tx = -dw;
- break;
- case 2:
- c = -1, s = 0, tx = -dw, ty = -dh;
- break;
- case 3:
- c = 0, s = 1, ty = -dh;
- break;
- }
- pixman_f_transform_translate(&ft, NULL, tx, ty);
- pixman_f_transform_rotate(&ft, NULL, c, s);
- }
-
- if (rstep % 2 == 0) {
- scale_x = (double)sw / dw;
- scale_y = (double)sh / dh;
- } else {
- scale_x = (double)sw / dh;
- scale_y = (double)sh / dw;
- }
- pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
- pixman_f_transform_translate(&ft, NULL, sx, sy);
- pixman_transform_from_pixman_f_transform(&t, &ft);
- pixman_image_set_transform(src_img, &t);
-
-
- op = PIXMAN_OP_SRC;
- pixman_image_composite(op, src_img, NULL, dst_img, 0, 0, 0, 0, dx, dy, dw, dh);
-
- if (src_img)
- pixman_image_unref(src_img);
- if (dst_img)
- pixman_image_unref(dst_img);
-}
-
-/*-----------------------------------------------------------------------------
- __init_screen
- ----------------------------------------------------------------------------*/
-static void __init_screen(FbInfo *fbi)
-{
- /* create tbm_surface for original image */
- tbm_surface_h tbm_surface_ori = NULL;
- tbm_surface_info_s surface_info_ori;
- tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
- if(!tbm_surface_ori){
- LOG("failed to tbm_surface_create\n");
- }
- tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
-
-
- _gr_direct_clear_screen_init(&surface_info_ori, COLOR_BLACK);
-
- _gr_direct_draw_main_img(&surface_info_ori);
-
- _gr_direct_draw_main_prog_img(&surface_info_ori, 0);
-
- _gr_direct_draw_prog_text(&surface_info_ori, 0);
-
-
- _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- fbi->buf[0], fbi->w, fbi->h, fbi->w * RGB32_PITCH,
- 0,0,surface_info_ori.width, surface_info_ori.height,
- 0,0,fbi->w, fbi->h, rotate_step);
- tbm_surface_unmap(tbm_surface_ori);
- tbm_surface_destroy(tbm_surface_ori);
-}
-
-static void _gr_direct_progress_bar(tbm_surface_info_s *surface_info, int progress)
-{
- char img_name[MAX_PATH];
-
- static int prog_pre = 0;
- int count = 0;
- int prog_cnt = 0;
- int img_x = 0;
- int img_y = 0;
-
- if (progress <= 0)
- return;
-
- if (progress > 100)
- progress = 100;
-
- prog_cnt = progress;
-
-
- img_x = x_offset_prog_bar_img_pos;
- img_y = y_offset_prog_bar_img_pos;
-
- for (; prog_pre <= prog_cnt; prog_pre++) {
- LOG("prog_pre/prog_cnt : %d, %d \n", prog_pre , prog_cnt);
-
- // draw current progress image
- snprintf(img_name, MAX_PATH, "%s%s%03d.png", IMG_BASE, PROGRESS_BAR_IMG_PREFIX, prog_pre);
- if (read_png_file(img_name) < 0) {
- LOG("ERROR \n");
- return;
- }
-
- //draw_png_img_xy(fbi, 240, 355);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- s_saved_percent = prog_pre;
-
- if(progress != 100)
- {
- count++;
- if (count > 3)
- break;
- }
- }
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_update_screen
- ----------------------------------------------------------------------------*/
-static void _gr_direct_update_screen()
-{
- s_disp.current_buf_id = s_fbi.current_fb_id;
-
- tdm_if_display_update(&s_disp);
-}
-
-/*-----------------------------------------------------------------------------
- recovery_gr_direct_update_progress
- ----------------------------------------------------------------------------*/
-void recovery_gr_direct_progress(void)
-{
- LOG("recovery_gr_direct_progress progress : %d \n", s_percent_to_draw);
-
- if (s_percent_to_draw > 0) {
- /* create tbm_surface for original image */
- tbm_surface_h tbm_surface_ori = NULL;
- tbm_surface_info_s surface_info_ori;
-
- tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
- if(!tbm_surface_ori){
- LOG("failed to tbm_surface_create\n");
- }
- tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
- // need to keep previous image
- _copy_buffers_by_rotate(s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
- surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- 0,0,s_fbi.w, s_fbi.h,
- 0,0,surface_info_ori.width, surface_info_ori.height, rollback_step);
-
- _gr_direct_progress_bar(&surface_info_ori, s_percent_to_draw);
- _gr_direct_draw_prog_text(&surface_info_ori, s_saved_percent);
-
- _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
- 0,0,surface_info_ori.width, surface_info_ori.height,
- 0,0,s_fbi.w, s_fbi.h, rotate_step);
- tbm_surface_unmap(tbm_surface_ori);
- tbm_surface_destroy(tbm_surface_ori);
- } else if (s_percent_to_draw == 0) {
- s_saved_percent = 0;
- }
-
- _gr_direct_update_screen();
-}
+#include "base_gui_direct.h"
/*-----------------------------------------------------------------------------
recovery_gr_direct_update_progress
----------------------------------------------------------------------------*/
-int recovery_gr_direct_update_progress(void)
+int fota_gr_direct_update_progress(int * s_saved_percent, int * s_percent_to_draw)
{
- int percent = s_percent_to_draw;
+ int percent = *s_percent_to_draw;
FILE *fp;
percent = 0xffffff;
fclose(fp);
} else
- percent = s_percent_to_draw;
+ percent = *s_percent_to_draw;
}
- s_percent_to_draw = percent;
- if (s_saved_percent < s_percent_to_draw) {
- LOG("s_saved_percent %d , s_percent_to_draw %d \n", s_saved_percent, s_percent_to_draw);
- recovery_gr_direct_progress();
+ *s_percent_to_draw = percent;
+ if (*s_saved_percent < *s_percent_to_draw) {
+ LOG("s_saved_percent %d , s_percent_to_draw %d \n", *s_saved_percent, *s_percent_to_draw);
+ fota_gr_direct_progress(s_saved_percent, s_percent_to_draw);
}
- return s_saved_percent;
-}
-
-/*-----------------------------------------------------------------------------
- recovery_gr_direct_clear_screen
- ----------------------------------------------------------------------------*/
-void recovery_gr_direct_clear_screen(u32 color)
-{
- _gr_direct_clear_screen(&s_fbi, color);
- _gr_direct_update_screen();
-}
-
-void _get_rotate(void)
-{
- char *rotate_state = getenv("ROTATE_STATE");
- int rotate_angle = -1;
- if(!rotate_state)
- {
- rotate_angle = ROTATE;
- }
- else
- {
- rotate_angle = atoi(rotate_state);
- }
-
- if(rotate_angle < -360 || rotate_angle > 360) // for prevent interger overflow
- rotate_angle = 0;
- LOG("Print Rotate Angle value = %d\n", rotate_angle);
-
- rotate_step = (rotate_angle + 360) / 90 % 4;
- if(rotate_step < 0 || rotate_step > 4) // for prevent interger overflow
- rotate_step = 0;
- rollback_step = (4 - rotate_step) % 4;
- LOG("rotate_step = %d, rollback_step = %d\n", rotate_step, rollback_step);
-
- if (rotate_step % 2 == 0) {
- img_buf_width = s_fbi.w;
- img_buf_height = s_fbi.h;
- } else {
- img_buf_width = s_fbi.h;
- img_buf_height = s_fbi.w;
- }
- LOG("Print Img buffer(=image w,h) width = %d, height = %d\n", img_buf_width, img_buf_height);
-}
-
-/*-----------------------------------------------------------------------------
- recovery_gr_direct_init
- ----------------------------------------------------------------------------*/
-int recovery_gr_direct_init(void)
-{
- /* open display interface */
- if (fb_open(&s_fbi) < 0)
- LOG("fb_open failed \n");
-
- _get_rotate();
- __init_screen(&s_fbi);
-
- tdm_if_lcd_on(&s_disp);
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- recovery_gr_direct_deinit
- ----------------------------------------------------------------------------*/
-void recovery_gr_direct_deinit(void)
-{
- fb_close(&s_fbi);
-}
-
+ return *s_saved_percent;
+}
\ No newline at end of file
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 __RECOVERY_GR_DIRECT_COMMON_H__
-#define __RECOVERY_GR_DIRECT_COMMON_H__
-
-#include "gui_general.h"
-
-extern int recovery_gr_direct_init(void);
-extern void recovery_gr_direct_deinit(void);
-extern void recovery_gr_direct_clear_screen(u32 color);
-extern int recovery_gr_direct_update_progress(void);
-
-#endif /* __RECOVERY_GR_DIRECT_COMMON_H__ */
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#include "gui_general.h"
-#include "gui_util.h"
-#include "recovery_gr_common.h"
-
-//#define WAIT
-//#undef WAIT
-
-unsigned int __log_level__ =
- (LOG_DEBUG | LOG_FLASH | LOG_FILE | LOG_FUNCS | LOG_GUI | LOG_SSENGINE | LOG_INFO);
-FILE *__log_out_file__;
-
-int s_prog_percent = 0;
-int s_last_prog_percent = 0;
-
-int s_pid = -1;
-
-static int wait_main_system_recovery(void)
-{
- int delay = 20000;
-
- char *xdg_env = getenv("XDG_RUNTIME_DIR");
- if(!xdg_env)
- {
- setenv("XDG_RUNTIME_DIR","/run",1);
- char *c = getenv("XDG_RUNTIME_DIR");
- LOG("check env XDG_RUNTIME_DIR = %s\n", c);
- }
-
- char *tbm_env = getenv("TBM_DISPLAY_SERVER");
- if(!tbm_env)
- {
- setenv("TBM_DISPLAY_SERVER","1",1);
- char *c = getenv("TBM_DISPLAY_SERVER");
- LOG("check env XBM_DISPLAY_SERVER = %s\n", c);
- }
-
- if (setpriority(PRIO_PROCESS, getpid(), -11) < 0)
- LOG("failed to setpriority\n");
-
- if (recovery_gr_init() < 0) {
- LOG("recovery_gr_init() failed.\n");
- _exit_stdio();
- return -1;
- }
-
- while (s_prog_percent < 100) {
- usleep(delay);
- s_prog_percent = recovery_gr_update_progress();
- sleep(1);
- }
- LOG("MAIN :: 100 percent out = %d\n", s_prog_percent);
-
- recovery_gr_deinit();
-
- return 0;
-}
-
-int main(int argc, char **argv)
-{
-#ifdef WAIT
- 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}
- };
-
- opt = getopt_long(argc, argv, "", options, &index);
- if (opt == -1) {
- LOGE("getopt_long failed\n");
- return 0;
- }
-
- switch (index) {
- case 0: {
- int ret = wait_main_system_recovery();
- return ret;
- }
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
- default:
- break;
- }
-#else
- int ret = 0;
- ret = wait_main_system_recovery();
-#endif
- _exit_stdio();
- return 0;
-}
${BASE_DIR}/fota_png.c
${BASE_DIR}/gui_util.c
${BASE_DIR}/tdm-if.c
+ ${BASE_DIR}/base_gui.c
+ ${BASE_DIR}/base_gui_direct.c
+ ${BASE_DIR}/base_main.c
)
SET(GUI_SRCS
${BASE_SRCS}
- fota_gui_rw_common_main.c
- fota_gr_rw_common.c
fota_gr_direct_rw_common.c
)
ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
ADD_DEFINITIONS("-DROTATE=0")
ADD_DEFINITIONS("-DLOG_PRFIX=\"FOTA_RW\"")
+ADD_DEFINITIONS("-DRW_PROGRESS=1")
+ADD_DEFINITIONS("-DWAIT=1")
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
#INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/images DESTINATION ${RESDIR_COMMON})
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <pixman.h>
-#include "gui_general.h"
-#include "fota_png.h"
-#include "fbinfo.h"
-#include "tdm-if.h"
-
-#define UNUSED(x) (void)(x)
-
-#define COLOR_BLACK 0xFF000000
-
-#define MAX_PATH 256
-#define MAX_FILE_PATH 512
-
-#if !defined(ROTATE)
-#define ROTATE 0
-#endif
-
-#if !defined(RESDIR)
-#define RESDIR "/usr/share/res"
-#endif
-#define IMG_BASE RESDIR "/images/"
-
-#define MAIN_IMG_NAME "common_base_rect_bg.png"
-#define MAIN_TEXT_NAME "common_rw_bg_text.png"
-#define MAIN_PG_IMG_NAME "common_progress_bar.png"
-#define PROGRESS_BAR_IMG_PREFIX "common_progress_"
-#define PROGRESS_NUM_PREFIX "common_downloading_"
-#define PERCENT_IMG_NAME "common_downloading_percent.png"
-
-/*****************************************************************************
-** global variables
-*****************************************************************************/
-const int x_offset_main_bg_text_pos = 518;
-const int y_offset_main_bg_text_pos = 300;
-const int x_offset_prog_bar_img_pos = 240;
-const int y_offset_prog_bar_img_pos = 355;
-int rotate_step = 0;
-int rollback_step = 0;
-int img_buf_width = 0;
-int img_buf_height = 0;
-
-FbInfo s_fbi;
-tdm_if_disp s_disp;
-
-int s_percent_to_draw = 0;
-int s_saved_percent = -1;
-
-/*-----------------------------------------------------------------------------
- fb_open()
- ----------------------------------------------------------------------------*/
-int fb_open(FbInfo *fbi)
-{
- memset(&s_disp, 0x00, sizeof(struct _tdm_if_disp));
-
- if (tdm_if_display_init(&s_disp)) {
- LOGE("tdm_if_display_init fail!!\n");
- 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;
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fb_close()
- ----------------------------------------------------------------------------*/
-void fb_close(FbInfo *fbi)
-{
- UNUSED(fbi);
- tdm_if_display_deinit(&s_disp);
-}
-
-/*------------------------------------------------------------------------------
- fb_display()
-------------------------------------------------------------------------------*/
-int fb_display(FbInfo *fbi)
-{
- s_disp.current_buf_id = fbi->current_fb_id;
- LOG("current_fb_id : %d\n", fbi->current_fb_id);
- tdm_if_display_update(&s_disp);
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fb_draw_img_forced_update()
- ----------------------------------------------------------------------------*/
-void fb_draw_img_forced_update(FbInfo *fbi)
-{
- int ret = 0;
- ret = fb_display(fbi);
- LOG("current_fb_id : %d, ret : %d\n", fbi->current_fb_id, ret);
-}
-/*-----------------------------------------------------------------------------
- fb_draw_img_check_lcd_on()
- ----------------------------------------------------------------------------*/
-void fb_draw_img_check_lcd_on(FbInfo *fbi)
-{
-
- int ret = 0;
-
- fbi->current_fb_id = FRONT_BUFFER;
-
- LOG("current_fb_id :%d\n", fbi->current_fb_id);
-
- ret = fb_display(fbi);
-
- LOG("%s - drawing... ret : %d\n", __func__, ret);
-}
-
-/*-----------------------------------------------------------------------------
- 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) {
- LOG("fb_buf_cur is null error...\n");
- return;
- }
- while (loop_count--)
- *(fb_buf_cur++) = color;
-
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_fill_rect
- ----------------------------------------------------------------------------*/
-static void _gr_direct_fill_rect(tbm_surface_info_s *surface_info, s32 x, s32 y, s32 w, s32 h, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 wb = 0;
-
- if (NULL == surface_info)
- return;
-
- dx = w;
- dy = h;
- wb = w * sizeof(u32);
-
- fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
- fb_buf_int += y * surface_info->width + x;
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- fb_buf_cur -= w;
- fb_buf_cur += surface_info->width;
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, wb);
- fb_buf_cur += surface_info->width;
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_clear_screen
- ----------------------------------------------------------------------------*/
-static void _gr_direct_clear_screen(FbInfo *fbi, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 w = 0;
-
- if (NULL == fbi)
- return;
-
- dx = fbi->w;
- dy = fbi->h;
- w = fbi->w * sizeof(u32);
-
- fb_buf_int = (unsigned int *)fbi->buf[FRONT_BUFFER];
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
- fb_buf_cur += fbi->w;
- }
-}
-
-static void _gr_direct_clear_screen_init(tbm_surface_info_s *surface_info, u32 color)
-{
- unsigned int *fb_buf_int = NULL;
- unsigned int *fb_buf_cur = NULL;
- s32 dx = 0;
- s32 dy = 0;
- s32 w = 0;
-
- if (NULL == surface_info)
- return;
-
- dx = surface_info->width;
- dy = surface_info->height;
- w = surface_info->width * sizeof(u32);
-
- fb_buf_int = (unsigned int *)surface_info->planes[0].ptr;
- fb_buf_cur = fb_buf_int;
-
- while (dx--)
- *fb_buf_cur++ = color;
-
- dy--;
- while (dy--) {
- memcpy((void*)fb_buf_cur, (void*)fb_buf_int, w);
- fb_buf_cur += surface_info->width;
- }
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_text
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_text(tbm_surface_info_s *surface_info, int percent)
-{
- char img_name[MAX_PATH];
- int img_x;
- int img_y;
- int num;
-
- img_x = 588;
- img_y = 395;
-
- if (percent < 10)
- img_x += 7;
- else if (percent < 100)
- img_x += 14;
- else if (percent == 100)
- img_x += 21;
-
- if (percent == 100) {
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, 1);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
- }
-
- img_x += 14;
- if (percent >= 10) {
- num = percent / 10;
- if (num == 10)
- num = 0;
-
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
- }
-
- img_x += 14;
- num = percent % 10;
-
- snprintf(img_name, MAX_PATH, "%s%s%d.png", IMG_BASE, PROGRESS_NUM_PREFIX, num);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- img_x += 13;
-
- snprintf(img_name, MAX_PATH, "%s%s", IMG_BASE, PERCENT_IMG_NAME);
- if (read_png_file(img_name) < 0)
- return;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_prog_text
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_prog_text(tbm_surface_info_s *surface_info, int percent)
-{
- if (percent <= 0)
- percent = 0;
-
- if (percent > 100)
- percent = 100;
-
- _gr_direct_fill_rect(surface_info, 610, 395, 65, 41, COLOR_BLACK);
- _gr_direct_draw_text(surface_info, percent);
-}
-
-static void _gr_direct_draw_main_prog_img(tbm_surface_info_s *surface_info, int percent)
-{
- int img_x = 0;
- int img_y = 0;
-
- if (read_png_file(IMG_BASE MAIN_PG_IMG_NAME) < 0)
- return;
-
- img_x = x_offset_prog_bar_img_pos;
- img_y = y_offset_prog_bar_img_pos;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_draw_main_img
- ----------------------------------------------------------------------------*/
-static void _gr_direct_draw_main_img(tbm_surface_info_s *surface_info)
-{
- int img_x = 0;
- int img_y = 0;
-
- if (read_png_file(IMG_BASE MAIN_IMG_NAME) < 0)
- return;
-
- img_x = 0;
- img_y = 0;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- if (read_png_file(IMG_BASE MAIN_TEXT_NAME) < 0)
- return;
-
- img_x = x_offset_main_bg_text_pos;
- img_y = y_offset_main_bg_text_pos;
-
- //draw_png_img_xy(fbi, img_x, img_y);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
-}
-
-
-void _copy_buffers_by_rotate(void *srcptr, int srcw, int srch, int srcstride,
- void *dstptr, int dstw, int dsth, int dststride,
- int sx, int sy, int sw, int sh,
- int dx, int dy, int dw, int dh, int rstep)
-{
- pixman_image_t *src_img = NULL, *dst_img = NULL;
- pixman_op_t op;
-
- int buf_width;
-
- buf_width = srcstride/4;
- src_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, srch, (uint32_t*)srcptr, srcstride);
- if(!src_img)
- {
- LOG("No source image.\n");
- return;
- }
-
- buf_width = dststride/4;
- dst_img = pixman_image_create_bits(PIXMAN_a8r8g8b8, buf_width, dsth, (uint32_t*)dstptr, dststride);
-
- struct pixman_f_transform ft;
- double scale_x, scale_y;
- pixman_transform_t t;
- pixman_f_transform_init_identity(&ft);
-
- if (rstep > 0) {
- int c = 0, s = 0, tx = 0, ty = 0;
- switch (rstep) {
- case 1:
- c = 0, s = -1, tx = -dw;
- break;
- case 2:
- c = -1, s = 0, tx = -dw, ty = -dh;
- break;
- case 3:
- c = 0, s = 1, ty = -dh;
- break;
- }
- pixman_f_transform_translate(&ft, NULL, tx, ty);
- pixman_f_transform_rotate(&ft, NULL, c, s);
- }
-
- if (rstep % 2 == 0) {
- scale_x = (double)sw / dw;
- scale_y = (double)sh / dh;
- } else {
- scale_x = (double)sw / dh;
- scale_y = (double)sh / dw;
- }
- pixman_f_transform_scale(&ft, NULL, scale_x, scale_y);
- pixman_f_transform_translate(&ft, NULL, sx, sy);
- pixman_transform_from_pixman_f_transform(&t, &ft);
- pixman_image_set_transform(src_img, &t);
-
-
- op = PIXMAN_OP_SRC;
- pixman_image_composite(op, src_img, NULL, dst_img, 0, 0, 0, 0, dx, dy, dw, dh);
-
- if (src_img)
- pixman_image_unref(src_img);
- if (dst_img)
- pixman_image_unref(dst_img);
-}
-
-/*-----------------------------------------------------------------------------
- __init_screen
- ----------------------------------------------------------------------------*/
-static void __init_screen(FbInfo *fbi)
-{
- /* create tbm_surface for original image */
- tbm_surface_h tbm_surface_ori = NULL;
- tbm_surface_info_s surface_info_ori;
- tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
- if(!tbm_surface_ori){
- LOG("failed to tbm_surface_create\n");
- }
- tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
-
-
- _gr_direct_clear_screen_init(&surface_info_ori, COLOR_BLACK);
-
- _gr_direct_draw_main_img(&surface_info_ori);
-
- _gr_direct_draw_main_prog_img(&surface_info_ori, 0);
-
- _gr_direct_draw_prog_text(&surface_info_ori, 0);
-
-
- _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- fbi->buf[0], fbi->w, fbi->h, fbi->w * RGB32_PITCH,
- 0,0,surface_info_ori.width, surface_info_ori.height,
- 0,0,fbi->w, fbi->h, rotate_step);
- tbm_surface_unmap(tbm_surface_ori);
- tbm_surface_destroy(tbm_surface_ori);
-}
-
-static void _gr_direct_progress_bar(tbm_surface_info_s *surface_info, int progress)
-{
- char img_name[MAX_PATH];
-
- static int prog_pre = 0;
- int count = 0;
- int prog_cnt = 0;
- int img_x = 0;
- int img_y = 0;
-
- if (progress <= 0)
- return;
-
- if (progress > 100)
- progress = 100;
-
- prog_cnt = progress;
-
-
- img_x = x_offset_prog_bar_img_pos;
- img_y = y_offset_prog_bar_img_pos;
-
- for (; prog_pre <= prog_cnt; prog_pre++) {
- LOG("prog_pre/prog_cnt : %d, %d \n", prog_pre , prog_cnt);
-
- // draw current progress image
- snprintf(img_name, MAX_PATH, "%s%s%03d.png", IMG_BASE, PROGRESS_BAR_IMG_PREFIX, prog_pre);
- if (read_png_file(img_name) < 0) {
- LOG("ERROR \n");
- return;
- }
-
- //draw_png_img_xy(fbi, 240, 355);
- draw_png_img_original(surface_info->planes[0].ptr, img_x, img_y, surface_info->width, surface_info->height, surface_info->planes[0].stride);
- release_png_res();
-
- s_saved_percent = prog_pre;
-
- if(progress != 100)
- {
- count++;
- if (count > 3)
- break;
- }
- }
-}
-
-/*-----------------------------------------------------------------------------
- _gr_direct_update_screen
- ----------------------------------------------------------------------------*/
-static void _gr_direct_update_screen()
-{
- s_disp.current_buf_id = s_fbi.current_fb_id;
-
- tdm_if_display_update(&s_disp);
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_update_progress
- ----------------------------------------------------------------------------*/
-void fota_gr_direct_progress(void)
-{
- LOG("fota_gr_direct_progress progress : %d \n", s_percent_to_draw);
-
- if (s_percent_to_draw > 0) {
- /* create tbm_surface for original image */
- tbm_surface_h tbm_surface_ori = NULL;
- tbm_surface_info_s surface_info_ori;
-
- tbm_surface_ori = tbm_surface_create(img_buf_width, img_buf_height, TBM_FORMAT_ARGB8888); // rotated width, height
- if(!tbm_surface_ori){
- LOG("failed to tbm_surface_create\n");
- }
- tbm_surface_map(tbm_surface_ori, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &surface_info_ori);
- // need to keep previous image
- _copy_buffers_by_rotate(s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
- surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- 0,0,s_fbi.w, s_fbi.h,
- 0,0,surface_info_ori.width, surface_info_ori.height, rollback_step);
-
- _gr_direct_progress_bar(&surface_info_ori, s_percent_to_draw);
- _gr_direct_draw_prog_text(&surface_info_ori, s_saved_percent);
-
- _copy_buffers_by_rotate(surface_info_ori.planes[0].ptr, surface_info_ori.width, surface_info_ori.height, surface_info_ori.planes[0].stride,
- s_fbi.buf[0], s_fbi.w, s_fbi.h, s_fbi.w * RGB32_PITCH,
- 0,0,surface_info_ori.width, surface_info_ori.height,
- 0,0,s_fbi.w, s_fbi.h, rotate_step);
- tbm_surface_unmap(tbm_surface_ori);
- tbm_surface_destroy(tbm_surface_ori);
- } else if (s_percent_to_draw == 0) {
- s_saved_percent = 0;
- }
-
- _gr_direct_update_screen();
-}
+#include "base_gui_direct.h"
static int total = 0;
-void fota_gr_direct_rw_update_progress(void)
+//void fota_gr_direct_rw_update_progress(void)
+int fota_gr_direct_update_progress(int * s_saved_percent, int * s_percent_to_draw)
{
- int acc;
int progress = 0;
//static int b_text_drawn = 0;
FILE *fp;
}
if (total == 0)
- s_percent_to_draw = 0;
- else
- s_percent_to_draw = 100 * ((float)progress / total);
-
- if (s_saved_percent < s_percent_to_draw) {
- LOG("s_saved_percent %d , s_percent_to_draw %d \n", s_saved_percent, s_percent_to_draw);
- fota_gr_direct_progress();
- }
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_clear_screen
- ----------------------------------------------------------------------------*/
-void fota_gr_direct_clear_screen(u32 color)
-{
- _gr_direct_clear_screen(&s_fbi, color);
- _gr_direct_update_screen();
-}
-
-void _get_rotate(void)
-{
- char *rotate_state = getenv("ROTATE_STATE");
- int rotate_angle = -1;
- if(!rotate_state)
- {
- rotate_angle = ROTATE;
- }
+ *s_percent_to_draw = 0;
else
- {
- rotate_angle = atoi(rotate_state);
- }
+ *s_percent_to_draw = 100 * ((float)progress / total);
- if(rotate_angle < -360 || rotate_angle > 360) // for prevent interger overflow
- rotate_angle = 0;
- LOG("Print Rotate Angle value = %d\n", rotate_angle);
-
- rotate_step = (rotate_angle + 360) / 90 % 4;
- if(rotate_step < 0 || rotate_step > 4) // for prevent interger overflow
- rotate_step = 0;
- rollback_step = (4 - rotate_step) % 4;
- LOG("rotate_step = %d, rollback_step = %d\n", rotate_step, rollback_step);
-
- if (rotate_step % 2 == 0) {
- img_buf_width = s_fbi.w;
- img_buf_height = s_fbi.h;
- } else {
- img_buf_width = s_fbi.h;
- img_buf_height = s_fbi.w;
+ if (*s_saved_percent < *s_percent_to_draw) {
+ LOG("s_saved_percent %d , s_percent_to_draw %d \n", *s_saved_percent, *s_percent_to_draw);
+ fota_gr_direct_progress(s_saved_percent, s_percent_to_draw);
}
- LOG("Print Img buffer(=image w,h) width = %d, height = %d\n", img_buf_width, img_buf_height);
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_init
- ----------------------------------------------------------------------------*/
-int fota_gr_direct_init(void)
-{
- /* open display interface */
- if (fb_open(&s_fbi) < 0)
- LOG("fb_open failed \n");
-
- _get_rotate();
- __init_screen(&s_fbi);
-
- tdm_if_lcd_on(&s_disp);
-
- return 0;
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_direct_deinit
- ----------------------------------------------------------------------------*/
-void fota_gr_direct_deinit(void)
-{
- fb_close(&s_fbi);
-}
-
+ return *s_saved_percent;
+}
\ No newline at end of file
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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_GR_DIRECT_RW_COMMOM_H__
-#define __FOTA_GR_DIRECT_RW_COMMOM_H__
-
-#include "gui_general.h"
-
-extern int fota_gr_direct_init(void);
-extern void fota_gr_direct_deinit(void);
-extern void fota_gr_direct_clear_screen(u32 color);
-extern void fota_gr_direct_update_progress(int percent);
-extern void fota_gr_direct_rw_update_progress(void);
-
-
-#endif /* __FOTA_GR_DIRECT_RW_COMMOM_H__ */
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 "fota_gr_rw_common.h"
-#include "fota_gr_direct_rw_common.h"
-
-/*-----------------------------------------------------------------------------
- fota_gr_init
- ----------------------------------------------------------------------------*/
-int fota_gr_init(void)
-{
- return fota_gr_direct_init();
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_deinit
- ----------------------------------------------------------------------------*/
-void fota_gr_deinit(void)
-{
- fota_gr_direct_deinit();
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_clear_screen
- ----------------------------------------------------------------------------*/
-void fota_gr_clear_screen(u32 color)
-{
- fota_gr_direct_clear_screen(color);
-}
-
-/*-----------------------------------------------------------------------------
- fota_gr_update_progress
- ----------------------------------------------------------------------------*/
-void fota_gr_update_progress(void)
-{
- fota_gr_direct_rw_update_progress();
-}
-
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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_GR_RW_COMMON_H__
-#define __FOTA_GR_RW_COMMON_H__
-
-extern int fota_gr_init(void);
-extern void fota_gr_deinit(void);
-extern void fota_gr_update_progress(void);
-extern void fota_gr_clear_screen(unsigned int color);
-
-#endif /* __FOTA_GR_RW_COMMON_H__ */
-
+++ /dev/null
-/*
- * firmware-update-system-ui
- *
- * 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 <unistd.h>
-#include <sys/poll.h>
-#include <linux/input.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <pthread.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#include "gui_general.h"
-#include "fota_gr_rw_common.h"
-
-unsigned int __log_level__ =
- (LOG_DEBUG | LOG_FLASH | LOG_FILE | LOG_FUNCS | LOG_GUI | LOG_SSENGINE | LOG_INFO);
-FILE *__log_out_file__;
-
-int s_prog_percent = 0;
-int s_last_prog_percent = 0;
-
-
-#define CMD_SUCCESS 0
-#define CMD_ERROR -1
-#define MISSING_PARAM -2
-
-int do_exit = 0;
-
-int s_pid = -1;
-
-
-static int wait_main_fota_rw(void)
-{
- int delay = 20000;
-
- if (setpriority(PRIO_PROCESS, getpid(), -11) < 0)
- LOG("failed to setpriority\n");
-
- if (fota_gr_init() < 0) {
- LOG("fota_gr_init() failed.\n");
- _exit_stdio();
- return -1;
- }
-
- while (do_exit != 1) {
- usleep(delay);
- fota_gr_update_progress();
- }
-
- fota_gr_deinit();
-
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- 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}
- };
-
- opt = getopt_long(argc, argv, "", options, &index);
- if (opt == -1) {
- LOGE("getopt_long failed\n");
- return 0;
- }
-
- switch (index) {
- case 0: {
- int ret = wait_main_fota_rw();
- return ret;
- }
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
- default:
- break;
- }
-
- return 0;
-}