[android] Disable Proximity Sensor during call

I dropped my phone and looks like my proximity sensor no longer works reliably. It returns Near all the time. The problem is, the display turns off during call and I wont be able to use the number pad to enter pin or conference another call, or even disconnect the call. I found the Power button disconnect option in Accessibility settings and uses that now.

I tried to create an app that tries to obtain a full wakelock when a call is received hoping that it will keep the display on.

  • Created a broadcast receiver that invokes a service when the phone state changes to OFFHOOK

  • The service acquires a full wakelock and releases it only when phone state is IDLE.

But still, proximity sensor turns the display off. I used the isHeld() method to make sure that the lock is acquired. I used PowerManager's isScreenOn() method and it returned true even when the screen was off during the call. I tried to obtain the wakelocks every two second in a loop for testing, still the display won't come up.

I'm using a Nexus 5 Android version 4.4.4

Can anyone suggest an idea to override the proximity sensor behaviour? A root-required option is also fine.

Thanks!

The answer is


If you have LineageOS 7.1.2 (and have root), try this solution from XDA.


After having tried all the solutions proposed here, none of which worked for my Nexus 4 (mako), I found one on XDA that solves the problem with the Android dialer (but not with other apps). Basically I downloaded a recompiled version of the Dialer.apk file, which simply ignores the proximity sensor and behaves in the same way as the stock dialer app does.

Rename /system/priv-app/Dialer/Dialer.apk to something, then place the downloaded file to that folder. After reboot, I had to install the new dialer manually (simply by clicking on it). So now the original app is replaced, and the calls should be handled by this new one.

[Downside: the new way to answer a call is by pulling down the status bar and clicking 'Answer' (or 'Dismiss'), the usual slider is missing. Also, you'll need to repeat this every time your Android updates to a newer version.]


After trying a whole bunch of fixes including:

  • Phone app's menu option (my phone did not have a option to disable)
  • Proximity Screen Off Lite (did not work)
  • Xposed Framework with sensor disabler (works till phone is rebooted or app updates)
  • Macrodroid macro (Macrodroid does not run on my phone for some reason)
  • put some tin foil in front of it?(i don't know what i was thinking)

Here is My fix: I figured you cannot break it more so I opened up my phone and removed the proximity sensor all together from the motherboard. The sensor tester app now shows "no_value" where it use to give "Distance: 0" and my screen no longer goes black after dialing. Please note I can only confirm this working on a Samsung I8190 Galaxy S III mini with CM MOD 5.1.1. Here is a picture of the device i removed: prox sensor I have removed it using a SMD solder station's heat gun at 400 degrees, some tweezers and flux.But a sharp hobby knife might work too.


I also had problem with proximity sensor (I shattered screen in that region on my Nexus 6, Android Marshmallow) and none of proposed solutions / third party apps worked when I tried to disable proximity sensor. What worked for me was to calibrate the sensor using Proximity Sensor Reset/Repair. You have to follow the instruction in app (cover sensor and uncover it) and then restart your phone. Although my sensor is no longer behind the glass, it still showed slightly different results when covered / uncovered and recalibration did the job.

What I tried and didn't work? Proximity Screen Off Lite, Macrodroid and KinScreen.

What would've I tried had it still not worked?[XPOSED] Sensor Disabler, but it requires you to be rooted and have Xposed Framework, so I'm really glad I've found the easier way.


Unfortunately my proximity sensor doesn't work, too (always returns 0.0 cm). I found the way, but not easy one: you need to root your phone, install XPOSED framework and Sensor Disabler (https://play.google.com/store/apps/details?id=com.mrchandler.disableprox). You can mock proximity sensor return value in the app. (e.g. always return 2.0 cm). Then your display will be always on during the call.


Some more answers from the interwebs: "fix" the sensor (glue screen back on more, or clean it with alcohol, or blow it off with air sent through the headphone jack, tap on it, clean the screen, etc.).

Adjust (after some finding) setting in the "phone" app to disable proximity sensor use. No such setting in mine, that I could find. Proximity Screen Off Lite also didn't work, nor macrodroid.

Another option: root your phone and remove some files:

From root explorer or similar program delete these folders and file
/data/system/sensors
/data/misc/sensors
/persist/sensors/sns.reg

Or if you're truly desperate I suppose a totally different dialer system like TextNow or google hangouts dialer :|


I have been researching this for a while, tested and wrote apps.

If you have no option in Settings ? Phone ? Use proximity sensor, then the only choice, seem to be to disable or modify its settings in rooted devices.

Also consider, that if you plug the headset, the screen will remain on :D


I found my solution here. Basically use an app called Proximity Screen Off Lite and set it as below:

  1. Screen On/Off Modes Check "Cover and hold to turn on Screen" Timeout: 1 second Check "Disable Accidentla Lock" Timeout: 4 seconds

  2. All settings Check "Disable in Lanscape" Check "Lock phone on screen ON"

  3. [Advanced] Configure Sensore Select sensor: Proximity sensor Value when sensor covered: 0 Value when sensor un-covered: 1


edit build.prop in folder /system if below line is exist change the value and if not exist add this line and save.(device must be rooted)

ro.lge.proximity.delay=25
mot.proximity.delay=25