From e2bd876043c3f26ad4712c2aad62b320368ad815 Mon Sep 17 00:00:00 2001 From: Luke Song Date: Mon, 12 Jun 2017 16:08:33 -0700 Subject: Introduce VR recovery ui A version of screen ui with specific adjustments for vr device compatibility. (cherrypick of a44dba7f4e7296077f65fd571232e8a61aed9418 to AOSP) Bug: 37779982 Test: "adb reboot recovery" to view Change-Id: If6b0f26c1b587f8d0176060685b5efb6c67593b1 --- screen_ui.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index a2322c36c..bd99254f6 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -107,6 +107,7 @@ class ScreenRecoveryUI : public RecoveryUI { // Log text overlay, displayed when a magic key is pressed. char** text_; size_t text_col_, text_row_, text_top_; + int log_bottom_offset_; bool show_text; bool show_text_ever; // has show_text ever been true? @@ -165,8 +166,9 @@ class ScreenRecoveryUI : public RecoveryUI { virtual int GetProgressBaseline(); virtual int GetTextBaseline(); - void DrawHorizontalRule(int* y); - void DrawTextLine(int x, int* y, const char* line, bool bold) const; + virtual void DrawHorizontalRule(int* y); + virtual void DrawHighlightBar(int x, int y, int width, int height) const; + virtual void DrawTextLine(int x, int* y, const char* line, bool bold) const; void DrawTextLines(int x, int* y, const char* const* lines) const; }; -- cgit v1.2.3 From 171b4c4cbe6ba5af3fd7df87d227eda44e308727 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 19 Jun 2017 23:10:44 -0700 Subject: screen_ui: Allow setting screen margin space. We already have outer_width and outer_height in wear UI, and x_offset and y_offset in VR UI. This CL adds margin_width_ and margin_height_ to their base class (ScreenRecoveryUI) to shorten the gap. This will be in general useful for round or round-cornered screens. Move the density computation to ScreenRecoveryUI ctor so that the value can be used earlier. Bug: 62732748 Test: Setting and not setting margin_{width,height}_ on angler. Check the recovery texts (recovery menu as well as 'View recovery logs'). Change-Id: Ibf6238c9cc8949a42ed8a410e1c09d55b0b5a151 (cherry picked from commit 87f4650874346f1d0238e70b148a31cea5e19a2e) --- screen_ui.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index bd99254f6..fd9f471e9 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -72,10 +72,11 @@ class ScreenRecoveryUI : public RecoveryUI { void SetColor(UIElement e); protected: + // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. + const float density_; + Icon currentIcon; - // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. - float density_; // The layout to use. int layout_; @@ -136,6 +137,12 @@ class ScreenRecoveryUI : public RecoveryUI { int char_width_; int char_height_; + + // The margin that we don't want to use for showing texts (e.g. round screen, or screen with + // rounded corners). + int margin_width_; + int margin_height_; + pthread_mutex_t updateMutex; virtual bool InitTextParams(); -- cgit v1.2.3 From 4521b7027fd4305b7cb3a86607a8a0b0a2a48ca7 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 20 Jun 2017 18:11:21 -0700 Subject: Use Makefile variables to specify margin settings. Instead of defining device-specific UI class, this CL allows using Makefile variables to specify margin values directly. Values explicitly defined via TARGET_RECOVERY_UI_MARGIN_HEIGHT and TARGET_RECOVERY_UI_MARGIN_WIDTH will be used. Otherwise they will default to zero. Bug: 62732748 Test: Specify the height and width and check recovery texts. Change-Id: Icb6f7466c8d407f877b93da38aebfdf7e6b41be7 (cherry picked from commit a92d8fb45676566a56d7c27d2e8fb644523adc94) --- screen_ui.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index fd9f471e9..e961c1c93 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -72,6 +72,11 @@ class ScreenRecoveryUI : public RecoveryUI { void SetColor(UIElement e); protected: + // The margin that we don't want to use for showing texts (e.g. round screen, or screen with + // rounded corners). + const int kMarginWidth; + const int kMarginHeight; + // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. const float density_; @@ -138,11 +143,6 @@ class ScreenRecoveryUI : public RecoveryUI { int char_width_; int char_height_; - // The margin that we don't want to use for showing texts (e.g. round screen, or screen with - // rounded corners). - int margin_width_; - int margin_height_; - pthread_mutex_t updateMutex; virtual bool InitTextParams(); -- cgit v1.2.3 From 9d4839c60fc51068ba8a389545b2751a7c5a14b0 Mon Sep 17 00:00:00 2001 From: Luke Song Date: Fri, 23 Jun 2017 14:33:46 -0700 Subject: Restructure vr_ui Get rid of pixel offset variables, and use makefile variables in BoardConfigs. Bug: 37779982 Test: Verified vr ui has same behavior. Change-Id: Ifbf44e27d7101aedbe3c0e6db4b8181d56efadfd (cherry picked from commit 81a8e4cab2a20fd1b1a4716563d4d2586bd1e1de) --- screen_ui.h | 1 - 1 file changed, 1 deletion(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index e961c1c93..2500575ca 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -113,7 +113,6 @@ class ScreenRecoveryUI : public RecoveryUI { // Log text overlay, displayed when a magic key is pressed. char** text_; size_t text_col_, text_row_, text_top_; - int log_bottom_offset_; bool show_text; bool show_text_ever; // has show_text ever been true? -- cgit v1.2.3 From 5d2e3bd109539282d1829e3579c1f762a9486382 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 23 Jun 2017 22:23:50 -0700 Subject: Formatting RecoveryUI related files. All cosmetic changes about indentation reformatting in this CL. Test: mmma bootable/recovery Change-Id: I4539e6244697d1f356b7eb10b961b52d7db561f7 --- screen_ui.h | 216 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 111 insertions(+), 105 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 2500575ca..2a3d8c30b 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -30,152 +30,158 @@ struct GRSurface; // Implementation of RecoveryUI appropriate for devices with a screen // (shows an icon + a progress bar, text logging, menu, etc.) class ScreenRecoveryUI : public RecoveryUI { - public: - ScreenRecoveryUI(); + public: + ScreenRecoveryUI(); - bool Init(const std::string& locale) override; + bool Init(const std::string& locale) override; - // overall recovery state ("background image") - void SetBackground(Icon icon); - void SetSystemUpdateText(bool security_update); + // overall recovery state ("background image") + void SetBackground(Icon icon); + void SetSystemUpdateText(bool security_update); - // progress indicator - void SetProgressType(ProgressType type) override; - void ShowProgress(float portion, float seconds) override; - void SetProgress(float fraction) override; + // progress indicator + void SetProgressType(ProgressType type) override; + void ShowProgress(float portion, float seconds) override; + void SetProgress(float fraction) override; - void SetStage(int current, int max) override; + void SetStage(int current, int max) override; - // text log - void ShowText(bool visible) override; - bool IsTextVisible() override; - bool WasTextEverVisible() override; + // text log + void ShowText(bool visible) override; + bool IsTextVisible() override; + bool WasTextEverVisible() override; - // printing messages - void Print(const char* fmt, ...) __printflike(2, 3); - void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3); - void ShowFile(const char* filename); + // printing messages + void Print(const char* fmt, ...) __printflike(2, 3); + void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3); + void ShowFile(const char* filename); - // menu display - void StartMenu(const char* const * headers, const char* const * items, - int initial_selection); - int SelectMenu(int sel); - void EndMenu(); + // menu display + void StartMenu(const char* const* headers, const char* const* items, int initial_selection); + int SelectMenu(int sel); + void EndMenu(); - void KeyLongPress(int); + void KeyLongPress(int); - void Redraw(); + void Redraw(); - enum UIElement { - HEADER, MENU, MENU_SEL_BG, MENU_SEL_BG_ACTIVE, MENU_SEL_FG, LOG, TEXT_FILL, INFO - }; - void SetColor(UIElement e); + enum UIElement { + HEADER, + MENU, + MENU_SEL_BG, + MENU_SEL_BG_ACTIVE, + MENU_SEL_FG, + LOG, + TEXT_FILL, + INFO + }; + void SetColor(UIElement e); - protected: - // The margin that we don't want to use for showing texts (e.g. round screen, or screen with - // rounded corners). - const int kMarginWidth; - const int kMarginHeight; + protected: + // The margin that we don't want to use for showing texts (e.g. round screen, or screen with + // rounded corners). + const int kMarginWidth; + const int kMarginHeight; - // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. - const float density_; + // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. + const float density_; - Icon currentIcon; + Icon currentIcon; - // The layout to use. - int layout_; + // The layout to use. + int layout_; - GRSurface* error_icon; + GRSurface* error_icon; - GRSurface* erasing_text; - GRSurface* error_text; - GRSurface* installing_text; - GRSurface* no_command_text; + GRSurface* erasing_text; + GRSurface* error_text; + GRSurface* installing_text; + GRSurface* no_command_text; - GRSurface** introFrames; - GRSurface** loopFrames; + GRSurface** introFrames; + GRSurface** loopFrames; - GRSurface* progressBarEmpty; - GRSurface* progressBarFill; - GRSurface* stageMarkerEmpty; - GRSurface* stageMarkerFill; + GRSurface* progressBarEmpty; + GRSurface* progressBarFill; + GRSurface* stageMarkerEmpty; + GRSurface* stageMarkerFill; - ProgressType progressBarType; + ProgressType progressBarType; - float progressScopeStart, progressScopeSize, progress; - double progressScopeTime, progressScopeDuration; + float progressScopeStart, progressScopeSize, progress; + double progressScopeTime, progressScopeDuration; - // true when both graphics pages are the same (except for the progress bar). - bool pagesIdentical; + // true when both graphics pages are the same (except for the progress bar). + bool pagesIdentical; - size_t text_cols_, text_rows_; + size_t text_cols_, text_rows_; - // Log text overlay, displayed when a magic key is pressed. - char** text_; - size_t text_col_, text_row_, text_top_; + // Log text overlay, displayed when a magic key is pressed. + char** text_; + size_t text_col_, text_row_, text_top_; - bool show_text; - bool show_text_ever; // has show_text ever been true? + bool show_text; + bool show_text_ever; // has show_text ever been true? - char** menu_; - const char* const* menu_headers_; - bool show_menu; - int menu_items, menu_sel; + char** menu_; + const char* const* menu_headers_; + bool show_menu; + int menu_items, menu_sel; - // An alternate text screen, swapped with 'text_' when we're viewing a log file. - char** file_viewer_text_; + // An alternate text screen, swapped with 'text_' when we're viewing a log file. + char** file_viewer_text_; - pthread_t progress_thread_; + pthread_t progress_thread_; - // Number of intro frames and loop frames in the animation. - size_t intro_frames; - size_t loop_frames; + // Number of intro frames and loop frames in the animation. + size_t intro_frames; + size_t loop_frames; - size_t current_frame; - bool intro_done; + size_t current_frame; + bool intro_done; - // Number of frames per sec (default: 30) for both parts of the animation. - int animation_fps; + // Number of frames per sec (default: 30) for both parts of the animation. + int animation_fps; - int stage, max_stage; + int stage, max_stage; - int char_width_; - int char_height_; + int char_width_; + int char_height_; - pthread_mutex_t updateMutex; + pthread_mutex_t updateMutex; - virtual bool InitTextParams(); + virtual bool InitTextParams(); - virtual void draw_background_locked(); - virtual void draw_foreground_locked(); - virtual void draw_screen_locked(); - virtual void update_screen_locked(); - virtual void update_progress_locked(); + virtual void draw_background_locked(); + virtual void draw_foreground_locked(); + virtual void draw_screen_locked(); + virtual void update_screen_locked(); + virtual void update_progress_locked(); - GRSurface* GetCurrentFrame(); - GRSurface* GetCurrentText(); + GRSurface* GetCurrentFrame(); + GRSurface* GetCurrentText(); - static void* ProgressThreadStartRoutine(void* data); - void ProgressThreadLoop(); + static void* ProgressThreadStartRoutine(void* data); + void ProgressThreadLoop(); - virtual void ShowFile(FILE*); - virtual void PrintV(const char*, bool, va_list); - void PutChar(char); - void ClearText(); + virtual void ShowFile(FILE*); + virtual void PrintV(const char*, bool, va_list); + void PutChar(char); + void ClearText(); - void LoadAnimation(); - void LoadBitmap(const char* filename, GRSurface** surface); - void LoadLocalizedBitmap(const char* filename, GRSurface** surface); + void LoadAnimation(); + void LoadBitmap(const char* filename, GRSurface** surface); + void LoadLocalizedBitmap(const char* filename, GRSurface** surface); - int PixelsFromDp(int dp) const; - virtual int GetAnimationBaseline(); - virtual int GetProgressBaseline(); - virtual int GetTextBaseline(); + int PixelsFromDp(int dp) const; + virtual int GetAnimationBaseline(); + virtual int GetProgressBaseline(); + virtual int GetTextBaseline(); - virtual void DrawHorizontalRule(int* y); - virtual void DrawHighlightBar(int x, int y, int width, int height) const; - virtual void DrawTextLine(int x, int* y, const char* line, bool bold) const; - void DrawTextLines(int x, int* y, const char* const* lines) const; + virtual void DrawHorizontalRule(int* y); + virtual void DrawHighlightBar(int x, int y, int width, int height) const; + virtual void DrawTextLine(int x, int* y, const char* line, bool bold) const; + void DrawTextLines(int x, int* y, const char* const* lines) const; }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From 99b2d774751041a5cfb5a48ac93292bb92acef98 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 23 Jun 2017 22:47:03 -0700 Subject: Add override specifier and member constness to RecoveryUI classes. Test: mmma bootable/recovery Change-Id: I66e328614423488a4027d7878f4569fbf3a3721e --- screen_ui.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 2a3d8c30b..e8d3c3222 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -36,8 +36,8 @@ class ScreenRecoveryUI : public RecoveryUI { bool Init(const std::string& locale) override; // overall recovery state ("background image") - void SetBackground(Icon icon); - void SetSystemUpdateText(bool security_update); + void SetBackground(Icon icon) override; + void SetSystemUpdateText(bool security_update) override; // progress indicator void SetProgressType(ProgressType type) override; @@ -52,16 +52,17 @@ class ScreenRecoveryUI : public RecoveryUI { bool WasTextEverVisible() override; // printing messages - void Print(const char* fmt, ...) __printflike(2, 3); - void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3); - void ShowFile(const char* filename); + void Print(const char* fmt, ...) override __printflike(2, 3); + void PrintOnScreenOnly(const char* fmt, ...) override __printflike(2, 3); + void ShowFile(const char* filename) override; // menu display - void StartMenu(const char* const* headers, const char* const* items, int initial_selection); - int SelectMenu(int sel); - void EndMenu(); + void StartMenu(const char* const* headers, const char* const* items, + int initial_selection) override; + int SelectMenu(int sel) override; + void EndMenu() override; - void KeyLongPress(int); + void KeyLongPress(int) override; void Redraw(); @@ -75,7 +76,7 @@ class ScreenRecoveryUI : public RecoveryUI { TEXT_FILL, INFO }; - void SetColor(UIElement e); + void SetColor(UIElement e) const; protected: // The margin that we don't want to use for showing texts (e.g. round screen, or screen with @@ -158,8 +159,8 @@ class ScreenRecoveryUI : public RecoveryUI { virtual void update_screen_locked(); virtual void update_progress_locked(); - GRSurface* GetCurrentFrame(); - GRSurface* GetCurrentText(); + GRSurface* GetCurrentFrame() const; + GRSurface* GetCurrentText() const; static void* ProgressThreadStartRoutine(void* data); void ProgressThreadLoop(); @@ -174,11 +175,11 @@ class ScreenRecoveryUI : public RecoveryUI { void LoadLocalizedBitmap(const char* filename, GRSurface** surface); int PixelsFromDp(int dp) const; - virtual int GetAnimationBaseline(); - virtual int GetProgressBaseline(); - virtual int GetTextBaseline(); + virtual int GetAnimationBaseline() const; + virtual int GetProgressBaseline() const; + virtual int GetTextBaseline() const; - virtual void DrawHorizontalRule(int* y); + virtual void DrawHorizontalRule(int* y) const; virtual void DrawHighlightBar(int x, int y, int width, int height) const; virtual void DrawTextLine(int x, int* y, const char* line, bool bold) const; void DrawTextLines(int x, int* y, const char* const* lines) const; -- cgit v1.2.3 From ea78d86b44661c69fcb740b9d40b47af821dbd57 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 28 Jun 2017 14:52:17 -0700 Subject: Update ScreenRecoveryUI::Draw* function signatures. Move away from taking int* for the Y-offset. Change it to int and return the offset instead. Test: Check the recovery menu and 'Wipe data' menu. Change-Id: Ib15e070a0d576a0f8f66f35605cb8479e7071f26 --- screen_ui.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index e8d3c3222..8402fac00 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -179,10 +179,14 @@ class ScreenRecoveryUI : public RecoveryUI { virtual int GetProgressBaseline() const; virtual int GetTextBaseline() const; - virtual void DrawHorizontalRule(int* y) const; + // Draws a highlight bar at (x, y) - (x + width, y + height). virtual void DrawHighlightBar(int x, int y, int width, int height) const; - virtual void DrawTextLine(int x, int* y, const char* line, bool bold) const; - void DrawTextLines(int x, int* y, const char* const* lines) const; + // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis. + virtual int DrawHorizontalRule(int y) const; + // Draws a line of text. Returns the offset it should be moving along Y-axis. + virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; + // Draws multiple text lines. Returns the offset it should be moving along Y-axis. + int DrawTextLines(int x, int y, const char* const* lines) const; }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From 016120f395795fb1be600c1e85f4dfd324797122 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 2 Aug 2017 17:11:04 -0700 Subject: Allow customizing WearRecoveryUI via Makefile variables. With the following Makefile variables, we can reduce the work of writing (copy/pasting) device-specific WearRecoveryUI classes. The list of Makefile variables (the ones useful for Wear devices): - TARGET_RECOVERY_UI_MARGIN_HEIGHT (default: 0) - TARGET_RECOVERY_UI_MARGIN_WIDTH (default: 0) Specify the margin space that we don't want to display texts. They replace the former outer_width and outer_height. - TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD (default: 50) - TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD (default: 90) Specify the sensitivity of recognizing a swipe. Devices give absolute positions, so for some devices we need to adjust the thresholds. - TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE Specify the progress bar vertical position, which should be adjusted to the actual height of a device. It replaces the former progress_bar_y. - TARGET_RECOVERY_UI_ANIMATION_FPS (default: 30) Specify the animation FPS if using device-specific animation images. It replaces the former animation_fps. Devices can specify "TARGET_RECOVERY_UI_LIB := librecovery_ui_wear", with optionally defined Makefile vars above, in BoardConfig.mk to customize their WearRecoveryUI. Also remove the obsolete wear_touch.{cpp,h}, which has been merged into ui.cpp in commit 5f8dd9951d986b65d98d6a9ea38003427e9e46df. Bug: 64307776 Test: Change the device BoardConfig.mk and test recovery image. Change-Id: Id0fb2d4e3977ab5ddd31e71f9535470cab70e41b (cherry picked from commit 0470ceea381775b09eee931858c3320be88cc637) --- screen_ui.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 8402fac00..1f40164af 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -84,6 +84,9 @@ class ScreenRecoveryUI : public RecoveryUI { const int kMarginWidth; const int kMarginHeight; + // Number of frames per sec (default: 30) for both parts of the animation. + const int kAnimationFps; + // The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi. const float density_; @@ -141,9 +144,6 @@ class ScreenRecoveryUI : public RecoveryUI { size_t current_frame; bool intro_done; - // Number of frames per sec (default: 30) for both parts of the animation. - int animation_fps; - int stage, max_stage; int char_width_; -- cgit v1.2.3 From ee6fefd2f203a7df2164b3262fa54e62f61e6ad2 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Sun, 13 Aug 2017 23:48:55 -0700 Subject: screen_ui: Word-wrap menu headers. This CL adds ScreenRecoveryUI::DrawWrappedTextLines() to better handle long menu header texts. It does a word wrap at spaces, if available. This avoids fixed-length menu headers being truncated on small screens. Bug: 64293520 Test: On bullhead, boot into recovery with --prompt_and_wipe_data, and check the prompt texts. Change-Id: Ia22746583516dd230567a267584aca558429395e (cherry picked from commit 2bbc6d642d1fbfb007905d95b629fe5f833b2a1b) --- screen_ui.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 8402fac00..df7cc25b3 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -187,6 +187,9 @@ class ScreenRecoveryUI : public RecoveryUI { virtual int DrawTextLine(int x, int y, const char* line, bool bold) const; // Draws multiple text lines. Returns the offset it should be moving along Y-axis. int DrawTextLines(int x, int y, const char* const* lines) const; + // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines. + // Returns the offset it should be moving along Y-axis. + int DrawWrappedTextLines(int x, int y, const char* const* lines) const; }; #endif // RECOVERY_UI_H -- cgit v1.2.3 From 17fa5c7cab503015bde05fbe0455f8a6a3344396 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 7 Sep 2017 13:38:51 -0700 Subject: ui: Manage menu_ with std::vector. Prior to this CL, menu_ is allocated with a fixed length of text_rows_. However, because we support scrollable menu in wear_ui, there might be more menu entries than text_rows_, which would lead to out-of-bounds array access. This CL addresses the issue by switching to std::vector. Bug: 65416558 Test: Run 'View recovery logs' on angler. Test: Set large margin height that leaves text_rows less than 21. Then run 'View recovery logs' with 21 menu entries. Change-Id: I5d4e3a0a097039e1104eda7d494c6269053dc894 (cherry picked from commit e15d7a5104978cd8399501636aec0df9c1a4823c) --- screen_ui.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'screen_ui.h') diff --git a/screen_ui.h b/screen_ui.h index 62dda7558..8231a2ba0 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -21,6 +21,7 @@ #include #include +#include #include "ui.h" @@ -127,7 +128,7 @@ class ScreenRecoveryUI : public RecoveryUI { bool show_text; bool show_text_ever; // has show_text ever been true? - char** menu_; + std::vector menu_; const char* const* menu_headers_; bool show_menu; int menu_items, menu_sel; -- cgit v1.2.3