From ba4edb3e82d383a274cea979c9cacfd2e7f62568 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 13 Jun 2018 11:22:50 -0700 Subject: screen_ui: Move the call to gr_init() into Init(). gr_init() does general initialization works, in addition to loading font file. InitTextParams() handles text related works. Also check the font initialization result before using, as gr_init() would ignore font initialization failures. Test: recovery_unit_test on marlin. Test: Boot into recovery. Run graphics test. Change-Id: I12da22dfe8d13448cfbc83dbc51cd96f23c2deee --- screen_ui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/screen_ui.cpp b/screen_ui.cpp index e8444b6ca..f9c4a06c1 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -702,10 +702,10 @@ void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) { } bool ScreenRecoveryUI::InitTextParams() { - if (gr_init() < 0) { + // gr_init() would return successfully on font initialization failure. + if (gr_sys_font() == nullptr) { return false; } - gr_font_size(gr_sys_font(), &char_width_, &char_height_); text_rows_ = (ScreenHeight() - kMarginHeight * 2) / char_height_; text_cols_ = (ScreenWidth() - kMarginWidth * 2) / char_width_; @@ -715,6 +715,10 @@ bool ScreenRecoveryUI::InitTextParams() { bool ScreenRecoveryUI::Init(const std::string& locale) { RecoveryUI::Init(locale); + if (gr_init() == -1) { + return false; + } + if (!InitTextParams()) { return false; } -- cgit v1.2.3