Post Reply

[MOD][XPOSED][N5] Ambient Light Sensor fix for Nexus 5

OP abusalimov

14th April 2014, 03:16 PM   |  #1  
OP Member
Flag St. Petersburg
Thanks Meter: 63
 
56 posts
Join Date:Joined: Mar 2014
Donate to Me
More
This module aims to fix Nexus 5 ambient light sensor issues leading to random auto-brightness spikes under certain lighting.

The issue
Sometimes the 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. These random spikes happen when you hold a phone at certain angles and depend on light bulbs used in a room.

The solution
The fix is implemented as an Xposed module.

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

Installation
  1. Download and install Xposed framework
  2. Then install Nexus 5 Light Sensor fix module and activate it
  3. Reboot
Usage
The module provides no user interface, nor it runs any services in a background. It only injects a proxy method to the implementation of Android sensors API. You won't be able to notice it in the main menu or in a task manager. Think of it as a patch that can be turned on and off through Xposed installer.

Source
The mod is open source (with permissive MIT licence), the source code is available on my GitHub.

Thanks
  • @rovo89 for his Xposed framework
  • @n3ocort3x and @wantabe for the initial attention and for kicking me up to finally create a new thread
  • and you (the community) for your feedback
Last edited by abusalimov; 16th May 2014 at 01:53 AM.
The Following 20 Users Say Thank You to abusalimov For This Useful Post: [ View ]
14th April 2014, 03:21 PM   |  #2  
OP Member
Flag St. Petersburg
Thanks Meter: 63
 
56 posts
Join Date:Joined: Mar 2014
Donate to Me
More
More on the issue

Two major issues with the Nexus 5 ambient light sensor (original module announcement)
Quote:
Originally Posted by Palmadores

1. The sensor reading often jumps to 30000lx momentarily, (measured using Lux Dash in Debug mode), and so the phone blinds you for while. This happens in a repeatable fashion when you hold the phone at certain angles. Try it yourself.
2. The N5 reads zero lux even in moderate/dim light, while my old N4 still reads around 10 lux.

Quote:
Originally Posted by exorz

Using the Lux app debug mode I rotated the phone while in a room lit with incandescent bulbs and one lit with daylight. When rotating the phone I sometimes see a spike of 30000 lx but more importantly the sensor drops to 0 even though there is plenty of ambient light. During daylight I don't see the 30000 lx spikes but I still see the sensor dropping to 0 when there's plenty of ambient light.

Is the Auto-Brightness Functionality wonky on the Nexus5?
Quote:
Originally Posted by Aria807

I think it may be bugged with Halogen lighting (correct me if I'm wrong). My home is ~ 18 years old, and we have some bulbs that have not been changed yet (yellow). Sometimes when I use my N5 under those lighting, the sensors go whack and don't register properly picking up 0lx, then spike up to 30000lx. Once I move to areas in the house with newer bulbs, the sensors work normal, picking up the right readings.

The Following 3 Users Say Thank You to abusalimov For This Useful Post: [ View ]
14th April 2014, 06:04 PM   |  #3  
Senior Member
Colorado Springs
Thanks Meter: 164
 
427 posts
Join Date:Joined: Mar 2011
More
Well done! Auto-brightness accuracy is much improved indoors! Appreciate your work on this!
Last edited by wantabe; 14th April 2014 at 06:08 PM.
14th April 2014, 07:26 PM   |  #4  
augoza's Avatar
Senior Member
Thanks Meter: 18
 
363 posts
Join Date:Joined: Feb 2010
Do I need to disable the modules if I dirty flash a new Carbon nightly? Or is that not necessary
Last edited by augoza; 14th April 2014 at 07:26 PM. Reason: words
14th April 2014, 07:51 PM   |  #5  
OP Member
Flag St. Petersburg
Thanks Meter: 63
 
56 posts
Join Date:Joined: Mar 2014
Donate to Me
More
Quote:
Originally Posted by augoza

Do I need to disable the modules if I dirty flash a new Carbon nightly? Or is that not necessary

I'm not sure, cause I use stock ROM, but I guess there is no need to disable it. As I can see from Carbon sources, related parts of code was not modified at all. To be sure, please ask ROM developers or other Xposed guys.
15th April 2014, 09:20 PM   |  #6  
ddloco's Avatar
Senior Member
Flag Rialto,Ca
Thanks Meter: 123
 
495 posts
Join Date:Joined: Jun 2010
More
1.1 update won't install on nexus 5 signature mismatch

Sent from my Nexus 5 using Tapatalk
16th April 2014, 03:10 AM   |  #7  
OP Member
Flag St. Petersburg
Thanks Meter: 63
 
56 posts
Join Date:Joined: Mar 2014
Donate to Me
More
Quote:
Originally Posted by ddloco

1.1 update won't install on nexus 5 signature mismatch

I know, this is my fault and this is actually stated in the module description. Please remove version 1.0 and install 1.1 from scratch.
18th April 2014, 12:28 AM   |  #8  
Senior Member
Flag Suffolk
Thanks Meter: 21
 
432 posts
Join Date:Joined: Aug 2010
More
Still coming up very bright compared to Lux. Battery drain WILL be an issue.
18th April 2014, 12:48 AM   |  #9  
OP Member
Flag St. Petersburg
Thanks Meter: 63
 
56 posts
Join Date:Joined: Mar 2014
Donate to Me
More
Quote:
Originally Posted by mcnob

Still coming up very bright compared to Lux. Battery drain WILL be an issue.

The mod only removes random spikes reported by sensors. It does not affect an algo used by stock auto-brightness (any auto-broghtness is basically a function that maps a given input value from the sensors to the screen brightness; the mod just removes some trash from the input).

AFAIK the stock auto-brightness is configured through framework-res (google: config_autoBrightnessLcdBacklightValues, e.g. http://forum.xda-developers.com/show....php?t=2616914). Probably there is some app/mod for tweaking these options.
18th April 2014, 04:43 AM   |  #10  
Senior Member
Thanks Meter: 67
 
393 posts
Join Date:Joined: Oct 2010
More
Wonder if custom ROMs like Omni and CM already have the fix baked in?

Post Reply Subscribe to Thread

Tags
auto-brightness, hal, hammerhead, light sensor, nexus 5
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Xposed Framework Modules by ThreadRank