Android 在通话期间禁用接近传感器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24982571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:59:06  来源:igfitidea点击:

Disable Proximity Sensor during call

androidtelephonytelephonymanagerproximitysensorandroid-dialer

提问by jobinbasani

I dropped my phone and looks like my proximity sensor no longer works reliably. It returns Nearall 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.

我掉了手机,看起来我的接近传感器不再可靠地工作。它一直返回Near。问题是,显示屏在通话过程中关闭,我将无法使用数字键盘输入密码或召开另一个电话会议,甚至无法断开通话。我在辅助功能设置中找到了电源按钮断开连接选项,现在就使用它。

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.

但是,接近传感器会关闭显示。我使用 isHeld() 方法来确保获取了锁。我使用了 PowerManager 的 isScreenOn() 方法,即使在通话过程中屏幕关闭,它也返回 true。我试图在循环中每两秒获取一次唤醒锁以进行测试,但仍然无法显示。

I'm using a Nexus 5 Android version 4.4.4

我使用的是 Nexus 5 Android 版本 4.4.4

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

任何人都可以提出一个想法来覆盖接近传感器的行为吗?需要 root 的选项也可以。

Thanks!

谢谢!

采纳答案by Surya R Praveen

Proximity Sensor Dial

接近传感器表盘

*#*#7378423#*#*

1) Service Tests - (If present)

1) 服务测试 -(如果存在)

2) Proximity Switch

2) 接近开关

3) Test on sensor (Next to logo(top) of mobile)

3) 传感器测试(在手机标志(顶部)旁边)

4) Yes if works, then u can keep on and proximity switch forever which gives beep all the time and consumes lot of battery

4)是的,如果有效,那么您可以永远保持开启和接近开关一直发出哔哔声并消耗大量电池

OR

或者

4) No it doesn't work - Then simply clean the mobile screen or screen guard and clear the blocked screen from sensor. It works charm.

4) 不,它不起作用 - 然后只需清洁手机屏幕或屏幕保护装置,并清除传感器上被阻挡的屏幕。它很有魅力。

Technically, Its not any software solution, but hardware solution will work.

从技术上讲,它不是任何软件解决方案,而是硬件解决方案。

回答by tlegutko

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 disableproximity sensor. What worked for me was to calibratethe 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.

我也遇到了接近传感器的问题(我在 Nexus 6、Android Marshmallow 上的那个区域的屏幕破碎了),并且当我尝试禁用接近传感器时,建议的解决方案/第三方应用程序都没有工作。对我有用的是使用Proximity Sensor Reset/Repair校准传感器。您必须按照应用程序中的说明(盖住传感器并揭开它),然后重新启动手机。尽管我的传感器不再位于玻璃后面,但在覆盖/未覆盖和重新校准完成工作时,它仍然显示出略有不同的结果。

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

我尝试过但没有奏效?Proximity Screen Off Lite、Macrodroid 和 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.

如果它仍然不起作用,我会尝试什么?[XPOSED] Sensor Disabler,但它要求您扎根并拥有 Xposed 框架,所以我很高兴我找到了更简单的方法。

回答by fangmobile.com

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

我在这里找到了我的解决方案。基本上使用名为Proximity Screen Off Lite的应用程序 并将其设置如下:

  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

  1. 屏幕开/关模式选中“覆盖并按住以打开屏幕”超时:1 秒选中“禁用意外锁定”超时:4 秒

  2. 所有设置 勾选“在 Lanscape 中禁用” 勾选“在屏幕上锁定手机”

  3. [高级] 配置传感器 选择传感器:接近传感器 传感器覆盖时的值:0 传感器未覆盖时的值:1

回答by ncomputers

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.

如果您在 中没有选项Settings → Phone → Use proximity sensor,那么唯一的选择似乎是在有根设备中禁用或修改其设置。

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

还要考虑一下,如果您插入耳机,屏幕将保持亮起 :D

回答by DarkPh03n1X

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)
  • 电话应用程序的菜单选项(我的手机没有禁用选项)
  • 接近屏幕关闭精简版(不起作用)
  • 带有传感器禁用程序的 Xposed 框架(工作到手机重启或应用更新)
  • Macrodroid 宏(由于某种原因,Macrodroid 无法在我的手机上运行)
  • 在它前面放一些锡纸?(我不知道我在想什么)

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 sensorI 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.

这是我的解决方法:我认为你不能再破坏它了,所以我打开了我的手机并从主板上一起卸下了接近传感器。传感器测试器应用程序现在显示“ no_value”,它用于提供“距离:0”,并且我的屏幕在拨号后不再变黑。请注意,我只能在带有 CM MOD 5.1.1 的 Samsung I8190 Galaxy S III mini 上确认此操作。这是我移除的设备的图片: 接近传感器我已经使用 SMD 焊台的 400 度热风枪、一些镊子和助焊剂将其移除。但是一把锋利的业余刀也可以工作。

回答by zahypeti

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

如果你有 LineageOS 7.1.2(并且有 root),试试这个来自 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.

在尝试了这里提出的所有解决方案后,没有一个适用于我的 Nexus 4 (mako),我在 XDA 上找到了一个解决 Android 拨号器问题的方法(但不适用于其他应用程序)。基本上,我下载了 Dialer.apk 文件的重新编译版本,它只是忽略接近传感器,其行为方式与股票拨号器应用程序相同。

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.

将 /system/priv-app/Dialer/Dialer.apk 重命名为某个名称,然后将下载的文件放到该文件夹​​中。重新启动后,我必须手动安装新的拨号器(只需单击它)。所以现在原来的应用程序被替换了,调用应该由这个新的应用程序来处理。

[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.]

[缺点:接听电话的新方法是拉下状态栏并单击“接听”(或“关闭”),缺少通常的滑块。此外,每次您的 Android 更新到较新版本时,您都需要重复此操作。]

回答by rejthy

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.

不幸的是,我的接近传感器也不起作用(总是返回 0.0 厘米)。我找到了方法,但并不容易:你需要 root 手机,安装 XPOSED 框架和 Sensor Disabler ( https://play.google.com/store/apps/details?id=com.mrchandler.disableprox)。您可以在应用程序中模拟接近传感器的返回值。(例如始终返回 2.0 厘米)。然后您的显示器将在通话期间始终开启。

回答by meysam

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)

编辑文件夹 /system 中的 build.prop 如果以下行存在更改值,如果不存在添加此行并保存。(设备必须植根)

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

回答by rogerdpack

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

一些更多的答案从interwebs:“修复”的传感器(胶屏幕的背面更大,或用酒精清洗,或通过耳机插孔送出的空气,抽头吹飞就可以了,清洁屏幕等)。

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 Litealso didn't work, nor macrodroid.

在“电话”应用程序中调整(经过一些发现)设置以禁用接近传感器的使用。我没有这样的设置,我可以找到。 Proximity Screen Off Lite也没有用,也没有macrodroid

Another option: root your phone and remove some files:

另一种选择:root你的手机并删除一些文件

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 :|

或者,如果你真的很绝望,我想一个完全不同的拨号系统,比如 TextNow 或谷歌环聊拨号器:|