Sometimes Nexus 5 light sensor goes crazy and reports 30000 lux even in a dim light because of what auto-brightness attempts to blind you in a moment. This happens when you hold a phone at certain angles and depends on light bulbs used in a room.

This mod is a filter inserted near a point where native HAL communicates to Android framework. It intercepts all sensor readings and replaces abnormal 30k lux (and 0 lux following 30k) with an averaged value from a sliding window. This affects any process that use Android sensors interface including system_process, so that default Android auto-brightness works fine too (no need to use apps like Lux Dash to workaround the issue).