安卓11重力感应不灵敏问题

在安卓11上调试da218-gsensor芯片,底层数据上报正常,但就是在机器旋转的时候,系统旋转时灵时不灵,排除底层数据的问题,直接打开frameworks\base\services\core\java\com\android\server\policy\WindowOrientationListener.java

看这里监听处理数据的位置,日志打开后,发现不灵敏的时候一直报:Ignoring sensor data, device is overhead: tiltAngle=-88 ,就是底层的数据在处理的时候被忽略了,找到代码位置:

复制代码
public void onSensorChanged(SensorEvent event) {

                // If the tilt angle is too close to horizontal then we cannot determine
                // the orientation angle of the screen.
                if (tiltAngle <= TILT_OVERHEAD_ENTER) {
                    mOverhead = true;
                } else if (tiltAngle >= TILT_OVERHEAD_EXIT) {
                    mOverhead = false;
                }
                if (mOverhead) {
                    if (LOG) {
                        Slog.v(TAG, "Ignoring sensor data, device is overhead: "
                                + "tiltAngle=" + tiltAngle);
                    }
                    clearPredictedRotationLocked();
                } else if (Math.abs(tiltAngle) > MAX_TILT) {
                    if (LOG) {
                        Slog.v(TAG, "Ignoring sensor data, tilt angle too high: "
                                + "tiltAngle=" + tiltAngle);
                    }
                    clearPredictedRotationLocked();
                }
                直接吧这个宏修改为:
                        private static final int TILT_OVERHEAD_ENTER = -100;

问题解决,反正机器只需要4个方向旋转,其他的特殊的功能不需要,误差大点无所谓,这样修改能满足产品需求就行

相关推荐
传奇开心果编程7 小时前
【Rust入门练中学】 第1课:从零开始
开发语言·学习·rust
K 旺仔小馒头7 小时前
【项目】商城系统用户端测试报告
自动化测试·python·功能测试
东莞市云毅网络有限公司7 小时前
用 SQLite FTS5 给企业文档建本地全文索引:中文分词与权重调优
python·数据清洗·rag·企业知识库·文档解析
钱栈up7 小时前
health从200变000:一次差点引发双端口冲突的后端巡检复盘
python
正经教主7 小时前
【FDE系列】阶段2:Day 22:变量、数据类型、条件判断 — Python 的“记忆“和“判断“
人工智能·python·fde
是店小二呀7 小时前
鸿蒙PC开源移植:CodeLite原生IDE与Remote Agent适配
android·智能手机·远程桌面
Brilliantwxx8 小时前
【STM32】 SPI阻塞式通信与HAL源码(串口读ID实战)
开发语言·stm32·单片机·嵌入式硬件·ecmascript
打工仔折腾 AI8 小时前
Pascal Editor 本地部署实战:Bun 启动 WebGPU 3D 编辑器并解决公网访问报错
人工智能·后端·python·性能优化
m0_547486668 小时前
《Python从入门到数据分析应用》全套PPT课件2026
python·数据分析
All for pursuit.8 小时前
FastAPI+Ollama 部署本地AI大模型对话助手
python·github·aigc·ollama