aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2017-01-03 12:15:33 -0600
committerTao Bao2017-01-04 00:40:03 -0600
commit736d59c56754b86135d9156208645b8b1814fba1 (patch)
treeb34e26851aaea9d8958f818d32c7d0e15196fa27 /wear_ui.cpp
parent71633ebfb00103dd95a82cd813824dbddd9b905d (diff)
downloadplatform-bootable-recovery-736d59c56754b86135d9156208645b8b1814fba1.tar.gz
platform-bootable-recovery-736d59c56754b86135d9156208645b8b1814fba1.tar.xz
platform-bootable-recovery-736d59c56754b86135d9156208645b8b1814fba1.zip
recovery: Fix the broken UI text.
UI text is broken (doesn't show any text during FDR) due to commit d530449e54bd327e9c26209ffa0490c6508afe6c, which reordered the calls to RecoveryUI::SetLocale() and RecoveryUI::Init(). Because Init() uses the locale info to load the localized texts (from images), the locale must be set prior to that via SetLocale(). This CL refactors Init() to take the locale parameter, and removes the odd SetLocale() API. Bug: 34029338 Test: 'Run graphics test' under recovery. Change-Id: I620394a3d4e3705e9af5a1f6299285d143ae1b01
Diffstat (limited to 'wear_ui.cpp')
-rw-r--r--wear_ui.cpp71
1 files changed, 35 insertions, 36 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index bdb0ef00..b4c63a5a 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -14,6 +14,8 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17#include "wear_ui.h"
18
17#include <errno.h> 19#include <errno.h>
18#include <fcntl.h> 20#include <fcntl.h>
19#include <stdarg.h> 21#include <stdarg.h>
@@ -25,11 +27,11 @@
25#include <time.h> 27#include <time.h>
26#include <unistd.h> 28#include <unistd.h>
27 29
30#include <string>
28#include <vector> 31#include <vector>
29 32
30#include "common.h" 33#include "common.h"
31#include "device.h" 34#include "device.h"
32#include "wear_ui.h"
33#include "android-base/properties.h" 35#include "android-base/properties.h"
34#include "android-base/strings.h" 36#include "android-base/strings.h"
35#include "android-base/stringprintf.h" 37#include "android-base/stringprintf.h"
@@ -204,51 +206,48 @@ bool WearRecoveryUI::InitTextParams() {
204 return true; 206 return true;
205} 207}
206 208
207bool WearRecoveryUI::Init() { 209bool WearRecoveryUI::Init(const std::string& locale) {
208 if (!ScreenRecoveryUI::Init()) { 210 if (!ScreenRecoveryUI::Init(locale)) {
209 return false; 211 return false;
210 } 212 }
211 213
212 LoadBitmap("icon_error", &backgroundIcon[ERROR]); 214 LoadBitmap("icon_error", &backgroundIcon[ERROR]);
213 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; 215 backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];
214 216
215 // This leaves backgroundIcon[INSTALLING_UPDATE] and backgroundIcon[ERASING] 217 // This leaves backgroundIcon[INSTALLING_UPDATE] and backgroundIcon[ERASING]
216 // as NULL which is fine since draw_background_locked() doesn't use them. 218 // as NULL which is fine since draw_background_locked() doesn't use them.
217 219
218 return true; 220 return true;
219} 221}
220 222
221void WearRecoveryUI::SetStage(int current, int max) 223void WearRecoveryUI::SetStage(int current, int max) {}
222{
223}
224 224
225void WearRecoveryUI::Print(const char *fmt, ...) 225void WearRecoveryUI::Print(const char* fmt, ...) {
226{ 226 char buf[256];
227 char buf[256]; 227 va_list ap;
228 va_list ap; 228 va_start(ap, fmt);
229 va_start(ap, fmt); 229 vsnprintf(buf, 256, fmt, ap);
230 vsnprintf(buf, 256, fmt, ap); 230 va_end(ap);
231 va_end(ap);
232 231
233 fputs(buf, stdout); 232 fputs(buf, stdout);
234 233
235 // This can get called before ui_init(), so be careful. 234 // This can get called before ui_init(), so be careful.
236 pthread_mutex_lock(&updateMutex); 235 pthread_mutex_lock(&updateMutex);
237 if (text_rows_ > 0 && text_cols_ > 0) { 236 if (text_rows_ > 0 && text_cols_ > 0) {
238 char *ptr; 237 char* ptr;
239 for (ptr = buf; *ptr != '\0'; ++ptr) { 238 for (ptr = buf; *ptr != '\0'; ++ptr) {
240 if (*ptr == '\n' || text_col_ >= text_cols_) { 239 if (*ptr == '\n' || text_col_ >= text_cols_) {
241 text_[text_row_][text_col_] = '\0';
242 text_col_ = 0;
243 text_row_ = (text_row_ + 1) % text_rows_;
244 if (text_row_ == text_top_) text_top_ = (text_top_ + 1) % text_rows_;
245 }
246 if (*ptr != '\n') text_[text_row_][text_col_++] = *ptr;
247 }
248 text_[text_row_][text_col_] = '\0'; 240 text_[text_row_][text_col_] = '\0';
249 update_screen_locked(); 241 text_col_ = 0;
242 text_row_ = (text_row_ + 1) % text_rows_;
243 if (text_row_ == text_top_) text_top_ = (text_top_ + 1) % text_rows_;
244 }
245 if (*ptr != '\n') text_[text_row_][text_col_++] = *ptr;
250 } 246 }
251 pthread_mutex_unlock(&updateMutex); 247 text_[text_row_][text_col_] = '\0';
248 update_screen_locked();
249 }
250 pthread_mutex_unlock(&updateMutex);
252} 251}
253 252
254void WearRecoveryUI::StartMenu(const char* const * headers, const char* const * items, 253void WearRecoveryUI::StartMenu(const char* const * headers, const char* const * items,