Merge "healthd: charger loads resources from /product" am: 9474063654
am: c85de61ada
Change-Id: I286f8d2a76b2559ef5cb7ddbcf06df9e7afd2078
This commit is contained in:
commit
2e62511bcb
2 changed files with 30 additions and 3 deletions
|
|
@ -48,6 +48,25 @@ struct animation {
|
||||||
GRFont* font;
|
GRFont* font;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// When libminui loads PNG images:
|
||||||
|
// - When treating paths as relative paths, it adds ".png" suffix.
|
||||||
|
// - When treating paths as absolute paths, it doesn't add the suffix. Hence, the suffix
|
||||||
|
// is added here.
|
||||||
|
void set_resource_root(const std::string& root) {
|
||||||
|
if (!animation_file.empty()) {
|
||||||
|
animation_file = root + animation_file + ".png";
|
||||||
|
}
|
||||||
|
if (!fail_file.empty()) {
|
||||||
|
fail_file = root + fail_file + ".png";
|
||||||
|
}
|
||||||
|
if (!text_clock.font_file.empty()) {
|
||||||
|
text_clock.font_file = root + text_clock.font_file + ".png";
|
||||||
|
}
|
||||||
|
if (!text_percent.font_file.empty()) {
|
||||||
|
text_percent.font_file = root + text_percent.font_file + ".png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string animation_file;
|
std::string animation_file;
|
||||||
std::string fail_file;
|
std::string fail_file;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,13 @@ char* locale;
|
||||||
#define LOGW(x...) KLOG_WARNING("charger", x);
|
#define LOGW(x...) KLOG_WARNING("charger", x);
|
||||||
#define LOGV(x...) KLOG_DEBUG("charger", x);
|
#define LOGV(x...) KLOG_DEBUG("charger", x);
|
||||||
|
|
||||||
static constexpr const char* animation_desc_path =
|
// Resources in /product/etc/res overrides resources in /res.
|
||||||
"/res/values/charger/animation.txt";
|
// If the device is using the Generic System Image (GSI), resources may exist in
|
||||||
|
// both paths.
|
||||||
|
static constexpr const char* product_animation_desc_path =
|
||||||
|
"/product/etc/res/values/charger/animation.txt";
|
||||||
|
static constexpr const char* product_animation_root = "/product/etc/res/images/";
|
||||||
|
static constexpr const char* animation_desc_path = "/res/values/charger/animation.txt";
|
||||||
|
|
||||||
struct key_state {
|
struct key_state {
|
||||||
bool pending;
|
bool pending;
|
||||||
|
|
@ -600,7 +605,10 @@ animation* init_animation() {
|
||||||
bool parse_success;
|
bool parse_success;
|
||||||
|
|
||||||
std::string content;
|
std::string content;
|
||||||
if (base::ReadFileToString(animation_desc_path, &content)) {
|
if (base::ReadFileToString(product_animation_desc_path, &content)) {
|
||||||
|
parse_success = parse_animation_desc(content, &battery_animation);
|
||||||
|
battery_animation.set_resource_root(product_animation_root);
|
||||||
|
} else if (base::ReadFileToString(animation_desc_path, &content)) {
|
||||||
parse_success = parse_animation_desc(content, &battery_animation);
|
parse_success = parse_animation_desc(content, &battery_animation);
|
||||||
} else {
|
} else {
|
||||||
LOGW("Could not open animation description at %s\n", animation_desc_path);
|
LOGW("Could not open animation description at %s\n", animation_desc_path);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue