How to Disable proximity sensor in Nougat

Search This thread

Shimakaze

Senior Member
Aug 21, 2012
74
20
Vancouver
I've disabled the proximity sensor at the framework level. This means that when any app queries the system for the proximity sensor capability, it will get back a reply saying that the phone does not have a proximity sensor. The AOSP Dialer will not acquire the screen-off wake lock if the device reports no proximity sensor. In fact, the Google Phone app does the same thing, and so this fix will allow you to use Google's dialer as well. This is useful because I want the Duo integration in the dialer, which is missing in the AOSP version. In simpler terms, this fix will prevent any app from turning off the screen if it is triggered by the proximity sensor.

This might break apps that depend on the existence of the proximity sensor to work. I have not encountered any issues so far, but use at your own risk.

Please note that I've only tested this on the LineageOS 20171214 nightly for Nexus 4, and not on any other device; however, I don't see why this fix should not work elsewhere.

The fix is the attached services.jar. Source code is up to date as of 2017-12-18. You will need to replace the original jar at /system/framework/services.jar. Make sure you backup the original before proceeding. The steps to apply the fix is similar to applying the Dialer.apk; the only difference is the file path. You must wipe dalvik cache and cache from recovery after the replacement in order for the fix to take effect.

If you wish to do your own build of the services.jar, the diff is a one-liner that you can see at https://github.com/earthgrazer/andr...mmit/563a2c6c2267f667b4f05f0bce1a1e83892baeb5
 

Attachments

  • services.jar
    3 MB · Views: 340
Last edited:

dhmerino

New member
Dec 22, 2017
1
1
Hi Shimakaze,

I tried your solution in a BQ Aquaris X5 (paella) with LineageOS 14.1, nightly 20171215, and my phone is stuck in the startup animation (the one with the circles moving from right to left over a curve). Good thing I kept the backup from the original services.jar.

Thank you for your work and your contribution nevertheless.
 
  • Like
Reactions: MrHaroldA

TKMankindv2

Member
Dec 28, 2017
7
0
If you wish to do your own build of the services.jar, the diff is a one-liner that you can see at [external link]

Hello,

Thanks for this information, it does seem the right way to do it. But... how to compile a specific part of the android code, here android_frameworks_base ?

I mean, despite my lack of knowledge in development, there are multiple wikis who explain how to set up a build environment for LineageOS compilation, git interaction etc. and so I have a Xubuntu LTS on Virtualbox to do so. But there is nothing about compiling only android_frameworks_base or others. Each time I try something (make, mmm, etc.), there are always errors. Well, make services works, but give no files.

I can launch a full compilation of my actual fork of LineageOS with your correction as the environment is created for that, but I bet it will be SLIGHTLY longer :D than compile only android_frameworks_base, or a module from it.

Can you explain how you compile it ?

EDIT : Ok... I think that I need to build the full OS BEFORE trying to get one module only, for dependencies sake. Am I right ?
 
Last edited:

RomeoRoot

Member
Jan 29, 2018
6
0
Fix for Samsung S7? (SM_G930F)

Hi all,

Tried this on a Pixel and worked perfectly.
However this doesn't work for my S7!

I read on another forum that this is because on the S7 the app only replaces the front end not the back end so the proximity sensor remains unchanged :(

Does anyone know of any dialers for the S7 that disable the proximity sensor/keep the screen on permanently while on calls?

Thank you!
 

TKMankindv2

Member
Dec 28, 2017
7
0
Hello,

Ok, so I tried the method from Shimakaze in the post #61 and it didn't work. I think that it is my fault, as I use a LineageOS+microG system but there is no source code available to download and modify/compile, only a Docker app who don't seem to work on my virtual machine (I don't understand how Docker work, to be honest... it is so confusing...). So I tried with a pure LineageOS version as the base, coming from the same day of the microG release, but the result bricked my phone. TRWP, reinstall, fine again.

Only way remaining, modify Dialer.apk directly. Chances that a LineageOS+microG has a different Dialer.apk than a pure version is rather low, so I modified it from my pure LineageOS version and applied it on my phone (I first renamed the original Dialer.apk, restarted the phone, then install my Dialer.apk like any other apps because I didn't use Minimal ADB (check post #71)) = it works. Well, the FIRST launch did crash -maybe because of the lack of authorizations that I granted after that- but it works fine since then. Now, I know how create my own Dialer.apk at will.

Still, I don't use the same modifications than the post #17 or the linked #253.

Well, it is VERY close of #17. In the ProximitySensor.java file, he added a variable and modify an IF condition in the class constructor, to make sure that the new variable disable the "wake lock" (the IF condition define a variable called mProximityWaveLock. If mProximityWaveLock remains null at all times, the screen will remain on). It does sound more professional, at it is possible to restore at will.

For my case, as it is necessary to modify the file anyway at each update of all the source code, I removed the condition itself and only keep the declaration of mProximityWaveLock at null, like in this image :

https://i.imgur.com/MluwOKP.png

It is less professional, but easier. I just had to remove 5 lines :) Of course, the Power button will shutdown or wake up the screen at will without any effects on the call (don't forget to remove the "Stop call with Power button" function in system parameters).

I share here the Dialer.apk I have, but it is for LineageOS 14.1 (7.1.2_r36, NJH47F), not for any 8.x version. And obviously, I have only tested on my old Samsung Galaxy S4 (i9505 / jfltexx) who don't have any LineageOS 15.x so I can't do more. And no clue on other devices :

http://dl.free.fr/qXLmhzAtW

EDIT : Oups, so there is a latency to each post created. I didn't know :D

EDIT 2 : I don't abandon the idea of using post #61. Disable it at a system level would be so much more convenient. I just have to find a way...
 
Last edited:

bilatche

Senior Member
Dec 7, 2010
382
47
Thanks I will try this apk.
I'm on nougat on my 9505.
Just have to install the apk without anything else?
 

TKMankindv2

Member
Dec 28, 2017
7
0
Thanks I will try this apk.
I'm on nougat on my 9505.
Just have to install the apk without anything else?

In all cases, you have to rename the old Dialer to make it powerless and so avoid any problems (and be able to restore if needed). It is located in /system/priv-apps/Dialer. Rename as Dialer.bak or anything else, as long that you don't delete it.

For the rest :

*** If you are NOT using Minimal ADB (available in XDA) or the official ADB (too heavy, I don't recommend it), you will have to install it as any other application/dialer. Because if you try to just place the new file in the same location than the old one, it won't work, period. So first, rename the old one, then reboot (the old dialer should disappear from shortcut bar and apps list), then install the new one and configure.

*** If you are willing to install Minimal ADB, then you can do better : rename the old file (DON'T reboot for the moment), activate the USB debugging in the device (System parameters > Developper Options), make sure that root access are given to "Applications and ADB", and then you can use the method described in post #15, and now you can reboot (using "ADB reboot" command). The new file will take the place of the old one (that you have to rename anyway) and it will work this time. Lastly, disable USB debugging :)

In both cases, the first start will crash the app, because of the authorizations. Once granted, it will be good.
 
Last edited:

Shimakaze

Senior Member
Aug 21, 2012
74
20
Vancouver
Hello,

Ok, so I tried the method from Shimakaze in the post #61 and it didn't work. I think that it is my fault, as I use a LineageOS+microG system but there is no source code available to download and modify/compile, only a Docker app who don't seem to work on my virtual machine (I don't understand how Docker work, to be honest... it is so confusing...). So I tried with a pure LineageOS version as the base, coming from the same day of the microG release, but the result bricked my phone. TRWP, reinstall, fine again.

Sorry, I haven't checked the forums in a long while.

I've never heard of LineageOS+microG before, but taking a quick look, it seems like the Docker image will do a full build when run. Think of Docker images like recipes for a VM crafted to do very specific things. In this case, the image is created from an Ubuntu base image, and contains bash scripts that will essentially do all the steps required to perform a full LineageOS build with microG.

One of the first steps to perform a LOS build is to pull remote sources, as you can see here at this line in the script: https://github.com/lineageos4microg...1af491962552b9cd236cb271128c/src/build.sh#L34. You can modify that line to point to your fork of the remote resource manifest. In your fork of the manifest, you would want to modify the "frameworks/base" project to be sourced from your own fork that has the proximity sensor fix. By doing this, when you run the Docker image, it'll build LineageOS+microG from all the default sources, plus your modified "frameworks/base" code.

All of this of course hinges on you getting Docker to work, which is beyond the scope of my post. There are plenty of resources that you can google to help you with that. Good luck!
 

bilatche

Senior Member
Dec 7, 2010
382
47
Hi everyone

Does an Oreo update if this moded apk dialer exist?

When will if be released?

Thanks.
 

Rhaegar85

Senior Member
Oct 26, 2014
128
27
Xiaomi Poco X3 Pro
Just out of curiousity, what was the reason to comment out the ALTER TABLE line in DialerDatabaseHelper.java?

I've attached my version of the fix that I've been running since CM13, now recompiled for CM14.1. There's effectively only one line of code changed. Source is up-to-date to Feb 6, 2017.

As far as I can tell, digital0's version works just as well, so there's no reason to try mine if you're not having issues with his.

Same way to install the apk. Attached diff for the curious.
Big help, thank you and yes this one doesn't hide the answer button for an incoming call. Thanks again!

Sent from my gemini using XDA Labs
 

digital0

Senior Member
Oct 18, 2010
346
147
Vilnius
I recompiled Dialer.apk for Lineage 8.1. I also post instructions how to do that in the future:
According to https://forum.xda-developers.com/chef-central/android/how-to-build-lineageos-14-1-t3551484 I used these commands on Linux PC :
repo init -u https://github.com/LineageOS/android.git -b lineage-15.1
repo sync
patch the source file packages/apps/Dialer/java/com/android/incallui/ProximitySensor.java with the attached diff file or make the corrections manually
make Dialer DISABLE_DEXPREOPT=true WITH_DEXPREOPT=false
you will find Dialer.apk in ./out/target/product/generic/system/priv-app/Dialer/Dialer.apk
 

Attachments

  • Dialer_lineage-15.1.diff
    952 bytes · Views: 284
  • Dialer.apk
    11.8 MB · Views: 1,614

bilatche

Senior Member
Dec 7, 2010
382
47
Wow nice thank you! I will try this new dialer apk for 8.1 with the simple method which worked on nougat (juste replace in system/app....)
 

bk0012000

Member
Jul 25, 2007
5
0
OMG!! I have been having problems since I upgraded to Lineage 15.1 (Android 8.1) with the dialer and the proximity sensor. Nothing I tried worked. I used to replace the dialer in Lineage 14.1 and that worked, but didn't know anyone did an update for 15.1. I downloaded your dialer for 15.1 and NO more blank screen on calls. I can't say thank you enough!!

---------- Post added at 04:55 PM ---------- Previous post was at 04:49 PM ----------

I recompiled Dialer.apk for Lineage 8.1. I also post instructions how to do that in the future:
According to https://forum.xda-developers.com/chef-central/android/how-to-build-lineageos-14-1-t3551484 I used these commands on Linux PC :
repo init -u https://github.com/LineageOS/android.git -b lineage-15.1
repo sync
patch the source file packages/apps/Dialer/java/com/android/incallui/ProximitySensor.java with the attached diff file or make the corrections manually
make Dialer DISABLE_DEXPREOPT=true WITH_DEXPREOPT=false
you will find Dialer.apk in ./out/target/product/generic/system/priv-app/Dialer/Dialer.apk

Thank you!! It works great on my Samsung Note 4, N910P, using Lineage 15.1.......spent many days trying to research any proximity sensor apps, nothing worked.....Thank you again!!
 

furi0n786

Member
Jun 8, 2016
8
0
OMG!! I have been having problems since I upgraded to Lineage 15.1 (Android 8.1) with the dialer and the proximity sensor. Nothing I tried worked. I used to replace the dialer in Lineage 14.1 and that worked, but didn't know anyone did an update for 15.1. I downloaded your dialer for 15.1 and NO more blank screen on calls. I can't say thank you enough!!

---------- Post added at 04:55 PM ---------- Previous post was at 04:49 PM ----------



Thank you!! It works great on my Samsung Note 4, N910P, using Lineage 15.1.......spent many days trying to research any proximity sensor apps, nothing worked.....Thank you again!!

I likewise have the proximity issue with my SM-N910F Galaxy Note 4, under Nougat I replaced the dialer.apk file as described here in an earlier post.

However, I've since 'upgraded' to Resurrection Remix 6.0 (Oreo/Lineage 15.1) and attempted to replace the dialer.apk as before -

1. Rename existing app in /System/priv-app/Dialer
2. Copy new Dialer apk to this location, renaming as necessary.
3. Set permissions
4. Reboot phone

Unfortunately, when I launch the app it force closes immediately. Where am I going wrong? Or could you please provide the steps you followed to succeed?

Thanks


***Please ignore request for help, I somehow mixed up several dialer.apk's and initially used the wrong one. All working now. Great, thanks Digital :good::laugh::victory:
 
Last edited:

bk0012000

Member
Jul 25, 2007
5
0
I likewise have the proximity issue with my SM-N910F Galaxy Note 4, under Nougat I replaced the dialer.apk file as described here in an earlier post.

However, I've since 'upgraded' to Resurrection Remix 6.0 (Oreo/Lineage 15.1) and attempted to replace the dialer.apk as before -

1. Rename existing app in /System/priv-app/Dialer
2. Copy new Dialer apk to this location, renaming as necessary.
3. Set permissions
4. Reboot phone

Unfortunately, when I launch the app it force closes immediately. Where am I going wrong? Or could you please provide the steps you followed to succeed?

Thanks

I don't know what to tell you. It works for me with rippee's uploads. Rippee's is at https://forum.xda-developers.com/no...eo-8-1-0-unofficial-lineage-15-1-rom-t3760969
You've done what I've would have checked, but it works great for me....I'm on 0410 and it still works...
 

Top Liked Posts