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

相关推荐
Brilliantwxx8 分钟前
【Linux】 软件包管理器(yum)+ Vim使用
linux·运维·服务器·开发语言·编辑器·vim
雪的季节12 分钟前
Python 线程同步与异步编程 全解析
java·开发语言
IT小盘18 分钟前
08-FastAPI加MySQL实现AI对话记录持久化
android·mysql·fastapi
清泓y23 分钟前
Android内存管理与性能优化面试真题
android·面试·性能优化
再渊28 分钟前
基因归因到底怎么计算的?
python·深度学习·机器学习
520拼好饭被践踏31 分钟前
JAVA+Agent学习day22
java·开发语言·后端·学习
E_ICEBLUE37 分钟前
Python 拆分 Excel 文件:使用 Spire.XLS 实现按工作表、行、列和条件拆分
python·excel
笨蛋不要掉眼泪42 分钟前
Java虚拟机:堆的参数配置
java·开发语言·jvm
冰暮流星1 小时前
javascript之date对象
开发语言·javascript·ecmascript
aiqianji1 小时前
有哪些稳定的AI短篇小说写作软件可以推荐?
人工智能·python