In the continuing saga of updating to 7.1.2, I’ve run into an interesting error about gr_text and gr_measure that are used to set the fonts properly when you are charging your phone while it is off. In 7.1.1, this worked just fine:

AOKP711/system/core/healthd/healthd_mode_charger.cpp

[CODE]
static int draw_text(const char *str, int x, int y)
{
int str_len_px = gr_measure(str);

if (x < 0)
x = (gr_fb_width() – str_len_px) / 2;
if (y < 0)
y = (gr_fb_height() – char_height) / 2;
gr_text(x, y, str, 0);

return y + char_height;
———- Abreviated for space ——————–
gr_init();
gr_font_size(&char_width, &char_height);

#ifndef CHARGER_DISABLE_INIT_BLANK
[/CODE]

But that didn’t work in 7.1.2. I found this github commit for a sony phone: https://github.com/sonyxperiadev/device-sony-common/pull/247 and was able to modify it enough to fix the S4, like so:

AOKP712/system/core/healthd/healthd_mode_charger.cpp

[CODE]
static int draw_text(const char *str, int x, int y)
{
int str_len_px = gr_measure(gr_sys_font(), str); // WJH

if (x < 0)
x = (gr_fb_width() – str_len_px) / 2;
if (y < 0)
y = (gr_fb_height() – char_height) / 2;
gr_text(gr_sys_font(), x, y, str, 0); // WJH

return y + char_height;
———- Abreviated for space ——————–
gr_init();
gr_font_size(gr_sys_font(), &char_width, &char_height); //WJH

#ifndef CHARGER_DISABLE_INIT_BLANK
[/CODE]

It even worked! Hopefully that can help someone else out as well.

Linux – keep it simple.

 

Leave a Reply

Your email address will not be published. Required fields are marked *