If you've ever noticed, even just for a fleeting moment, that the auto brightness on your Nexus 5 seemed to "glitch out"—you are not alone.
Several Nexus 5 owners, myself included, have complained of a seemingly random spike in auto brightness levels towards the high or low end of the spectrum. You might be using your Nexus in a dimly lit room when, all of a sudden, the screen jumps to full brightness for a couple of seconds before returning to normal.
I've even noticed the opposite outside, where my Nexus 5 randomly went dim for a brief period of time under bright sunlight.
As it turns out, these issues are due to a split-second misreading of the ambient light levels by the sensor that is assigned to monitor them.
The Nexus 5 has a light sensor that periodically checks the lux value of its surroundings. That data is then sent over to Android's auto brightness function so that your screen backlight can be adjusted accordingly. For some reason, these lux readings are occasionally incorrect, but auto brightness adjusts the phone's backlight as if they were true nonetheless.
Enter Nexus 5 Light Sensor Fix, an Xposed module by developer Eldar Abusalimov. This module seeks to fix the Nexus 5's auto brightness issues by intercepting the lux readings before they can be conveyed to the Android system. It then uses a weighted average of all the most recent lux values to filter out erroneous readings before passing the data on to the auto brightness function.
For instance, if your light sensor has been reading 1,000 lux for the last 15 minutes, but a value of 30,000 comes across suddenly, it replaces this high number with the previous reading before passing it along to the auto brightness function. If consecutive 30,000 lux readings come through (perhaps you've stepped outside), it then sends the new value.
From the Xposed Installer app, head into the Download section. From here, search Nexus 5 Light Sensor Fix and tap the top result. Hit Download, and then follow the prompts for installation.
Once installed, be sure to activate this module and reboot, and that's all there is to it.
The module does not provide an interface, as it works silently in the background. I've been using it for over a day now, and haven't noticed any brightness issues since. So give it a shot, and hopefully your random auto brightness spikes will be a thing of the past.