Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,731,985 Members 40,897 Now Online
XDA Developers Android and Mobile Development Forum

[APP] DHD Proximity Sensor Recalibrator 1.10 (26-Sep-12)

Tip us?
 
leppie
Old
(Last edited by leppie; 26th September 2012 at 07:22 PM.) Reason: New release
#1  
Senior Member - OP
Thanks Meter 281
Posts: 565
Join Date: Dec 2008
Location: Cape Town
Lightbulb [APP] DHD Proximity Sensor Recalibrator 1.10 (26-Sep-12)

Due to many DHD's being incorrectly factory calibrated with regards to the proximity sensor, I wrote a little app to allow one to change the calibration on-the-fly and persist it over reboots.

This app is specifically for those experience issues with the proximity sensor.

Well known symptoms include the following:

- Screen fails to turn off when holding to face on a call
- Screen does turn off when holding to face on a call, but fails to come back on, requiring taking out the battery

These problems are common in custom kernels/ROM's. HTC has addressed this issue however in their kernels from 1.32 onwards, but have failed to provide an acceptable solution for some.

I present DHD Proximity Sensor Recalibrator. Download from the attachments below.

Here are some screenshots:





Usage:

1. Install app.
2. Run app.
3. Press the toggle button to start monitoring.
4. Move your finger over the proximity sensor (the little LED next to the front facing speaker).
5. Adjust the High and Low threshold values to your liking.

For those whose screen does not turn off, it probably means the factory values are set too high.

For those whose screen does not turn back on, it probably means the factory values are set too low.

The setting will be saved, and will be applied every time you reboot your phone. No need to go through any of the steps unless you want to change the calibration. When the settings are applied at boot time, you will get a toasty indicating the calibration value applied.

Possible calibration procedure:

1. Put both values high (will show FAR).
2. Cover sensor with finger.
3. Lower High threshold till it says NEAR.
4. Lower Low threshold by a notch or 2.
5. Test behavior

Removal:

If for whatever reason you find the application does not work, or you do not want it anymore, just uninstall the app, and reboot. Your original factory settings will be in effect again. This application does not modify your system. It might require root rights.

Source code repo:

https://github.com/leppie/DHD-Proxim...r-Recalibrator

Known issues:

- Permissions have changed in CM7 RC2, preventing the application from working correctly. The application will need root. Will investigate how to add that, if needed.

- Some reports that the Gingerbread leaked ROM is not working.

Gingerbread/newer kernel update:

Due to changes in the source code made by HTC to overcome this issue in the kernel, this app will probably not run correctly.

There are 2 problems (as found from latest CM kernel source):

1. When the kernel recalibrates the proximity on the fly, it fails to update the internal structures in the kernel. This makes the kernel not report correct values. I have made a kernel patch to rectify the issue. Please ask your kernel developer to apply the following changes: https://github.com/leppie/htc-kernel...61bcb1b8498d8a

2. Secondly and more seriously, depending on the initial calibrated value (if LT is greater or equal to 0x50), the kernel will kick off a polling thread. This will overwrite the changes made by this app, as soon as you use the proximity sensor for the first time (eg the phone). Afterwards you can apply the values from this app again, and from my experiments the value sticks then (up to the next reboot). Unfortunately, this polling mechanism fixes the issue for most users, so it cannot just be disabled. It is easy to disable in the kernel source however, but will probably break most other people's proximity behavior if they do not have this app installed. As you can see, there is not much I can do about this. The best option is to compile your own kernel.

Manual cleaning of the sensor:

After time the sensor will become dirty from the environment. See http://forum.xda-developers.com/show...&postcount=357 for details on cleaning it.

Please report any bug and suggestions.

Cheers

Revisions:

1.0

- Initial public release

1.1

- Replaced toggle button with normal one to resolve known issue

1.2

- Removed amount from Paypal, feel free to donate whatever you feel like. Beers are around US$2 here.

1.3

- Add some better handling when something goes not as planned (likely on non-DHD hardware).

1.4

- Added some alert dialogs to aid with the problems people are experiencing. (In case of error, please note both the title text, and the first few lines in the text of the alert dialog.)

1.5

- Only for CM7 users. Use nightly 92 or above. This includes the necessary kernel patch.
- Should work on SENSE with custom kernel. Apply this patch (or ask your kernel 'builder' to do so).
- Removed Beer button due to crappy paypal policy...

1.6

- Added support for calling 'su' when permissions are wrong. Thanks VampireWicked.

1.7

- Correct boot permissions for ICS

1.8

- Prevent app from being installed on SD card (which will cause issues) (thanks makarand14)

1.9

- Fix issues with sensor listener not getting disabled (thanks Roberto_Lim and Stoffl_)

1.10

- Fix issues with slow process manager in Android, notably in BlackOut ROM (thanks tonylee000 and others)

Supported kernels:

- CM7 nightly #92 or later
- LorDModUE V2.6 or later
The Following 152 Users Say Thank You to leppie For This Useful Post: [ Click to Expand ]
 
gamesawy
Old
#2  
gamesawy's Avatar
Member
Thanks Meter 0
Posts: 45
Join Date: Jun 2008
Location: Cairo
great .. gona try this now ..!!
 
jkoljo
Old
#3  
jkoljo's Avatar
Recognized Developer
Thanks Meter 2523
Posts: 3,377
Join Date: Jun 2009
Location: Tampere

 
DONATE TO ME
Simply works. Great job!
SE X1 → Garmin-Asus A10 → HTC Desire HD → Galaxy Nexus → Nexus 4 → Nexus 5
 
sahirhussain
Old
#4  
sahirhussain's Avatar
Member
Thanks Meter 2
Posts: 66
Join Date: Jul 2010
Quote:
Originally Posted by jkoljo View Post
Simply works. Great job!
how do you get it to work? when i move my finger over the sensor nothing happens. it always says near?
Proud owner of a Dell Streak-HTC Desire HD-HTC HD7
 
kramerty88
Old
#5  
kramerty88's Avatar
Senior Member
Thanks Meter 9
Posts: 140
Join Date: Feb 2010
Location: Groningen
Them you have to change the settings. The app works great btw!

Sent from my Desire HD using XDA App
Device: Desire HD / Samsung Galaxy S II
Rom: Cyanogenmod 7 Nightly #xx
Kernel: Cyanogen OC/UV 1.51Ghz / Codeworkx unmodified CM7
Theme: Honeycomb theme for CM7
Radio: 12.28e.60.140f_26.04.02.17_M2_SF / Codeworkx modified KG3

Past: Samsung GalaxyS i9000 | HTC HD2 | HTC Touch | Nokia N95 | Nokia 6700 | Samsung E900 | Samsung D500 | Sagem MC920
 
leppie
Old
#6  
Senior Member - OP
Thanks Meter 281
Posts: 565
Join Date: Dec 2008
Location: Cape Town
If it says near, make your values higher.

In a bad case, keep your finger over the sensor, and then increase the low threshold till it changes.

Then work from the settings there.
The Following 2 Users Say Thank You to leppie For This Useful Post: [ Click to Expand ]
 
Stuclint
Old
#7  
Stuclint's Avatar
Member
Thanks Meter 1
Posts: 59
Join Date: Nov 2006
Location: Berlin
Talking Awesome!

This is my favorite app to date! I couldn't use any Cyanogen mod because of this issue. (My device was not waking up after the first phone call) Everything else worked fine.

Now I can use my phone as a phone too!

Would recommend to any O2 Germany DHD user having similar issues.
Device: Desire HD
ROM: always changing
Headset: Plantronics 590a
BT Speakers: Logitech Pure-fi Mobile
The Following User Says Thank You to Stuclint For This Useful Post: [ Click to Expand ]
 
Pwoap
Old
#8  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Jan 2011
Quote:
Originally Posted by Stuclint View Post
This is my favorite app to date! I couldn't use any Cyanogen mod because of this issue. (My device was not waking up after the first phone call) Everything else worked fine.

Now I can use my phone as a phone too!

Would recommend to any O2 Germany DHD user having similar issues.
Yep i'm O2 Germany DHD user too and had this issue.
This is really a life-saver app, thanks!
You are awesome, leppie!
 
coolacrille
Old
#9  
coolacrille's Avatar
Senior Member
Thanks Meter 91
Posts: 520
Join Date: Dec 2010
Location: Skövde
I didn't even have a problem with my sensor, but I tuned it a little bit anyway. Awesome. THANK YOU
 
burkow
Old
#10  
Junior Member
Thanks Meter 0
Posts: 1
Join Date: Feb 2011
Thanks man! Helped me a lot!

Burkow

Tags
proximitysensor
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes