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

相关推荐
战略性的菠萝12 分钟前
研究生基础-Python快速入门(终)——面向对象
python
陈皮波比茶17 分钟前
Python项目实战-网络机器人(爬虫)
开发语言·网络·爬虫·python·机器人
明雨-开发21 分钟前
Android打包时候Execution failed for task ‘:launcher:lintVitalAnalyzeRelease‘.
android
游戏开发爱好者822 分钟前
开心上架是什么,一站式 Apple 开发者工作台总览
android·小程序·https·uni-app·iphone·webview
Android-Flutter32 分钟前
android kotlin launch 源码分析
android·kotlin
winfredzhang1 小时前
从零构建家庭照片管理系统:Django 模块化单体实战,以及我踩到的 4 个真实坑
python·postgresql·django·sqlite·bootsrap
Android-Flutter1 小时前
android kotlin 状态机 Continuation 详解
android·kotlin
jyOverQ1 小时前
LangGraph 流式执行详解:stream、astream 与 stream_mode 怎么选?
python·langchain
法哥20121 小时前
用 C++ 控制 CMW100,到底在干什么?
开发语言·c++
闲猫1 小时前
LangGraph / Capabilities / Stores
python·agent·langgraph