安卓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个方向旋转,其他的特殊的功能不需要,误差大点无所谓,这样修改能满足产品需求就行

相关推荐
老歌老听老掉牙几秒前
Python 模块深度解析:从创建、导入到属性机制
python·模块
2301_79509974几秒前
HTML5中Object标签定义外部资源容器的备份逻辑
jvm·数据库·python
z4424753261 分钟前
CSS如何保证移动端顶部Fixed头部的安全区域
jvm·数据库·python
weixin_458580123 分钟前
golang如何优化反射性能_golang反射性能优化技巧
jvm·数据库·python
深蓝海拓4 分钟前
Qt:创建一套基于HSL颜色体系的颜色库
笔记·python·qt·学习·ui
步辞5 分钟前
CSS如何解决小屏幕上的长单词截断版面
jvm·数据库·python
Thanks_ks8 分钟前
【第 001 讲】计算机底层基础与 Python 生态全景:硬件架构 | 语言演进 | 执行机制 | 语言特性 | 解释器 | 版本策略
python·编程语言·python入门·计算机基础·解释器·底层原理·cpython
qq_460978409 分钟前
如何在无向图中找出从任意节点可达的所有节点(连通分量识别)
jvm·数据库·python
大蚂蚁2号13 分钟前
本地视频转文字|video2text
python·音视频·视频转文本