Default [Q] compile charger.c to enable auto boot in aosp?

Hi guys, I want my Nexus 7 to auto boot when its battery level is higher than 20% in off charge mode. I edite the charger.c file in system/core/charger directory, in the event_loop() function, like this:

int batt_cap = get_battery_capacity(charger);
if (batt_cap > 20) {
android_reboot(ANDROID_RB_RESTART, 0, 0);

It never worked. but it works fine when i build and flash the bootimage on a Nexus 10. I guess there must be some differences between their makefiles. I try my best to solve it, but it seems like that the charger file is overwritten somewhere else in Nexus 7. I need some help, any info will be appreciate!