We are developing on i.MX8MQ and Android 8.1 BSP. We have battery and need charger manager.
We have implemented the battery/charger drivers and the healthd daemon is working well. Android shows correct battery capacity and charging/discharging information. The question is if we power on the unit by plugging in the USB-C adapter it should boot into “charger” mode that shows a big battery icon on screen and plays charging animation. The method is setting “androidboot.mode=charger” in uboot but when I did this I didn’t see that the “charger” service is running. I can manually start the charger service by the following commands on the console:
It then starts the battery animation on the screen that is corresponding to the real battery level, and with the following logs (see attachments):
[ 19.315741] charger:
[ 19.318054] charger: *************** LAST KMSG ***************
[ 19.323904] charger:
[ 19.326273] charger: last_kmsg not found. Cold reset?
[ 19.331353] charger:
[ 19.333634] charger: ************* END LAST KMSG *************
[ 19.339481] charger:
[ 19.341763] charger: --------------- STARTING CHARGER MODE ---------------
[ 19.383070] charger: Could not open animation description at /res/values/charger/animation.txt
[ 19.391753] charger: Could not parse animation description. Using default animation.
So the key is to automatically start the “charger” service when “androidboot.mode=charger” is set. I tried to modify device/fsl/evk_8mq/init.rc and system/core/rootdir/init.rc, but it didn’t work. In system/core/init/init.cpp it triggers the “charger” event when boot mode is charger but it looks not working:
Can you help have a look on this?
Attached are a log that including the manual starting of the charger service, and a picture when the charger service is running.
It looks that we just need a simple setting in init.rc that starts the charger service if boot mode is charger. I did the following changes in init.rc, but it doesn’t work:
diff --git a/evk_8mq/init.rc b/evk_8mq/init.rc
index 3309b05..ebbd1a9 100644
@@ -138,6 +138,17 @@ on early-boot
# Dectect DSF streams when scanning media
setprop ro.FSL_DSF_PARSER 1
+ # Enable Power modes and set the CPU Freq Sampling rates
+ write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "powersave"
+ write /sys/devices/system/cpu/cpufreq/ondemand/up_threshold 90
+ write /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate 50000
+ write /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy 1
+ write /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor 4
+ write /sys/devices/system/cpu/cpu1/online 0
+ write /sys/devices/system/cpu/cpu2/online 0
+ write /sys/devices/system/cpu/cpu3/online 0
service wpa_supplicant /vendor/bin/hw/wpa_supplicant \
-ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf -N \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
@@ -223,6 +234,9 @@ service g3d /vendor/bin/g3d
+service charger /sbin/charger
+ class charger