android禁用传感器,Android 系统 强制 禁用 距离传感器 方法

前两中办法是网络上流传的方法,只针对有些机型使用:

方法一:

通过修改系统文件实现,这就要求手机要已经root过。首先RE文件管理器(或ES文件管理器)进入根目录下/system文件夹,找到build.prop文件,将该文件的所有权限都改为可读和可写,并用文本编辑器打开,查找文件中是否有以下两行代码

# try to disable proximity sensor in call by default

# gsm.proximity.enable=false

如果有,那么将第二行的“#”删除,改为

# try to disable proximity sensor in call by default

gsm.proximity.enable=false

如果文件中没有这两行代码,那么在文件最后手动加入一行,gsm.proximity.enable=false。修改完成后保存文件,并将文件的权限改回原来的状态(rw- r-- r--)。重启手机(需关闭“快速启动”),这时距离感应器已经被强制关闭了

自己的小米1+android 原生 4.1.2,亲测不可用。

方法二:

OK people thanks to UksusoFF

‘s help and my own Linux background i was able to have my phone fixed and running. No more screen going offs & phone locks!!

I see that many of you had asked for a step by step process on working with the command line for disabling the proximity censor right?:cool:

Well here it goes folks , the complete step by step:

1 - You have to beROOTto

complete this task so ROOT your phone (There are many links on google on HowTo ROOT your phone so do it!!!)

操作前提:手机必须root !

2- Open the Emulator on your phone.

打开手机上的终端模拟器(如果没有,去市场搜索下载安装,或者使用在cmd 终端 使用adb shell ,如果有电脑有配置adb环境的话)

3- Typesuand make sure that$ sign changes to

#meaning you are the ROOT User now and can make serious changes to your device‘s system.

输入 su ,获取管理员权限,此时应该会看到开头的 $ 符号变成了 # 号,说明成功获取超级用户(即管理员)权限。

4- Insert the following commands in the Emulator

随后输入下列指令

# cd /data/local

# touch userinit.sh

# echo "#!/system/bin/sh" > userinit.sh

# echo "#" >> userinit.sh

# echo "chmod 0000 /dev/cm3602" >> userinit.sh

# echo "chmod 000 /dev/cm3602" >> userinit.sh

# chmod 777 userinit.sh

5- Now verify that the file exists

然后输入下一句指令来检查userinit.sh文件是否成功创建并且内容输入是否正确

# cat userinit.sh

(You should see the information

inserted above appearing).

再一次对比确认输入的内容

6- Restart your phone

重启手机

If you have done it right , your phone should be fine now. Starting now You will be in charge of turning on/off your screen instead of the proximity

censor.

Hope it works for ya:rolleyes:

Cheers!:p

此方法在米一测试不可用。

方法三:

去市场搜索下载安装 HardWare Disabler,安装后打开应用,能够看到自己手机的所有硬件驱动的代号和开关选项,找到 /sys/bus/i2c/drivers/isl29028 目录下的代号为0-0044的驱动,勾选disable之后就能够成功禁用距离感应器了。

由于前两种办法在这我手机上都not works,只能自己摸索出第三个办法,还是在不小心关错了一个重要的驱动差点导致重刷的教训之后,才最终得以实现。

目前只在自己的米一上尝试成功了,其他机型未知。

由于不同设备驱动代号不一,自己的所列的代号仅供参考,具体手机具体分析。新手务必慎选,不确定的情况下千万不能乱点,否则后果自负。。。。

原文:http://blog.csdn.net/ydcool/article/details/18359851

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android 9.0 及更高版本中,您可以使用 MediaProjection API 来设置应用程序禁用系统录屏。您可以通过以下方式实现: 1. 在您的 AndroidManifest.xml 文件中添加以下权限: ``` <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> ``` 2. 在您的 Activity 或 Service 中,使用以下代码请求媒体投影权限: ```java private static final int REQUEST_CODE_SCREEN_CAPTURE = 1; private MediaProjectionManager mProjectionManager; private MediaProjection mMediaProjection; private void requestScreenCapturePermission() { mProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); startActivityForResult(mProjectionManager.createScreenCaptureIntent(), REQUEST_CODE_SCREEN_CAPTURE); } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_SCREEN_CAPTURE && resultCode == RESULT_OK) { mMediaProjection = mProjectionManager.getMediaProjection(resultCode, data); // 在此处执行禁用系统录屏的逻辑 } } ``` 3. 在获取到 MediaProjection 对象后,您可以使用 `mMediaProjection.createVirtualDisplay()` 方法创建一个虚拟显示器,并通过 `Display.FLAG_SECURE` 标志来禁用系统录屏: ```java private static final int DISPLAY_WIDTH = 720; private static final int DISPLAY_HEIGHT = 1280; private static final int DISPLAY_DPI = 320; private void createVirtualDisplay() { VirtualDisplay virtualDisplay = mMediaProjection.createVirtualDisplay( "MyVirtualDisplay", DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_DPI, DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | Display.FLAG_SECURE, null, null ); } ``` 这样,您就可以在您的应用程序中禁用系统录屏了。注意,这只会影响到 Android 9.0 及更高版本的系统。在之前的版本中,您无法禁用系统录屏。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值