FORUMS

Which OEM Would You Like to Help?

Most manufacturers have moments of greatness and moments of decadence, and in the past few years … more

Root T-Mobile S6/Edge on 5.1.1 Without Tripping Knox

If you purchase phones from a carrier, you may be no stranger to the difficulties … more

IonVR Coming Soon, HTC M9 Dev Edition Gets Android 5.1 – XDA TV

The HTC M9 Developer Edition has received Android 5.1. That and … more

Android 5.1.1 Omni ROM For Motorola Xoom

Back in Feb 2011, the Motorola Xoom became the first device to be sold with Android 3.0 … more

[ADB SHELL] Proximity Sensor Recalibration

2,969 posts
Thanks Meter: 6,108
 
By hawkerpaul, Recognized Contributor on 4th September 2014, 10:29 AM
Post Reply Subscribe to Thread Email Thread
I have written this shell script for those of you who are having problems with your GS4's screen not responding as expected during calls, such as the screen not turning off when you put your device to your ear, and not turning on when you take your device away from your ear etc.

Before running this script, the first thing to try would be to clean the proximity sensor itself. Dismantling the device and cleaning it is by far the best method. See this video.
However, an easier method is to blow compressed air down into the sensor (which is located under the silver earpiece at the top of the phone) and also clean it with a vacuum cleaner.


If you are still experiencing erratic behaviour even after doing this, then this adb shell utility may be of some help to you.
NOTE: You need a rooted device for this utility to work!!


Downoad Here

Download Here


Installation Instructions
1. Download ProxCal.sh from the above link
2. If downloaded via PC, copy ProxCal.sh onto your device.
Job done!


Script Execution
1. Open up an ADB Shell on your PC, or any sort of Terminal Emulator console session on your handset
2. If you are not at the root (#) prompt, enter su
3. Change directory to where you downloaded/copied ProxCal.sh eg. cd /sdcard/scripts
4. sh ProxCal.sh

You will then be presented with a straight forward menu of options:
ProxCal v1.00
-------------
Re-calibrate your handset's proximity sensor

Use this utility if you are having problems with your handset's
screen reacting normally during calls, even after cleaning
the sensor with compressed air etc.

Handset: GS4 (GT-I9505G)
Sensor: MAX88920

1. Show current values
2. Test run
3. Recalibrate proximity sensor
X. Exit
Enter choice:

1. Show current values
Shows the current values of proximity sensor related files on your device. The state value is the important one here. With nothing in front of the sensor, this should be as close to 0 as possible. A high value signifies a problem with the sensor, and that it requires cleaning and/or re-calibrating. Try performing this function as many times as you wish, placing your hand at varying distances from the sensor each time. See how the sensor reacts by examining the state value.
Current Proximity Sensor Values:
prox_cal : 0,60,45
state : 4
efs_prox_cal: *

2. Test run
Performs a test run. No files are altered during this process. The function only displays what it would have done on an actual recalibration run.
Re-calibrating GS4 proximity sensor.
(Test Mode)
Please wait.......
Recalculating efs offset...
Current offset: 0
Current state: 3
New offset: 3

Test Run Log
------------
echo 0 > /sys/devices/virtual/sensors/proximity_sensor/prox_cal
echo 1 > /sys/devices/virtual/sensors/proximity_sensor/prox_cal
mkdir -p /sdcard/tmp/ProxCal/BKP
cp /efs/prox_cal /sdcard/tmp/ProxCal/BKP/efs_prox_cal.2014-09-04--07-55
echo $\x3 > /efs/prox_cal
chown system:system /efs/prox_cal
chmod 644 /efs/prox_cal

Re-calibration test complete.

3. Recalibrate proximity sensor
This option actually recalibrates the sensor by updating the necessary files.
The proximity sensor will now be recalibrated.
Please ensure there is nothing in front of the sensor.
Proceed? (Y/N) y
y
Re-calibrating GS4 proximity sensor.
Please wait.......
Recalculating efs offset...
Current offset: 0
Current state: 3
/efs/prox_cal backup created:
/sdcard/tmp/ProxCal/BKP/efs_prox_cal.2014-09-04--08-01
New offset: 3
Re-calibration complete.
Backups
A backup of /efs/prox_cal is performed during an actual run (menu option 3)
Backups of this file are made into /sdcard/tmp/ProxCal/BKP
A backup is made on a date/time basis. Eg. efs_prox_cal.2014-09-04--07-55
Should you need to restore a backed up file, then type the following at and adb shell # prompt:
cd /sdcard/tmp/ProxCal/BKP
cp efs_prox_cal.[date-stamp] /efs/prox_cal


X. Exit
Exits the shell script and returns you back to a # prompt.
If the sensor was calibrated you will get the following message:
Your proximity sensor has been re-calibrated.
Please reboot your GS4 then re-run
this utility to check the new values.
Pay particular attention to the 'state' value.
When nothing is close to the sensor, this should
be a very low value (the closer to 0 the better)

** Please reboot your GS4 ***
proxcal.sh completed successfully.

Automatic Script Execution
The script can be called to automatically calibrate the sensor without any further user interaction.
This is done by including the auto parameter.
ie:
sh ProxCal.sh auto
This is useful if you want to automatically recalibrate the sensor on each boot using init.d scripts.


Credits
This script merely automates the tasks that I found on the internet which recalibrates the sensor. Examples:
XDA thread: Proximity Sensor Bug Fixed, .Screen turns off during call.ISSUE FIXED by @Ammar Saood
Android Legend post
CM thread on Reddit
CM Forum thread
Recalibration app on the Play Store, suggested in above thread
Full credit goes to these guys.
Last edited by hawkerpaul; 7th January 2015 at 01:14 PM.
The Following 8 Users Say Thank You to hawkerpaul For This Useful Post: [ View ]
 
 
4th September 2014, 10:30 AM |#2  
hawkerpaul's Avatar
OP Recognized Contributor
Flag UK
Thanks Meter: 6,108
 
Donate to Me
More
*** Reserved 1 ***
4th September 2014, 10:30 AM |#3  
hawkerpaul's Avatar
OP Recognized Contributor
Flag UK
Thanks Meter: 6,108
 
Donate to Me
More
*** Reserved 2 ***
4th September 2014, 12:59 PM |#4  
Senior Member
Thanks Meter: 67
 
More
Excellent job, made it so easy its unbelievable!!

Many thanks
The Following User Says Thank You to UniqueFreak For This Useful Post: [ View ]
30th April 2015, 05:22 PM |#5  
0kti's Avatar
Senior Member
Thanks Meter: 139
 
More
Works great

Send from my phone
21st May 2015, 02:33 PM |#6  
Senior Member
Thanks Meter: 17
 
More
Why do people love crappy file hosts? There are two download buttons, one is a phishing attack, the other is malicious download. Why not use pastebin?
Last edited by sbcontt; 21st May 2015 at 02:35 PM.
21st May 2015, 10:30 PM |#7  
magnamentis's Avatar
Senior Member
Flag Marbella
Thanks Meter: 2,707
 
More
Quote:
Originally Posted by sbcontt

Why do people love crappy file hosts? There are two download buttons, one is a phishing attack, the other is malicious download. Why not use pastebin?

good questions. can be very annoying while the problem for me only exists on mobile devices. i recommend to download stuff on your computer and use USB OTG to tranfer. of course there is ADB and other means of transfer but noting is faster and more reliable for me than an USB stick with sufficient memory and dual ports one micro USB and USB A on the opposite end. those things have gotten very cheap lately.
Post Reply Subscribe to Thread

Tags
hawker's threads
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes