From 7bad7c4646ee8fd8d6e6ed0ffd3ddbb0c1b41a2f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 28 Apr 2015 17:24:24 -0700 Subject: Check all lseek calls succeed. Also add missing TEMP_FAILURE_RETRYs on read, write, and lseek. Bug: http://b/20625546 Change-Id: I03b198e11c1921b35518ee2dd005a7cfcf4fd94b --- minui/events.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'minui') diff --git a/minui/events.cpp b/minui/events.cpp index 2d47a587f..3b2262a4b 100644 --- a/minui/events.cpp +++ b/minui/events.cpp @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -165,7 +166,7 @@ void ev_dispatch(void) { int ev_get_input(int fd, uint32_t epevents, input_event* ev) { if (epevents & EPOLLIN) { - ssize_t r = read(fd, ev, sizeof(*ev)); + ssize_t r = TEMP_FAILURE_RETRY(read(fd, ev, sizeof(*ev))); if (r == sizeof(*ev)) { return 0; } -- cgit v1.2.3 From 80e46e08de5f65702fa7f7cd3ef83f905d919bbc Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 3 Jun 2015 10:49:29 -0700 Subject: recovery: Switch to clang And a few trival fixes to suppress warnings. Change-Id: I38734b5f4434643e85feab25f4807b46a45d8d65 --- minui/Android.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'minui') diff --git a/minui/Android.mk b/minui/Android.mk index 52f066256..5584612df 100644 --- a/minui/Android.mk +++ b/minui/Android.mk @@ -39,6 +39,7 @@ include $(BUILD_STATIC_LIBRARY) # Used by OEMs for factory test images. include $(CLEAR_VARS) +LOCAL_CLANG := true LOCAL_MODULE := libminui LOCAL_WHOLE_STATIC_LIBRARIES += libminui LOCAL_SHARED_LIBRARIES := libpng -- cgit v1.2.3 From 7101b2e2854985727b7ef65e5b5057e0ecf2d034 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 3 Jun 2015 10:49:29 -0700 Subject: recovery: Switch to clang And a few trival fixes to suppress warnings. Change-Id: Id28e3581aaca4bda59826afa80c0c1cdfb0442fc (cherry picked from commit 80e46e08de5f65702fa7f7cd3ef83f905d919bbc) --- minui/Android.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'minui') diff --git a/minui/Android.mk b/minui/Android.mk index 97724fbf0..3057f452c 100644 --- a/minui/Android.mk +++ b/minui/Android.mk @@ -41,6 +41,7 @@ include $(BUILD_STATIC_LIBRARY) # Used by OEMs for factory test images. include $(CLEAR_VARS) +LOCAL_CLANG := true LOCAL_MODULE := libminui LOCAL_WHOLE_STATIC_LIBRARIES += libminui LOCAL_SHARED_LIBRARIES := libpng -- cgit v1.2.3 From b723f4f38f53a38502abb1a63165ac0749bc9cd9 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 11 Dec 2015 15:18:51 -0800 Subject: res: Embed FPS into icon_installing.png. We allow vendor-specific icon installing image but have defined private animation_fps that can't be overridden. This CL changes the image generator to optionally embed FPS (otherwise use the default value of 20) into the generated image. For wear devices, they are using individual images instead of the interlaced one. Change the animation_fps from private to protected so that it can be customized. Bug: 26009230 Change-Id: I9fbf64ec717029d4c54f72316f6cb079e8dbfb5e --- minui/minui.h | 4 ++-- minui/resources.cpp | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'minui') diff --git a/minui/minui.h b/minui/minui.h index bdde083f3..e3bc00548 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -101,8 +101,8 @@ int res_create_display_surface(const char* name, GRSurface** pSurface); // should have a 'Frames' text chunk whose value is the number of // frames this image represents. The pixel data itself is interlaced // by row. -int res_create_multi_display_surface(const char* name, - int* frames, GRSurface*** pSurface); +int res_create_multi_display_surface(const char* name, int* frames, + int* fps, GRSurface*** pSurface); // Load a single alpha surface from a grayscale PNG image. int res_create_alpha_surface(const char* name, GRSurface** pSurface); diff --git a/minui/resources.cpp b/minui/resources.cpp index 5e4789277..63a0dff28 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -237,14 +237,14 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) { return result; } -int res_create_multi_display_surface(const char* name, int* frames, GRSurface*** pSurface) { +int res_create_multi_display_surface(const char* name, int* frames, int* fps, + GRSurface*** pSurface) { GRSurface** surface = NULL; int result = 0; png_structp png_ptr = NULL; png_infop info_ptr = NULL; png_uint_32 width, height; png_byte channels; - int i; png_textp text; int num_text; unsigned char* p_row; @@ -257,14 +257,23 @@ int res_create_multi_display_surface(const char* name, int* frames, GRSurface*** if (result < 0) return result; *frames = 1; + *fps = 20; if (png_get_text(png_ptr, info_ptr, &text, &num_text)) { - for (i = 0; i < num_text; ++i) { + for (int i = 0; i < num_text; ++i) { if (text[i].key && strcmp(text[i].key, "Frames") == 0 && text[i].text) { *frames = atoi(text[i].text); - break; + } else if (text[i].key && strcmp(text[i].key, "FPS") == 0 && text[i].text) { + *fps = atoi(text[i].text); } } printf(" found frames = %d\n", *frames); + printf(" found fps = %d\n", *fps); + } + + if (frames <= 0 || fps <= 0) { + printf("bad number of frames (%d) and/or FPS (%d)\n", *frames, *fps); + result = -10; + goto exit; } if (height % *frames != 0) { @@ -278,7 +287,7 @@ int res_create_multi_display_surface(const char* name, int* frames, GRSurface*** result = -8; goto exit; } - for (i = 0; i < *frames; ++i) { + for (int i = 0; i < *frames; ++i) { surface[i] = init_display_surface(width, height / *frames); if (surface[i] == NULL) { result = -8; @@ -307,7 +316,7 @@ exit: if (result < 0) { if (surface) { - for (i = 0; i < *frames; ++i) { + for (int i = 0; i < *frames; ++i) { if (surface[i]) free(surface[i]); } free(surface); -- cgit v1.2.3 From a5d5082222b7420801cdb77f09305dd4c3afb4db Mon Sep 17 00:00:00 2001 From: Andriy Naborskyy Date: Fri, 8 Jan 2016 10:11:41 -0800 Subject: Revert "Byte swap to support BGRA in recovery mode" This reverts commit e5879c3639789d61803605c12371a4f291e0b3cc. The swap in page flip code is not needed any more. New changes take care of ABGR and BGRA formats swapping bytes in png and drawing routines See commit fd778e3e406a7e83536ea66776996f032f24af64 Bug: 26243152 Change-Id: I313ee41bee2c143b4e5412515285a65ac394ec77 --- minui/graphics_fbdev.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'minui') diff --git a/minui/graphics_fbdev.cpp b/minui/graphics_fbdev.cpp index 997e9cac2..0788f7552 100644 --- a/minui/graphics_fbdev.cpp +++ b/minui/graphics_fbdev.cpp @@ -176,18 +176,6 @@ static GRSurface* fbdev_init(minui_backend* backend) { static GRSurface* fbdev_flip(minui_backend* backend __unused) { if (double_buffered) { -#if defined(RECOVERY_BGRA) - // In case of BGRA, do some byte swapping - unsigned int idx; - unsigned char tmp; - unsigned char* ucfb_vaddr = (unsigned char*)gr_draw->data; - for (idx = 0 ; idx < (gr_draw->height * gr_draw->row_bytes); - idx += 4) { - tmp = ucfb_vaddr[idx]; - ucfb_vaddr[idx ] = ucfb_vaddr[idx + 2]; - ucfb_vaddr[idx + 2] = tmp; - } -#endif // Change gr_draw to point to the buffer currently displayed, // then flip the driver so we're displaying the other buffer // instead. -- cgit v1.2.3 From 498cda6ef6c610efb055221d6c689185d49447bb Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 14 Apr 2016 16:49:04 -0700 Subject: Update the system update animation. Switch to a Wear-like intro/loop system. We don't have an intro yet, but hopefully this will let Wear delete more code when they move to N. Unlike them, we don't hard-code the number of frames: we just look to see what we have available. We do hard-code the fps though. Also add a graphics test mode so you can see a demo of the UI components without having to actually apply an OTA. Also fix a bug where default locale is null rather than en-US: it's more useful to show _some_ text if we don't have a locale (which should only be during development anyway). Bug: http://b/26548285 Change-Id: I63422e3fef3c41109f924d96fb5ded0b3ae7815d --- minui/resources.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'minui') diff --git a/minui/resources.cpp b/minui/resources.cpp index 63a0dff28..5d69ea2d0 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -32,8 +32,6 @@ #include "minui.h" -extern char* locale; - #define SURFACE_DATA_ALIGNMENT 8 static GRSurface* malloc_surface(size_t data_size) { -- cgit v1.2.3 From 2430e2978b95ff364c304e0aeeeaeec6df929146 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Tue, 19 Apr 2016 15:02:41 -0700 Subject: Fix matches_locale function matches_locale was expecting input locale string to have at most one underscore; as a result "zh_CN_#Hans" ignores "zh_CN" and matches into "zh". Fix the match function and add unit tests. Bug: 27837319 Change-Id: I4e8a66f91cae6ac2a46b6bf21f670d5ea564c7c8 --- minui/minui.h | 2 ++ minui/resources.cpp | 21 ++++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'minui') diff --git a/minui/minui.h b/minui/minui.h index e3bc00548..fb0bbe10c 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -84,6 +84,8 @@ int ev_get_epollfd(); // Resources // +bool matches_locale(const char* prefix, const char* locale); + // res_create_*_surface() functions return 0 if no error, else // negative. // diff --git a/minui/resources.cpp b/minui/resources.cpp index 5d69ea2d0..40d3c2c88 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -370,21 +370,16 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) { return result; } -static int matches_locale(const char* loc, const char* locale) { - if (locale == NULL) return 0; +// This function tests if a locale string stored in PNG (prefix) matches +// the locale string provided by the system (locale). +bool matches_locale(const char* prefix, const char* locale) { + if (locale == NULL) return false; - if (strcmp(loc, locale) == 0) return 1; + // Return true if the whole string of prefix matches the top part of + // locale. For instance, prefix == "en" matches locale == "en_US"; + // and prefix == "zh_CN" matches locale == "zh_CN_#Hans". - // if loc does *not* have an underscore, and it matches the start - // of locale, and the next character in locale *is* an underscore, - // that's a match. For instance, loc == "en" matches locale == - // "en_US". - - int i; - for (i = 0; loc[i] != 0 && loc[i] != '_'; ++i); - if (loc[i] == '_') return 0; - - return (strncmp(locale, loc, i) == 0 && locale[i] == '_'); + return (strncmp(prefix, locale, strlen(prefix)) == 0); } int res_create_localized_alpha_surface(const char* name, -- cgit v1.2.3