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

相关推荐
2501_944452234 分钟前
字数统计 Cordova 与 OpenHarmony 混合开发实战
python
养一回月亮!10 分钟前
使用Qt实现简单绘图板:鼠标绘制与擦除功能详解
开发语言·qt
骚戴16 分钟前
2025 Python AI 实战:零基础调用 LLM API 开发指南
人工智能·python·大模型·llm·api·ai gateway
BanyeBirth17 分钟前
C++差分数组(二维)
开发语言·c++·算法
kobe_OKOK_20 分钟前
tdeinge REST API 客户端
python·缓存·django
io_T_T35 分钟前
Python os库 os.walk使用(详细教程、带实践)
python
Tony Bai42 分钟前
Go 的 AI 时代宣言:我们如何用“老”原则,解决“新”问题?
开发语言·人工智能·后端·golang
Fcy6481 小时前
C++ map和multimap的使用
开发语言·c++·stl
鹿人戛1 小时前
HarmonyOS应用开发:状态栏动画实现
android·程序员·harmonyos
鹿人戛1 小时前
HarmonyOS应用开发:自定义动效tab实现
android·程序员·harmonyos