charger: vendor charger use resources from /vendor
For the vendor variant of libhealthd_mode_charger, read resources from /vendor. The core variant continues to read resources from /product, /system, and /res. Test: run charger from /vendor manually Bug: 203246116 Change-Id: Ia9df1d081a51783409b5dbd3e3d4719efc3cb6a7
This commit is contained in:
parent
e3ffd1bfc2
commit
ac748369bb
2 changed files with 58 additions and 3 deletions
|
@ -325,3 +325,29 @@ phony {
|
|||
"system_core_charger_res_images_battery_scale.png",
|
||||
],
|
||||
}
|
||||
|
||||
// /vendor/etc/res/images/charger/battery_fail.png
|
||||
prebuilt_etc {
|
||||
name: "system_core_charger_res_images_battery_fail.png_default_vendor",
|
||||
src: "images/battery_fail.png",
|
||||
relative_install_path: "res/images/charger/default",
|
||||
vendor: true,
|
||||
filename: "battery_fail.png",
|
||||
}
|
||||
|
||||
// /vendor/etc/res/images/charger/battery_scale.png
|
||||
prebuilt_etc {
|
||||
name: "system_core_charger_res_images_battery_scale.png_default_vendor",
|
||||
src: "images/battery_scale.png",
|
||||
relative_install_path: "res/images/charger/default",
|
||||
vendor: true,
|
||||
filename: "battery_scale.png",
|
||||
}
|
||||
|
||||
phony {
|
||||
name: "charger_res_images_vendor",
|
||||
required: [
|
||||
"system_core_charger_res_images_battery_fail.png_default_vendor",
|
||||
"system_core_charger_res_images_battery_scale.png_default_vendor",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -99,6 +99,13 @@ char* locale;
|
|||
|
||||
namespace android {
|
||||
|
||||
#if defined(__ANDROID_VNDK__)
|
||||
static constexpr const char* vendor_animation_desc_path =
|
||||
"/vendor/etc/res/values/charger/animation.txt";
|
||||
static constexpr const char* vendor_animation_root = "/vendor/etc/res/images/";
|
||||
static constexpr const char* vendor_default_animation_root = "/vendor/etc/res/images/default/";
|
||||
#else
|
||||
|
||||
// Legacy animation resources are loaded from this directory.
|
||||
static constexpr const char* legacy_animation_root = "/res/images/";
|
||||
|
||||
|
@ -112,6 +119,7 @@ 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";
|
||||
#endif
|
||||
|
||||
static const animation BASE_ANIMATION = {
|
||||
.text_clock =
|
||||
|
@ -619,6 +627,16 @@ void Charger::InitAnimation() {
|
|||
bool parse_success;
|
||||
|
||||
std::string content;
|
||||
|
||||
#if defined(__ANDROID_VNDK__)
|
||||
if (base::ReadFileToString(vendor_animation_desc_path, &content)) {
|
||||
parse_success = parse_animation_desc(content, &batt_anim_);
|
||||
batt_anim_.set_resource_root(vendor_animation_root);
|
||||
} else {
|
||||
LOGW("Could not open animation description at %s\n", vendor_animation_desc_path);
|
||||
parse_success = false;
|
||||
}
|
||||
#else
|
||||
if (base::ReadFileToString(product_animation_desc_path, &content)) {
|
||||
parse_success = parse_animation_desc(content, &batt_anim_);
|
||||
batt_anim_.set_resource_root(product_animation_root);
|
||||
|
@ -634,17 +652,26 @@ void Charger::InitAnimation() {
|
|||
LOGW("Could not open animation description at %s\n", animation_desc_path);
|
||||
parse_success = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID_VNDK__)
|
||||
auto default_animation_root = vendor_default_animation_root;
|
||||
#else
|
||||
auto default_animation_root = system_animation_root;
|
||||
#endif
|
||||
|
||||
if (!parse_success) {
|
||||
LOGW("Could not parse animation description. Using default animation.\n");
|
||||
LOGW("Could not parse animation description. "
|
||||
"Using default animation with resources at %s\n",
|
||||
default_animation_root);
|
||||
batt_anim_ = BASE_ANIMATION;
|
||||
batt_anim_.animation_file.assign(system_animation_root + "charger/battery_scale.png"s);
|
||||
batt_anim_.animation_file.assign(default_animation_root + "charger/battery_scale.png"s);
|
||||
InitDefaultAnimationFrames();
|
||||
batt_anim_.frames = owned_frames_.data();
|
||||
batt_anim_.num_frames = owned_frames_.size();
|
||||
}
|
||||
if (batt_anim_.fail_file.empty()) {
|
||||
batt_anim_.fail_file.assign(system_animation_root + "charger/battery_fail.png"s);
|
||||
batt_anim_.fail_file.assign(default_animation_root + "charger/battery_fail.png"s);
|
||||
}
|
||||
|
||||
LOGV("Animation Description:\n");
|
||||
|
@ -685,9 +712,11 @@ void Charger::OnInit(struct healthd_config* config) {
|
|||
|
||||
ret = CreateDisplaySurface(batt_anim_.fail_file, &surf_unknown_);
|
||||
if (ret < 0) {
|
||||
#if !defined(__ANDROID_VNDK__)
|
||||
LOGE("Cannot load custom battery_fail image. Reverting to built in: %d\n", ret);
|
||||
ret = CreateDisplaySurface((system_animation_root + "charger/battery_fail.png"s).c_str(),
|
||||
&surf_unknown_);
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
LOGE("Cannot load built in battery_fail image\n");
|
||||
surf_unknown_ = NULL;
|
||||
|
|
Loading…
Reference in a new issue