diff --git a/healthd/Android.mk b/healthd/Android.mk index 5cd5ce186..715c2ed79 100644 --- a/healthd/Android.mk +++ b/healthd/Android.mk @@ -36,7 +36,7 @@ endif LOCAL_C_INCLUDES := bootable/recovery -LOCAL_STATIC_LIBRARIES := libbatteryservice libbinder libminui libpixelflinger_static libpng libz libutils libstdc++ libcutils liblog libm libc +LOCAL_STATIC_LIBRARIES := libbatteryservice libbinder libminui libpng libz libutils libstdc++ libcutils liblog libm libc ifeq ($(strip $(BOARD_CHARGER_ENABLE_SUSPEND)),true) LOCAL_STATIC_LIBRARIES += libsuspend diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 33a179bf8..fc3ac67c4 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -81,7 +81,6 @@ struct key_state { }; struct frame { - const char *name; int disp_time; int min_capacity; bool level_only; @@ -119,42 +118,36 @@ struct charger { static struct frame batt_anim_frames[] = { { - .name = "charger/battery_0", .disp_time = 750, .min_capacity = 0, .level_only = false, .surface = NULL, }, { - .name = "charger/battery_1", .disp_time = 750, .min_capacity = 20, .level_only = false, .surface = NULL, }, { - .name = "charger/battery_2", .disp_time = 750, .min_capacity = 40, .level_only = false, .surface = NULL, }, { - .name = "charger/battery_3", .disp_time = 750, .min_capacity = 60, .level_only = false, .surface = NULL, }, { - .name = "charger/battery_4", .disp_time = 750, .min_capacity = 80, .level_only = true, .surface = NULL, }, { - .name = "charger/battery_5", .disp_time = 750, .min_capacity = BATTERY_FULL_THRESH, .level_only = false, @@ -188,8 +181,8 @@ static int64_t curr_time_ms(void) static void clear_screen(void) { gr_color(0, 0, 0, 255); - gr_fill(0, 0, gr_fb_width(), gr_fb_height()); -}; + gr_clear(); +} #define MAX_KLOG_WRITE_BUF_SZ 256 @@ -317,8 +310,8 @@ static void draw_battery(struct charger *charger) if (batt_anim->num_frames != 0) { draw_surface_centered(charger, frame->surface); - LOGV("drawing frame #%d name=%s min_cap=%d time=%d\n", - batt_anim->cur_frame, frame->name, frame->min_capacity, + LOGV("drawing frame #%d min_cap=%d time=%d\n", + batt_anim->cur_frame, frame->min_capacity, frame->disp_time); } } @@ -655,22 +648,27 @@ void healthd_mode_charger_init(struct healthd_config *config) ret = res_create_surface("charger/battery_fail", &charger->surf_unknown); if (ret < 0) { - LOGE("Cannot load image\n"); + LOGE("Cannot load battery_fail image\n"); charger->surf_unknown = NULL; } charger->batt_anim = &battery_animation; - for (i = 0; i < charger->batt_anim->num_frames; i++) { - struct frame *frame = &charger->batt_anim->frames[i]; - - ret = res_create_surface(frame->name, &frame->surface); - if (ret < 0) { - LOGE("Cannot load image %s\n", frame->name); - /* TODO: free the already allocated surfaces... */ - charger->batt_anim->num_frames = 0; - charger->batt_anim->num_cycles = 1; - break; + gr_surface* scale_frames; + int scale_count; + ret = res_create_multi_surface("charger/battery_scale", &scale_count, &scale_frames); + if (ret < 0) { + LOGE("Cannot load battery_scale image\n"); + charger->batt_anim->num_frames = 0; + charger->batt_anim->num_cycles = 1; + } else if (scale_count != charger->batt_anim->num_frames) { + LOGE("battery_scale image has unexpected frame count (%d, expected %d)\n", + scale_count, charger->batt_anim->num_frames); + charger->batt_anim->num_frames = 0; + charger->batt_anim->num_cycles = 1; + } else { + for (i = 0; i < charger->batt_anim->num_frames; i++) { + charger->batt_anim->frames[i].surface = scale_frames[i]; } } diff --git a/healthd/images/battery_0.png b/healthd/images/battery_0.png deleted file mode 100644 index 2347074b2..000000000 Binary files a/healthd/images/battery_0.png and /dev/null differ diff --git a/healthd/images/battery_1.png b/healthd/images/battery_1.png deleted file mode 100644 index cd34620ef..000000000 Binary files a/healthd/images/battery_1.png and /dev/null differ diff --git a/healthd/images/battery_2.png b/healthd/images/battery_2.png deleted file mode 100644 index 3e4095e8f..000000000 Binary files a/healthd/images/battery_2.png and /dev/null differ diff --git a/healthd/images/battery_3.png b/healthd/images/battery_3.png deleted file mode 100644 index 08c155125..000000000 Binary files a/healthd/images/battery_3.png and /dev/null differ diff --git a/healthd/images/battery_4.png b/healthd/images/battery_4.png deleted file mode 100644 index 3a678da09..000000000 Binary files a/healthd/images/battery_4.png and /dev/null differ diff --git a/healthd/images/battery_5.png b/healthd/images/battery_5.png deleted file mode 100644 index d8dc40e87..000000000 Binary files a/healthd/images/battery_5.png and /dev/null differ diff --git a/healthd/images/battery_charge.png b/healthd/images/battery_charge.png deleted file mode 100644 index b501933a0..000000000 Binary files a/healthd/images/battery_charge.png and /dev/null differ diff --git a/healthd/images/battery_fail.png b/healthd/images/battery_fail.png index 36fc254d0..aded88a00 100644 Binary files a/healthd/images/battery_fail.png and b/healthd/images/battery_fail.png differ diff --git a/healthd/images/battery_scale.png b/healthd/images/battery_scale.png new file mode 100644 index 000000000..2ae8f0fd7 Binary files /dev/null and b/healthd/images/battery_scale.png differ