Can't you get levelchange events even when the battery is charging?  I don't see any check about whether we're charging or not.