charger: Use the same metrics as recovery to pick a density

Change-Id: Ieb046c493ca3d367cff570bd08d38c84c74e5fbd
diff --git a/charger/Android.mk b/charger/Android.mk
index 0e3b1df..f2bdde2 100644
--- a/charger/Android.mk
+++ b/charger/Android.mk
@@ -1,5 +1,19 @@
 LOCAL_PATH := $(call my-dir)
 
+# Set healthd_density to the density bucket of the device.
+healthd_density := unknown
+ifneq (,$(TARGET_RECOVERY_DENSITY))
+healthd_density := $(filter %dpi,$(TARGET_RECOVERY_DENSITY))
+else
+ifneq (,$(PRODUCT_AAPT_PREF_CONFIG))
+# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value.
+healthd_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG))
+else
+# Otherwise, use the default medium density.
+healthd_density := mdpi
+endif
+endif
+
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := healthd_board_cm.cpp
 LOCAL_MODULE := libhealthd.cm
@@ -20,7 +34,7 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := font_log.png
-LOCAL_SRC_FILES := fonts/$(PRODUCT_AAPT_PREF_CONFIG)/font_log.png
+LOCAL_SRC_FILES := fonts/$(healthd_density)/font_log.png
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)/res/images
@@ -42,7 +56,7 @@
 
 _img_modules :=
 _images :=
-$(foreach _img, $(call find-subdir-subdir-files, "images/$(PRODUCT_AAPT_PREF_CONFIG)", "*.png"), \
+$(foreach _img, $(call find-subdir-subdir-files, "images/$(healthd_density)", "*.png"), \
   $(eval $(call _add-charger-image,$(_img))))
 
 include $(CLEAR_VARS)